Skip to content

Commit

Permalink
Add WS status icon
Browse files Browse the repository at this point in the history
Ref #305
  • Loading branch information
algorys committed Apr 23, 2018
1 parent 6d7e6a0 commit d09ed11
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 9 deletions.
15 changes: 14 additions & 1 deletion alignak_app/backend/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -753,7 +753,7 @@ def get_backend_status_icon(self):
"""
Return backend status icon name
:return: daemon status icon name
:return: status icon name
:rtype: str
"""

Expand All @@ -762,6 +762,19 @@ def get_backend_status_icon(self):

return Daemon.get_states('ko')

def get_ws_status_icon(self):
"""
Return Web Service status icon name
:return: status icon name
:rtype: str
"""

if self.ws_client.auth:
return Daemon.get_states('ok')

return Daemon.get_states('ko')


# Creation of "app_backend" object
app_backend = BackendClient()
32 changes: 24 additions & 8 deletions alignak_app/qobjects/alignak/alignak.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ def __init__(self, parent=None):
self.backend_connected = QLabel('pending...')
self.status_dialog = StatusQDialog()
self.status_btn = QPushButton()
self.ws_connected = QLabel()
self.profile_widget = ProfileQWidget()
self.profile_btn = QPushButton()
self.refresh_timer = QTimer()
Expand All @@ -77,38 +78,50 @@ def initialize(self):
connected_title = QLabel(_('Backend'))
connected_title.setObjectName('subtitle')
layout.addWidget(connected_title, 0, 0, 1, 1)
layout.setAlignment(connected_title, Qt.AlignCenter)

self.backend_connected.setFixedSize(16, 16)
self.backend_connected.setScaledContents(True)
self.backend_connected.setToolTip(_('Status of the backend API connection'))
layout.addWidget(self.backend_connected, 0, 1, 1, 1)
layout.setAlignment(self.backend_connected, Qt.AlignCenter)

# Daemons Status
# WS state
ws_title = QLabel(_('Web Service'))
ws_title.setObjectName('subtitle')
layout.addWidget(ws_title, 0, 2, 1, 1)

self.ws_connected.setFixedSize(16, 16)
self.ws_connected.setScaledContents(True)
self.ws_connected.setToolTip(_('Status of the Web Service connection'))
layout.addWidget(self.ws_connected, 0, 3, 1, 1)
layout.setAlignment(self.ws_connected, Qt.AlignCenter)

# Daemons state
daemons_title = QLabel(_('Status'))
daemons_title.setObjectName('subtitle')
layout.addWidget(daemons_title, 1, 0, 1, 1)
layout.setAlignment(daemons_title, Qt.AlignCenter)

# Status button
self.status_dialog.initialize()
self.update_status_btn(self.status_dialog.update_dialog())
self.status_btn.setFixedSize(32, 32)
self.status_btn.clicked.connect(self.show_status_dialog)
self.status_btn.setToolTip(_('Status of daemons connection'))
layout.addWidget(self.status_btn, 1, 1, 1, 1)
layout.setAlignment(self.status_btn, Qt.AlignCenter)

# User
user_lbl = QLabel(_('User'))
user_lbl.setObjectName('subtitle')
layout.addWidget(user_lbl, 0, 2, 2, 1)
layout.addWidget(user_lbl, 1, 2, 1, 1)

self.profile_widget.initialize()
self.profile_btn.setIcon(QIcon(settings.get_image('user')))
self.profile_btn.setFixedSize(40, 40)
self.profile_btn.setFixedSize(32, 32)
self.profile_btn.clicked.connect(self.show_user_widget)
self.profile_btn.setToolTip(_('User'))
layout.addWidget(self.profile_btn, 0, 3, 2, 1)
self.profile_btn.setToolTip(_('View current user'))
layout.addWidget(self.profile_btn, 1, 3, 1, 1)

# Refresh timer
update_status = int(settings.get_config('Alignak-app', 'update_status')) * 1000
self.refresh_timer.setInterval(update_status)
self.refresh_timer.start()
Expand Down Expand Up @@ -153,6 +166,9 @@ def update_status(self):
self.backend_connected.setPixmap(
QPixmap(settings.get_image(app_backend.get_backend_status_icon()))
)
self.ws_connected.setPixmap(
QPixmap(settings.get_image(app_backend.get_ws_status_icon()))
)
self.status_btn.setEnabled(bool(data_manager.database['alignakdaemon']))

if self.status_dialog.labels:
Expand Down

0 comments on commit d09ed11

Please sign in to comment.