# Path: alignak_app/items/item.py
# def get_icon_name_from_state(item_type, state):
#     """
#     Return icon name from state for host or service
# 
#     :param item_type: type of item: host or service
#     :type item_type: str
#     :param state: state of item
#     :type state: str
#     :return:
#     """
# 
#     if state == 'DOWNTIME':
#         return 'downtime'
#     if state == 'ACKNOWLEDGE':
#         return 'acknowledge'
# 
#     return '%ss_%s' % (item_type, state.lower())
# 
# Path: alignak_app/items/service.py
# class Service(Item):
#     """
#         Class who create a service item
#     """
# 
#     def __init__(self):
#         super(Service, self).__init__()
#         self.item_type = 'service'
# 
#     @staticmethod
#     def get_request_model(host_id=None):
#         """
#         Return the request model for service requests
# 
#         :param host_id: "_id" of host, needed to get only host services
#         :type host_id: str
#         :return: request model for service endpoint
#         :rtype: dict
#         """
# 
#         services_projection = [
#             'name', 'alias', 'ls_state', 'ls_acknowledged', 'ls_downtimed', 'ls_last_check',
#             'ls_output', '_overall_state_id', 'aggregation', 'host', 'passive_checks_enabled',
#             'active_checks_enabled'
#         ]
# 
#         request_model = {
#             'endpoint': 'service',
#             'projection': services_projection
#         }
# 
#         if host_id:
#             request_model['params'] = {
#                 'where': json.dumps({'_is_template': False, 'host': host_id})
#             }
#         else:
#             request_model['params'] = {'where': json.dumps({'_is_template': False})}
# 
#         return request_model
# 
#     @staticmethod
#     def get_service_states_nb():
#         """
#         Return all service state in a dict with int() as zero
# 
#         :return: all service state with int() as zero
#         :rtype: dict
#         """
# 
#         return {
#             'OK': 0,
#             'UNKNOWN': 0,
#             'WARNING': 0,
#             'UNREACHABLE': 0,
#             'CRITICAL': 0,
#             'NOT_MONITORED': 0,
#             'ACKNOWLEDGE': 0,
#             'DOWNTIME': 0
#         }
# 
#     @staticmethod
#     def get_available_icons():
#         """
#         Return list of available icons for a Service item
# 
#         :return: list of available icons for Service
#         :rtype: list
#         """
# 
#         return [
#             'services_ok', 'services_warning', 'services_critical', 'services_unknown',
#             'services_unreachable', 'services_not_monitored', 'acknowledge', 'downtime'
#         ]
# 
#     def get_display_name(self):
#         """
#         Return alias or name if available
# 
#         :return: name or alias
#         :rtype: str
#         """
# 
#         if 'alias' in self.data:
#             return self.data['alias'].title()
# 
#         return self.name.title()
# 
# Path: alignak_app/utils/config.py
# class Settings(object):
#     def __init__(self):
#     def init_config(self):
#     def get_config(self, section, option, boolean=False):
#     def set_config(self, section, option, new_value):
#     def get_image(self, name):
#     def init_css(self):
# def open_url(endpoint='login'):  # pragma: no cover
# def get_url_endpoint_from_icon_name(icon_name):


from logging import getLogger
from PyQt5.Qt import QLabel, QWidget, Qt, QPixmap, QHBoxLayout, QPushButton, QIcon
from alignak_app.items.item import get_icon_name_from_state
from alignak_app.items.service import Service
from alignak_app.utils.config import settings
        layout.addWidget(self.services_title)
        layout.setAlignment(self.services_title, Qt.AlignLeft)

        icons_widget = QWidget()
        icons_layout = QHBoxLayout()
        icons_widget.setLayout(icons_layout)

        for icon in Service.get_available_icons():
            state = icon.replace('services_', '').upper()
            icon_pixmap = QIcon(settings.get_image(icon))
            self.states_btns[state].setIcon(icon_pixmap)
            self.states_btns[state].setFixedSize(20, 20)
            self.states_btns[state].setToolTip(state)
            self.states_btns[state].setCheckable(True)
            self.states_btns[state].setObjectName('services')
            icons_layout.addWidget(self.states_btns[state])
            self.nb_labels[state].setObjectName(get_icon_name_from_state('service', state))
            icons_layout.addWidget(self.nb_labels[state])

        layout.addWidget(icons_widget)
        layout.setAlignment(icons_widget, Qt.AlignRight)

    def update_widget(self, services_items):
        """
        Update QWidget

        :param services_items: list of Service items
        :type services_items: list
        """


