This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository mum. See http://git.chorem.org/mum.git commit 1ecd69dcc249188322996f595eb05b9cf5bddf30 Author: Alexis Guilbaud <guilbaud@codelutin.com> Date: Tue Jun 23 12:01:03 2015 +0200 subscription on service --- app/modules/storage_modules/shelve_db.py | 206 +++++++++++++++++-------------- debian/copyright | 4 + static/js/controllers/dashboardCtrl.js | 115 +---------------- static/js/controllers/headCtrl.js | 137 ++++++++++++++++++++ static/js/controllers/hostPageCtrl.js | 28 +++++ views/dashboard.html | 80 ------------ views/hostpage.html | 27 +++- views/index.html | 81 ++++++++++++ 8 files changed, 393 insertions(+), 285 deletions(-) diff --git a/app/modules/storage_modules/shelve_db.py b/app/modules/storage_modules/shelve_db.py index 609b71d..3836e45 100644 --- a/app/modules/storage_modules/shelve_db.py +++ b/app/modules/storage_modules/shelve_db.py @@ -111,9 +111,10 @@ class shelve_db: else: mod_conf['minor_limit'] = 8 mod_conf['major_limit'] = 10 - self.db['global_conf'][mod] = mod_conf if 'param' in loaded_mod_moni: mod_conf['param'] = loaded_mod_moni['param'] + mod_conf['subscribers'] = {} + self.db['global_conf'][mod] = mod_conf # removing entries of modules that are no loaded anymore mods_to_del = [] for mod in self.db['global_conf']: @@ -485,9 +486,11 @@ class shelve_db: res['detected'][mod] = json.loads(self.db['hosts'][addr_host]['detected'][mod]) res['activated_monitoring'] = {} res['subparts'] = {} + res['subscribers'] = {} for mod in self.db['hosts'][addr_host]['conf']['monitoring']: res['activated_monitoring'][mod] = self.db['hosts'][addr_host]['conf']['monitoring'][mod]['activated'] res['subparts'][mod] = self.db['hosts'][addr_host]['conf']['monitoring'][mod]['subparts'] + res['subscribers'][mod] = self.db['hosts'][addr_host]['conf']['monitoring'][mod]['subscribers'] res['custom_infos'] = self.db['hosts'][addr_host]['conf']['custom_info'] res['interventions'] = self.db['hosts'][addr_host]['conf']['interventions'] res['status'] = self.db['hosts'][addr_host]['status']['state'] @@ -942,7 +945,7 @@ class shelve_db: # create a notification structure if the state is not a success if dict_new_val['state'] != 'success': - dict_notif = self.create_notif_structure(addr_host, mod_name, dict_new_val['state']) + dict_notif = self.create_notif_structure(addr_host, mod_name, dict_new_val['state'], val) # incrementation of the consecutive fails nunmber for this module self.db['hosts'][addr_host]["monitoring"][mod_name]['nb_'+dict_new_val['state']] += 1 else: @@ -1072,7 +1075,7 @@ class shelve_db: size_arch -= 1 return dict_archive - def create_notif_structure(self, addr_host, moni_mod, status): + def create_notif_structure(self, addr_host, moni_mod, status, val): """ Creates and returns a data structure that will be used by the notification modules. :param addr_host: the IP address of the host @@ -1084,10 +1087,19 @@ class shelve_db: ... } """ - title = "[Mum] " + status + " for " + addr_host + " " + moni_mod - msg = "Mum reported a " + status + " value from the " + moni_mod + " module. " - msg += "The following users will be notified: " - msg += str(self.db['hosts'][addr_host]['conf']['subscribers']) + host_display_name = self.db['hosts'][addr_host]['conf']['display_name'] + consecutive_fails = self.db['hosts'][addr_host]["monitoring"][moni_mod]['nb_' + status] + + common_title = "[Mum] " + status + " for " + host_display_name + " (" + addr_host + ") with " + moni_mod + common_msg = "Mum reported a " + status + " for " + host_display_name + " (" + addr_host + ") with " + moni_mod+ " module for the " + str(consecutive_fails) + " consecutive time " + common_msg += "The last value checked for this part is: " + str(val) + ".\n" + + # Lists to avoid to send the same message to the same user twice if registered on the same host from different ways + users_from_group = [] + users_from_host = [] + + #msg += "The following users will be notified: " + #msg += str(self.db['hosts'][addr_host]['conf']['subscribers']) dict_notif = {} notif_type = "" if status == 'warning': @@ -1095,38 +1107,61 @@ class shelve_db: else: notif_type = 'major' - for username in self.db['hosts'][addr_host]['conf']['subscribers']: - # creates a message for all subscribers in the host - for notif_mod in self.db['hosts'][addr_host]['conf']['subscribers'][username][notif_type]: - #{'priority': int, 'activated': bool} - param_notif = self.db['hosts'][addr_host]['conf']['subscribers'][username][notif_type][notif_mod] - if param_notif['activated'] and \ - param_notif['priority'] == self.db['hosts'][addr_host]['status']['nb_' + status]: - if notif_mod not in dict_notif: - dict_notif[notif_mod] = [] - dict_notif[notif_mod].append({'user': self.db['users'][username]['settings'], - 'moni_mod': moni_mod, - 'title': "[Mum] " + status + " on " + addr_host, - 'msg': msg}) + # 1) group notifications for group in self.db['groups']: - # creates a message for all subscribers in a group which the host is member if addr_host in self.db['groups'][group]['hosts']: for username in self.db['groups'][group]['subscribers']: for notif_mod in self.db['groups'][group]['subscribers'][username][notif_type]: param_notif = self.db['groups'][group]['subscribers'][username][notif_type][notif_mod] if param_notif['activated'] and \ - param_notif['priority'] == self.db['hosts'][addr_host]['status']['nb_' + status]: - title = "[Mum] " + status + " for " + addr_host + " on group " + group - msg = "Mum reported a " + status + " from the " + moni_mod + " module on host " + \ - addr_host + " member of group " + group + "." - + param_notif['priority'] == consecutive_fails: + users_from_group.append(username) + title = common_title + " on group " + group + msg = common_msg + "This machine is a member of the group " + group + " which you are registered." if notif_mod not in dict_notif: dict_notif[notif_mod] = [] dict_notif[notif_mod].append({'user': self.db['users'][username]['settings'], 'moni_mod': moni_mod, 'title': title, 'msg': msg}) + + # 2) host notifications + for username in self.db['hosts'][addr_host]['conf']['subscribers']: + # creates a message for all subscribers in the host + for notif_mod in self.db['hosts'][addr_host]['conf']['subscribers'][username][notif_type]: + #{'priority': int, 'activated': bool} + param_notif = self.db['hosts'][addr_host]['conf']['subscribers'][username][notif_type][notif_mod] + if param_notif['activated'] and param_notif['priority'] == consecutive_fails and username not in users_from_group: + users_from_host.append(username) + msg = common_msg + if users_from_group != []: + msg += "The following users will also be notified : " + str(users_from_group) + if notif_mod not in dict_notif: + dict_notif[notif_mod] = [] + dict_notif[notif_mod].append({'user': self.db['users'][username]['settings'], + 'moni_mod': moni_mod, + 'title': "[Mum] " + status + " on " + addr_host, + 'msg': msg}) + + # 3) service notifications + for username in self.db['hosts'][addr_host]['conf']['monitoring'][moni_mod]['subscribers']: + for notif_mod in self.db['hosts'][addr_host]['conf']['monitoring'][moni_mod]['subscribers'][username][notif_type]: + param_notif = self.db['hosts'][addr_host]['conf']['monitoring'][moni_mod]['subscribers'][username][notif_type][notif_mod] + if param_notif['activated'] and param_notif['priority'] == consecutive_fails and username not in users_from_group\ + and username not in users_from_host: + title = common_title + msg = common_msg + if users_from_group != []: + msg += "The following users will also be notified (group notifications): " + str(users_from_group) + "\n" + if users_from_host != []: + msg += "The following users will also be notified (host notifications): " + str(users_from_host) + "\n" + if notif_mod not in dict_notif: + dict_notif[notif_mod] = [] + dict_notif[notif_mod].append({'user': self.db['users'][username]['settings'], + 'moni_mod': moni_mod, + 'title': "[Mum] " + status + " on " + addr_host, + 'msg': msg}) return dict_notif def get_stats(self, args): @@ -1206,25 +1241,6 @@ class shelve_db: finally: self.close_db() - def subscribe_to_group(self, args): - """ - Called from the notifications page. Add a list of users to the group notifications structure. - :param args: a dictionary containing : - { 'users': list<string>, 'group': string } - """ - users = args['users'] - group = args['group'] - self.open_db() - try: - for user in users: - self.db['groups'][group]['subscribers'][user] = {} - self.db['groups'][group]['subscribers'][user]['major'] = {} - self.db['groups'][group]['subscribers'][user]['minor'] = {} - except Exception: - self.logger.error(traceback.format_exc()) - finally: - self.close_db() - def update_subscription_to_group(self, args): """ Called from the notifications page. Updates the subscription to a following user from a host. @@ -1253,22 +1269,6 @@ class shelve_db: finally: self.close_db() - def unsubscribe_to_group(self, args): - """ - Called from the notifications page. Unsubscribes an user for a host notifications. - :param args: a dictionary containing : - { 'username': string, 'group': string } - """ - username = args['username'] - group = args['group'] - self.open_db() - try: - del self.db['groups'][group]['subscribers'][username] - except Exception: - self.logger.error(traceback.format_exc()) - finally: - self.close_db() - def get_groups(self, args): """ Get all the groups informations @@ -1461,30 +1461,12 @@ class shelve_db: finally: self.close_db() - def subscribe_to_host(self, args): - """ - Called from the notifications page. Add a list of users to the host notifications structure. - :param args: a dictionary containing : - { 'users': list<string>, 'addr_host': string } - """ - users = args['users'] - addr_host = args['addr_host'] - self.open_db() - try: - for user in users: - self.db['hosts'][addr_host]['conf']['subscribers'][user] = {} - self.db['hosts'][addr_host]['conf']['subscribers'][user]['minor'] = {} - self.db['hosts'][addr_host]['conf']['subscribers'][user]['major'] = {} - except Exception: - self.logger.error(traceback.format_exc()) - finally: - self.close_db() - def update_subscription_to_host(self, args): """ Called from the notifications page. Updates the subscription to a following user from a host. :param args: - { 'group': string, + { 'addr_host' :str, + 'group': string, 'subscription': username:{ {'minor': @@ -1508,27 +1490,40 @@ class shelve_db: finally: self.close_db() - def unsubscribe_to_host(self, args): + def get_host_subscribers(self, args): """ - Called from the notifications page. Unsubscribes an user for host notifications. - :param args: a dictionary containing : - { 'username': string, 'addr_host': string } + Called from the notifications page. Get informations about the subscribers to a host. + :param args: A dictionary containing : + { 'addr_host': string } + :return: a dictionary containing : + { username: + {'minor': + { notif_mod: priority }, + ... + , + 'major': + { notif_mod: priority }, + ... + }}} """ - username = args['username'] addr_host = args['addr_host'] + res = {} self.open_db() try: - del self.db['hosts'][addr_host]['conf']['subscribers'][username] + res = self.db['hosts'][addr_host]['conf']['subscribers'] except Exception: self.logger.error(traceback.format_exc()) finally: self.close_db() + return res - def get_host_subscribers(self, args): + def get_service_subscribers(self, args): """ Called from the notifications page. Get informations about the subscribers to a host. :param args: A dictionary containing : - { 'addr_host': string } + { 'addr_host': string, + 'service': string + } :return: a dictionary containing : { username: {'minor': @@ -1541,16 +1536,47 @@ class shelve_db: }}} """ addr_host = args['addr_host'] + service = args['service'] res = {} self.open_db() try: - res = self.db['hosts'][addr_host]['conf']['subscribers'] + res = self.db['hosts'][addr_host]['conf']['monitoring'][service]['subscribers'] except Exception: self.logger.error(traceback.format_exc()) finally: self.close_db() return res + def update_subscription_to_service(self, args): + """ + Called from the notifications page. Updates the subscription to a following user from a host. + :param args: + { 'addr_host' : str, + 'service': string, + 'subscription': + username:{ + {'minor': + { notif_mod: priority }, + ... + },{ + 'major': + { notif_mod: priority }, + ... + } + } + } + :return: + """ + addr_host = args['addr_host'] + service = args['service'] + self.open_db() + try: + self.db['hosts'][addr_host]['conf']['monitoring'][service]['subscribers'] = args['subscription'] + except Exception: + self.logger.error(traceback.format_exc()) + finally: + self.close_db() + def store_task(self, task_id): """ Stores a new task into the database diff --git a/debian/copyright b/debian/copyright index a75fb76..e6c4a31 100644 --- a/debian/copyright +++ b/debian/copyright @@ -44,4 +44,8 @@ License: MIT Files: debian/mum/usr/lib/bower_components/es5-shim/* Copyright: 2009-2014 Kristopher Michael Kowal and contributors +License: MIT + +Files: debian/mum/usr/lib/bower_components/fontawesome/* +Copyright: 2015 davegandy License: MIT \ No newline at end of file diff --git a/static/js/controllers/dashboardCtrl.js b/static/js/controllers/dashboardCtrl.js index ea383cc..98e9acc 100644 --- a/static/js/controllers/dashboardCtrl.js +++ b/static/js/controllers/dashboardCtrl.js @@ -140,7 +140,8 @@ mumApp.controller('dashboardCtrl', function ($scope, $routeParams, $location, $r resolve: { notif_args: function () { return {'addr_host' : addr_host, - 'group_name': group_name}; + 'group_name': group_name, + 'service': null}; } } }); @@ -221,118 +222,6 @@ mumApp.controller('dashboardCtrl', function ($scope, $routeParams, $location, $r } }); -mumApp.controller('ModalNotifInstanceCtrl', function ($scope, $rootScope, $modalInstance, $route, $timeout, notif_args) { - $scope.addr_host = null; - $scope.grp_name = null; - - $scope.option_selected = ""; // 'grp' OR 'host' - - $scope.notif_mods = []; - - $scope.subscribers = {};/* { username: - {'minor': { - { notif_mod: priority }, - ... - }, - 'major': { - { notif_mod: priority }, - ... - }}} */ - - $scope.users = {}; - - $scope.new_notif = {"priority": null, "activated": true}; - $scope.new_notif_type = ""; - $scope.new_mod_notif = ""; - $scope.new_username = ""; - - $scope.get_group_subscribers = function () { - var args = {'group': $scope.grp_name}; - $rootScope.$broadcast("sendViaWs", JSON.stringify({"CALL_FUNC_DB": {'func': 'get_group_subscribers', 'args': args}})); - }; - - $scope.get_host_subscribers = function () { - var args = {'addr_host': $scope.addr_host}; - $rootScope.$broadcast("sendViaWs", JSON.stringify({"CALL_FUNC_DB": {'func': 'get_host_subscribers', 'args': args}})); - }; - - if(notif_args.addr_host != null){ - $scope.addr_host = notif_args.addr_host; - $scope.option_selected = "host"; - $scope.get_host_subscribers(); - } - else{ - $scope.grp_name = notif_args.group_name; - $scope.option_selected = "grp"; - $scope.get_group_subscribers(); - } - - $scope.$on("resCall", function (event, args) { - if (args.func == 'get_host_subscribers' || args.func == 'get_group_subscribers') { - $timeout(function () { - $scope.subscribers = args.res; - }, 0); - $rootScope.$broadcast("sendViaWs", JSON.stringify({"GET_LOADED_NOTIF_MOD": ""})); - } - else if (args.func == 'get_users') { - $timeout(function () { - $scope.users = args.res; - }, 0); - } - else if (args.func == 'update_subscription_to_group' || 'update_subscription_to_host'){ - $rootScope.$broadcast("sendViaWs", JSON.stringify({"GET_HOSTS": ""})); - //$modalInstance.close(); - } - }); - - $scope.$on("resGetLoadedNotifMod", function (event, args) { - for (var notif_mod_name in args){ - $scope.notif_mods.push(notif_mod_name); - } - $rootScope.$broadcast("sendViaWs", JSON.stringify({"CALL_FUNC_DB": {'func': 'get_users', 'args': null}})); - }); - - $scope.add_notif = function(){ - if (!$scope.subscribers.hasOwnProperty($scope.new_username)){ - $scope.subscribers[$scope.new_username] = {}; - $scope.subscribers[$scope.new_username].minor = {}; - $scope.subscribers[$scope.new_username].major = {}; - } - $scope.subscribers[$scope.new_username][$scope.new_notif_type][$scope.new_mod_notif] = $scope.new_notif; - $scope.new_notif = {"priority": null, "activated": true}; - $scope.new_notif_type = ""; - $scope.new_mod_notif = ""; - $scope.new_username = ""; - $scope.save(); - }; - - $scope.remove_notif = function(username, notif_type, mod_notif_name){ - delete $scope.subscribers[username][notif_type][mod_notif_name]; - if (Object.keys($scope.subscribers[username].minor).length == 0 && - Object.keys($scope.subscribers[username].major).length == 0){ - delete $scope.subscribers[username]; - } - $scope.save(); - }; - - $scope.save = function () { - var args = {}; - args['subscription'] = $scope.subscribers; - if ($scope.option_selected == 'grp') { - args['group'] = $scope.grp_name; - $rootScope.$broadcast("sendViaWs", JSON.stringify({"CALL_FUNC_DB": {'func': 'update_subscription_to_group', 'args': args}})); - } - else { - args['addr_host'] = $scope.addr_host; - $rootScope.$broadcast("sendViaWs", JSON.stringify({"CALL_FUNC_DB": {'func': 'update_subscription_to_host', 'args': args}})); - } - }; - - $scope.close = function () { - $modalInstance.close(); - }; -}); - mumApp.controller('ModalLogInstanceCtrl', function ($scope, $rootScope, $modalInstance, $route, $timeout) { $scope.log_content = ""; $scope.nb_lines = 50; diff --git a/static/js/controllers/headCtrl.js b/static/js/controllers/headCtrl.js index 4e30dde..4a32550 100644 --- a/static/js/controllers/headCtrl.js +++ b/static/js/controllers/headCtrl.js @@ -167,4 +167,141 @@ mumApp.controller('headCtrl', function ($scope, $rootScope, toastr, $interval, $ return res; }; +}); + +mumApp.controller('ModalNotifInstanceCtrl', function ($scope, $rootScope, $modalInstance, $route, $timeout, notif_args) { + $scope.addr_host = null; + $scope.grp_name = null; + $scope.service = null; + + $scope.option_selected = ""; // 'grp' OR 'host' OR 'service' + + $scope.notif_mods = []; + + $scope.subscribers = {};/* { username: + {'minor': { + { notif_mod: priority }, + ... + }, + 'major': { + { notif_mod: priority }, + ... + }}} */ + + $scope.users = {}; + + $scope.new_notif = {"priority": null, "activated": true}; + $scope.new_notif_type = ""; + $scope.new_mod_notif = ""; + $scope.new_username = ""; + + $scope.get_group_subscribers = function () { + var args = {'group': $scope.grp_name}; + $rootScope.$broadcast("sendViaWs", JSON.stringify({"CALL_FUNC_DB": {'func': 'get_group_subscribers', 'args': args}})); + }; + + $scope.get_host_subscribers = function () { + var args = {'addr_host': $scope.addr_host}; + $rootScope.$broadcast("sendViaWs", JSON.stringify({"CALL_FUNC_DB": {'func': 'get_host_subscribers', 'args': args}})); + }; + + $scope.get_service_subscribers = function () { + var args = {'addr_host': $scope.addr_host, + 'service': $scope.service}; + $rootScope.$broadcast("sendViaWs", JSON.stringify({"CALL_FUNC_DB": {'func': 'get_service_subscribers', 'args': args}})); + }; + + if(notif_args.addr_host != null && notif_args.service == null){ + // notifications by machine + $scope.addr_host = notif_args.addr_host; + $scope.option_selected = "host"; + $scope.get_host_subscribers(); + } + else if(notif_args.group_name != null){ + // notifications by group + $scope.grp_name = notif_args.group_name; + $scope.option_selected = "grp"; + $scope.get_group_subscribers(); + } + else{ + // notifications by service + $scope.service = notif_args.service; + $scope.addr_host = notif_args.addr_host; + $scope.option_selected = "service"; + $scope.get_service_subscribers(); + } + + $scope.$on("resCall", function (event, args) { + if (args.func == 'get_host_subscribers' || args.func == 'get_group_subscribers' || args.func == 'get_service_subscribers') { + $timeout(function () { + $scope.subscribers = args.res; + }, 0); + $rootScope.$broadcast("sendViaWs", JSON.stringify({"GET_LOADED_NOTIF_MOD": ""})); + } + else if (args.func == 'get_users') { + $timeout(function () { + $scope.users = args.res; + }, 0); + } + else if (args.func == 'update_subscription_to_group' || 'update_subscription_to_host'){ + if($scope.option_selected != 'service'){ + $rootScope.$broadcast("sendViaWs", JSON.stringify({"GET_HOSTS": ""})); + } + else{ + $rootScope.$broadcast("sendViaWs", JSON.stringify({"GET_HOST_INFO": $scope.addr_host})); + } + } + }); + + $scope.$on("resGetLoadedNotifMod", function (event, args) { + for (var notif_mod_name in args){ + $scope.notif_mods.push(notif_mod_name); + } + $rootScope.$broadcast("sendViaWs", JSON.stringify({"CALL_FUNC_DB": {'func': 'get_users', 'args': null}})); + }); + + $scope.add_notif = function(){ + if (!$scope.subscribers.hasOwnProperty($scope.new_username)){ + $scope.subscribers[$scope.new_username] = {}; + $scope.subscribers[$scope.new_username].minor = {}; + $scope.subscribers[$scope.new_username].major = {}; + } + $scope.subscribers[$scope.new_username][$scope.new_notif_type][$scope.new_mod_notif] = $scope.new_notif; + $scope.new_notif = {"priority": null, "activated": true}; + $scope.new_notif_type = ""; + $scope.new_mod_notif = ""; + $scope.new_username = ""; + $scope.save(); + }; + + $scope.remove_notif = function(username, notif_type, mod_notif_name){ + delete $scope.subscribers[username][notif_type][mod_notif_name]; + if (Object.keys($scope.subscribers[username].minor).length == 0 && + Object.keys($scope.subscribers[username].major).length == 0){ + delete $scope.subscribers[username]; + } + $scope.save(); + }; + + $scope.save = function () { + var args = {}; + args['subscription'] = $scope.subscribers; + if ($scope.option_selected == 'grp') { + args['group'] = $scope.grp_name; + $rootScope.$broadcast("sendViaWs", JSON.stringify({"CALL_FUNC_DB": {'func': 'update_subscription_to_group', 'args': args}})); + } + else if($scope.option_selected == 'host'){ + args['addr_host'] = $scope.addr_host; + $rootScope.$broadcast("sendViaWs", JSON.stringify({"CALL_FUNC_DB": {'func': 'update_subscription_to_host', 'args': args}})); + } + else{ + args['addr_host'] = $scope.addr_host; + args['service'] = $scope.service; + $rootScope.$broadcast("sendViaWs", JSON.stringify({"CALL_FUNC_DB": {'func': 'update_subscription_to_service', 'args': args}})); + } + }; + + $scope.close = function () { + $modalInstance.close(); + }; }); \ No newline at end of file diff --git a/static/js/controllers/hostPageCtrl.js b/static/js/controllers/hostPageCtrl.js index a335d10..c7c3da5 100644 --- a/static/js/controllers/hostPageCtrl.js +++ b/static/js/controllers/hostPageCtrl.js @@ -69,6 +69,18 @@ mumApp.controller('hostPageCtrl', function ($scope, $rootScope, $route, $routePa $scope.selected_mod_part = ""; + $scope.get_service_sub_num = function(service_name){ + res = {}; + res.nb_sub = Object.keys($scope.items.subscribers[service_name]).length; + if (res.nb_sub == 0){ + res.btn_type = 'default'; + } + else{ + res.btn_type = 'primary'; + } + return res; + }; + $scope.rescan = function () { $location.path('/scan/' + $scope.addr_host); }; @@ -206,6 +218,7 @@ mumApp.controller('hostPageCtrl', function ($scope, $rootScope, $route, $routePa else { // we take only monitoring updates $scope.items.monitoring = args.monitoring; $scope.items.status = args.status; + $scope.items.subscribers = args.subscribers; } // Updating struct for activated modules selection in any case @@ -331,6 +344,21 @@ mumApp.controller('hostPageCtrl', function ($scope, $rootScope, $route, $routePa } }); }; + + $scope.open_modal_notif_service = function (addr_host, service) { + var modalInstance = $modal.open({ + templateUrl: 'modal_notif_label.html', + controller: 'ModalNotifInstanceCtrl', + size: 'lg', + resolve: { + notif_args: function () { + return {'addr_host' : addr_host, + 'group_name': null, + 'service': service}; + } + } + }); + }; }); // modals controllers diff --git a/views/dashboard.html b/views/dashboard.html index 5713e93..7be0830 100644 --- a/views/dashboard.html +++ b/views/dashboard.html @@ -223,86 +223,6 @@ <button type="button" class="btn btn-default" ng-click="open_modal_log()">See the logs...</button> </div> - <script type="text/ng-template" id="modal_notif_label.html"> - <div class="modal-header"> - <h3 class="modal-title">Notifications for {{addr_host}}{{grp_name}}</h3> - </div> - <div class="modal-body"> - <div ng-repeat="(username, subscriber) in subscribers"> - {{username}} will be notified: - <ul> - <li ng-repeat="(minor_notif_name, minor_notif_obj) in subscriber.minor" - ng-show="minor_notif_obj.activated"> - with {{minor_notif_name}} after {{minor_notif_obj.priority}} minor notification(s). - <button type="button" - class="btn btn-danger btn-xs" - aria-label="Remove notification instruction" - ng-click="remove_notif(username, 'minor', minor_notif_name)"> - <span class="fa fa-minus" - aria-hidden="true"></span> - </button> - </li> - <li ng-repeat="(major_notif_name, major_notif_obj) in subscriber.major" - ng-show="major_notif_obj.activated"> - with {{major_notif_name}} after {{major_notif_obj.priority}} major notification(s). - <button type="button" - class="btn btn-danger btn-xs" - aria-label="Remove notification instruction" - ng-click="remove_notif(username, 'major', major_notif_name)"> - <span class="fa fa-minus" - aria-hidden="true"></span> - </button> - </li> - </ul> - </div> - - <div class="row"> - <div class="col-md-4"> - <label for="selected_users">Add</label> - <select class="form-control" - id="selected_users" - ng-model="new_username" - ng-options="user as user for user in users"> - </select> - </div> - - <div class="col-md-4"> - <label for="new_mod_notif">with</label> - <select class="form-control" - id="new_mod_notif" - ng-model="new_mod_notif" - ng-options="notif_mod for notif_mod in notif_mods"> - </select> - </div> - - <div class="col-md-4"> - <label for="new_notif_prio">after</label><br/> - <input type="number" - id="new_notif_prio" - min="1" - ng-model="new_notif.priority"> - <select ng-model="new_notif_type" - id="new_notif_type"> - <option>major</option> - <option>minor</option> - </select> notification(s) - </div> - </div> - <button type="button" - class="btn btn-success" - aria-label="Add a notification rule" - ng-click="add_notif()" - ng-disabled="new_notif.priority==null || new_notif_type=='' || new_mod_notif=='' || new_username==''"> - <span class="fa fa-plus" - aria-hidden="true"></span> - </button> - </div> - <div class="modal-footer"> - <button type="button" class="btn btn-default" data-dismiss="modal" ng-click="close()">Close</button> - <!--<button type="button" class="btn btn-primary" ng-click="save()">Save changes</button>--> - </div> - </script> - <script type="text/ng-template" id="modal_log_label.html"> <div class="modal-header"> <h3 class="modal-title">Logs from Mum Service</h3> diff --git a/views/hostpage.html b/views/hostpage.html index 7ac57f6..8cd95ff 100644 --- a/views/hostpage.html +++ b/views/hostpage.html @@ -77,7 +77,12 @@ </a> </td> <td> - {{mod.state}} + <span popover-placement="left" + popover="Consecutive warnings: {{mod.nb_warning}} ; Consecutive dangers: {{mod.nb_danger}}" + popover-trigger="mouseenter" + style="text-decoration:underline"> + {{mod.state}} + </span> </td> <td> {{mod.date.split('.')[0]}} @@ -110,7 +115,25 @@ <span class="fa fa-times" aria-hidden="true"></span> </button> </td> - <td>{{mod.nb_warning}},{{mod.nb_danger}}</td> + <td> + <button type="button" + class="btn btn-{{get_service_sub_num(modname).btn_type}} btn-xs" + aria-label="Subscribers" + popover-placement="left" + popover="{{get_service_sub_num(modname).nb_sub}} subscribers" + popover-trigger="mouseenter" + ng-click="open_modal_notif_service(addr_host, modname)" + ng-show="groupname != 'all'"> + <span class="fa fa-user" + aria-hidden="true" + ng-show="get_service_sub_num(modname).nb_sub > 0"> + </span> + <span class="fa fa-user-times" + aria-hidden="true" + ng-show="get_service_sub_num(modname).nb_sub == 0"> + </span> + </button> + </td> </tr> <tr ng-repeat-end ng-repeat="(valname, val) in mod.value" diff --git a/views/index.html b/views/index.html index 80d02a2..00b08de 100644 --- a/views/index.html +++ b/views/index.html @@ -109,6 +109,87 @@ </div> </div> </div> + + <script type="text/ng-template" id="modal_notif_label.html"> + <div class="modal-header"> + <h3 class="modal-title">Notifications for {{service}}{{addr_host}}{{grp_name}}</h3> + </div> + <div class="modal-body"> + <div ng-repeat="(username, subscriber) in subscribers"> + {{username}} will be notified: + <ul> + <li ng-repeat="(minor_notif_name, minor_notif_obj) in subscriber.minor" + ng-show="minor_notif_obj.activated"> + with {{minor_notif_name}} after {{minor_notif_obj.priority}} minor notification(s). + <button type="button" + class="btn btn-danger btn-xs" + aria-label="Remove notification instruction" + ng-click="remove_notif(username, 'minor', minor_notif_name)"> + <span class="fa fa-minus" + aria-hidden="true"></span> + </button> + </li> + <li ng-repeat="(major_notif_name, major_notif_obj) in subscriber.major" + ng-show="major_notif_obj.activated"> + with {{major_notif_name}} after {{major_notif_obj.priority}} major notification(s). + <button type="button" + class="btn btn-danger btn-xs" + aria-label="Remove notification instruction" + ng-click="remove_notif(username, 'major', major_notif_name)"> + <span class="fa fa-minus" + aria-hidden="true"></span> + </button> + </li> + </ul> + </div> + + <div class="row"> + <div class="col-md-4"> + <label for="selected_users">Add</label> + <select class="form-control" + id="selected_users" + ng-model="new_username" + ng-options="user as user for user in users"> + </select> + </div> + + <div class="col-md-4"> + <label for="new_mod_notif">with</label> + <select class="form-control" + id="new_mod_notif" + ng-model="new_mod_notif" + ng-options="notif_mod for notif_mod in notif_mods"> + </select> + </div> + + <div class="col-md-4"> + <label for="new_notif_prio">after</label><br/> + <input type="number" + id="new_notif_prio" + min="1" + ng-model="new_notif.priority"> + <select ng-model="new_notif_type" + id="new_notif_type"> + <option>major</option> + <option>minor</option> + </select> notification(s) + </div> + </div> + <button type="button" + class="btn btn-success" + aria-label="Add a notification rule" + ng-click="add_notif()" + ng-disabled="new_notif.priority==null || new_notif_type=='' || new_mod_notif=='' || new_username==''"> + <span class="fa fa-plus" + aria-hidden="true"></span> + </button> + </div> + <div class="modal-footer"> + <button type="button" class="btn btn-default" data-dismiss="modal" ng-click="close()">Close</button> + <!--<button type="button" class="btn btn-primary" ng-click="save()">Save changes</button>--> + </div> + </script> + </body> </html> -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.