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 6099878d2c0586712e5329779aaf74816cef5000 Author: Alexis Guilbaud <guilbaud@codelutin.com> Date: Fri Mar 20 15:20:31 2015 +0100 notifications page : affichage du tableau correspondant aux données de notification concerannt 1 utilisateur sur 1 groupe/hote et modification possible de ces données via formulaire --- app/modules/storage_modules/shelve_db.py | 188 ++++++++++++++++------------- static/js/controllers/notificationsCtrl.js | 44 ++++++- views/notifications.html | 118 ++---------------- 3 files changed, 158 insertions(+), 192 deletions(-) diff --git a/app/modules/storage_modules/shelve_db.py b/app/modules/storage_modules/shelve_db.py index 69c6c65..78e0c9a 100644 --- a/app/modules/storage_modules/shelve_db.py +++ b/app/modules/storage_modules/shelve_db.py @@ -117,11 +117,11 @@ class shelve_db: { mod_name: { - 'class_name': val, => the name of the class to instanciate - 'compatible_os': [val1, val2, ...], => a list containing the compatibles os - 'unit': val, => the unit type of return ('%', 'bool' or other) - 'block': val, => the monitoring block of the module - 'external': bool => indicates if this modules comes from external directory + 'class_name': string, => the name of the class to instanciate + 'compatible_os': [string1, string2, ...], => a list containing the compatibles os + 'unit': string, => the unit type of return ('%', 'bool' or other) + 'block': string, => the monitoring block of the module + 'external': bool => indicates if this modules comes from external directory } } :return a list containing the default parameters for each monitoring module (at least ping) @@ -180,11 +180,11 @@ class shelve_db: { mod_name: { - 'class_name': val, => the name of the class to instanciate - 'compatible_os': [val1, val2, ...], => a list containing the compatibles os - 'unit': val, => the unit type of return ('%', 'bool' or other) - 'block': val, => the monitoring block of the module - 'external': bool => indicates if this modules comes from external directory + 'class_name': string, => the name of the class to instanciate + 'compatible_os': [string1, string2, ...], => a list containing the compatibles os + 'unit': string, => the unit type of return ('%', 'bool' or other) + 'block': string, => the monitoring block of the module + 'external': bool => indicates if this modules comes from external directory } } :return a list containing the default parameters for each monitoring module (at least ping) @@ -216,10 +216,10 @@ class shelve_db: """ Returns the connection parameters of an host. :param args: A dictionnary containing : - {'addr_host': val} + {'addr_host': string} :return: The connection parameters in the form: mod_name: { - {param1: val1, param2: val2, ...} + {param1: string1, param2: string2, ...} } """ self.open_db() @@ -236,11 +236,11 @@ class shelve_db: :param addr_host: the address IP of the host :return: structured informations about monitoring in form : [{ - 'addr' : val, => the IP address of the host - 'os', val, => the operating system of the host - 'mod_name', val, => the name of the monitoring module - 'time', val, => the time at when to launch the monitoring module - 'freq', val => the frequency check (in seconds) + 'addr' : string, => the IP address of the host + 'os', string, => the operating system of the host + 'mod_name', string, => the name of the monitoring module + 'time', datetime, => the time at when to launch the monitoring module + 'freq', int => the frequency check (in seconds) }, ...] """ self.open_db() @@ -283,12 +283,12 @@ class shelve_db: { "addr":"192.168.74.1", "name":"www.example.com", - "status":val, //"success" or "warning" or "danger" or "" + "status":string, //"success" or "warning" or "danger" or "" "group":[ "all", ...], - "last_check":val //UNIX time + "last_check":datetime "subscribers":{ - "uid":val, - "priority":val + "uid":string, + "priority":int } "warning": [mod_name, ...] "danger": [mod_name, ...] @@ -345,24 +345,24 @@ class shelve_db: { modname: { - key:val, + key:string, ... } } - "hostname":val, + "hostname":string, "monitoring": { modname: { - "date":val, - "state":val, - "value":val + "date":datetime, + "state":string, + "value":string } }, 'activated_monitoring':{ mod_name: bool }, - "custom_infos":val + "custom_infos":string } """ self.open_db() @@ -395,7 +395,7 @@ class shelve_db: Removes a host from the database. All the monitoring intructions concerning this host will be deleted. Finally, if the host is part of a group, it will be also removed from these groups. :param args: A dictionary containing: - {'addr_host': val} + {'addr_host': string} """ addr_host = args['addr_host'] self.open_db() @@ -431,8 +431,8 @@ class shelve_db: Updates the custom informations stored on the host's configuration :param args: a structure containing the values : { - 'addr_host': val, - 'txt': val + 'addr_host': string, + 'txt': string } """ addr_host = args['addr_host'] @@ -448,10 +448,10 @@ class shelve_db: Add a new intervention, stored on the host's configuration :param args: a structure containing the values : { - 'addr_host': val, => the IP adress of the host - 'user' : val, => the username responsible of the intervention - 'date' : val, => the intervention's date - 'details' : val => a string explaining the intervetion + 'addr_host': string, => the IP adress of the host + 'user' : string, => the username responsible of the intervention + 'date' : string, => the intervention's date + 'details' : string => a string explaining the intervetion } """ addr_host = args['addr_host'] @@ -470,7 +470,7 @@ class shelve_db: Activates or desactivates monitoring modules for a given host :param args: a dictionary containing : { - 'addr_host': val, + 'addr_host': string, 'activated':{ mod_name: bool } @@ -479,10 +479,10 @@ class shelve_db: { mod_name: { - 'class_name': val, => the name of the class to instanciate - 'compatible_os': [val1, val2, ...], => a list containing the compatibles os - 'unit': val, => the unit type of return ('%', 'bool' or other) - 'block': val, => the monitoring block of the module + 'class_name': string, => the name of the class to instanciate + 'compatible_os': [string1, string2, ...], => a list containing the compatibles os + 'unit': string, => the unit type of return ('%', 'bool' or other) + 'block': string, => the monitoring block of the module 'external': bool => indicates if this modules comes from external directory } } @@ -519,13 +519,13 @@ class shelve_db: """ Returns a structure containing informations about the settings of a monitoring module for a given host. :param args: a list containing the arguments : - {'addr_host': val, 'mod_name':val] + {'addr_host': string, 'mod_name':string] :return: a structure containing : { - 'unit' : val, // the unit of the value - 'minor_limit' : val, - 'major_limit' : val, - 'freq' : val + 'unit' : string, // the unit of the value + 'minor_limit' : int, + 'major_limit' : int, + 'freq' : int // in seconds } """ addr_host = args['addr_host'] @@ -548,11 +548,11 @@ class shelve_db: Save a new configuration for a monitoring module and for a specific host. :param args: a structure containing the values : { - 'addr_host': val, - 'mod_name': val, - 'freq' : val, - 'minor_limit' : val, - 'major_limit' : val + 'addr_host': string, + 'mod_name': string, + 'freq' : int, + 'minor_limit' : int, + 'major_limit' : int } """ addr_host = args['addr_host'] @@ -569,9 +569,9 @@ class shelve_db: """ Save the priorities of connections modules for a host. :param args: A dictionary containing: - {'addr_host' : val, + {'addr_host' : string, 'priorities':{ - mod_name: val + mod_name: string } } """ @@ -587,8 +587,8 @@ class shelve_db: """ Save the connection configuration of a host. :param args: A dictionary containting: - {'addr_host': val, - 'modname': val, + {'addr_host': string, + 'modname': string, 'current_config': val} """ addr_host = args['addr_host'] @@ -606,7 +606,7 @@ class shelve_db: Get the configured connections by priority of a host. :param addr_host: The IP address of the host. :return: A list containing: - [{'conn_mod_name': val, 'priority': val, 'args': {arg1: val, ...}}] + [{'conn_mod_name': string, 'priority': int, 'args': {arg1: val, ...}}] """ res = [] self.open_db() @@ -723,8 +723,8 @@ class shelve_db: Add given hosts to a group. If the group doesn't exists on the database, it will be created. :param args: a dictionary containing : { - 'host_list': val, # a list of IP adresses - 'group'; val # the group name + 'host_list': list<string>, # a list of IP adresses + 'group'; string # the group name } """ group = args['group'] @@ -748,8 +748,8 @@ class shelve_db: Remove given hosts to a group. If the group is empty afterwards, il will be also deleted. :param args: a dictionary containing : { - 'host_list': val, # a list of IP adresses - 'group'; val # the group name + 'host_list': list<string>, # a list of IP adresses + 'group'; string # the group name } """ group = args['group'] @@ -769,7 +769,7 @@ class shelve_db: """ Add a list of users to the group notifications structure. :param args: a dictionary containing : - { 'users': list<string>, 'group': val } + { 'users': list<string>, 'group': string } """ users = args['users'] group = args['group'] @@ -784,12 +784,17 @@ class shelve_db: """ Updates the subscription to a following user from a host. :param args: - { 'group': val, - 'username': val, - 'subscription: [ - { notif_mod: priority }, - ... - ] + { 'group': string, + 'username': string, + 'subscription': + {'minor': [ + { notif_mod: priority }, + ... + ], + 'major': [ + { notif_mod: priority }, + ... + ]} } :return: """ @@ -805,7 +810,7 @@ class shelve_db: """ Unsubscribes an user for a host notifications. :param args: a dictionary containing : - { 'username': val, 'group': val } + { 'username': string, 'group': string } """ username = args['username'] group = args['group'] @@ -819,9 +824,17 @@ class shelve_db: """ :param args: A dictionary containing : - { 'group': val } - :return: a list containing : - [{ 'username': val, 'priority': val }, ... ] + { 'group': string } + :return: a dictionary containing : + { username: + {'minor': [ + { notif_mod: priority }, + ... + ], + 'major': [ + { notif_mod: priority }, + ... + ]}} """ group = args['group'] res = [] @@ -836,7 +849,7 @@ class shelve_db: """ Create a basic empty structure on the database for a new user. :param args: a dictionary containing : - { 'username': val } + { 'username': string } """ username = args['username'] self.open_db() @@ -869,7 +882,7 @@ class shelve_db: Removes a user from the database. If the user is registered to a host or a group, it is also deleted from these lists :param args: a dictionary containing : - { 'username': val } + { 'username': string } """ username = args['username'] self.open_db() @@ -891,7 +904,7 @@ class shelve_db: """ Add a list of users to the host notifications structure. :param args: a dictionary containing : - { 'users': list<string>, 'addr_host': val } + { 'users': list<string>, 'addr_host': string } """ users = args['users'] addr_host = args['addr_host'] @@ -906,12 +919,17 @@ class shelve_db: """ Updates the subscription to a following user from a host. :param args: - { 'addr_host': val, - 'username': val, - 'subscription: [ - { notif_mod: priority }, - ... - ] + { 'addr_host': string, + 'username': string, + 'subscription': + {'minor': [ + { notif_mod: priority }, + ... + ], + 'major': [ + { notif_mod: priority }, + ... + ]} } :return: """ @@ -927,7 +945,7 @@ class shelve_db: """ Unsubscribes an user for host notifications. :param args: a dictionary containing : - { 'username': val, 'addr_host': val } + { 'username': string, 'addr_host': string } """ username = args['username'] addr_host = args['addr_host'] @@ -941,9 +959,17 @@ class shelve_db: """ Get informations about the subscribers to a host. :param args: A dictionary containing : - { 'addr_host': val } + { 'addr_host': string } :return: a dictionary containing : - { username: [{ 'notif_mod': val, 'priority': val }, ... ]} + { username: + {'minor': [ + { notif_mod: priority }, + ... + ], + 'major': [ + { notif_mod: priority }, + ... + ]}} """ addr_host = args['addr_host'] res = {} diff --git a/static/js/controllers/notificationsCtrl.js b/static/js/controllers/notificationsCtrl.js index 38fcfe0..1e19332 100644 --- a/static/js/controllers/notificationsCtrl.js +++ b/static/js/controllers/notificationsCtrl.js @@ -17,7 +17,7 @@ mumApp.controller('notificationsCtrl', function($scope, $rootScope, $modal, Data ] */ - $scope.notif_mods = {}; + $scope.notif_mods = {}; // {notif_mod :{param1:val1, param2:val2, ...}} $rootScope.$broadcast("sendViaWs", JSON.stringify({"GET_LOADED_NOTIF_MOD": ""})); @@ -27,7 +27,10 @@ mumApp.controller('notificationsCtrl', function($scope, $rootScope, $modal, Data }); }); - $scope.subscriber_data = {}; + $scope.subscriber_data = {}; /* {username:{"minor":{mod_notif:{"activated":bool,"priority":int}, ...}, + "major":{mod_notif:{"activated":bool,"priority":int}}}} */ + + $scope.subscriber_data_unchanged = {}; // used to discard changes $scope.allGroups = function(){ var res = [] @@ -58,12 +61,45 @@ mumApp.controller('notificationsCtrl', function($scope, $rootScope, $modal, Data } } - $scope.$on("resCall", function (event, args) { + $scope.$on("resCall", function (event, args) { /* args= { username: + {'minor': [ + { notif_mod: priority }, + ... + ], + 'major': [ + { notif_mod: priority }, + ... + ]}} */ $scope.$apply(function(){ - $scope.subscriber_data = args; + var sd = {}; + for(user in args){ + sd[user] = {}; + sd[user]['minor'] = {}; + sd[user]['major'] = {}; + for(var i=0 ; i<args[user].length ; i++){ + sd[user]['minor'][args[user]['minor'][i]['notif_mod']] = {'activated': true, 'priority':args[user]['minor'][i]['priority']}; + sd[user]['major'][args[user]['major'][i]['notif_mod']] = {'activated': true, 'priority':args[user]['major'][i]['priority']}; + } + for(notif_mod in $scope.notif_mods){ + if(!sd[user].hasOwnProperty(notif_mod)){ + sd[user]['minor'][notif_mod] = {'activated': false, 'priority': null}; + sd[user]['major'][notif_mod] = {'activated': false, 'priority': null}; + } + } + } + $scope.subscriber_data = sd; + $scope.subscriber_data_unchanged = sd; }); }); + $scope.discard = function(){ + $scope.subscriber_data = $scope.subscriber_data_unchanged; + } + + $scope.save = function(){ + + } + $scope.open_modal_add_subscriber = function (mod_name) { var modalInstance = $modal.open({ templateUrl: 'modal_add_subscriber_label.html', diff --git a/views/notifications.html b/views/notifications.html index 9647ed8..0f73cce 100644 --- a/views/notifications.html +++ b/views/notifications.html @@ -54,126 +54,30 @@ </tr> </thead> <tbody> - <tr> - <td rowspan="3">G.G.</td> - <td>Browser</td> - <td> - <div class="input-group"> - <span class="input-group-addon"> - <input type="checkbox" aria-label="jcbrowsermincheck"> - </span> - <input type="number" min="1" class="form-control" aria-label="jcbrowserminnb" placeholder="1"> - </div> - </td> - <td> - <div class="input-group"> - <span class="input-group-addon"> - <input type="checkbox" aria-label="jcbrowsermajcheck"> - </span> - <input type="number" min="1" class="form-control" aria-label="jcbrowsermajnb" placeholder="1"> - </div> - </td> - </tr> - <tr> - <td>E-mail</td> - <td> - <div class="input-group"> - <span class="input-group-addon"> - <input type="checkbox" aria-label="jcmailmincheck"> - </span> - <input type="number" min="1" class="form-control" aria-label="jcmailminnb" placeholder="1"> - </div> - </td> - <td> - <div class="input-group"> - <span class="input-group-addon"> - <input type="checkbox" aria-label="jcmailmajcheck"> - </span> - <input type="number" min="1" class="form-control" aria-label="jcmailmajnb" placeholder="1"> - </div> - </td> - </tr> - <tr> - <td>SMS</td> - <td> - <div class="input-group"> - <span class="input-group-addon"> - <input type="checkbox" aria-label="jcsmsmincheck"> - </span> - <input type="number" min="1" class="form-control" aria-label="jcsmsminnb" placeholder="1"> - </div> - </td> - <td> - <div class="input-group"> - <span class="input-group-addon"> - <input type="checkbox" aria-label="jcsmsmajcheck"> - </span> - <input type="number" min="1" class="form-control" aria-label="jcsmsmajnb" placeholder="1"> - </div> - </td> - </tr> - <tr> - <td rowspan="3">J.C.</td> - <td>Browser</td> - <td> - <div class="input-group"> - <span class="input-group-addon"> - <input type="checkbox" aria-label="ggbrowserminchecj"> - </span> - <input type="number" min="1" class="form-control" aria-label="ggbrowserminnb" placeholder="1"> - </div> - </td> - <td> - <div class="input-group"> - <span class="input-group-addon"> - <input type="checkbox" aria-label="ggbrowsermajcheck"> - </span> - <input type="number" min="1" class="form-control" aria-label="ggbrowsermajnb" placeholder="1"> - </div> - </td> - </tr> - <tr> - <td>E-mail</td> - <td> - <div class="input-group"> - <span class="input-group-addon"> - <input type="checkbox" aria-label="ggmailmincheck"> - </span> - <input type="number" min="1" class="form-control" aria-label="ggmailminnb" placeholder="1"> - </div> - </td> - <td> - <div class="input-group"> - <span class="input-group-addon"> - <input type="checkbox" aria-label="ggmailmajcheck"> - </span> - <input type="number" min="1" class="form-control" aria-label="ggmailmajnb" placeholder="1"> - </div> - </td> - </tr> - <tr> - <td>SMS</td> - <td> + <tr ng-repeat="(username, user) in subscriber_data"> + <td>{{username}}</td> + <td ng-repeat="(mod_name, mod_param) in user.minor">{{mod_name}}</td> + <td ng-repeat="(mod_name, mod_param) in user.minor"> <div class="input-group"> <span class="input-group-addon"> - <input type="checkbox" aria-label="ggsmsmincheck"> + <input type="checkbox" ng-model="mod_param.activated"> </span> - <input type="number" min="1" class="form-control" aria-label="ggsmsminnb" placeholder="1"> + <input type="number" min="1" class="form-control" ng-model="mod_param.priority"> </div> </td> - <td> + <td ng-repeat="(mod_name, mod_param) in user.major"> <div class="input-group"> <span class="input-group-addon"> - <input type="checkbox" aria-label="ggsmsmajcheck"> + <input type="checkbox" ng-model="mod_param.activated"> </span> - <input type="number" min="1" class="form-control" aria-label="ggsmsmajnb" placeholder="1"> + <input type="number" min="1" class="form-control" ng-model="mod_param.priority"> </div> </td> </tr> </tbody> </table> - <button type="button" class="btn btn-default">Discard changes</button> - <button type="button" class="btn btn-primary">Save changes</button> + <button type="button" class="btn btn-default" ng-click="discard()">Discard changes</button> + <button type="button" class="btn btn-primary" ng-click="save()">Save changes</button> </div> </div> -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.