# Path: alignak_app/items/item.py
# def get_icon_name_from_state(item_type, state):
#     """
#     Return icon name from state for host or service
# 
#     :param item_type: type of item: host or service
#     :type item_type: str
#     :param state: state of item
#     :type state: str
#     :return:
#     """
# 
#     if state == 'DOWNTIME':
#         return 'downtime'
#     if state == 'ACKNOWLEDGE':
#         return 'acknowledge'
# 
#     return '%ss_%s' % (item_type, state.lower())
# 
# Path: alignak_app/items/service.py
# class Service(Item):
#     """
#         Class who create a service item
#     """
# 
#     def __init__(self):
#         super(Service, self).__init__()
#         self.item_type = 'service'
# 
#     @staticmethod
#     def get_request_model(host_id=None):
#         """
#         Return the request model for service requests
# 
#         :param host_id: "_id" of host, needed to get only host services
#         :type host_id: str
#         :return: request model for service endpoint
#         :rtype: dict
#         """
# 
#         services_projection = [
#             'name', 'alias', 'ls_state', 'ls_acknowledged', 'ls_downtimed', 'ls_last_check',
#             'ls_output', '_overall_state_id', 'aggregation', 'host', 'passive_checks_enabled',
#             'active_checks_enabled'
#         ]
# 
#         request_model = {
#             'endpoint': 'service',
#             'projection': services_projection
#         }
# 
#         if host_id:
#             request_model['params'] = {
#                 'where': json.dumps({'_is_template': False, 'host': host_id})
#             }
#         else:
#             request_model['params'] = {'where': json.dumps({'_is_template': False})}
# 
#         return request_model
# 
#     @staticmethod
#     def get_service_states_nb():
#         """
#         Return all service state in a dict with int() as zero
# 
#         :return: all service state with int() as zero
#         :rtype: dict
#         """
# 
#         return {
#             'OK': 0,
#             'UNKNOWN': 0,
#             'WARNING': 0,
#             'UNREACHABLE': 0,
#             'CRITICAL': 0,
#             'NOT_MONITORED': 0,
#             'ACKNOWLEDGE': 0,
#             'DOWNTIME': 0
#         }
# 
#     @staticmethod
#     def get_available_icons():
#         """
#         Return list of available icons for a Service item
# 
#         :return: list of available icons for Service
#         :rtype: list
#         """
# 
#         return [
#             'services_ok', 'services_warning', 'services_critical', 'services_unknown',
#             'services_unreachable', 'services_not_monitored', 'acknowledge', 'downtime'
#         ]
# 
#     def get_display_name(self):
#         """
#         Return alias or name if available
# 
#         :return: name or alias
#         :rtype: str
#         """
# 
#         if 'alias' in self.data:
#             return self.data['alias'].title()
# 
#         return self.name.title()
# 
# Path: alignak_app/utils/config.py
# class Settings(object):
#     def __init__(self):
#     def init_config(self):
#     def get_config(self, section, option, boolean=False):
#     def set_config(self, section, option, new_value):
#     def get_image(self, name):
#     def init_css(self):
# def open_url(endpoint='login'):  # pragma: no cover
# def get_url_endpoint_from_icon_name(icon_name):


# Path: alignak_app/qobjects/service/services_dashboard.py
from logging import getLogger
from PyQt5.Qt import QLabel, QWidget, Qt, QPixmap, QHBoxLayout, QPushButton, QIcon
from alignak_app.items.item import get_icon_name_from_state
from alignak_app.items.service import Service
from alignak_app.utils.config import settings

        layout.addWidget(self.services_title)
        layout.setAlignment(self.services_title, Qt.AlignLeft)

        icons_widget = QWidget()
        icons_layout = QHBoxLayout()
        icons_widget.setLayout(icons_layout)

        for icon in Service.get_available_icons():
            state = icon.replace('services_', '').upper()
            icon_pixmap = QIcon(settings.get_image(icon))
            self.states_btns[state].setIcon(icon_pixmap)
            self.states_btns[state].setFixedSize(20, 20)
            self.states_btns[state].setToolTip(state)
            self.states_btns[state].setCheckable(True)
            self.states_btns[state].setObjectName('services')
            icons_layout.addWidget(self.states_btns[state])
            self.nb_labels[state].setObjectName(get_icon_name_from_state('service', state))
            icons_layout.addWidget(self.nb_labels[state])

        layout.addWidget(icons_widget)
        layout.setAlignment(icons_widget, Qt.AlignRight)

    def update_widget(self, services_items):
        """
        Update QWidget

        :param services_items: list of Service items
        :type services_items: list
        """


        services_data = Service.get_service_states_nb()