From fdebd8508d241d9183f9cc3a221bddf99f03e299 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20MOHIER?= Date: Sun, 17 Apr 2016 09:43:56 +0200 Subject: [PATCH 1/8] Clean data / user relation --- module/datamanager.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/module/datamanager.py b/module/datamanager.py index a37e1ba0..fb38500c 100644 --- a/module/datamanager.py +++ b/module/datamanager.py @@ -135,7 +135,8 @@ def __init__(self, rg=None, frontend=None, alignak=False): def _is_related_to(item, user): """ """ - if not user: + # if no user or user is an admin, always consider there is a relation + if not user or user.is_administrator(): return item return user._is_related_to(item) @@ -146,7 +147,8 @@ def _only_related_to(items, user): :returns: List of elements related to the user """ - if not user: + # if no user or user is an admin, always consider there is a relation + if not user or user.is_administrator(): return items try: From 208121515d377a5e7e1efa827c5844bd7eea3055 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20MOHIER?= Date: Sun, 17 Apr 2016 09:50:19 +0200 Subject: [PATCH 2/8] Clean contacts pages --- module/plugins/contacts/contacts.py | 3 +-- module/plugins/contacts/views/contact.tpl | 14 +++++--------- module/plugins/contacts/views/contacts.tpl | 2 +- 3 files changed, 7 insertions(+), 12 deletions(-) diff --git a/module/plugins/contacts/contacts.py b/module/plugins/contacts/contacts.py index 19f8b893..521c2575 100644 --- a/module/plugins/contacts/contacts.py +++ b/module/plugins/contacts/contacts.py @@ -37,8 +37,7 @@ def show_contacts(): user = app.request.environ['USER'] user.is_administrator() or app.redirect403() - return {'contacts': sorted(app.datamgr.get_contacts(user=user), - key=lambda c: c.contact_name)} + return {'contacts': sorted(app.datamgr.get_contacts(user=user), key=lambda c: c.contact_name)} pages = { show_contact: { diff --git a/module/plugins/contacts/views/contact.tpl b/module/plugins/contacts/views/contact.tpl index 00923b67..358493ed 100644 --- a/module/plugins/contacts/views/contact.tpl +++ b/module/plugins/contacts/views/contact.tpl @@ -4,18 +4,15 @@ %# If got no element, bailout %if not contact: %rebase("layout", title='Invalid contact name') - -%else: +%end %helper = app.helper %username = 'anonymous' -%if user is not None: -%if hasattr(contact, 'alias'): +%if hasattr(contact, 'alias') and contact.alias != 'none': %username = contact.alias %else: -%username = contact.get_name() -%end +%username = contact.contact_name %end %rebase("layout", title='Contact ' + username, breadcrumb=[ ['All contacts', '/contacts'], [username, '/contact/'+username] ]) @@ -71,7 +68,7 @@

%if app.manage_acl:

- {{'Administrator' if contact.is_administrator() else 'User'}} + {{'Administrator' if contact.is_admin else 'User'}}

