Skip to content

Commit

Permalink
Fix css events, add title to spy tab
Browse files Browse the repository at this point in the history
Ref #256
  • Loading branch information
algorys committed Mar 10, 2018
1 parent 0244247 commit 3545948
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 33 deletions.
31 changes: 1 addition & 30 deletions alignak_app/qobjects/events/item.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
Event item manage creation of ``QListWidgetItem`` for events
"""

from PyQt5.Qt import QTimer, QColor, QListWidgetItem, QIcon
from PyQt5.Qt import QTimer, QListWidgetItem, QIcon

from alignak_app.utils.config import settings
from alignak_app.utils.time import get_current_time
Expand Down Expand Up @@ -74,9 +74,6 @@ def initialize(self, event_type, msg, timer=False, spied_on=False, host=None):
)
)

# self.setForeground(QColor('#064c79'))
self.setForeground(QColor(self.get_foreground_color(event_type)))

def close_item(self):
"""
Hide items when timer is finished
Expand All @@ -85,32 +82,6 @@ def close_item(self):

self.setHidden(True)

@staticmethod
def get_foreground_color(event_type):
"""
Return corresponding color of event type
:param event_type: the type of event
:type event_type: str
:return: the associated color with the event
:rtype: str
"""

available_colors = {
'#27ae60': ['OK', 'UP'],
'#2980b9': ['UNKNOWN', 'INFO', 'SPY'],
'#e67e22': ['WARNING', 'UNREACHABLE', 'WARN'],
'#e74c3c': ['DOWN', 'CRITICAL', 'ALERT'],
'#f39c12': ['ACK'],
'#f1c40f': ['DOWNTIME', 'DOWNTIMESTART (DOWN)'],
}

for key, _ in available_colors.items():
if event_type in available_colors[key]:
return key

return '#e74c3c'

@staticmethod
def get_icon(event_type):
"""
Expand Down
9 changes: 7 additions & 2 deletions alignak_app/qobjects/events/spy.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
from logging import getLogger

from PyQt5.Qt import QVBoxLayout, Qt, QWidget, QAbstractItemView, QListWidget, pyqtSignal, QSize
from PyQt5.Qt import QTimer
from PyQt5.Qt import QTimer, QLabel

from alignak_app.backend.datamanager import data_manager
from alignak_app.items.item import get_host_msg_and_event_type
Expand Down Expand Up @@ -131,13 +131,18 @@ def __init__(self):

def initialize(self):
"""
Intialize QWidget
Intialize Spy QWidget
"""

layout = QVBoxLayout()
self.setLayout(layout)

spy_title = QLabel(_('Spy Hosts (double click to stop spying)'))
spy_title.setObjectName('itemtitle')
spy_title.setMinimumHeight(40)
layout.addWidget(spy_title)

self.spy_list_widget.setDragDropMode(QAbstractItemView.DragDrop)
self.spy_list_widget.setSelectionMode(QAbstractItemView.ExtendedSelection)
self.spy_list_widget.doubleClicked.connect(self.remove_event)
Expand Down
3 changes: 2 additions & 1 deletion etc/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,8 @@ QListWidget {
}

QListWidget::item {
height: 34px;
height: 35px;
color: #3b4155;
}

QListWidget::item:hover {
Expand Down

0 comments on commit 3545948

Please sign in to comment.