branch develop updated (13ba585 -> 2379592)
This is an automated email from the git hooks/post-receive script. New change to branch develop in repository mum. See http://git.chorem.org/mum.git from 13ba585 notifications: corrigé bug d'affichage si plusieurs modules de notif chargés new 51c4809 sms_notif = ok + correction bug subscription dans bdd + affichage traceback new 2379592 profile: modal pour visualiser les abonnements de l'utilisateur The 2 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "adds" were already present in the repository and have only been added to this reference. Detailed log of new commits: commit 2379592f52a6df2aae3bc68aeb53ec7a953f7039 Author: Alexis Guilbaud <guilbaud@codelutin.com> Date: Thu Mar 26 11:47:32 2015 +0100 profile: modal pour visualiser les abonnements de l'utilisateur commit 51c4809f8e7a1ebb46c5aba2025953c95eda9d00 Author: Alexis Guilbaud <guilbaud@codelutin.com> Date: Thu Mar 26 09:57:49 2015 +0100 sms_notif = ok + correction bug subscription dans bdd + affichage traceback Summary of changes: app/app.py | 2 +- app/modules/storage_modules/shelve_db.py | 179 +++++++++++++++++++------------ static/js/controllers/profileCtrl.js | 61 ++++++++++- views/profile.html | 71 +++++++++++- 4 files changed, 240 insertions(+), 73 deletions(-) -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.
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 51c4809f8e7a1ebb46c5aba2025953c95eda9d00 Author: Alexis Guilbaud <guilbaud@codelutin.com> Date: Thu Mar 26 09:57:49 2015 +0100 sms_notif = ok + correction bug subscription dans bdd + affichage traceback --- app/app.py | 5 +- app/modules/storage_modules/shelve_db.py | 139 ++++++++++++++++--------------- 2 files changed, 75 insertions(+), 69 deletions(-) diff --git a/app/app.py b/app/app.py index 829f32f..92c5d26 100755 --- a/app/app.py +++ b/app/app.py @@ -184,8 +184,9 @@ if __name__ == '__main__': ml.load_all_detection_modules() ml.load_all_notification_modules() wsc = WebSocketContainer(ml.get_db()) - #dict_notif = ml.db.add_check('127.0.0.1', "ping", False) - #ml.run_notification_modules(dict_notif) + dict_notif = ml.db.add_check('127.0.0.1', "ping", False) + print dict_notif + ml.run_notification_modules(dict_notif) #process_monitoring.init(ml, wsc) port = int(os.environ.get('PORT', 1337)) run(host='0.0.0.0', port=port, debug=True, server=GeventWebSocketServer) diff --git a/app/modules/storage_modules/shelve_db.py b/app/modules/storage_modules/shelve_db.py index d24133a..a935b88 100644 --- a/app/modules/storage_modules/shelve_db.py +++ b/app/modules/storage_modules/shelve_db.py @@ -3,6 +3,7 @@ __author__ = 'aguilbaud' from datetime import datetime import json import shelve +import traceback import os.path @@ -80,8 +81,8 @@ class shelve_db: self.db["hosts"][addr_host]["status"] = {} # Create structure for archiving data self.db["hosts"][addr_host]["archive"] = {} - except Exception as e: - print e.__str__() + except Exception: + print traceback.format_exc() finally: self.close_db() @@ -228,8 +229,8 @@ class shelve_db: res = None try: res = self.db['hosts'][args['addr_host']]['conf']['connections'] - except Exception as e: - print e.__str__() + except Exception: + print traceback.format_exc() finally: self.close_db() return res @@ -259,8 +260,8 @@ class shelve_db: dict_moni['time'] = datetime.now() dict_moni['freq'] = self.db['hosts'][addr_host]['conf']['monitoring'][mod]['check_frequency'] res.append(dict_moni) - except Exception as e: - print e.__str__() + except Exception: + print traceback.format_exc() finally: self.close_db() return res @@ -275,8 +276,8 @@ class shelve_db: try: for addr_host in self.db['hosts']: res.append(addr_host) - except Exception as e: - print e.__str__() + except Exception: + print traceback.format_exc() finally: self.close_db() return res @@ -336,8 +337,8 @@ class shelve_db: elif self.db["hosts"][host]["monitoring"][mod]["state"] == "danger": info_host["danger"].append(mod) res.append(info_host) - except Exception as e: - print e.__str__() + except Exception: + print traceback.format_exc() finally: self.close_db() return res @@ -392,8 +393,8 @@ class shelve_db: res['activated_monitoring'][mod] = self.db['hosts'][addr_host]['conf']['monitoring'][mod]['activated'] res['custom_infos'] = self.db['hosts'][addr_host]['conf']['custom_info'] res['interventions'] = self.db['hosts'][addr_host]['conf']['interventions'] - except Exception as e: - print e.__str__() + except Exception: + print traceback.format_exc() finally: self.close_db() return res @@ -418,8 +419,8 @@ class shelve_db: for host in self.db['groups'][group_id]['hosts']: if self.db['groups'][group_id]['hosts'][host]['addr'] == addr_host: del self.db['groups'][group_id]['hosts'][host] - except Exception as e: - print e.__str__() + except Exception: + print traceback.format_exc() finally: self.close_db() @@ -433,8 +434,8 @@ class shelve_db: self.open_db() try: self.db["hosts"][addr_host]["detected"][name_part] = json_res_str - except Exception as e: - print e.__str__() + except Exception: + print traceback.format_exc() finally: self.close_db() @@ -452,8 +453,8 @@ class shelve_db: nmap_detection = json.loads(self.db['hosts'][args['addr_host']]['detected']['nmap']) nmap_detection['os'] = args['new_os_name'].lower() self.db['hosts'][args['addr_host']]['detected']['nmap'] = json.dumps(nmap_detection) - except Exception as e: - print e.__str__() + except Exception: + print traceback.format_exc() finally: self.close_db() @@ -471,8 +472,8 @@ class shelve_db: self.open_db() try: self.db["hosts"][addr_host]["conf"]["custom_info"] = txt - except Exception as e: - print e.__str__() + except Exception: + print traceback.format_exc() finally: self.close_db() @@ -495,8 +496,8 @@ class shelve_db: self.open_db() try: self.db["hosts"][addr_host]["conf"]["interventions"].append(intervention) - except Exception as e: - print e.__str__() + except Exception: + print traceback.format_exc() finally: self.close_db() @@ -547,8 +548,8 @@ class shelve_db: # if not, we have to remove it from the monitoring list self.db["hosts"][addr_host]["conf"]["monitoring"][mod_name]["activated"] = False self.rem_to_monitoring_list(args['addr_host'], mod_name) - except Exception as e: - print e.__str__() + except Exception: + print traceback.format_exc() finally: self.close_db() @@ -574,8 +575,8 @@ class shelve_db: res['minor_limit'] = self.db['hosts'][addr_host]['conf']['monitoring'][mod_name]['minor_limit'] res['major_limit'] = self.db['hosts'][addr_host]['conf']['monitoring'][mod_name]['major_limit'] res['freq'] = self.db['hosts'][addr_host]['conf']['monitoring'][mod_name]['check_frequency'] - except Exception as e: - print e.__str__() + except Exception: + print traceback.format_exc() finally: self.close_db() return res @@ -599,8 +600,8 @@ class shelve_db: self.db['hosts'][addr_host]['conf']['monitoring'][mod_name]['minor_limit'] = args['minor_limit'] self.db['hosts'][addr_host]['conf']['monitoring'][mod_name]['major_limit'] = args['major_limit'] self.db['hosts'][addr_host]['conf']['monitoring'][mod_name]['check_frequency'] = args['freq'] - except Exception as e: - print e.__str__() + except Exception: + print traceback.format_exc() finally: self.close_db() @@ -619,8 +620,8 @@ class shelve_db: try: for mod in args['priorities']: self.db['hosts'][addr_host]['conf']['connections'][mod]['priority'] = args['priorities'][mod] - except Exception as e: - print e.__str__() + except Exception: + print traceback.format_exc() finally: self.close_db() @@ -639,8 +640,8 @@ class shelve_db: for param in args['current_config'][modname]: self.db['hosts'][addr_host]['conf']['connections'][modname][param] = \ args['current_config']['ssh'][param] - except Exception as e: - print e.__str__() + except Exception: + print traceback.format_exc() finally: self.close_db() @@ -661,8 +662,8 @@ class shelve_db: dict_conn['priority'] = self.db['hosts'][addr_host]['conf']['connections'][conn]['priority'] dict_conn['args'] = self.db['hosts'][addr_host]['conf']['connections'][conn] res.append(dict_conn) - except Exception as e: - print e.__str__() + except Exception: + print traceback.format_exc() finally: self.close_db() return res @@ -733,8 +734,8 @@ class shelve_db: self.db['hosts'][addr_host]['archive'][mod_name] = \ self.update_stats(self.db['hosts'][addr_host]['archive'][mod_name], val) """ - except Exception as e: - print e.__str__() + except Exception: + print traceback.format_exc() finally: self.close_db() return dict_notif @@ -833,8 +834,8 @@ class shelve_db: if group not in self.db['hosts'][host]['conf']['groups']: self.db['groups'][group]['hosts'].append(host) self.db['hosts'][host]['conf']['groups'].append(group) - except Exception as e: - print e.__str__() + except Exception: + print traceback.format_exc() finally: self.close_db() @@ -857,8 +858,8 @@ class shelve_db: # deletion of the group if empty if len(self.db['groups'][group]['hosts']) == 0: del self.db['groups'][group] - except Exception as e: - print e.__str__() + except Exception: + print traceback.format_exc() finally: self.close_db() @@ -874,8 +875,10 @@ class shelve_db: try: for user in users: self.db['groups'][group]['subscribers'][user] = {} - except Exception as e: - print e.__str__() + self.db['groups'][group]['subscribers'][user]['major'] = {} + self.db['groups'][group]['subscribers'][user]['minor'] = {} + except Exception: + print traceback.format_exc() finally: self.close_db() @@ -903,8 +906,8 @@ class shelve_db: try: for username in args['subscription']: self.db['groups'][group]['subscribers'][username] = args['subscription'][username] - except Exception as e: - print e.__str__() + except Exception: + print traceback.format_exc() finally: self.close_db() @@ -919,8 +922,8 @@ class shelve_db: self.open_db() try: del self.db['groups'][group]['subscribers'][username] - except Exception as e: - print e.__str__() + except Exception: + print traceback.format_exc() finally: self.close_db() @@ -945,8 +948,8 @@ class shelve_db: self.open_db() try: res = self.db['groups'][group]['subscribers'] - except Exception as e: - print e.__str__() + except Exception: + print traceback.format_exc() finally: self.close_db() return res @@ -966,8 +969,8 @@ class shelve_db: self.db['users'][username]['preferences']['major_notifications'] = {} self.db['users'][username]['account'] = {} self.db['users'][username]['settings'] = {} - except Exception as e: - print e.__str__() + except Exception: + print traceback.format_exc() finally: self.close_db() @@ -982,8 +985,8 @@ class shelve_db: try: for user in self.db['users']: res.append(user) - except Exception as e: - print e.__str__() + except Exception: + print traceback.format_exc() finally: self.close_db() return res @@ -1005,8 +1008,8 @@ class shelve_db: self.open_db() try: res['settings'] = self.db['users'][args['username']]['settings'] - except Exception as e: - print e.__str__() + except Exception: + print traceback.format_exc() finally: self.close_db() return res @@ -1026,9 +1029,9 @@ class shelve_db: """ self.open_db() try: - self.db['users'][args['username']]['settings'] = args['settings'] - except Exception as e: - print e.__str__() + self.db['users'][args['user']]['settings'] = args['settings'] + except Exception: + print traceback.format_exc() finally: self.close_db() @@ -1052,8 +1055,8 @@ class shelve_db: for group in self.db['groups']: if username in self.db['groups'][group]['subscribers']: del self.db['groups'][group]['subscribers'][username] - except Exception as e: - print e.__str__() + except Exception: + print traceback.format_exc() finally: self.close_db() @@ -1069,8 +1072,10 @@ class shelve_db: try: for user in users: self.db['hosts'][addr_host]['conf']['subscribers'][user] = {} - except Exception as e: - print e.__str__() + self.db['hosts'][addr_host]['conf']['subscribers'][user]['minor'] = {} + self.db['hosts'][addr_host]['conf']['subscribers'][user]['major'] = {} + except Exception: + print traceback.format_exc() finally: self.close_db() @@ -1098,8 +1103,8 @@ class shelve_db: try: for username in args['subscription']: self.db['hosts'][addr_host]['conf']['subscribers'][username] = args['subscription'][username] - except Exception as e: - print e.__str__() + except Exception: + print traceback.format_exc() finally: self.close_db() @@ -1114,8 +1119,8 @@ class shelve_db: self.open_db() try: del self.db['hosts'][addr_host]['conf']['subscribers'][username] - except Exception as e: - print e.__str__() + except Exception: + print traceback.format_exc() finally: self.close_db() @@ -1140,8 +1145,8 @@ class shelve_db: self.open_db() try: res = self.db['hosts'][addr_host]['conf']['subscribers'] - except Exception as e: - print e.__str__() + except Exception: + print traceback.format_exc() finally: self.close_db() return res \ No newline at end of file -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.
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 2379592f52a6df2aae3bc68aeb53ec7a953f7039 Author: Alexis Guilbaud <guilbaud@codelutin.com> Date: Thu Mar 26 11:47:32 2015 +0100 profile: modal pour visualiser les abonnements de l'utilisateur --- app/app.py | 7 ++-- app/modules/storage_modules/shelve_db.py | 40 +++++++++++++++++- static/js/controllers/profileCtrl.js | 61 ++++++++++++++++++++++++++- views/profile.html | 71 +++++++++++++++++++++++++++++++- 4 files changed, 170 insertions(+), 9 deletions(-) diff --git a/app/app.py b/app/app.py index 92c5d26..7ec70c8 100755 --- a/app/app.py +++ b/app/app.py @@ -184,10 +184,9 @@ if __name__ == '__main__': ml.load_all_detection_modules() ml.load_all_notification_modules() wsc = WebSocketContainer(ml.get_db()) - dict_notif = ml.db.add_check('127.0.0.1', "ping", False) - print dict_notif - ml.run_notification_modules(dict_notif) - #process_monitoring.init(ml, wsc) + #dict_notif = ml.db.add_check('127.0.0.1', "ping", False) + #ml.run_notification_modules(dict_notif) + process_monitoring.init(ml, wsc) port = int(os.environ.get('PORT', 1337)) run(host='0.0.0.0', port=port, debug=True, server=GeventWebSocketServer) # after ending diff --git a/app/modules/storage_modules/shelve_db.py b/app/modules/storage_modules/shelve_db.py index a935b88..083e7c4 100644 --- a/app/modules/storage_modules/shelve_db.py +++ b/app/modules/storage_modules/shelve_db.py @@ -1035,6 +1035,44 @@ class shelve_db: finally: self.close_db() + def get_user_subscriptions(self, username): + """ + Get every subscriptions of a given user (host or group), by notifications modules, including the number of + itterations necessary to get the notification. + :param username: the user name + :return: a dictionary containing : + { + 'hosts':{ + addr_host:{ + 'major':{ + notif_mod:{ + 'priority': int, + 'activated': bool + }, ... + } + 'minor':{...} + }, ... + }, + 'groups':{ ... } + } + """ + res = {} + res['hosts'] = {} + res['groups'] = {} + self.open_db() + try: + for addr_host in self.db['hosts']: + if username in self.db['hosts'][addr_host]['conf']['subscribers']: + res['hosts'][addr_host] = self.db['hosts'][addr_host]['conf']['subscribers'][username] + for group in self.db['groups']: + if username in self.db['groups'][group]['subscribers']: + res['groups'][group] = self.db['groups'][group]['subscribers'][username] + except Exception: + print traceback.format_exc() + finally: + self.close_db() + return res + def remove_user(self, args): """ Removes a user from the database. If the user is registered to a host or a group, @@ -1049,7 +1087,7 @@ class shelve_db: del self.db['users'][username] # unregistering user from hosts for host in self.db['hosts']: - if username in self.db['hosts'][host]['subscribers']: + if username in self.db['hosts'][host]['conf']['subscribers']: del self.db['hosts'][host]['conf']['subscribers'][username] # unregistering user form groups for group in self.db['groups']: diff --git a/static/js/controllers/profileCtrl.js b/static/js/controllers/profileCtrl.js index fa3bbb9..2ca21a6 100644 --- a/static/js/controllers/profileCtrl.js +++ b/static/js/controllers/profileCtrl.js @@ -1,4 +1,4 @@ -mumApp.controller('profileCtrl', function($scope, $rootScope, $route){ +mumApp.controller('profileCtrl', function($scope, $rootScope, $route, $modal){ $scope.users = {}; @@ -9,7 +9,7 @@ mumApp.controller('profileCtrl', function($scope, $rootScope, $route){ $rootScope.$broadcast("sendViaWs", JSON.stringify({"CALL_FUNC_DB": {'func': 'get_users', 'args': null}})); - // receiving the user list + // after calling db functions $scope.$on("resCall", function (event, args) { if(args.func == 'get_users'){ $scope.$apply(function(){ @@ -45,4 +45,61 @@ mumApp.controller('profileCtrl', function($scope, $rootScope, $route){ $rootScope.$broadcast("sendViaWs", JSON.stringify({"CALL_FUNC_DB": {'func': 'update_user_settings', 'args': args}})); } + + // creation of modals + $scope.open_modal_subscriptions = function () { + var modalInstance = $modal.open({ + templateUrl: 'modal_subscriptions_label.html', + controller: 'ModalSubscriptionsInstanceCtrl', + resolve: { + subs_args: function(){ + return {'username': $scope.selected_user}; + } + } + }); + }; +}); + +mumApp.controller('ModalSubscriptionsInstanceCtrl', function ($scope, $rootScope, $modalInstance, subs_args) { + $scope.subs_args = subs_args; // { 'username': string } + + $scope.user_subscriptions = {}; /* + { + 'hosts':{ + addr_host:{ + 'major':{ + notif_mod:{ + 'priority': int, + 'activated': bool + }, ... + } + 'minor':{...} + }, ... + }, + 'groups':{ ... } + } + */ + + $rootScope.$broadcast("sendViaWs", JSON.stringify({"CALL_FUNC_DB": {'func': 'get_user_subscriptions', + 'args': $scope.subs_args['username']}})); + + $scope.$on("resCall", function (event, args) { + if(args.func == 'get_user_subscriptions'){ + $scope.$apply(function(){ + $scope.user_subscriptions = args.res; + }); + } + }); + + $scope.get_class = function(sub_part, sub_type, target_name, notif_mod){ + res = ""; + if($scope.user_subscriptions[sub_part][target_name][sub_type][notif_mod]['activated']){ + res = "success"; + } + return res; + } + + $scope.close = function () { + $modalInstance.close(); + }; }); \ No newline at end of file diff --git a/views/profile.html b/views/profile.html index 074c630..1ed35ae 100644 --- a/views/profile.html +++ b/views/profile.html @@ -6,10 +6,13 @@ ng-options="user as user for user in users" ng-change="get_user_settings()"> </select> + <button type="button" class="btn btn-primary" + ng-click="open_modal_subscriptions()" + ng-disabled="selected_user==''">See your subscriptions</button> + <!--<h2 class="sub-header">They will be applied on each new host you will add.</h2>--> - <form> + <form ng-show="selected_user!=''"> <div class="row"> - <h3>Personal informations</h3> <div class="col-xs-3"> <label for="username">Username</label> <input type="text" class="form-control" id="username" @@ -75,6 +78,70 @@ --> </form> + + <script type="text/ng-template" id="modal_subscriptions_label.html"> + <div class="modal-header"> + <h3 class="modal-title">Summary of your subscriptions</h3> + </div> + <div class="modal-body"> + <p>Number of notifications between your last login</p> + <table class="table table-hover"> + <thead> + <tr> + <th>Host</th> + <th>Notification service</th> + <th>Minor</th> + <th>Major</th> + </tr> + </thead> + <tbody> + <tr ng-repeat-start="(addr_host, host) in user_subscriptions.hosts"> + <td>{{addr_host}}</td> + </tr> + <tr ng-repeat-end + ng-repeat="(notif_mod_name, notif_mod) in host.minor"> + <td></td> + <td>{{notif_mod_name}}</td> + <td class="{{get_class('hosts', 'minor', addr_host, notif_mod_name)}}"> + {{notif_mod.priority}} + </td> + <td class="{{get_class('hosts', 'major', addr_host, notif_mod_name)}}"> + {{user_subscriptions.hosts[addr_host].major[notif_mod_name].priority}} + </td> + </tr> + </tbody> + </table> + <table class="table table-hover"> + <thead> + <tr> + <th>Group</th> + <th>Notification service</th> + <th>Minor</th> + <th>Major</th> + </tr> + </thead> + <tbody> + <tr ng-repeat-start="(grp_name, grp) in user_subscriptions.groups"> + <td>{{grp_name}}</td> + </tr> + <tr ng-repeat-end + ng-repeat="(notif_mod_name, notif_mod) in grp.minor"> + <td></td> + <td>{{notif_mod_name}}</td> + <td class="{{get_class('groups', 'minor', grp_name, notif_mod_name)}}"> + {{notif_mod.priority}} + </td> + <td class="{{get_class('groups', 'major', grp_name, notif_mod_name)}}"> + {{user_subscriptions.groups[grp_name].major[notif_mod_name].priority}} + </td> + </tr> + </tbody> + </table> + </div> + <div class="modal-footer"> + <button type="button" class="btn btn-default" data-dismiss="modal" ng-click="close()">Close</button> + </div> + </script> <!--<h3>Summary of notification subscriptions</h3> <p>Number of notifications between your last login</p> <table class="table table-hover"> -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.
participants (1)
-
chorem.org scm