%end @@ -457,7 +454,7 @@ %i=1 %for item in my_contactgroups: - {{', ' if i!=1 else ''}}{{item.alias if item.alias!='' else item.get_name()}} + {{', ' if i!=1 else ''}}{{item.alias if item.alias!='' else item.get_name()}} %i+=1 %if i > 20: ... @@ -474,4 +471,3 @@ -%end diff --git a/module/plugins/contacts/views/contacts.tpl b/module/plugins/contacts/views/contacts.tpl index 7c96b292..c98505a4 100644 --- a/module/plugins/contacts/views/contacts.tpl +++ b/module/plugins/contacts/views/contacts.tpl @@ -19,7 +19,7 @@ {{contact.contact_name}} {{"%s (%s)" % (contact.alias, contact.contact_name) if contact.alias != 'none' else contact.contact_name}} {{contact.email}} - Detail + Detail %end From 21e0413c6c7e7a4ac329f2e0eca7dace82ff030e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20MOHIER?= Date: Sun, 17 Apr 2016 10:20:35 +0200 Subject: [PATCH 3/8] Update configuration file --- etc/modules/webui2.cfg | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/etc/modules/webui2.cfg b/etc/modules/webui2.cfg index 3c53283c..73116999 100644 --- a/etc/modules/webui2.cfg +++ b/etc/modules/webui2.cfg @@ -13,21 +13,33 @@ define module { # You may remove the modules 'auth-cfg-password' and 'auth-htpasswd' from your # configuration because the WebUI embeds those authentication methods. # + # - auth-alignak (internal) : Use alignak backend to authenticate users. + # This new authentication feature is used to authenticate a user near Alignak backend. + # # You may use these external modules: # - auth-ws-glpi : Use the Glpi Web Services for user authentication # - auth-active-directory : Use AD for auth backend (and retrieve photos). # htpasswd (apache like) file containing username/passwords # Use an Apache htpasswd file or build your own (http://www.htaccesstools.com/htpasswd-generator/) - #Default file - #htpasswd_file /etc/shinken/htpasswd.users + #htpasswd_file /etc/shinken/htpasswd.users + + # Alignak backend endpoint + # Configure this value to activate the Alignak backend authentication module + #alignak_backend_endpoint http://127.0.0.1:5020 + + # Use Alignak backend objects instead of Shinken objects + # NOTE : this feature is still experimental and should never be used in a production environment! + # ******************************* + #alignak_backend_objects 1 + # ******************************* ## Modules for WebUI ## Graphs: # You may use these external modules: # - ui-pnp : Use PNP graphs in the UI. - # - ui-graphite : Use graphs from Graphite time series database. + # - ui-graphite2 : Use graphs from Graphite time series database. ## Modules for WebUI @@ -84,13 +96,13 @@ define module { #port 7767 - # By default, a random secret for session cookies will be auto-generated - # and stored in file described by auth_secret_file. Alternatively, secret - # can be explicitly set using parameter auth_secret, for example if there - # are multiple instances providing webui behind a load balancer. - # - #auth_secret CHANGEME - #auth_secret_file /var/lib/shinken/auth_secret + # Authentication secret for session cookie + # 1/ Define here a secret string used to sign session cookie + # auth_secret CHANGEME + ; CHANGE THIS or someone could forge cookies + # 2/ Define here a file that will store an auto-generated secret (more secure) + # This configuration is more secure than the previous one ... + auth_secret_file /var/lib/shinken/auth_secret # Session cookie name cookie_name user_session From 5f38ba31012ab3e75cda0a0441c07157133d8a92 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20MOHIER?= Date: Sun, 17 Apr 2016 10:38:15 +0200 Subject: [PATCH 4/8] Updated readme --- README.md | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 515bfd1d..8ab157f9 100644 --- a/README.md +++ b/README.md @@ -3,17 +3,39 @@ ## Description Shinken Web User Interface -Current version is 2.3.1, available on [`shinken.io`](http://shinken.io/package/webui2). +Current version is 2.3.2, available on [`shinken.io`](http://shinken.io/package/webui2). ## Release notes +### Version 2.3.2 + - Features: + - Update (huge) dashboard currently view + - Improve problems widgets (synthesis, commands bar) + - Problems page metrics improvements (thanks @medismail) + - New dashboard widget to enable/disable global notifications + + - Enhancements: + - Clean dashboard widgets management (addition, options, removal, ...) + - Update JS/CSS/Fonts libraries (jQuery, Font Awesome) + - Update login process and user management + - Refactoring in the data manager + - Allows authenticating a user with Alignak backend + + - Bugs and fixes: + #471: downtime page error + #469: currently 404 + #468: CSS bug + #466: use display_name when available + ... and some others :) + ### Version 2.3.1 + Only for internal testings and not published on shinken.io - Features: - Update (huge) dashboard currently view - Improve problems widgets (synthesis, commands bar) - Problems page metrics improvements (thanks @medismail) - - Enhancements: + - Enhancements: - Clean dashboard widgets management (addition, options, removal, ...) - Update JS/CSS/Fonts libraries (jQuery, Font Awesome) - Update login process and user management From 572ecd87ee8989099dde1de4bf4d283a172b9242 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20MOHIER?= Date: Sun, 17 Apr 2016 10:42:49 +0200 Subject: [PATCH 5/8] Clean debug logs --- module/datamanager.py | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/module/datamanager.py b/module/datamanager.py index fb38500c..a5e061f0 100644 --- a/module/datamanager.py +++ b/module/datamanager.py @@ -417,7 +417,7 @@ def search_hosts_and_services(self, search, user, get_impacts=True, sorter=None) ) ) - logger.info("[WebUI - datamanager] search_hosts_and_services, search for %s", search) + logger.debug("[WebUI - datamanager] search_hosts_and_services, search for %s in %d items", search, len(items)) search = [s for s in search.split(' ')] @@ -679,7 +679,6 @@ def get_timeperiod(self, name): name = name.decode('utf8', 'ignore') except UnicodeEncodeError: pass - logger.info("[WebUI - datamanager] get_timeperiod, name: %s", name) return self.get_timeperiods(name=name) @@ -790,7 +789,7 @@ def get_contactgroups(self, user=None, name=None, parent=None, members=False): :param name: only this element :returns: List of elements related to the user """ - logger.info("[WebUI - datamanager] get_contactgroups, name: %s, members: %s", name, members) + logger.debug("[WebUI - datamanager] get_contactgroups, name: %s, members: %s", name, members) items = [] if parent: group = self.get_contactgroups(user=user, name=parent) @@ -803,7 +802,7 @@ def get_contactgroups(self, user=None, name=None, parent=None, members=False): items = self.fe.contactgroups else: items = self.rg.contactgroups - logger.info("[WebUI - datamanager] got %d contactgroups", len(items)) + logger.debug("[WebUI - datamanager] got %d contactgroups", len(items)) if name: return items.find_by_name(name) @@ -821,7 +820,7 @@ def get_contactgroup(self, name, user=None, members=False): name = name.decode('utf8', 'ignore') except UnicodeEncodeError: pass - logger.info("[WebUI - datamanager] get_contactgroup, name: %s", name) + logger.debug("[WebUI - datamanager] get_contactgroup, name: %s", name) return self._is_related_to(self.get_contactgroups(user=user, name=name, members=members), user) @@ -872,7 +871,7 @@ def get_hostgroups(self, user=None, name=None, parent=None, members=False): :param name: only this element :returns: List of elements related to the user """ - logger.info("[WebUI - datamanager] get_hostgroups, name: %s", name) + logger.debug("[WebUI - datamanager] get_hostgroups, name: %s", name) items = [] if parent: group = self.get_hostgroups(user=user, name=parent) @@ -885,7 +884,7 @@ def get_hostgroups(self, user=None, name=None, parent=None, members=False): items = self.fe.hostgroups else: items = self.rg.hostgroups - logger.info("[WebUI - datamanager] got %d hostgroups", len(items)) + logger.debug("[WebUI - datamanager] got %d hostgroups", len(items)) if name: return items.find_by_name(name) @@ -946,7 +945,7 @@ def get_servicegroups(self, user=None, name=None, parent=None, members=False): :param name: only this element :returns: List of elements related to the user """ - logger.info("[WebUI - datamanager] get_servicegroups, name: %s", user) + logger.debug("[WebUI - datamanager] get_servicegroups, name: %s", user) items = [] if parent: group = self.get_servicegroups(user=user, name=parent) @@ -959,7 +958,7 @@ def get_servicegroups(self, user=None, name=None, parent=None, members=False): items = self.fe.servicegroups else: items = self.rg.servicegroups - logger.info("[WebUI - datamanager] got %d servicegroups", len(items)) + logger.debug("[WebUI - datamanager] got %d servicegroups", len(items)) if name: return items.find_by_name(name) @@ -1010,7 +1009,7 @@ def get_host_tags(self): for name in names: items.append((name, self.rg.tags[name])) - logger.warning("[WebUI - datamanager] got %d hosts tags", len(items)) + logger.debug("[WebUI - datamanager] got %d hosts tags", len(items)) return items def get_hosts_tagged_with(self, tag, user): @@ -1032,7 +1031,7 @@ def get_service_tags(self): for name in names: items.append((name, self.rg.tags[name])) - logger.warning("[WebUI - datamanager] got %d services tags", len(items)) + logger.debug("[WebUI - datamanager] got %d services tags", len(items)) return items def get_services_tagged_with(self, tag, user): From 74067c68023cb4675fbd4bd730b504acafdc46c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20MOHIER?= Date: Sun, 17 Apr 2016 10:44:10 +0200 Subject: [PATCH 6/8] Improve #467 --- module/plugins/problems/views/problems.tpl | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/module/plugins/problems/views/problems.tpl b/module/plugins/problems/views/problems.tpl index b1307e28..d88f0ea1 100644 --- a/module/plugins/problems/views/problems.tpl +++ b/module/plugins/problems/views/problems.tpl @@ -62,7 +62,15 @@ %if i == 0: - {{pb.get_name() if pb.display_name == '' else pb.display_name}} + %if pb.__class__.my_type == 'service': + %if pb.host: + {{pb.host.get_name() if pb.host.display_name == '' else pb.host.display_name}} + %else: + {{pb.host_name}} + %end + %else: + {{pb.get_name() if pb.display_name == '' else pb.display_name}} + %end %end From 33953a1ded74ffb5061c4603a921bc0be24728b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20MOHIER?= Date: Sun, 17 Apr 2016 10:44:27 +0200 Subject: [PATCH 7/8] Set version to 2.3.2 --- module/module.py | 9 +++++---- package.json | 4 ++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/module/module.py b/module/module.py index ccc7dc3f..4baeb33f 100644 --- a/module/module.py +++ b/module/module.py @@ -25,17 +25,18 @@ # along with Shinken. If not, see . -WEBUI_VERSION = "2.4.0" +WEBUI_VERSION = "2.3.2" WEBUI_COPYRIGHT = "(c) 2009-2016 - License GNU AGPL as published by the FSF, minimum version 3 of the License." WEBUI_RELEASENOTES = """ -Stand-alone mode -Use Alignak backend +Dashboard currently view +Global notifications enable/disable widget +Use Alignak backend (experimental) """ """ This Class is a plugin for the Shinken Broker. It is in charge -to get brok and recreate real objects, and propose a Web interface :) +to get broks and recreate real objects, and propose a Web User Interface :) """ import traceback diff --git a/package.json b/package.json index 693da06c..54c9c5b6 100644 --- a/package.json +++ b/package.json @@ -1,10 +1,10 @@ { "name": "webui2", "types": ["module"], - "version": "2.2.1", + "version": "2.3.2", "homepage": "https://github.com/shinken-monitoring/mod-webui/wiki", "author": "Frédéric MOHIER", - "description": "Web User Interface for Shinken, version 2.2.0", + "description": "Web User Interface for Shinken, version 2.3.2", "contributors": [ { "name": "Frederic Mohier", From 9f405c8399b6a11709a6dbd83c8f3afe2d8c8907 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20MOHIER?= Date: Sun, 17 Apr 2016 10:49:43 +0200 Subject: [PATCH 8/8] Update README.md --- README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 8ab157f9..477ae31b 100644 --- a/README.md +++ b/README.md @@ -22,11 +22,11 @@ Current version is 2.3.2, available on [`shinken.io`](http://shinken.io/package/ - Allows authenticating a user with Alignak backend - Bugs and fixes: - #471: downtime page error - #469: currently 404 - #468: CSS bug - #466: use display_name when available - ... and some others :) + - #471: downtime page error + - #469: currently 404 + - #468: CSS bug + - #466: use display_name when available + - ... and some others :) ### Version 2.3.1 Only for internal testings and not published on shinken.io