204 lines
6.6 KiB
Python
204 lines
6.6 KiB
Python
# -*- coding: utf-8 -*-
|
|
"""
|
|
조치 단계 다이얼로그 모듈
|
|
조치 단계를 추가/편집하는 다이얼로그입니다.
|
|
"""
|
|
|
|
from typing import Optional, Dict, Any
|
|
from PySide6.QtWidgets import (
|
|
QWidget, QVBoxLayout, QHBoxLayout, QPushButton, QLabel
|
|
)
|
|
from PySide6.QtCore import Qt
|
|
|
|
from PySide6.QtCore import QPoint
|
|
from ui.base.base_dialog import BaseDialog
|
|
from ui.components.custom_input import CustomTextEdit
|
|
from ui.widgets.clickableLabel import ClickableLabel
|
|
from core.constants import TEAMS
|
|
from core.logger import get_logger
|
|
|
|
logger = get_logger(__name__)
|
|
|
|
|
|
class ActionStepDialog(BaseDialog):
|
|
"""조치 단계 다이얼로그"""
|
|
|
|
def __init__(self, parent=None, step_data: Optional[Dict[str, Any]] = None):
|
|
super().__init__(
|
|
parent=parent,
|
|
title="조치 단계 편집" if step_data else "조치 단계 추가",
|
|
width=500,
|
|
height=400,
|
|
min_width=450,
|
|
min_height=350
|
|
)
|
|
|
|
self.step_data = step_data
|
|
self._selected_team = ""
|
|
|
|
self._setup_ui()
|
|
self._apply_black_theme()
|
|
|
|
if step_data:
|
|
self._load_step_data(step_data)
|
|
|
|
def _setup_ui(self):
|
|
"""UI 설정"""
|
|
# 조치 내용
|
|
content_label = QLabel("조치 내용 *")
|
|
content_label.setStyleSheet("color: #e0e0e0; font-size: 11pt; font-weight: bold;")
|
|
self.content_layout.addWidget(content_label)
|
|
|
|
self.content_input = CustomTextEdit(
|
|
placeholder="조치 내용을 입력하세요\n예: 리셋 후 정상 복구 확인.",
|
|
min_height=150
|
|
)
|
|
self.content_layout.addWidget(self.content_input)
|
|
|
|
# 조치팀
|
|
team_label = QLabel("조치팀")
|
|
team_label.setStyleSheet("color: #e0e0e0; font-size: 11pt; font-weight: bold;")
|
|
self.content_layout.addWidget(team_label)
|
|
|
|
self.team_label = ClickableLabel("선택", enable_hover=True)
|
|
self.team_label.setStyleSheet("""
|
|
QLabel {
|
|
background-color: #2a2a2a;
|
|
color: #ffffff;
|
|
border: 1px solid #404040;
|
|
border-radius: 6px;
|
|
padding: 8px 12px;
|
|
font-size: 11pt;
|
|
}
|
|
QLabel:hover {
|
|
border-color: #3b82f6;
|
|
}
|
|
""")
|
|
self.team_label.clicked.connect(self._show_team_popup)
|
|
self.content_layout.addWidget(self.team_label)
|
|
|
|
# 버튼
|
|
self.add_confirm_cancel_buttons()
|
|
|
|
def _show_team_popup(self):
|
|
"""조치팀 선택 팝업"""
|
|
from ui.components.chips.choice_chip_button import ChoiceChipButton
|
|
from ui.components.popup_widget import PopupWidget
|
|
from PySide6.QtWidgets import QHBoxLayout, QWidget, QButtonGroup
|
|
|
|
popup = PopupWidget(self, title="조치팀 선택", width=300, auto_hide=False)
|
|
|
|
chip_container = QWidget()
|
|
chip_layout = QHBoxLayout(chip_container)
|
|
chip_layout.setContentsMargins(8, 8, 8, 8)
|
|
chip_layout.setSpacing(8)
|
|
|
|
button_group = QButtonGroup()
|
|
button_group.setExclusive(True)
|
|
|
|
current_team = self._selected_team or ""
|
|
|
|
def on_team_selected(team_key: str):
|
|
self._selected_team = team_key
|
|
self.team_label.setText(team_key)
|
|
popup.hide_popup()
|
|
|
|
for team in TEAMS:
|
|
chip_bg = "#64748b" if team == current_team else "#2979ff"
|
|
|
|
chip = ChoiceChipButton(text=team, key=team, bg=chip_bg)
|
|
button_group.addButton(chip)
|
|
chip_layout.addWidget(chip)
|
|
|
|
if team == current_team:
|
|
chip.setChecked(True)
|
|
|
|
def make_chip_handler(team_key: str):
|
|
def handler():
|
|
for btn in button_group.buttons():
|
|
if isinstance(btn, ChoiceChipButton):
|
|
if btn.key == team_key:
|
|
btn.set_bg("#64748b")
|
|
else:
|
|
btn.set_bg("#2979ff")
|
|
on_team_selected(team_key)
|
|
return handler
|
|
|
|
chip.clicked_key.connect(make_chip_handler(team))
|
|
|
|
chip_layout.addStretch()
|
|
popup.content_layout.addWidget(chip_container)
|
|
|
|
label_pos = self.team_label.mapToGlobal(QPoint(0, 0))
|
|
popup_pos = QPoint(label_pos.x(), label_pos.y() + self.team_label.height() + 5)
|
|
popup.show_at(popup_pos)
|
|
|
|
def _load_step_data(self, step_data: Dict[str, Any]):
|
|
"""조치 단계 데이터 로드"""
|
|
self.content_input.set_text(step_data.get('action_content', ''))
|
|
team = step_data.get('action_team', '')
|
|
if team:
|
|
self._selected_team = team
|
|
self.team_label.setText(team)
|
|
|
|
def _apply_black_theme(self):
|
|
"""블랙 테마 적용"""
|
|
self.setStyleSheet("""
|
|
QDialog {
|
|
background-color: #0a0a0a;
|
|
}
|
|
|
|
#dialogContainer {
|
|
background-color: #1a1a1a;
|
|
border: 1px solid #333333;
|
|
border-radius: 16px;
|
|
}
|
|
|
|
#dialogTitle {
|
|
color: #ffffff;
|
|
font-family: 'GmarketSans';
|
|
font-size: 18pt;
|
|
font-weight: bold;
|
|
}
|
|
|
|
#closeButton {
|
|
background-color: transparent;
|
|
border: none;
|
|
color: #ffffff;
|
|
font-size: 16px;
|
|
border-radius: 16px;
|
|
}
|
|
|
|
#closeButton:hover {
|
|
background-color: #dc2626;
|
|
color: white;
|
|
}
|
|
|
|
QLabel {
|
|
color: #e0e0e0;
|
|
font-family: 'GmarketSans';
|
|
font-size: 11pt;
|
|
}
|
|
""")
|
|
|
|
def get_data(self) -> Dict[str, Any]:
|
|
"""입력 데이터 반환"""
|
|
return {
|
|
'action_content': self.content_input.get_text(),
|
|
'action_team': self._selected_team
|
|
}
|
|
|
|
def validate(self) -> bool:
|
|
"""입력 유효성 검사"""
|
|
if not self.content_input.get_text().strip():
|
|
from PySide6.QtWidgets import QMessageBox
|
|
QMessageBox.warning(self, "입력 오류", "조치 내용을 입력해주세요.")
|
|
return False
|
|
return True
|
|
|
|
def _on_confirm(self):
|
|
"""확인 버튼 클릭"""
|
|
if self.validate():
|
|
super()._on_confirm()
|
|
|