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 ddbc857041aef49fa3d10c0bdcdb1c5822ae81fe Author: Alexis Guilbaud <guilbaud@codelutin.com> Date: Wed Jun 10 11:33:45 2015 +0200 display_name added --- app/modules/storage_modules/shelve_db.py | 34 +++++++++++++++--- static/js/controllers/dashboardCtrl.js | 1 + static/js/controllers/hostPageCtrl.js | 17 ++++++--- views/dashboard.html | 31 +++++++++++------ views/hostpage.html | 59 ++++++++++++++++++++++---------- views/settings.html | 10 +++--- 6 files changed, 109 insertions(+), 43 deletions(-) diff --git a/app/modules/storage_modules/shelve_db.py b/app/modules/storage_modules/shelve_db.py index 9bdb31a..185a0b2 100644 --- a/app/modules/storage_modules/shelve_db.py +++ b/app/modules/storage_modules/shelve_db.py @@ -91,11 +91,11 @@ class shelve_db: # once the check, if it exists a connection that can lauch the module mod_conf['activated'] = True mod_conf['check_frequency'] = 600 - mod_conf['nb_min'] = 30 - mod_conf['nb_hour'] = 12 - mod_conf['nb_day'] = 15 - mod_conf['nb_week'] = 2 - mod_conf['nb_month'] = 6 + mod_conf['nb_min'] = 59 + mod_conf['nb_hour'] = 23 + mod_conf['nb_day'] = 7 + mod_conf['nb_week'] = 4 + mod_conf['nb_month'] = 12 mod_conf['nb_year'] = None mod_conf['subparts'] = [] # a list that can contain for example the names of the disk partitions unit = loaded_mod_moni[mod]['unit'] @@ -235,6 +235,10 @@ class shelve_db: self.db["hosts"][addr_host]['detected']['nmap'] = nmap_res self.db["hosts"][addr_host]["conf"]["connections"] = self.init_conn(nmap_res_data, conn_infos) os_host = nmap_res_data['os'] + if nmap_res_data['hostname'] != "": + self.db["hosts"][addr_host]["conf"]["display_name"] = nmap_res_data['hostname'] + else: + self.db["hosts"][addr_host]["conf"]["display_name"] = str(addr_host) self.db["hosts"][addr_host]["conf"]["monitoring"] = {} for mod in dict_mod_info: if os_host in dict_mod_info[mod]['compatible_os'] or 'all' in dict_mod_info[mod]['compatible_os']: @@ -421,6 +425,7 @@ class shelve_db: info_host["danger"].append(mod) info_host['nb_subscribers'] = len(self.db['hosts'][host]['conf']['subscribers'].keys()) info_host['subscribers'] = self.db['hosts'][host]['conf']['subscribers'] + info_host['display_name'] = self.db['hosts'][host]['conf']['display_name'] res.append(info_host) except Exception: print traceback.format_exc() @@ -481,6 +486,7 @@ class shelve_db: 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'] + res['display_name'] = self.db['hosts'][addr_host]['conf']['display_name'] except Exception: print traceback.format_exc() finally: @@ -547,6 +553,24 @@ class shelve_db: finally: self.close_db() + def change_display_name(self, args): + """ + Called from the hostpage. + Updatdes the name to display of a given host. + :param args: a dictionary containing : + { + 'addr_host': string, + 'display_name': string, + } + """ + self.open_db() + try: + self.db['hosts'][args['addr_host']]['conf']['display_name'] = args['display_name'] + except Exception: + print traceback.format_exc() + finally: + self.close_db() + def update_custom_informations(self, args): """ Called from the hostpage. diff --git a/static/js/controllers/dashboardCtrl.js b/static/js/controllers/dashboardCtrl.js index 46d26e1..d9d3695 100644 --- a/static/js/controllers/dashboardCtrl.js +++ b/static/js/controllers/dashboardCtrl.js @@ -38,6 +38,7 @@ mumApp.controller('dashboardCtrl', function ($scope, $routeParams, $location, $r } }); + $scope.host_filter = ''; // input field $scope.addr_filter = ''; // input field $scope.name_filter = ''; // input field diff --git a/static/js/controllers/hostPageCtrl.js b/static/js/controllers/hostPageCtrl.js index 15326b2..a335d10 100644 --- a/static/js/controllers/hostPageCtrl.js +++ b/static/js/controllers/hostPageCtrl.js @@ -19,6 +19,7 @@ mumApp.controller('hostPageCtrl', function ($scope, $rootScope, $route, $routePa } } "hostname":val, + "display_name": str, "status": string, "monitoring": { @@ -51,6 +52,8 @@ mumApp.controller('hostPageCtrl', function ($scope, $rootScope, $route, $routePa $scope.subparts_checked = {}; + $scope.show_display_name_input = false; + $scope.selectedAll = false; $scope.blocks = {}; /* @@ -78,6 +81,13 @@ mumApp.controller('hostPageCtrl', function ($scope, $rootScope, $route, $routePa $rootScope.$broadcast("sendViaWs", JSON.stringify({"CALL_FUNC_DB": {'func': 'update_nmap_attribute', 'args': args}})); }; + $scope.change_display_name = function (){ + var args = {}; + args['addr_host'] = $scope.addr_host; + args['display_name'] = $scope.items.display_name; + $rootScope.$broadcast("sendViaWs", JSON.stringify({"CALL_FUNC_DB": {'func': 'change_display_name', 'args': args}})); + } + $scope.save_subpart = function (modname) { var args = {}; args['addr_host'] = $scope.addr_host; @@ -145,12 +155,11 @@ mumApp.controller('hostPageCtrl', function ($scope, $rootScope, $route, $routePa }; $scope.$on("resCall", function (event, args) { - if (args.func == 'update_nmap_attribute') { + if (args.func == 'update_nmap_attribute' || + args.func == 'update_custom_informations' || + args.func == 'change_display_name') { $route.reload(); } - if (args.func == 'update_custom_informations') { - $route.reload(); - } }); $scope.model = {custom_infos : '', diff --git a/views/dashboard.html b/views/dashboard.html index 3fb3fd6..81afb6e 100644 --- a/views/dashboard.html +++ b/views/dashboard.html @@ -12,6 +12,11 @@ ng-show="items.length > 0"> <div class="col-xs-3"> + <label for="host_f">Host filter</label> + <input class="form-control" type="text" id="host_f" ng-model="host_filter"> + </div> + + <div class="col-xs-3"> <label for="addr_f">Address filter</label> <input class="form-control" type="text" id="addr_f" ng-model="addr_filter"> </div> @@ -46,8 +51,11 @@ <table class="table table-condensed table-hover"> <thead> <tr> - <th><a ng-click="order_val='addr'">Address</a></th> - <th><a ng-click="order_val='name'">Name</a></th> + <th><a ng-click="order_val='display_name'">Host</a></th> + <th> + <a ng-click="order_val='addr'">Address</a> <br/> + <a ng-click="order_val='name'">Name</a> + </th> <th><a ng-click="order_val='status'">Status</a></th> <th><a ng-click="order_val='group'">Group</a></th> <th><a ng-click="order_val='last_check'">Last check</a></th> @@ -57,16 +65,20 @@ <tbody> <tr ng-repeat="host in items | orderBy:order_val | - filter:{addr:addr_filter, name:name_filter, group:group_filter} | + filter:{addr:addr_filter, name:name_filter, display_name:host_filter, group:group_filter} | filter:filtering_status" class={{host.status}}> <!-- group.name:group_filter --> - <td><a href="#/hostpage/{{host.addr}}">{{host.addr}}</a></td> - <td>{{host.name}}</td> + <td><a href="#/hostpage/{{host.addr}}">{{host.display_name}}</a></td> + <td> + {{host.addr}}<br/> + {{host.name}} + </td> <td> - <a popover-placement="bottom" - popover="warning: {{host.warning}} ; danger: {{host.danger}}" - popover-trigger="mouseenter">{{host.status}} - </a> + <span popover-placement="bottom" + popover="warning: {{host.warning}} ; danger: {{host.danger}}" + popover-trigger="mouseenter" + style="text-decoration:underline">{{host.status}} + </span> </td> <td> <ui-select multiple @@ -87,7 +99,6 @@ </ui-select-choices> </ui-select> </td> - <!--<td>{{host.group}}</td>--> <td>{{host.last_check.split('.')[0]}}</td> <td> <button type="button" class="btn btn-primary btn-xs" aria-label="Subscribers" diff --git a/views/hostpage.html b/views/hostpage.html index bbdabbd..c81d91f 100644 --- a/views/hostpage.html +++ b/views/hostpage.html @@ -1,16 +1,27 @@ <div class="col-md-offset-2 main"> - <h1 class="page-header">Current state of {{items.hostname}}<small> {{addr_host}} - <button type="button" - class="btn btn-{{get_idle_state()}}" - aria-label="Button activation" - style="" - popover-placement="bottom" - popover="{{popover_message()}}" - popover-trigger="mouseenter" - ng-click="set_idle_state()"> - <span class="glyphicon glyphicon-off" aria-hidden="true"></span> - </button></small></h1> + <h1 class="page-header">Current state of + <span ng-click="show_display_name_input = true" + ng-show="show_display_name_input == false" + style="text-decoration:underline"> + {{items.display_name}} + </span> + <div class="row" + ng-show="show_display_name_input == true"> + <div class="col-lg-6"> + <div class="input-group"> + <input type="text" class="form-control" ng-model="items.display_name"> + <span class="input-group-btn"> + <button class="btn btn-default" type="button" ng-click="change_display_name()">Change display name</button> + </span> + </div> + </div> + </div> + + <small> + {{items.hostname}} ({{addr_host}}) + </small> + </h1> <button type="button" class="btn btn-primary btn-xs" @@ -18,14 +29,24 @@ <button type="button" class="btn btn-info btn-xs" - ng-click="launch_detection()" - popover="Needs SSH to be configured" - popover-trigger="mouseenter">Launch a full detection</button> + ng-click="launch_detection()">Launch a full detection</button> <button type="button" class="btn btn-danger btn-xs" ng-click="open_modal_confirm_delete()">Remove this host</button> + <button type="button" + class="btn btn-{{get_idle_state()}} btn-xs" + aria-label="Button activation" + style="" + popover-placement="bottom" + popover="{{popover_message()}}" + popover-trigger="mouseenter" + ng-click="set_idle_state()"> + <span class="glyphicon glyphicon-off" aria-hidden="true"> + </span> + </button> + <table class="table table-condensed table-hover" ng-show="items.status != 'idling'"> @@ -232,27 +253,27 @@ <div class="row" id="arch"> <div class="col-xs-2"> - <input type="number" min="0" max="59" class="form-control" + <input type="number" min="59" class="form-control" ng-model="arch_min"> minute </div> <div class="col-xs-2"> - <input type="number" min="0" max="59" class="form-control" + <input type="number" min="23" class="form-control" ng-model="arch_hour"> hour </div> <div class="col-xs-2"> - <input type="number" min="0" max="23" class="form-control" + <input type="number" min="7" class="form-control" ng-model="arch_day"> day </div> <div class="col-xs-2"> - <input type="number" min="0" max="7" class="form-control" + <input type="number" min="4" class="form-control" ng-model="arch_week"> week </div> <div class="col-xs-2"> - <input type="number" min="0" max="31" class="form-control" + <input type="number" min="12" class="form-control" ng-model="arch_month"> month </div> diff --git a/views/settings.html b/views/settings.html index f77c156..b406797 100644 --- a/views/settings.html +++ b/views/settings.html @@ -21,23 +21,23 @@ <label for="arch">Archives to keep (in check numbers). Keep empty for no limit.</label> <div class="row" id="arch"> <div class="col-xs-2"> - <input type="number" min="0" max="59" class="form-control" + <input type="number" min="59" class="form-control" ng-model="arch_min"> minute </div> <div class="col-xs-2"> - <input type="number" min="0" max="59" class="form-control" + <input type="number" min="23" class="form-control" ng-model="arch_hour"> hour </div> <div class="col-xs-2"> - <input type="number" min="0" max="23" class="form-control" + <input type="number" min="7" class="form-control" ng-model="arch_day"> day </div> <div class="col-xs-2"> - <input type="number" min="0" max="7" class="form-control" + <input type="number" min="4" class="form-control" ng-model="arch_week"> week </div> <div class="col-xs-2"> - <input type="number" min="0" max="31" class="form-control" + <input type="number" min="12" class="form-control" ng-model="arch_month"> month </div> <div class="col-xs-2"> -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.