branch develop updated (f5f2cea -> f5637be)
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 f5f2cea running nmap without root privileges will raise an error new e56b244 spacing javascript code new f5637be statistics by module on hostpage 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 f5637be14655522df9b84671f345586779cd0242 Author: Alexis Guilbaud <guilbaud@codelutin.com> Date: Wed May 13 15:27:26 2015 +0200 statistics by module on hostpage commit e56b244abdfa2be7fc41d2bbfecefc41ef3e6bfd Author: Alexis Guilbaud <guilbaud@codelutin.com> Date: Tue May 12 10:29:03 2015 +0200 spacing javascript code Summary of changes: app/modules/connection_modules/ssh.py | 3 + app/modules/storage_modules/shelve_db.py | 2 + static/js/controllers/dashboardCtrl.js | 121 +--- static/js/controllers/groupCtrl.js | 46 +- static/js/controllers/headCtrl.js | 36 +- static/js/controllers/hostPageCtrl.js | 320 +++++++--- static/js/controllers/notificationsCtrl.js | 82 +-- static/js/controllers/profileCtrl.js | 28 +- static/js/controllers/scanCtrl.js | 10 +- static/js/controllers/settingsCtrl.js | 34 +- static/js/controllers/statsCtrl.js | 89 ++- static/js/controllers/usersCtrl.js | 18 +- static/js/mumApp.js | 4 +- views/dashboard.html | 145 ++--- views/groups.html | 178 +++--- views/hostpage.html | 973 ++++++++++++++++------------- views/notifications.html | 277 ++++---- views/profile.html | 273 ++++---- views/scan.html | 57 +- views/settings.html | 197 +++--- views/stats.html | 113 ++-- views/users.html | 159 +++-- 22 files changed, 1670 insertions(+), 1495 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 e56b244abdfa2be7fc41d2bbfecefc41ef3e6bfd Author: Alexis Guilbaud <guilbaud@codelutin.com> Date: Tue May 12 10:29:03 2015 +0200 spacing javascript code --- app/modules/connection_modules/ssh.py | 3 + app/modules/storage_modules/shelve_db.py | 2 + static/js/controllers/dashboardCtrl.js | 121 +--- static/js/controllers/groupCtrl.js | 46 +- static/js/controllers/headCtrl.js | 36 +- static/js/controllers/hostPageCtrl.js | 166 +++--- static/js/controllers/notificationsCtrl.js | 82 +-- static/js/controllers/profileCtrl.js | 28 +- static/js/controllers/scanCtrl.js | 10 +- static/js/controllers/settingsCtrl.js | 34 +- static/js/controllers/statsCtrl.js | 44 +- static/js/controllers/usersCtrl.js | 18 +- static/js/mumApp.js | 4 +- views/dashboard.html | 145 ++--- views/groups.html | 178 +++--- views/hostpage.html | 923 ++++++++++++++++------------- views/notifications.html | 277 +++++---- views/profile.html | 273 +++++---- views/scan.html | 57 +- views/settings.html | 197 +++--- views/stats.html | 113 ++-- views/users.html | 159 +++-- 22 files changed, 1433 insertions(+), 1483 deletions(-) diff --git a/app/modules/connection_modules/ssh.py b/app/modules/connection_modules/ssh.py index 37ba540..79ed72b 100644 --- a/app/modules/connection_modules/ssh.py +++ b/app/modules/connection_modules/ssh.py @@ -12,11 +12,14 @@ class SSH: self.addr_host = addr_host self.known_port = 22 self.CommandNotFoundException = cnfe + if params is not None: key_path = str(key_loc) + str(params['private_key']) key = paramiko.RSAKey.from_private_key_file(key_path) + if params['password'] == "": params['password'] = None + self.ssh = paramiko.SSHClient() self.ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) self.ssh.connect(addr_host, diff --git a/app/modules/storage_modules/shelve_db.py b/app/modules/storage_modules/shelve_db.py index 6dfbe32..c51853c 100644 --- a/app/modules/storage_modules/shelve_db.py +++ b/app/modules/storage_modules/shelve_db.py @@ -1033,6 +1033,7 @@ class shelve_db: notif_type = 'minor' 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]: @@ -1056,6 +1057,7 @@ class shelve_db: 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 + "." + if notif_mod not in dict_notif: dict_notif[notif_mod] = [] dict_notif[notif_mod].append({'user': self.db['users'][username]['settings'], diff --git a/static/js/controllers/dashboardCtrl.js b/static/js/controllers/dashboardCtrl.js index 9e0760d..ce4bc0c 100644 --- a/static/js/controllers/dashboardCtrl.js +++ b/static/js/controllers/dashboardCtrl.js @@ -1,12 +1,12 @@ -mumApp.controller('dashboardCtrl', function($scope, $filter, $routeParams, DataHosts){ - $scope.param = $routeParams.param; +mumApp.controller('dashboardCtrl', function ($scope, $filter, $routeParams, DataHosts) { + $scope.param = $routeParams.param; // parameter in URL, null if none - $scope.sort = { + /*$scope.sort = { sortingOrder : 'id', reverse : false - }; + };*/ - $scope.gap = 5; + //$scope.gap = 5; $scope.items = DataHosts.Items; /* [ { @@ -30,27 +30,24 @@ mumApp.controller('dashboardCtrl', function($scope, $filter, $routeParams, DataH $scope.items = DataHosts.Items; }); - /*$scope.filteredItems = []; - $scope.groupedItems = []; - $scope.itemsPerPage = 25; - $scope.pagedItems = []; - $scope.currentPage = 0;*/ + $scope.addr_filter = ''; // input field + $scope.name_filter = ''; // input field - $scope.addr_filter = ''; - $scope.name_filter = ''; + $scope.order_val = 'status'; // select field - $scope.order_val = 'status' - - if($routeParams.param == null){ + if ($routeParams.param == null) { + // if no status filter in parameters, show all status $scope.status_filter = ["success", "warning", "danger", "idling", ""]; } - else{ + else { // multiple params should be separated by ',' $scope.status_filter = []; tab_params = $routeParams.param.split(','); - for(var i = 0; i<tab_params.length; i++){ + + for (var i = 0; i<tab_params.length; i++) { $scope.status_filter.push(tab_params[i]); } + } $scope.group_filter = ''; @@ -59,97 +56,11 @@ mumApp.controller('dashboardCtrl', function($scope, $filter, $routeParams, DataH $scope.grp = "all"; - $scope.filtering_status = function(item){ + $scope.filtering_status = function (item) { return($scope.status_filter.lastIndexOf(item.status) >= 0); - } - - /* - // Concerning the table manipulation - var searchMatch = function (haystack, needle) { - return !needle || haystack.toLowerCase().indexOf(needle.toLowerCase()) !== -1; - }; - - // init the filtered items - $scope.search = function () { - $scope.filteredItems = $filter('filter')($scope.items, function (item) { - for(var attr in item) { - if (searchMatch(item[attr], $scope.query)) - return true; - } - return false; - }); - // take care of the sorting order - if ($scope.sort.sortingOrder !== '') { - $scope.filteredItems = $filter('orderBy')($scope.filteredItems, $scope.sort.sortingOrder, $scope.sort.reverse); - } - $scope.currentPage = 0; - // now group by pages - $scope.groupToPages(); - }; - - - // calculate page in place - $scope.groupToPages = function () { - $scope.pagedItems = []; - - for (var i = 0; i < $scope.filteredItems.length; i++) { - if (i % $scope.itemsPerPage === 0) { - $scope.pagedItems[Math.floor(i / $scope.itemsPerPage)] = [ $scope.filteredItems[i] ]; - } else { - $scope.pagedItems[Math.floor(i / $scope.itemsPerPage)].push($scope.filteredItems[i]); - } - } - }; - - $scope.range = function (size,start, end) { - var ret = []; - console.log(size,start, end); - - if (size < end) { - end = size; - start = size-$scope.gap; - } - for (var i = start; i < end; i++) { - ret.push(i); - } - console.log(ret); - return ret; - }; - - $scope.prevPage = function () { - if ($scope.currentPage > 0) { - $scope.currentPage--; - } - }; - - $scope.nextPage = function () { - if ($scope.currentPage < $scope.pagedItems.length - 1) { - $scope.currentPage++; - } }; - $scope.setPage = function () { - $scope.currentPage = this.n; - }; - - // functions have been describe process the data for display - $scope.search(); - - // $scope.groupsByAddr = {} - */ - /*$scope.getGroupsByAddr = function(addr) { - res = "" - for(var i = 0; i<$scope.items.length; i++){ - if($scope.items[i].addr === addr){ - for(var j = 0; j<$scope.items[i].group.length; j++){ - res += $scope.items[i].group[j].name + " "; - } - } - } - return res; - };*/ - - $scope.allGroups = function(){ + $scope.allGroups = function () { var res = [] for(var i = 0; i<$scope.items.length; i++){ for(var j = 0; j<$scope.items[i].group.length; j++){ diff --git a/static/js/controllers/groupCtrl.js b/static/js/controllers/groupCtrl.js index e436a23..d853b26 100644 --- a/static/js/controllers/groupCtrl.js +++ b/static/js/controllers/groupCtrl.js @@ -1,4 +1,4 @@ -mumApp.controller('groupCtrl', function($scope, $rootScope, $filter, $route, $routeParams, $modal, DataHosts){ +mumApp.controller('groupCtrl', function ($scope, $rootScope, $filter, $route, $routeParams, $modal, DataHosts) { $scope.sort = { sortingOrder : 'id', reverse : false @@ -28,7 +28,7 @@ mumApp.controller('groupCtrl', function($scope, $rootScope, $filter, $route, $ro $scope.selection = {}; // {addr_host: bool, ...} - for(i = 0 ; i < $scope.items.length ; i++){ + for (var i = 0, len = $scope.items.length ; i < len ; i++) { $scope.selection[$scope.items[i]['addr']] = false; } @@ -48,46 +48,46 @@ mumApp.controller('groupCtrl', function($scope, $rootScope, $filter, $route, $ro return res; };*/ - $scope.allGroups = function(){ + $scope.allGroups = function () { var res = [] - for(var i = 0; i<$scope.items.length; i++){ - for(var j = 0; j<$scope.items[i].group.length; j++){ + for (var i = 0; i<$scope.items.length; i++) { + for (var j = 0; j<$scope.items[i].group.length; j++) { res.push($scope.items[i].group[j]); } } return res; }; - $scope.change_group_displayed = function(){ + $scope.change_group_displayed = function () { $scope.checkAll(false); $scope.selection = {}; - for(i = 0 ; i < $scope.items.length ; i++){ - for(j = 0 ; j < $scope.items[i]['group'].length ; j++){ - if($scope.grp == $scope.items[i]['group'][j]){ + for (i = 0 ; i < $scope.items.length ; i++) { + for (j = 0 ; j < $scope.items[i]['group'].length ; j++) { + if ($scope.grp == $scope.items[i]['group'][j]) { $scope.selection[$scope.items[i]['addr']] = false; } } } }; - $scope.checkAll = function(bool){ + $scope.checkAll = function (bool) { $scope.selectedAll = bool; - for(host in $scope.selection){ + for (host in $scope.selection) { $scope.selection[host] = bool; } }; $scope.$on("resCall", function (event, args) { - if(args.func == 'remove_host_list_to_group'){ + if (args.func == 'remove_host_list_to_group') { $rootScope.$broadcast("sendViaWs", JSON.stringify({"GET_HOSTS": ""})); } }); - $scope.remove_host_list = function(){ + $scope.remove_host_list = function () { var args = {}; args['host_list'] = []; - for(host in $scope.selection){ - if($scope.selection[host]){ + for (host in $scope.selection) { + if ($scope.selection[host]) { args['host_list'][args['host_list'].length] = host; } } @@ -102,17 +102,17 @@ mumApp.controller('groupCtrl', function($scope, $rootScope, $filter, $route, $ro templateUrl: 'modal_group_label.html', controller: 'ModalGroupInstanceCtrl', resolve: { - group_args: function(){ + group_args: function () { var selected = []; - for(host in $scope.selection){ - if($scope.selection[host]){ + for (host in $scope.selection) { + if ($scope.selection[host]) { selected[selected.length] = host; } } var groups_without_all = []; var allGroups = $scope.allGroups() - for(n in allGroups){ - if(allGroups[n] != 'all'){ + for (n in allGroups) { + if (allGroups[n] != 'all') { groups_without_all[groups_without_all.length] = allGroups[n]; } } @@ -134,7 +134,7 @@ mumApp.controller('ModalGroupInstanceCtrl', function ($scope, $rootScope, $route $scope.selected_grp = "all"; $scope.$on("resCall", function (event, args) { - if(args.func == 'add_host_list_to_group'){ + if(args.func == 'add_host_list_to_group') { $modalInstance.close(); $rootScope.$broadcast("sendViaWs", JSON.stringify({"GET_HOSTS": ""})); } @@ -143,10 +143,10 @@ mumApp.controller('ModalGroupInstanceCtrl', function ($scope, $rootScope, $route $scope.ok = function () { var args = {}; args['host_list'] = $scope.group_args['selected']; - if($scope.new_grp_name == ""){ + if ($scope.new_grp_name == "") { args['group'] = $scope.selected_grp; } - else{ + else { args['group'] = $scope.new_grp_name; } diff --git a/static/js/controllers/headCtrl.js b/static/js/controllers/headCtrl.js index f21d1b8..993e171 100644 --- a/static/js/controllers/headCtrl.js +++ b/static/js/controllers/headCtrl.js @@ -1,4 +1,4 @@ -mumApp.controller('headCtrl', function($scope, $rootScope, toastr, $interval, $routeParams, $location, DataHosts) { +mumApp.controller('headCtrl', function ($scope, $rootScope, toastr, $interval, $routeParams, $location, DataHosts) { // init //$scope.master = {}; @@ -7,14 +7,14 @@ mumApp.controller('headCtrl', function($scope, $rootScope, toastr, $interval, $r $scope.task_list = []; - $scope.$on("hostsUpdate", function (event) { + $scope.$on ("hostsUpdate", function (event) { $scope.items = DataHosts.Items; }); // Concerning WebSocket var ws = new WebSocket("ws://" + $location.host() + ":" + $location.port() + "/websocket"); - ws.onopen = function() { + ws.onopen = function () { var request = JSON.stringify({"GET_HOSTS": ""}); ws.send(request); ws.send(JSON.stringify({"TASK_LIST": null})); @@ -22,14 +22,14 @@ mumApp.controller('headCtrl', function($scope, $rootScope, toastr, $interval, $r $scope.max_tasks = 2; - $scope.format_task_list = function(task_list){ + $scope.format_task_list = function (task_list) { res = ""; var i = 0; - while(i<$scope.task_list.length && i<$scope.max_tasks){ + while (i<$scope.task_list.length && i<$scope.max_tasks) { res += task_list[i] + ", "; i++; } - if($scope.task_list.length > $scope.max_tasks){ + if ($scope.task_list.length > $scope.max_tasks) { res += "+ " + (task_list.length - $scope.max_tasks) + " other tasks"; } return res; @@ -43,8 +43,8 @@ mumApp.controller('headCtrl', function($scope, $rootScope, toastr, $interval, $r ws.onmessage = function (evt) { // actions effectuees lors de la reception d'un message via la websocket var obj = JSON.parse(evt.data); - for(key in obj){ - switch(key){ + for (key in obj) { + switch (key) { case "SUCCESS_MODULE": // Success of a module execution $rootScope.$broadcast("success", obj[key]); toastr.success(obj[key], "Success on module execution"); @@ -122,34 +122,34 @@ mumApp.controller('headCtrl', function($scope, $rootScope, toastr, $interval, $r } }; - $scope.pop_success = function(title, msg){ + $scope.pop_success = function (title, msg) { toastr.success(msg, title); }; - $scope.pop_warning = function(title, msg){ + $scope.pop_warning = function (title, msg) { toastr.success(msg, title); }; - $scope.pop_danger = function(title, msg){ + $scope.pop_danger = function (title, msg) { toastr.error(msg, title); }; /* - * Return a vector with the number of hosts with a status of : success, warning, danger + * Return a vector with the number of hosts with a status of : success, warning, danger, idling */ - $scope.stateNumber = function(){ + $scope.stateNumber = function () { var res = [0,0,0,0]; - for(var i = 0; i<$scope.items.length; i++){ - if($scope.items[i].status === "success"){ + for (var i = 0; i<$scope.items.length; i++) { + if ($scope.items[i].status === "success") { res[0]++; } - if($scope.items[i].status === "warning"){ + if ($scope.items[i].status === "warning") { res[1]++; } - if($scope.items[i].status === "danger"){ + if ($scope.items[i].status === "danger") { res[2]++; } - if($scope.items[i].status === "idling"){ + if ($scope.items[i].status === "idling") { res[3]++; } } diff --git a/static/js/controllers/hostPageCtrl.js b/static/js/controllers/hostPageCtrl.js index 78e7e85..14ee7f4 100644 --- a/static/js/controllers/hostPageCtrl.js +++ b/static/js/controllers/hostPageCtrl.js @@ -1,8 +1,8 @@ -mumApp.controller('hostPageCtrl', function($scope, $rootScope, $route, $routeParams, $location, $modal, $timeout) { +mumApp.controller('hostPageCtrl', function ($scope, $rootScope, $route, $routeParams, $location, $modal, $timeout) { $scope.loaded = false; // indicates if this is the first loading of the page - $scope.addr_host = $routeParams.param + $scope.addr_host = $routeParams.param; // asks for host informations $rootScope.$broadcast("sendViaWs", JSON.stringify({"GET_HOST_INFO": $routeParams.param})); @@ -52,11 +52,11 @@ mumApp.controller('hostPageCtrl', function($scope, $rootScope, $route, $routePar $scope.selectedAll = false; - $scope.rescan = function(){ + $scope.rescan = function () { $location.path('/scan/' + $scope.addr_host); } - $scope.update_nmap_attribute = function(attribute, new_value){ + $scope.update_nmap_attribute = function (attribute, new_value) { var args = {}; args['attribute'] = attribute; args['addr_host'] = $scope.addr_host; @@ -64,65 +64,65 @@ mumApp.controller('hostPageCtrl', function($scope, $rootScope, $route, $routePar $rootScope.$broadcast("sendViaWs", JSON.stringify({"CALL_FUNC_DB": {'func': 'update_nmap_attribute', 'args': args}})); }; - $scope.save_subpart = function(modname){ + $scope.save_subpart = function (modname) { var args = {}; args['addr_host'] = $scope.addr_host; args['modname'] = modname; args['subpart_list'] = []; - for(key in $scope.subparts_checked[modname]){ - if($scope.subparts_checked[modname][key]){ + for (key in $scope.subparts_checked[modname]) { + if ($scope.subparts_checked[modname][key]) { args['subpart_list'].push(key); } } $rootScope.$broadcast("sendViaWs", JSON.stringify({"CALL_FUNC_DB": {'func': 'set_subpart', 'args': args}})); } - $scope.checkAll = function(modname, bool){ + $scope.checkAll = function (modname, bool) { $scope.selectedAll = bool; - for(key in $scope.subparts_checked[modname]){ + for(key in $scope.subparts_checked[modname]) { $scope.subparts_checked[modname][key] = bool; } } - $scope.get_unit = function(mod_name){ + $scope.get_unit = function(mod_name) { res = ''; - if($scope.items.loaded_moni_mod[mod_name].unit != 'bool'){ + if ($scope.items.loaded_moni_mod[mod_name].unit != 'bool') { res = $scope.items.loaded_moni_mod[mod_name].unit; } return res; }; - $scope.get_type_of = function(attr){ + $scope.get_type_of = function (attr) { return typeof(attr); }; - $scope.get_idle_state = function(){ + $scope.get_idle_state = function () { res = ""; - if($scope.items.status == "idling"){ + if ($scope.items.status == "idling") { res = "danger"; } - else{ + else { res = "success"; } return res }; - $scope.popover_message = function(){ + $scope.popover_message = function () { msg = ""; - if($scope.items.status == "idling"){ + if ($scope.items.status == "idling") { msg = "Click to activate again the monitoring for this host."; } - else{ + else { msg = "Click to suspend the monitoring for this host."; } return msg }; $scope.$on("resCall", function (event, args) { - if(args.func == 'update_nmap_attribute'){ + if (args.func == 'update_nmap_attribute') { $route.reload(); } - if(args.func == 'update_custom_informations'){ + if (args.func == 'update_custom_informations') { $route.reload(); } }); @@ -132,42 +132,42 @@ mumApp.controller('hostPageCtrl', function($scope, $rootScope, $route, $routePar new_hostname : '', compatible_os_list: []}; - $scope.check = function(modname){ + $scope.check = function (modname) { var args = {}; args['mod_name'] = modname; args['addr_host'] = $scope.addr_host; $rootScope.$broadcast("sendViaWs", JSON.stringify({"CHECK_NOW": args})); }; - $scope.set_idle_state = function(){ + $scope.set_idle_state = function () { $rootScope.$broadcast("sendViaWs", JSON.stringify({"SET_IDLE_STATE": $scope.addr_host})); } - $scope.get_addr_host = function(){ + $scope.get_addr_host = function () { return($scope.addr_host); }; - $scope.launch_detection = function(){ + $scope.launch_detection = function () { $rootScope.$broadcast("sendViaWs", JSON.stringify({"LAUNCH_FULL_DETECTION": $scope.addr_host})); }; // receiving the host informations $scope.$on("hostInfos", function (event, args) { - $timeout(function() { - if(!$scope.loaded){ // we take all the fields of information + $timeout(function () { + if (!$scope.loaded) { // we take all the fields of information $scope.items = args; $scope.model.custom_infos = args.custom_infos; $scope.loaded = true; $scope.model['compatible_os_list'] = args['compatible_os_list']; - for(var modname in args.monitoring){ + for (var modname in args.monitoring) { $scope.collapsed[modname] = true; $scope.subparts_checked[modname] = {} - for(var key in args.detected[modname]){ + for (var key in args.detected[modname]) { $scope.subparts_checked[modname][args.detected[modname][key]] = args.subparts[modname].hasOwnProperty(key); } } } - else{ // we take only monitoring updates + else { // we take only monitoring updates $scope.items.monitoring = args.monitoring; $scope.items.status = args.status; } @@ -176,7 +176,7 @@ mumApp.controller('hostPageCtrl', function($scope, $rootScope, $route, $routePar // refresh after full detection $scope.$on("success", function (event, args) { - if(args == 'Full detection'){ + if (args == 'Full detection') { $route.reload(); } }); @@ -187,7 +187,7 @@ mumApp.controller('hostPageCtrl', function($scope, $rootScope, $route, $routePar }); // save custom informations - $scope.save_custom_infos = function(){ + $scope.save_custom_infos = function () { var args = {}; args.addr_host = $scope.addr_host; args.txt = $scope.model.custom_infos; @@ -200,7 +200,7 @@ mumApp.controller('hostPageCtrl', function($scope, $rootScope, $route, $routePar templateUrl: 'modal_conf_label.html', controller: 'ModalConfInstanceCtrl', resolve: { - conf_args: function(){ + conf_args: function () { return {'addr_host' : $scope.addr_host, 'mod_name': mod_name}; } } @@ -212,7 +212,7 @@ mumApp.controller('hostPageCtrl', function($scope, $rootScope, $route, $routePar templateUrl: 'modal_interv_label.html', controller: 'ModalIntervInstanceCtrl', resolve: { - interv_args: function(){ + interv_args: function () { return {'addr_host' : $scope.addr_host}; } } @@ -224,7 +224,7 @@ mumApp.controller('hostPageCtrl', function($scope, $rootScope, $route, $routePar templateUrl: 'modal_conn_label.html', controller: 'ModalConnInstanceCtrl', resolve: { - conn_args: function(){ + conn_args: function () { return {'addr_host' : $scope.addr_host}; } } @@ -237,7 +237,7 @@ mumApp.controller('hostPageCtrl', function($scope, $rootScope, $route, $routePar controller: 'ModalBlockInstanceCtrl', size: 'lg', resolve: { - block_args: function(){ + block_args: function () { return {'addr_host' : $scope.addr_host, 'activated_mod': $scope.items['activated_monitoring'], 'os_host': $scope.items.detected.nmap.os, @@ -252,7 +252,7 @@ mumApp.controller('hostPageCtrl', function($scope, $rootScope, $route, $routePar templateUrl: 'modal_confirm_delete_label.html', controller: 'ModalConfirmDeleteInstanceCtrl', resolve: { - confirm_delete_args: function(){ + confirm_delete_args: function () { return {'addr_host' : $scope.addr_host}; } } @@ -264,7 +264,7 @@ mumApp.controller('hostPageCtrl', function($scope, $rootScope, $route, $routePar templateUrl: 'modal_port_config.html', controller: 'ModalPortConfigInstanceCtrl', resolve: { - port_config_args: function(){ + port_config_args: function () { return {'addr_host' : $scope.addr_host, 'port_list': port_list}; } @@ -310,23 +310,23 @@ mumApp.controller('ModalConfInstanceCtrl', function ($scope, $rootScope, $modalI // when the actual conf of the module is received $scope.$on("resCall", function (event, args) { - if(args.func == 'get_conf_mod'){ - $timeout(function() { + if (args.func == 'get_conf_mod') { + $timeout(function () { $scope.items = args.res; $scope.freq_days = Math.floor(args.res.freq / 86400); $scope.freq_hours = Math.floor((args.res.freq - $scope.freq_days * 86400) / 3600); $scope.freq_minutes = Math.floor((args.res.freq - ($scope.freq_days * 86400) - ($scope.freq_hours * 3600)) / 60) - if(args.res.unit == 'bool'){ - if(args.res.major_limit){ + if (args.res.unit == 'bool') { + if (args.res.major_limit) { $scope.limit_bool = 'major'; } } - else if(args.res.unit == '%'){ + else if (args.res.unit == '%') { $scope.minor_limit_percent = args.res.minor_limit; $scope.major_limit_percent = args.res.major_limit; } - else{ + else { $scope.minor_limit_unit = args.res.minor_limit; $scope.major_limit_unit = args.res.major_limit; } @@ -346,15 +346,15 @@ mumApp.controller('ModalConfInstanceCtrl', function ($scope, $rootScope, $modalI args.addr_host = $scope.conf_args.addr_host; args.mod_name = $scope.conf_args.mod_name; args.freq = 86400 * $scope.freq_days + 3600 * $scope.freq_hours + 60 * $scope.freq_minutes; - if($scope.items.unit == 'bool'){ + if ($scope.items.unit == 'bool') { args.minor_limit = ($scope.limit_bool == 'minor'); args.major_limit = ($scope.limit_bool == 'major'); } - else if($scope.items.unit == '%'){ + else if ($scope.items.unit == '%') { args.minor_limit = $scope.minor_limit_percent; args.major_limit = $scope.major_limit_percent; } - else{ + else { args.minor_limit = $scope.minor_limit_unit; args.major_limit = $scope.major_limit_unit; } @@ -385,7 +385,7 @@ mumApp.controller('ModalIntervInstanceCtrl', function ($scope, $rootScope, $moda $scope.details = ''; $scope.$on("resCall", function (event, args) { - if(args.func == 'add_intervention'){ + if (args.func == 'add_intervention') { $modalInstance.close(); $route.reload(); } @@ -413,7 +413,7 @@ mumApp.controller('ModalConnInstanceCtrl', function ($scope, $rootScope, $modalI $scope.priorities = {}; - $scope.isNotConfigured = function(modname){ + $scope.isNotConfigured = function (modname) { res = false; /*for(param in $scope.current_config[modname]){ if($scope.current_config[modname][param] == null){ @@ -428,9 +428,9 @@ mumApp.controller('ModalConnInstanceCtrl', function ($scope, $rootScope, $modalI // when the configuration of the connection is received $scope.$on("resCall", function (event, args) { if(args.func == 'get_conn_param'){ - $timeout(function() { + $timeout(function () { $scope.current_config = args.res; - for(mod in args.res){ + for (mod in args.res) { $scope.priorities[mod] = args.res[mod]['priority'] } }, 0); @@ -443,10 +443,10 @@ mumApp.controller('ModalConnInstanceCtrl', function ($scope, $rootScope, $modalI }); $scope.$on("resGetLoadedConnMod", function (event, args) { - $timeout(function() { + $timeout(function () { $scope.loaded_conn_mods = args; - for(mod in $scope.loaded_conn_mods){ - if(!$scope.current_config.hasOwnProperty(mod)){ + for (mod in $scope.loaded_conn_mods) { + if (!$scope.current_config.hasOwnProperty(mod)) { $scope.current_config[mod] = {}; $scope.current_config[mod]['priority'] = 0; } @@ -454,7 +454,7 @@ mumApp.controller('ModalConnInstanceCtrl', function ($scope, $rootScope, $modalI }, 0); }); - $scope.testConn = function(connModName){ + $scope.testConn = function (connModName) { var args = {}; args['addr_host'] = $scope.conn_args["addr_host"]; args['conn_mod_name'] = connModName; @@ -479,7 +479,7 @@ mumApp.controller('ModalConnInstanceCtrl', function ($scope, $rootScope, $modalI controller: 'ModalConfConnInstanceCtrl', size: 'lg', resolve: { - conf_conn_args: function(){ + conf_conn_args: function () { return {'addr_host' : $scope.conn_args['addr_host'], 'modname': modname, 'current_config': $scope.current_config, @@ -517,20 +517,20 @@ mumApp.controller('ModalConfConnInstanceCtrl', function ($scope, $rootScope, $mo $scope.keys_list = []; - $scope.show_form = function(param_name){ + $scope.show_form = function (param_name) { return $scope.conf_conn_args.loaded_conn_mods[$scope.conf_conn_args.modname].hasOwnProperty(param_name); } $rootScope.$broadcast("sendViaWs", JSON.stringify({"GET_KEYS_LIST": ""})); $scope.$on("keysList", function (event, args) { - $timeout(function() { + $timeout(function () { $scope.keys_list = args; }, 0); }); $scope.$on("resCall", function (event, args) { - if(args.func == 'set_conf_conn'){ + if (args.func == 'set_conf_conn') { $modalInstance.close(); $route.reload(); } @@ -586,39 +586,39 @@ mumApp.controller('ModalBlockInstanceCtrl', function ($scope, $rootScope, $modal } */ - for(mod in $scope.block_args.loaded_moni_mod){ + for (mod in $scope.block_args.loaded_moni_mod) { var activated = false; var block = $scope.block_args.loaded_moni_mod[mod]['block']; - if($scope.block_args.activated_mod.hasOwnProperty(mod)) { // if the module is known by the host - if($scope.block_args.activated_mod[mod]){ // if the module is activated + if ($scope.block_args.activated_mod.hasOwnProperty(mod)) { // if the module is known by the host + if ($scope.block_args.activated_mod[mod]) { // if the module is activated activated = true; } } - if(!$scope.blocks.hasOwnProperty(block)){ + if (!$scope.blocks.hasOwnProperty(block)) { $scope.blocks[block] = []; } $scope.blocks[block][$scope.blocks[block].length] = {modname: mod, activated: activated}; } - $scope.select_all = function(block){ - $timeout(function() { // to prevent "inprog" angular error - for(var i=0; i<block.length; i++){ - if(!$scope.is_not_compatible(block[i].modname)){ + $scope.select_all = function (block) { + $timeout(function () { // to prevent "inprog" angular error + for (var i=0; i<block.length; i++) { + if (!$scope.is_not_compatible(block[i].modname)) { block[i].activated = true; } } }, 0); }; - $scope.select_none = function(block){ - $timeout(function() { // to prevent "inprog" angular error - for(var i=0; i<block.length; i++){ + $scope.select_none = function (block) { + $timeout(function () { // to prevent "inprog" angular error + for (var i=0; i<block.length; i++) { block[i].activated = false; } }, 0); }; - $scope.is_not_compatible = function(modname){ + $scope.is_not_compatible = function (modname) { // returns true if the OS of the host is part of the compatible OS list of the module modname ; Or if the module // modname is comatible with all OS. return ($scope.block_args.loaded_moni_mod[modname].compatible_os.lastIndexOf($scope.block_args.os_host) < 0) && @@ -629,8 +629,8 @@ mumApp.controller('ModalBlockInstanceCtrl', function ($scope, $rootScope, $modal var args = {}; args['addr_host'] = $scope.block_args['addr_host']; args['activated'] = {}; - for(block in $scope.blocks){ - for(mod in $scope.blocks[block]){ + for (block in $scope.blocks) { + for (mod in $scope.blocks[block]) { args['activated'][$scope.blocks[block][mod]['modname']] = $scope.blocks[block][mod]['activated']; } } @@ -657,7 +657,7 @@ mumApp.controller('ModalConfirmDeleteInstanceCtrl', function ($scope, $rootScope }; $scope.$on("remHost", function (event, args) { - $timeout(function() { + $timeout(function () { $rootScope.$broadcast("sendViaWs", JSON.stringify({"GET_HOSTS": ""})); $location.path('/'); $modalInstance.close(); @@ -680,12 +680,12 @@ mumApp.controller('ModalPortConfigInstanceCtrl', function ($scope, $rootScope, $ $scope.new_portid = null; - $scope.remove_port = function(port_dict){ + $scope.remove_port = function (port_dict) { var i = 0; var port_found = false; - while(i<$scope.port_config_args.port_list.length && !port_found){ - if($scope.port_config_args.port_list[i].portname == port_dict.portname && - $scope.port_config_args.port_list[i].portid == port_dict.portid){ + while (i<$scope.port_config_args.port_list.length && !port_found) { + if ($scope.port_config_args.port_list[i].portname == port_dict.portname && + $scope.port_config_args.port_list[i].portid == port_dict.portid) { port_found = true; $scope.port_config_args.port_list.splice(i, 1); } @@ -693,17 +693,17 @@ mumApp.controller('ModalPortConfigInstanceCtrl', function ($scope, $rootScope, $ } }; - $scope.add_port = function(){ + $scope.add_port = function () { var i = 0; var port_found = false; - while(i<$scope.port_config_args.port_list.length && !port_found){ - if($scope.port_config_args.port_list[i].portname == $scope.new_portname && - $scope.port_config_args.port_list[i].portid == $scope.new_portid){ + while (i<$scope.port_config_args.port_list.length && !port_found) { + if ($scope.port_config_args.port_list[i].portname == $scope.new_portname && + $scope.port_config_args.port_list[i].portid == $scope.new_portid) { port_found = true; } i++; } - if(!port_found){ + if (!port_found) { // avoiding the same value twice in the list var new_dict_port = {}; new_dict_port['portname'] = $scope.new_portname; @@ -723,7 +723,7 @@ mumApp.controller('ModalPortConfigInstanceCtrl', function ($scope, $rootScope, $ }; $scope.$on("resCall", function (event, args) { - if(args.func == 'update_nmap_attribute'){ + if (args.func == 'update_nmap_attribute') { $route.reload(); $modalInstance.close(); } diff --git a/static/js/controllers/notificationsCtrl.js b/static/js/controllers/notificationsCtrl.js index 0a24ed3..396ca72 100644 --- a/static/js/controllers/notificationsCtrl.js +++ b/static/js/controllers/notificationsCtrl.js @@ -1,4 +1,4 @@ -mumApp.controller('notificationsCtrl', function($scope, $rootScope, $modal, $route, $timeout, DataHosts) { +mumApp.controller('notificationsCtrl', function ($scope, $rootScope, $modal, $route, $timeout, DataHosts) { $scope.items = DataHosts.Items; /* [ { "addr":"192.168.74.1", @@ -26,14 +26,14 @@ mumApp.controller('notificationsCtrl', function($scope, $rootScope, $modal, $rou $rootScope.$broadcast("sendViaWs", JSON.stringify({"GET_ALL_SUBSCRIPTIONS": ""})); $scope.$on("resGetAllSubscriptions", function (event, args) { - $timeout(function() { + $timeout(function () { $scope.all_subscriptions = args; }, 0); $rootScope.$broadcast("sendViaWs", JSON.stringify({"GET_LOADED_NOTIF_MOD": ""})); }); $scope.$on("resGetLoadedNotifMod", function (event, args) { - $timeout(function() { + $timeout(function () { $scope.notif_mods = args; }, 0); }); @@ -44,11 +44,11 @@ mumApp.controller('notificationsCtrl', function($scope, $rootScope, $modal, $rou $scope.subscriber_data_unchanged = {}; // used to discard changes // returns all groups except 'all' - $scope.allGroups = function(){ + $scope.allGroups = function (){ var res = [] - for(var i = 0; i<$scope.items.length; i++){ - for(var j = 0; j<$scope.items[i].group.length; j++){ - if($scope.items[i].group[j] != 'all'){ + for (var i = 0; i<$scope.items.length; i++) { + for (var j = 0; j<$scope.items[i].group.length; j++) { + if ($scope.items[i].group[j] != 'all') { res.push($scope.items[i].group[j]); } } @@ -56,11 +56,11 @@ mumApp.controller('notificationsCtrl', function($scope, $rootScope, $modal, $rou return res; }; - $scope.is_activated = function(struct){ // {modname:{"priority":int,"activated":bool}, ...} + $scope.is_activated = function(struct) { // {modname:{"priority":int,"activated":bool}, ...} res = false; - if(struct != {}){ - for(mod in struct){ - if(struct[mod].activated){ + if (struct != {}) { + for (mod in struct) { + if (struct[mod].activated) { res = true; } } @@ -68,10 +68,10 @@ mumApp.controller('notificationsCtrl', function($scope, $rootScope, $modal, $rou return res; }; - $scope.get_activated = function(struct){ // {modname:{"priority":int,"activated":bool}, ...} + $scope.get_activated = function (struct) { // {modname:{"priority":int,"activated":bool}, ...} res = []; - for(mod in struct){ - if(struct[mod].activated){ + for (mod in struct) { + if (struct[mod].activated) { res[res.length] = mod + " at " + struct[mod].priority; } } @@ -83,17 +83,17 @@ mumApp.controller('notificationsCtrl', function($scope, $rootScope, $modal, $rou $scope.option_selected = ""; // 'grp' OR 'host' - $scope.get_group_subscribers = function(){ + $scope.get_group_subscribers = function () { $scope.subtitle = "Group " + $scope.selected_grp; - if($scope.selected_grp != ""){ + if ($scope.selected_grp != "") { var args = {'group': $scope.selected_grp}; $rootScope.$broadcast("sendViaWs", JSON.stringify({"CALL_FUNC_DB": {'func': 'get_group_subscribers', 'args': args}})); } }; - $scope.get_host_subscribers = function(){ + $scope.get_host_subscribers = function () { $scope.subtitle = $scope.selected_host['addr'] + '('+ $scope.selected_host['name'] + ')'; - if($scope.selected_host != ""){ + if ($scope.selected_host != "") { var args = {'addr_host': $scope.selected_host['addr']}; $rootScope.$broadcast("sendViaWs", JSON.stringify({"CALL_FUNC_DB": {'func': 'get_host_subscribers', 'args': args}})); } @@ -108,14 +108,14 @@ mumApp.controller('notificationsCtrl', function($scope, $rootScope, $modal, $rou { notif_mod: priority }, ... }}} */ - if(args.func == 'get_host_subscribers' || args.func == 'get_group_subscribers'){ - $timeout(function() { + if (args.func == 'get_host_subscribers' || args.func == 'get_group_subscribers') { + $timeout(function () { var sd = {}; - for(user in args.res){ + for (user in args.res) { sd[user] = {}; sd[user]['minor'] = {}; sd[user]['major'] = {}; - for(notif_mod in args.res[user]['minor']){ + for (notif_mod in args.res[user]['minor']) { sd[user]['minor'][notif_mod] = {'activated': args.res[user]['minor'][notif_mod]['activated'], 'priority':args.res[user]['minor'][notif_mod]['priority']}; @@ -123,8 +123,8 @@ mumApp.controller('notificationsCtrl', function($scope, $rootScope, $modal, $rou {'activated': args.res[user]['major'][notif_mod]['activated'], 'priority':args.res[user]['major'][notif_mod]['priority']}; } - for(notif_mod in $scope.notif_mods){ - if(!sd[user]['minor'].hasOwnProperty(notif_mod)){ + for (notif_mod in $scope.notif_mods) { + if (!sd[user]['minor'].hasOwnProperty(notif_mod)) { sd[user]['minor'][notif_mod] = {'activated': false, 'priority': null}; sd[user]['major'][notif_mod] = {'activated': false, 'priority': null}; } @@ -134,39 +134,39 @@ mumApp.controller('notificationsCtrl', function($scope, $rootScope, $modal, $rou $scope.subscriber_data_unchanged = sd; }, 0); } - if(args.func == 'update_subscription_to_group' || args.func == 'update_subscription_to_host'){ + if (args.func == 'update_subscription_to_group' || args.func == 'update_subscription_to_host') { $route.reload(); } - if(args.func == 'unsubscribe_to_group' || args.func == 'unsubscribe_to_host'){ + if (args.func == 'unsubscribe_to_group' || args.func == 'unsubscribe_to_host') { $route.reload(); } }); - $scope.discard = function(){ + $scope.discard = function () { $scope.subscriber_data = $scope.subscriber_data_unchanged; }; - $scope.save = function(){ + $scope.save = function () { var args = {}; args['subscription'] = $scope.subscriber_data; - if($scope.option_selected == 'grp'){ + if ($scope.option_selected == 'grp') { args['group'] = $scope.selected_grp; $rootScope.$broadcast("sendViaWs", JSON.stringify({"CALL_FUNC_DB": {'func': 'update_subscription_to_group', 'args': args}})); } - else{ + else { args['addr_host'] = $scope.selected_host.addr; $rootScope.$broadcast("sendViaWs", JSON.stringify({"CALL_FUNC_DB": {'func': 'update_subscription_to_host', 'args': args}})); } }; - $scope.unsubscribe = function(username){ + $scope.unsubscribe = function (username) { var args = {}; args['username'] = username; - if($scope.option_selected == 'grp'){ + if ($scope.option_selected == 'grp') { args['group'] = $scope.selected_grp; $rootScope.$broadcast("sendViaWs", JSON.stringify({"CALL_FUNC_DB": {'func': 'unsubscribe_to_group', 'args': args}})); } - else{ + else { args['addr_host'] = $scope.selected_host.addr; $rootScope.$broadcast("sendViaWs", JSON.stringify({"CALL_FUNC_DB": {'func': 'unsubscribe_to_host', 'args': args}})); } @@ -177,7 +177,7 @@ mumApp.controller('notificationsCtrl', function($scope, $rootScope, $modal, $rou templateUrl: 'modal_add_subscriber_label.html', controller: 'ModalAddSubscriberInstanceCtrl', resolve: { - add_subscriber_args: function(){ + add_subscriber_args: function () { return {"grp" : $scope.selected_grp, "host" : $scope.selected_host}; } @@ -190,10 +190,10 @@ mumApp.controller('ModalAddSubscriberInstanceCtrl', function ($scope, $rootScope $scope.add_subscriber_args = add_subscriber_args; /* {'grp': val, 'host': val */ $scope.modal_title = "Add users to "; - if($scope.add_subscriber_args['grp'] != ""){ + if ($scope.add_subscriber_args['grp'] != "") { $scope.modal_title += " group " + $scope.add_subscriber_args['grp']; } - else{ + else { $scope.modal_title += " host " + $scope.add_subscriber_args['host']['addr']; } @@ -205,13 +205,13 @@ mumApp.controller('ModalAddSubscriberInstanceCtrl', function ($scope, $rootScope // receiving the user list $scope.$on("resCall", function (event, args) { - if(args.func == 'get_users'){ - $timeout(function() { + if (args.func == 'get_users') { + $timeout(function () { $scope.users = args.res; }, 0); } - if(args.func == 'subscribe_to_group' || args.func == 'subscribe_to_host'){ + if (args.func == 'subscribe_to_group' || args.func == 'subscribe_to_host') { $modalInstance.close(); $route.reload(); } @@ -220,11 +220,11 @@ mumApp.controller('ModalAddSubscriberInstanceCtrl', function ($scope, $rootScope $scope.ok = function () { var args = {}; args['users'] = $scope.selected_users; - if($scope.add_subscriber_args['grp'] != ""){ + if ($scope.add_subscriber_args['grp'] != "") { args['group'] = $scope.add_subscriber_args['grp']; $rootScope.$broadcast("sendViaWs", JSON.stringify({"CALL_FUNC_DB": {'func': 'subscribe_to_group', 'args': args}})); } - else{ + else { args['addr_host'] = $scope.add_subscriber_args['host']['addr']; $rootScope.$broadcast("sendViaWs", JSON.stringify({"CALL_FUNC_DB": {'func': 'subscribe_to_host', 'args': args}})); } diff --git a/static/js/controllers/profileCtrl.js b/static/js/controllers/profileCtrl.js index 24b0d94..e4dff89 100644 --- a/static/js/controllers/profileCtrl.js +++ b/static/js/controllers/profileCtrl.js @@ -1,4 +1,4 @@ -mumApp.controller('profileCtrl', function($scope, $rootScope, $route, $modal, $timeout){ +mumApp.controller('profileCtrl', function ($scope, $rootScope, $route, $modal, $timeout) { $scope.users = {}; @@ -11,32 +11,32 @@ mumApp.controller('profileCtrl', function($scope, $rootScope, $route, $modal, $t // after calling db functions $scope.$on("resCall", function (event, args) { - if(args.func == 'get_users'){ - $timeout(function() { + if (args.func == 'get_users') { + $timeout(function () { $scope.users = args.res; }, 0); } - if(args.func == 'get_user_settings'){ - $timeout(function() { + if (args.func == 'get_user_settings') { + $timeout(function () { $scope.email = args.res.settings.email; $scope.sms_url = args.res.settings.sms_url; }, 0); } - if(args.func == 'update_user_settings'){ + if (args.func == 'update_user_settings') { $route.reload(); } }); - $scope.get_user_settings = function(){ + $scope.get_user_settings = function () { var args = {}; - if($scope.selected_user != ''){ + if ($scope.selected_user != '') { args['username'] = $scope.selected_user; } $rootScope.$broadcast("sendViaWs", JSON.stringify({"CALL_FUNC_DB": {'func': 'get_user_settings', 'args': args}})); }; - $scope.save_settings = function(){ + $scope.save_settings = function () { var args = {}; args['username'] = $scope.selected_user; args['settings'] = {}; @@ -52,7 +52,7 @@ mumApp.controller('profileCtrl', function($scope, $rootScope, $route, $modal, $t templateUrl: 'modal_subscriptions_label.html', controller: 'ModalSubscriptionsInstanceCtrl', resolve: { - subs_args: function(){ + subs_args: function () { return {'username': $scope.selected_user}; } } @@ -84,16 +84,16 @@ mumApp.controller('ModalSubscriptionsInstanceCtrl', function ($scope, $rootScope 'args': $scope.subs_args['username']}})); $scope.$on("resCall", function (event, args) { - if(args.func == 'get_user_subscriptions'){ - $timeout(function() { + if (args.func == 'get_user_subscriptions') { + $timeout(function () { $scope.user_subscriptions = args.res; }, 0); } }); - $scope.get_class = function(sub_part, sub_type, target_name, notif_mod){ + $scope.get_class = function (sub_part, sub_type, target_name, notif_mod) { var res = ""; - if($scope.user_subscriptions[sub_part][target_name][sub_type][notif_mod]['activated']){ + if ($scope.user_subscriptions[sub_part][target_name][sub_type][notif_mod]['activated']) { res = "success"; } return res; diff --git a/static/js/controllers/scanCtrl.js b/static/js/controllers/scanCtrl.js index d31609a..711f48a 100644 --- a/static/js/controllers/scanCtrl.js +++ b/static/js/controllers/scanCtrl.js @@ -1,10 +1,10 @@ -mumApp.controller('scanCtrl', function($scope, $rootScope, $routeParams) { +mumApp.controller('scanCtrl', function ($scope, $rootScope, $routeParams) { // Concerning the scan form - if($routeParams.param == null){ + if ($routeParams.param == null) { $scope.ip_range = ""; // la plage d'ip entree dans le champ } - else{ + else { $scope.ip_range = $routeParams.param; } @@ -29,14 +29,14 @@ mumApp.controller('scanCtrl', function($scope, $rootScope, $routeParams) { $scope.validated = false; // pour afficher ou non certaines parties de la page $scope.scan_is_over = false; // pour afficher ou non certaines parties de la page - $scope.post_val = function(){ //lace la detection apres remplissage du champ et validation du formulaire + $scope.post_val = function (){ //lace la detection apres remplissage du champ et validation du formulaire var args = {}; args.ip_range = $scope.ip_range; args.nmap_options = $scope.nmap_options; $rootScope.$broadcast("sendViaWs", JSON.stringify({"NMAP_SCAN_DEMAND": args})); }; - $scope.create_empty_host = function(){ + $scope.create_empty_host = function (){ $rootScope.$broadcast("sendViaWs", JSON.stringify({"CREATE_EMPTY_HOST": $scope.ip_manual_field})); } }); \ No newline at end of file diff --git a/static/js/controllers/settingsCtrl.js b/static/js/controllers/settingsCtrl.js index 2838b2b..3489193 100644 --- a/static/js/controllers/settingsCtrl.js +++ b/static/js/controllers/settingsCtrl.js @@ -1,30 +1,30 @@ -mumApp.controller('settingsCtrl', function($scope, $rootScope, $modal, $timeout) { +mumApp.controller('settingsCtrl', function ($scope, $rootScope, $modal, $timeout) { $scope.settings = {}; // { mod_name: {'check_frequency': 60, 'minor_limit': True, 'activated': False, 'major_limit': False, 'block': 'software', 'unit': 'bool'}} $rootScope.$broadcast("sendViaWs", JSON.stringify({"CALL_FUNC_DB": {'func': 'get_global_settings','args': null}})); $scope.$on("resCall", function (event, args) { - if(args.func == 'get_global_settings'){ - $timeout(function() { + if (args.func == 'get_global_settings') { + $timeout(function () { $scope.settings = args.res; }, 0); } }); - $scope.all_blocks = function(){ + $scope.all_blocks = function () { var res = []; - for(mod in $scope.settings){ - if(res.indexOf($scope.settings[mod]['block']) < 0){ // if the block is not in the res tab + for (mod in $scope.settings) { + if (res.indexOf($scope.settings[mod]['block']) < 0) { // if the block is not in the res tab res[res.length] = $scope.settings[mod].block; } } return res; }; - $scope.all_mod_by_block = function(block){ + $scope.all_mod_by_block = function (block) { var res = {}; - for(mod in $scope.settings){ - if($scope.settings[mod]['block'] == block){ + for (mod in $scope.settings) { + if ($scope.settings[mod]['block'] == block) { res[mod] = $scope.settings[mod]; } } @@ -36,7 +36,7 @@ mumApp.controller('settingsCtrl', function($scope, $rootScope, $modal, $timeout) templateUrl: 'modal_global_conf_label.html', controller: 'ModalGlobalConfInstanceCtrl', resolve: { - global_conf_args: function(){ + global_conf_args: function() { return {'conf_mod': $scope.settings[mod_name], 'mod_name': mod_name}; } } @@ -69,16 +69,16 @@ mumApp.controller('ModalGlobalConfInstanceCtrl', function ($scope, $rootScope, $ $scope.arch_month = global_conf_args.conf_mod.nb_month; $scope.arch_year = global_conf_args.conf_mod.nb_year; - if($scope.global_conf_args.conf_mod.unit == 'bool'){ - if($scope.global_conf_args.conf_mod.major_limit){ + if ($scope.global_conf_args.conf_mod.unit == 'bool') { + if ($scope.global_conf_args.conf_mod.major_limit) { $scope.limit_bool = 'major'; } } - else if($scope.global_conf_args.conf_mod.unit == '%'){ + else if ($scope.global_conf_args.conf_mod.unit == '%') { $scope.minor_limit_percent = $scope.global_conf_args.conf_mod.minor_limit; $scope.major_limit_percent = $scope.global_conf_args.conf_mod.major_limit; } - else{ + else { $scope.minor_limit_unit = $scope.global_conf_args.conf_mod.minor_limit; $scope.major_limit_unit = $scope.global_conf_args.conf_mod.major_limit; } @@ -88,15 +88,15 @@ mumApp.controller('ModalGlobalConfInstanceCtrl', function ($scope, $rootScope, $ var args = {}; args.mod_name = $scope.global_conf_args.mod_name; args.freq = 86400 * $scope.freq_days + 3600 * $scope.freq_hours + 60 * $scope.freq_minutes; - if($scope.global_conf_args.conf_mod.unit == 'bool'){ + if ($scope.global_conf_args.conf_mod.unit == 'bool') { args.minor_limit = ($scope.limit_bool == 'minor'); args.major_limit = ($scope.limit_bool == 'major'); } - else if($scope.global_conf_args.conf_mod.unit == '%'){ + else if ($scope.global_conf_args.conf_mod.unit == '%') { args.minor_limit = $scope.minor_limit_percent; args.major_limit = $scope.major_limit_percent; } - else{ + else { args.minor_limit = $scope.minor_limit_unit; args.major_limit = $scope.major_limit_unit; } diff --git a/static/js/controllers/statsCtrl.js b/static/js/controllers/statsCtrl.js index 5219ecf..10c49a1 100644 --- a/static/js/controllers/statsCtrl.js +++ b/static/js/controllers/statsCtrl.js @@ -1,6 +1,6 @@ -mumApp.controller('statsCtrl', function($scope, $rootScope, $timeout, DataHosts) { +mumApp.controller('statsCtrl', function ($scope, $rootScope, $timeout, DataHosts) { $scope.host_list = []; - for(var i = 0; i < DataHosts.Items.length; i++){ + for (var i = 0; i < DataHosts.Items.length; i++) { $scope.host_list.push(DataHosts.Items[i]['addr']) } $scope.mod_list = []; @@ -21,8 +21,8 @@ mumApp.controller('statsCtrl', function($scope, $rootScope, $timeout, DataHosts) $scope.standard_derivation = 0; $scope.slope_lr = 0; - $scope.get_stats = function(){ - if($scope.selected_host != null && $scope.selected_host != ''){ + $scope.get_stats = function() { + if ($scope.selected_host != null && $scope.selected_host != '') { var args = {}; args['addr_host'] = $scope.selected_host; $rootScope.$broadcast("sendViaWs", JSON.stringify({"CALL_FUNC_DB": {'func': 'get_stats', 'args': args}})); @@ -30,7 +30,7 @@ mumApp.controller('statsCtrl', function($scope, $rootScope, $timeout, DataHosts) }; $scope.$on("resCall", function (event, args) { - if(args.func == 'get_stats'){ + if (args.func == 'get_stats') { $scope.stats = args.res.stats; $scope.archive = args.res.archive; $scope.mod_list = []; @@ -40,31 +40,31 @@ mumApp.controller('statsCtrl', function($scope, $rootScope, $timeout, DataHosts) } }); - $scope.update_subpart_list = function(){ + $scope.update_subpart_list = function () { $scope.subpart_list = []; - for(subpart in $scope.stats[$scope.selected_mod]){ + for (subpart in $scope.stats[$scope.selected_mod]) { $scope.subpart_list.push(subpart); } $scope.selected_subpart = ''; - if($scope.subpart_list.length == 1 && $scope.subpart_list[0] == ''){ + if ($scope.subpart_list.length == 1 && $scope.subpart_list[0] == '') { $scope.update_stats(); } }; - $scope.update_stats = function(){ + $scope.update_stats = function() { $scope.selected_period = ''; update_mean(); update_standard_derivation(); update_slope_of_linear_regression(); }; - $scope.refresh_chart_data = function(){ + $scope.refresh_chart_data = function() { $scope.config.title = $scope.selected_host; $scope.data.data = []; - if(typeof($scope.archive[$scope.selected_mod][$scope.selected_period][0].value) == "object"){ + if (typeof($scope.archive[$scope.selected_mod][$scope.selected_period][0].value) == "object") { $scope.data.series = [$scope.selected_mod + ' on ' + $scope.selected_subpart]; - for(var i = 0; i<$scope.archive[$scope.selected_mod][$scope.selected_period].length; i++){ - if($scope.archive[$scope.selected_mod][$scope.selected_period][i].value.hasOwnProperty($scope.selected_subpart)){ + for (var i = 0; i<$scope.archive[$scope.selected_mod][$scope.selected_period].length; i++) { + if ($scope.archive[$scope.selected_mod][$scope.selected_period][i].value.hasOwnProperty($scope.selected_subpart)) { $scope.data.data.push({'x': i, 'y': [$scope.archive[$scope.selected_mod][$scope.selected_period][i].value[$scope.selected_subpart]], 'tooltip': $scope.archive[$scope.selected_mod][$scope.selected_period][i].value[$scope.selected_subpart] + " @ " + @@ -74,9 +74,9 @@ mumApp.controller('statsCtrl', function($scope, $rootScope, $timeout, DataHosts) } } } - else{ + else { $scope.data.series = [$scope.selected_mod]; - for(var i = 0; i<$scope.archive[$scope.selected_mod][$scope.selected_period].length; i++){ + for (var i = 0; i<$scope.archive[$scope.selected_mod][$scope.selected_period].length; i++) { $scope.data.data.push({'x': i, 'y': [$scope.archive[$scope.selected_mod][$scope.selected_period][i].value], 'tooltip': $scope.archive[$scope.selected_mod][$scope.selected_period][i].value + " @ " + @@ -87,20 +87,20 @@ mumApp.controller('statsCtrl', function($scope, $rootScope, $timeout, DataHosts) } }; - $scope.value_is_NaN = function(value){ + $scope.value_is_NaN = function (value) { return value !== value; }; - var update_mean = function(){ + var update_mean = function () { $scope.mean_value = $scope.stats[$scope.selected_mod][$scope.selected_subpart].total / $scope.stats[$scope.selected_mod][$scope.selected_subpart].nb_check; }; - var update_standard_derivation = function(){ + var update_standard_derivation = function () { var variance = $scope.stats[$scope.selected_mod][$scope.selected_subpart].M2 / Math.max(1, $scope.stats[$scope.selected_mod][$scope.selected_subpart].nb_check + 1); $scope.standard_derivation = Math.sqrt(variance); }; - var update_slope_of_linear_regression = function(){ + var update_slope_of_linear_regression = function () { var mX = ($scope.stats[$scope.selected_mod][$scope.selected_subpart].nb_check + 1) / 2; var mY = $scope.stats[$scope.selected_mod][$scope.selected_subpart].total / $scope.stats[$scope.selected_mod][$scope.selected_subpart].nb_check; var mX2 = ($scope.stats[$scope.selected_mod][$scope.selected_subpart].nb_check + 1) * (2 * $scope.stats[$scope.selected_mod][$scope.selected_subpart].nb_check + 1) / 6; @@ -112,9 +112,9 @@ mumApp.controller('statsCtrl', function($scope, $rootScope, $timeout, DataHosts) title: '', tooltips: true, labels: false, - mouseover: function() {}, - mouseout: function() {}, - click: function() {}, + mouseover: function () {}, + mouseout: function () {}, + click: function () {}, legend: { display: true, //could be 'left, right' diff --git a/static/js/controllers/usersCtrl.js b/static/js/controllers/usersCtrl.js index 2f61e47..4d616c0 100644 --- a/static/js/controllers/usersCtrl.js +++ b/static/js/controllers/usersCtrl.js @@ -1,4 +1,4 @@ -mumApp.controller('usersCtrl', function($scope, $rootScope, $route, $timeout) { +mumApp.controller('usersCtrl', function ($scope, $rootScope, $route, $timeout) { $scope.users = {}; $scope.selected_user = ""; @@ -29,7 +29,7 @@ mumApp.controller('usersCtrl', function($scope, $rootScope, $route, $timeout) { // receiving the user list $scope.$on("resCall", function (event, args) { if(args.func == 'get_users'){ - $timeout(function() { + $timeout(function () { $scope.users = args.res; }, 0); } @@ -37,36 +37,36 @@ mumApp.controller('usersCtrl', function($scope, $rootScope, $route, $timeout) { $route.reload(); } if(args.func == 'get_user_subscriptions'){ - $timeout(function() { + $timeout(function () { $scope.user_subscriptions = args.res; }, 0); } }); - $scope.addUser = function(){ + $scope.addUser = function () { var args = {}; args['username'] = $scope.new_username; $rootScope.$broadcast("sendViaWs", JSON.stringify({"CALL_FUNC_DB": {'func': 'create_user', 'args': args}})); $route.reload(); }; - $scope.removeUser = function(){ + $scope.removeUser = function () { var args = {}; args['username'] = $scope.selected_user; $rootScope.$broadcast("sendViaWs", JSON.stringify({"CALL_FUNC_DB": {'func': 'remove_user', 'args': args}})); $route.reload(); }; - $scope.get_user_subscriptions = function(){ - if($scope.selected_user != ''){ + $scope.get_user_subscriptions = function() { + if ($scope.selected_user != '') { $rootScope.$broadcast("sendViaWs", JSON.stringify({"CALL_FUNC_DB": {'func': 'get_user_subscriptions', 'args': $scope.selected_user}})); } }; - $scope.get_class = function(sub_part, sub_type, target_name, notif_mod){ + $scope.get_class = function (sub_part, sub_type, target_name, notif_mod) { var res = ""; - if($scope.user_subscriptions[sub_part][target_name][sub_type][notif_mod]['activated']){ + if ($scope.user_subscriptions[sub_part][target_name][sub_type][notif_mod]['activated']) { res = "success"; } return res; diff --git a/static/js/mumApp.js b/static/js/mumApp.js index 0e9c994..70080ee 100644 --- a/static/js/mumApp.js +++ b/static/js/mumApp.js @@ -1,10 +1,10 @@ var mumApp = angular.module('mumApp', ['angularFileUpload', 'angularCharts', 'ngRoute', 'ui.bootstrap', 'toastr']); -mumApp.factory('DataHosts', function(){ +mumApp.factory('DataHosts', function () { return {Items: []}; }); -mumApp.config(function($routeProvider){ +mumApp.config(function ($routeProvider) { $routeProvider .when('/',{ templateUrl : 'dashboard.html', diff --git a/views/dashboard.html b/views/dashboard.html index c8d7444..22f9ffa 100644 --- a/views/dashboard.html +++ b/views/dashboard.html @@ -1,89 +1,70 @@ +<div class="col-md-offset-2 main"> - <div class="col-md-offset-2 main"> - <h1 class="page-header">Dashboard</h1> - <h2 class="sub-header">Hosts currently on monitoring</h2> - <div class="row" - ng-show="items.length > 0"> - <div class="col-xs-3"> + <h1 class="page-header">Dashboard</h1> + <h2 class="sub-header">Hosts currently on monitoring</h2> + + <div class="row" + ng-show="items.length > 0"> + + <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> - <div class="col-xs-3"> - <label for="name_f">Name filter</label> - <input class="form-control" type="text" id="name_f" ng-model="name_filter"> - </div> - <div class="col-xs-2"> - <label for="status_f">Status filter</label> - <select multiple class="form-control input-sm" id="status_f" ng-model="status_filter"> - <option>success</option> - <option>warning</option> - <option>danger</option> - <option>idling</option> - </select> - </div> - <div class="col-xs-2"> - <label for="group_f">Group filter</label> - <select class="form-control input-sm" - id="group_f" - ng-model="group_filter" - ng-options="item for item in allGroups() | unique:'group'"> - </select> - </div> - <table class="table table-condensed table-hover"> - <thead> + <input class="form-control" type="text" id="addr_f" ng-model="addr_filter"> + </div> - <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='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> - </tr> - </thead> - - <!--<tfoot> === pour l'affichage du tableau par pages - <td colspan="6"> - <div class="pagination pull-right"> - <ul> - <li ng-class="{disabled: currentPage == 0}"> - <a href ng-click="prevPage()">« Prev</a> - </li> - - <li ng-repeat="n in range(pagedItems.length, currentPage, currentPage + gap) " - ng-class="{active: n == currentPage}" - ng-click="setPage()"> - <a href ng-bind="n + 1">1</a> - </li> - - <li ng-class="{disabled: (currentPage) == pagedItems.length - 1}"> - <a href ng-click="nextPage()">Next »</a> - </li> - </ul> - </div> - </td> - </tfoot> - - <pre>pagedItems.length: {{pagedItems.length|json}}</pre> - <pre>currentPage: {{currentPage|json}}</pre> - <pre>currentPage: {{sort|json}}</pre>--> - <tbody> - <tr ng-repeat="item in items | - orderBy:order_val | - filter:{addr:addr_filter, name:name_filter, group:group_filter} | - filter:filtering_status" - class={{item.status}}> <!-- group.name:group_filter --> - <td><a href="#/hostpage/{{item.addr}}">{{item.addr}}</a></td> - <td>{{item.name}}</td> - <td>warning : {{item.warning}}<br/> - danger : {{item.danger}}</td> - <td>{{item.group}}</td> - <td>{{item.last_check.split('.')[0]}}</td> - </tr> - </tbody> - </table> + <div class="col-xs-3"> + <label for="name_f">Name filter</label> + <input class="form-control" type="text" id="name_f" ng-model="name_filter"> </div> - <div ng-show="items.length == 0"> - <p>No hosts for the moment. <a href="#scan">Scan for new hosts now!</a></p> + + <div class="col-xs-2"> + <label for="status_f">Status filter</label> + <select multiple class="form-control input-sm" id="status_f" ng-model="status_filter"> + <option>success</option> + <option>warning</option> + <option>danger</option> + <option>idling</option> + </select> </div> + <div class="col-xs-2"> + <label for="group_f">Group filter</label> + <select class="form-control input-sm" + id="group_f" + ng-model="group_filter" + ng-options="item for item in allGroups() | unique:'group'"> + </select> </div> + + <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='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> + </tr> + </thead> + + <tbody> + <tr ng-repeat="item in items | + orderBy:order_val | + filter:{addr:addr_filter, name:name_filter, group:group_filter} | + filter:filtering_status" + class={{item.status}}> <!-- group.name:group_filter --> + <td><a href="#/hostpage/{{item.addr}}">{{item.addr}}</a></td> + <td>{{item.name}}</td> + <td>warning : {{item.warning}}<br/> + danger : {{item.danger}}</td> + <td>{{item.group}}</td> + <td>{{item.last_check.split('.')[0]}}</td> + </tr> + </tbody> + </table> + </div> + + <div ng-show="items.length == 0"> + <p>No hosts for the moment. <a href="#scan">Scan for new hosts now!</a></p> + </div> + +</div> \ No newline at end of file diff --git a/views/groups.html b/views/groups.html index 7db6edb..faf4252 100644 --- a/views/groups.html +++ b/views/groups.html @@ -1,103 +1,89 @@ +<div class="col-md-offset-2 main"> - <div class="col-md-offset-2 main"> - <h1 class="page-header">Group manager</h1> - <div class="row"> - <div class="col-xs-3"> - <label for="grpoption">Your existing groups</label> - <form class="form-inline" id="grpoption"> - <select class="form-control" ng-change="change_group_displayed()" ng-model="grp" ng-options="item for item in allGroups() | unique:'group'"> - </select> - </form> - </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> - <div class="col-xs-3"> - <label for="name_f">Name filter</label> - <input class="form-control" type="text" id="name_f" ng-model="name_filter"> - </div> - <table class="table table-striped 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='group'">Groups</a></th> - <th><input type="checkbox" ng-model="selectedAll" ng-click="checkAll(!selectedAll)"></th> - </tr> - </thead> - <tbody> - <tr ng-repeat="item in items | - filter:{addr:addr_filter, name:name_filter, group:grp} | - orderBy:order_val"> <!-- group:{name:grp} --> - <td>{{item.addr}}</td> - <td>{{item.name}}</td> - <td>{{item.group}}</td> - <td> - <input type="checkbox" ng-model="selection[item.addr]"/> - </td> - </tr> - </tbody> - </table> - <button type="button" class="btn btn-primary" - ng-click="open_modal_group()" - ng-disable="selection=={}">Add selected to group...</button> - <button ng-show="grp != 'all' || ''" type="button" class="btn btn-danger" ng-click="remove_host_list()">Remove selected from {{grp}}</button> - </div> + <h1 class="page-header">Group manager</h1> + + <div class="row"> + + <div class="col-xs-3"> + <label for="grpoption">Your existing groups</label> + <form class="form-inline" id="grpoption"> + <select class="form-control" ng-change="change_group_displayed()" ng-model="grp" ng-options="item for item in allGroups() | unique:'group'"> + </select> + </form> </div> - <script type="text/ng-template" id="modal_group_label.html"> - <div class="modal-header"> - <h3 class="modal-title">Add {{group_args.selected}}</h3> - </div> - <div class="modal-body"> - <form> - <div class="form-group"> - <label for="list_grp">to an existing group</label> - <select class="form-control" id="list_grp" - ng-model="selected_grp" - ng-options="item for item in group_args.groups | unique:'group'" - ng-disabled="new_grp_name!=''"> - </select> - <label for="grp_name">Or create a new group</label> - <input type="text" class="form-control" id="grp_name" - ng-model="new_grp_name" - ng-change="selected_grp = ''"> - </div> - </form> - </div> - <div class="modal-footer"> - <button type="button" class="btn btn-default" data-dismiss="modal" ng-click="cancel()">Close</button> - <button type="button" class="btn btn-primary" ng-click="ok()">Save changes</button> - </div> - </script> - -<!-- -<div class="modal fade" id="modal_add" tabindex="-1" role="dialog" aria-labelledby="modal_add_label" aria-hidden="true"> - <div class="modal-dialog"> - <div class="modal-content"> - <div class="modal-header"> - <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button> - <h4 class="modal-title" id="modal_add_label">Add to group</h4> - </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> - <div class="modal-body"> - <form> - <div class="form-group"> - <label for="list_grp">From an existing group</label> - <select class="form-control" id="list_grp" ng-model="selected_grp" ng-options= - "item for item in allGroups() | unique:'group'"> - </select> - <label for="grp_name">Or create a new group</label> - <input type="text" class="form-control" id="grp_name" placeholder="Group name"> - </div> - </form> - </div> - <div class="modal-footer"> - <button type="button" class="btn btn-default" data-dismiss="modal">Close</button> - <button type="button" class="btn btn-primary">Save changes</button> - </div> + <div class="col-xs-3"> + <label for="name_f">Name filter</label> + <input class="form-control" type="text" id="name_f" ng-model="name_filter"> </div> + + <table class="table table-striped 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='group'">Groups</a></th> + <th><input type="checkbox" ng-model="selectedAll" ng-click="checkAll(!selectedAll)"></th> + </tr> + </thead> + + <tbody> + <tr ng-repeat="item in items | + filter:{addr:addr_filter, name:name_filter, group:grp} | + orderBy:order_val"> <!-- group:{name:grp} --> + <td>{{item.addr}}</td> + <td>{{item.name}}</td> + <td>{{item.group}}</td> + <td> + <input type="checkbox" ng-model="selection[item.addr]"/> + </td> + </tr> + </tbody> + </table> + + <button type="button" class="btn btn-primary" + ng-click="open_modal_group()" + ng-disable="selection=={}">Add selected to group...</button> + + <button ng-show="grp != 'all' || ''" type="button" class="btn btn-danger" ng-click="remove_host_list()">Remove selected from {{grp}}</button> + </div> </div> ---> \ No newline at end of file + +<script type="text/ng-template" id="modal_group_label.html"> + + <div class="modal-header"> + <h3 class="modal-title">Add {{group_args.selected}}</h3> + </div> + + <div class="modal-body"> + <form> + <div class="form-group"> + + <label for="list_grp">to an existing group</label> + <select class="form-control" id="list_grp" + ng-model="selected_grp" + ng-options="item for item in group_args.groups | unique:'group'" + ng-disabled="new_grp_name!=''"> + </select> + + <label for="grp_name">Or create a new group</label> + <input type="text" class="form-control" id="grp_name" + ng-model="new_grp_name" + ng-change="selected_grp = ''"> + + </div> + </form> + </div> + + <div class="modal-footer"> + <button type="button" class="btn btn-default" data-dismiss="modal" ng-click="cancel()">Close</button> + <button type="button" class="btn btn-primary" ng-click="ok()">Save changes</button> + </div> + +</script> \ No newline at end of file diff --git a/views/hostpage.html b/views/hostpage.html index 724db7b..c0cfc8b 100644 --- a/views/hostpage.html +++ b/views/hostpage.html @@ -1,472 +1,545 @@ +<div class="col-md-offset-2 main"> + + <h1 class="page-header">Current state of {{addr_host}} <small>{{items.hostname}} + <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> + + <button type="button" class="btn btn-primary btn-xs" + ng-click="open_modal_block()" + popover="Activate or deactivate monitoring modules by section." + popover-trigger="mouseenter" + ng-disabled="items.status == 'idling'">Activate/Deactivate</button> + + <button type="button" + class="btn btn-primary btn-xs" + ng-click="open_modal_conn()">Connection settings</button> + + <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> + + <button type="button" + class="btn btn-danger btn-xs" + ng-click="open_modal_confirm_delete()">Remove this host</button> + + <table class="table table-condensed table-hover" + ng-show="items.status != 'idling'"> + + <thead> + <tr> + <th>Part </th> + <th>Value </th> + <th>State </th> + <th>Last check </th> + </tr> + </thead> + + <tbody> + <tr ng-repeat-start="(itemname, item) in items.monitoring" + class={{item.state}} + > <!-- ng-show="items.activated_monitoring[itemname]" --> + <td>{{itemname}}</td> + <td ng-show="get_type_of(item.value) != 'object'">{{item.value}} {{get_unit(itemname)}}</td> + <td ng-show="get_type_of(item.value) == 'object'"> + <a ng-click="collapsed[itemname] = !collapsed[itemname]">▼</a> + </td> + <td>{{item.state}}</td> + <td>{{item.date.split('.')[0]}}</td> + <td><button type="button" class="btn btn-primary btn-xs" + ng-click="open_modal_conf(itemname)">Configure</button></td> + <td><button type="button" class="btn btn-info btn-xs" + ng-click="check(itemname)">Check now</button></td> + </tr> + <tr ng-repeat-end + ng-repeat="(valname, val) in item.value" + collapse="collapsed[itemname]"> + <td>{{valname}}</td> + <td>{{val}} {{get_unit(itemname)}}</td> + </tr> + </tbody> + + </table> + + <accordion close-others="false"> + + <accordion-group heading="Essential configuration (nmap detection)"> - <div class="col-md-offset-2 main"> - <h1 class="page-header">Current state of {{addr_host}} <small>{{items.hostname}} - <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> <button type="button" class="btn btn-primary btn-xs" - ng-click="open_modal_block()" - popover="Activate or deactivate monitoring modules by section." - popover-trigger="mouseenter" - ng-disabled="items.status == 'idling'">Activate/Deactivate</button> - <button type="button" - class="btn btn-primary btn-xs" - ng-click="open_modal_conn()">Connection settings</button> - <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> - <button type="button" - class="btn btn-danger btn-xs" - ng-click="open_modal_confirm_delete()">Remove this host</button> - <table class="table table-condensed table-hover" - ng-show="items.status != 'idling'"> - <thead> + ng-click="rescan()">Scan again</button> + + <table class="table table-bordered table-hover"> + <tr ng-repeat="(key, val) in items.detected.nmap"> + <td>{{key}}</td> + <td>{{val}}</td> + <td ng-show="(key == 'os')"> + <select ng-model="model.new_os" + ng-options="os for os in model.compatible_os_list"> + </select> + <button type="button" class="btn btn-info btn-xs" + ng-click="update_nmap_attribute('os', model.new_os)" + ng-disabled="model.new_os==''">Correct OS name</button> + </td> + <td ng-show="(key == 'hostname')"> + <input type="text" + ng-model="model.new_hostname"/> + <button type="button" class="btn btn-info btn-xs" + ng-click="update_nmap_attribute('hostname', model.new_hostname)" + ng-disabled="model.new_hostname==''">Correct hostname</button> + </td> + <td ng-show="(key == 'openports')"> + <button type="button" class="btn btn-primary btn-xs" + ng-click="open_modal_port_config(val)"> + Add/remove detected ports + </button> + </td> + </tr> + </table> + + </accordion-group> + + <accordion-group heading="Detected configuration (select the subparts to monitore here)"> + + <table class="table table-bordered table-hover"> + <tr ng-repeat-start="(modname, mod) in items.detected" + ng-show="modname != 'nmap'"> + <th>{{modname}}</th> + <th> + <input type="checkbox" ng-model="selectedAll" ng-click="checkAll(modname, !selectedAll)"> + <button type="button" class="btn btn-info btn-xs" + ng-click="save_subpart(modname)"> + Monitore selected subparts + </button> + </th> + </tr> + <tr ng-repeat-end + ng-repeat="(key, val) in mod | orderBy : val" + ng-show="modname != 'nmap'"> + <td>{{val}}</td> + <td><input type="checkbox" ng-model="subparts_checked[modname][val]"></td> + </tr> + </table> + + </accordion-group> + + <accordion-group heading="Custom informations"> + <label for="custom_info">Add any information here :</label> + <textarea class="form-control" rows="3" id="custom_info" ng-model="model.custom_infos"></textarea> + <button type="button" class="btn btn-info btn-xs" ng-click="save_custom_infos()">Save</button> + + </accordion-group> + + <accordion-group heading="Interventions done"> + + <button type="button" class="btn btn-primary btn-xs" + ng-click="open_modal_interv()">Add a new intervention</button> + <div ng-show="items.interventions != ''"> + + <table class="table table-bordered table-hover"> + + <thead> <tr> - <th>Part </th> - <th>Value </th> - <th>State </th> - <th>Last check </th> + <th>Date </th> + <th>Person </th> + <th>Details </th> </tr> - </thead> + </thead> - <tbody> - <tr ng-repeat-start="(itemname, item) in items.monitoring" - class={{item.state}} - > <!-- ng-show="items.activated_monitoring[itemname]" --> - <td>{{itemname}}</td> - <td ng-show="get_type_of(item.value) != 'object'">{{item.value}} {{get_unit(itemname)}}</td> - <td ng-show="get_type_of(item.value) == 'object'"> - <a ng-click="collapsed[itemname] = !collapsed[itemname]">▼</a> - </td> - <td>{{item.state}}</td> - <td>{{item.date.split('.')[0]}}</td> - <td><button type="button" class="btn btn-primary btn-xs" - ng-click="open_modal_conf(itemname)">Configure</button></td> - <td><button type="button" class="btn btn-info btn-xs" - ng-click="check(itemname)">Check now</button></td> + <tbody> + <tr ng-repeat="interv in items.interventions | + orderBy:'-date'"> + <td>{{interv.date}}</td> + <td>{{interv.username}}</td> + <td>{{interv.details}}</td> </tr> - <tr ng-repeat-end - ng-repeat="(valname, val) in item.value" - collapse="collapsed[itemname]"> - <td>{{valname}}</td> - <td>{{val}} {{get_unit(itemname)}}</td> - </tr> - </tbody> - </table> - <accordion close-others="false"> - <accordion-group heading="Essential configuration (nmap detection)"> - <button type="button" class="btn btn-primary btn-xs" - ng-click="rescan()">Scan again</button> - <table class="table table-bordered table-hover"> - <tr ng-repeat="(key, val) in items.detected.nmap"> - <td>{{key}}</td> - <td>{{val}}</td> - <td ng-show="(key == 'os')"> - <select ng-model="model.new_os" - ng-options="os for os in model.compatible_os_list"> - </select> - <button type="button" class="btn btn-info btn-xs" - ng-click="update_nmap_attribute('os', model.new_os)" - ng-disabled="model.new_os==''">Correct OS name</button> - </td> - <td ng-show="(key == 'hostname')"> - <input type="text" - ng-model="model.new_hostname"/> - <button type="button" class="btn btn-info btn-xs" - ng-click="update_nmap_attribute('hostname', model.new_hostname)" - ng-disabled="model.new_hostname==''">Correct hostname</button> - </td> - <td ng-show="(key == 'openports')"> - <button type="button" class="btn btn-primary btn-xs" - ng-click="open_modal_port_config(val)"> - Add/remove detected ports - </button> - </td> - </tr> - </table> - </accordion-group> - <accordion-group heading="Detected configuration (select the subparts to monitore here)"> - <table class="table table-bordered table-hover"> - <tr ng-repeat-start="(modname, mod) in items.detected" - ng-show="modname != 'nmap'"> - <th>{{modname}}</th> - <th> - <input type="checkbox" ng-model="selectedAll" ng-click="checkAll(modname, !selectedAll)"> - <button type="button" class="btn btn-info btn-xs" - ng-click="save_subpart(modname)"> - Monitore selected subparts - </button> - </th> - </tr> - <tr ng-repeat-end - ng-repeat="(key, val) in mod | orderBy : val" - ng-show="modname != 'nmap'"> - <td>{{val}}</td> - <td><input type="checkbox" ng-model="subparts_checked[modname][val]"></td> - </tr> - </table> - </accordion-group> - - <accordion-group heading="Custom informations"> - <label for="custom_info">Add any information here :</label> - <textarea class="form-control" rows="3" id="custom_info" ng-model="model.custom_infos"></textarea> - <button type="button" class="btn btn-info btn-xs" ng-click="save_custom_infos()">Save</button> - </accordion-group> - - <accordion-group heading="Interventions done"> - <button type="button" class="btn btn-primary btn-xs" - ng-click="open_modal_interv()">Add a new intervention</button> - <div ng-show="items.interventions != ''"> - <table class="table table-bordered table-hover"> - <thead> - <tr> - <th>Date </th> - <th>Person </th> - <th>Details </th> - </tr> - </thead> - <tbody> - <tr ng-repeat="interv in items.interventions | - orderBy:'-date'"> - <td>{{interv.date}}</td> - <td>{{interv.username}}</td> - <td>{{interv.details}}</td> - </tr> - </tbody> - </table> - </div> - </accordion-group> - </accordion> + </tbody> - <script type="text/ng-template" id="modal_conf_label.html"> - <div class="modal-header"> - <h3 class="modal-title">Configure {{conf_args.mod_name}} for {{conf_args.addr_host}}</h3> - </div> - <div class="modal-body"> - <form> - <div class="form-group"> - <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" - ng-model="arch_min"> minute - </div> - <div class="col-xs-2"> - <input type="number" min="0" max="59" class="form-control" - ng-model="arch_hour"> hour - </div> - <div class="col-xs-2"> - <input type="number" min="0" max="23" class="form-control" - ng-model="arch_day"> day - </div> - <div class="col-xs-2"> - <input type="number" min="0" max="7" class="form-control" - ng-model="arch_week"> week - </div> - <div class="col-xs-2"> - <input type="number" min="0" max="31" class="form-control" - ng-model="arch_month"> month - </div> - <div class="col-xs-2"> - <input type="number" min="0" class="form-control" - ng-model="arch_year"> year - </div> - </div> - <label for="freq">Frequency check: each</label> - <div class="row" id="freq"> - <div class="col-xs-2"> - <input type="number" min="0" class="form-control" - ng-model="freq_days"> days - </div> - <div class="col-xs-2"> - <input type="number" min="0" max="23" class="form-control" - ng-model="freq_hours"> hours - </div> - <div class="col-xs-2"> - <input type="number" min="0" max="59" class="form-control" - ng-model="freq_minutes"> minutes - </div> - </div> - <div ng-show="items.unit == '%'"> - <label for="minor_%">Minor notification at {{minor_limit_percent}}% of charge</label> - <input type="range" min="0" max="99" id="minor_%" - ng-model="minor_limit_percent"> - <label for="major_%">Major notification at {{major_limit_percent}}% of charge</label> - <input type="range" min="{{minor_limit_percent}}" max="100" id="major_%" - ng-model="major_limit_percent"> - </div> - <div ng-show="items.unit == 'bool'"> - <label for="minor_bool">If down, send a </label> - <div class="radio"> - <label> - <input type="radio" id="minor_bool" value="minor" ng-model="limit_bool"> - minor notification - </label> - </div> - <div class="radio"> - <label> - <input type="radio" id="major_bool" value="major" ng-model="limit_bool"> - major notification - </label> - </div> - </div> - <div ng-show="items.unit != '%' && items.unit != 'bool'"> - <label for="minor_unit">Minor notif at {{minor_limit_unit}}</label> - <input type="number" class="form-control" id="minor_unit" min="0" - ng-model="minor_limit_unit"> - <label for="maj_pack">Major notif at {{major_limit_unit}}</label> - <input type="number" class="form-control" id="maj_pack" min="0" - ng-model="major_limit_unit"> - </div> - </div> - </form> - </div> - <div class="modal-footer"> - <button type="button" class="btn btn-default" data-dismiss="modal" - ng-click="cancel()">Close</button> - <button type="button" class="btn btn-primary" ng-click="ok()">Save changes</button> - </div> - </script> + </table> - <script type="text/ng-template" id="modal_interv_label.html"> - <div class="modal-header"> - <h3 class="modal-title">Add an intervention</h3> - </div> - <div class="modal-body"> - <form> - <div class="form-group"> + </div> + + </accordion-group> - <label for="username">User</label> - <input type="text" class="form-control" id="username" ng-model="user"> {{user}} + </accordion> - <label for="date">Date (YYYY-MM-DD HH:MM)</label> - <input type="datetime" class="form-control" id="date" ng-model="date"> + <script type="text/ng-template" id="modal_conf_label.html"> - <label for="interv_detail">Details of this intervention</label> - <textarea class="form-control" rows="3" id="interv_detail" ng-model="details"></textarea> + <div class="modal-header"> + <h3 class="modal-title">Configure {{conf_args.mod_name}} for {{conf_args.addr_host}}</h3> + </div> + + <div class="modal-body"> + + <form> + <div class="form-group"> + <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" + ng-model="arch_min"> minute </div> - </form> - </div> - <div class="modal-footer"> - <button type="button" class="btn btn-default" data-dismiss="modal" ng-click="cancel()">Close</button> - <button type="button" class="btn btn-primary" ng-click="ok()">Save changes</button> - </div> - </script> - <script type="text/ng-template" id="modal_conn_label.html"> - <div class="modal-header"> - <h3 class="modal-title">Connection configuration</h3> - </div> - <div class="modal-body"> - <form> - <div class="form-group"> - <h3>Choose the priority of each avaliable connection. The highest will be used first. - Set at 0 to not use this connection.</h3> - <table class="table table-bordered table-hover"> - <thead> - <tr> - <th>Protocol </th> - <th>Priority </th> - <th>Options </th> - </tr> - </thead> - <tbody> - <tr ng-repeat="(modname, modconf) in current_config"> - <td>{{modname}}</td> - <td><input type="number" min="0" ng-model="priorities[modname]" - ng-disabled="isNotConfigured(modname)"></td> - <td> - <button type="button" class="btn btn-primary" - ng-click="open_modal_conf_conn(modname)">Advanced configuration</button> - <button type="button" class="btn btn-success" - ng-click="testConn(modname)">Test</button> - </td> - - </tr> - </tbody> - </table> + <div class="col-xs-2"> + <input type="number" min="0" max="59" class="form-control" + ng-model="arch_hour"> hour </div> - </form> - </div> - <div class="modal-footer"> - <button type="button" class="btn btn-default" data-dismiss="modal" ng-click="cancel()">Close</button> - <button type="button" class="btn btn-primary" ng-click="ok()">Save changes</button> - </div> - </script> + <div class="col-xs-2"> + <input type="number" min="0" max="23" class="form-control" + ng-model="arch_day"> day + </div> + <div class="col-xs-2"> + <input type="number" min="0" max="7" class="form-control" + ng-model="arch_week"> week + </div> - <script type="text/ng-template" id="modal_conf_conn_label.html"> - <div class="modal-header"> - <h3 class="modal-title">Advanced settings for {{conf_conn_args['modname']}}</h3> - </div> + <div class="col-xs-2"> + <input type="number" min="0" max="31" class="form-control" + ng-model="arch_month"> month + </div> - <div class="modal-body"> - <!--<input type="file" nv-file-select uploader="uploader"/><br/> - <ul> - <li ng-repeat="item in uploader.queue"> - Upload a new key: <span ng-bind="item.file.name"></span><br/> - <button ng-click="item.upload(item, '\keys')">upload</button> - </li> - </ul>--> - <div class="row" ng-show="show_form('private_key')"> - <div class="col-xs-3"> - <label for="private_key">Select a private key</label> - <select class="form-control input-sm" id="private_key" - ng-model="private_key" - ng-options="key as key for key in keys_list"></select> + <div class="col-xs-2"> + <input type="number" min="0" class="form-control" + ng-model="arch_year"> year </div> + </div> - <div class="row" ng-show="show_form('private_key')"> - <div class="col-xs-3"> - <form action="/upload" method="post" enctype="multipart/form-data"> - <label for="upload_key">Or upload a new key couple:</label> - <input type="file" id="upload_key" name="upload" /> - <input type="submit" value="Start upload" /> - </form> + + <label for="freq">Frequency check: each</label> + <div class="row" id="freq"> + + <div class="col-xs-2"> + <input type="number" min="0" class="form-control" + ng-model="freq_days"> days </div> - </div> - <div class="row" ng-show="show_form('port')"> + <div class="col-xs-2"> - <label for="port">Port used</label> - <input type="number" id="port" min="0" ng-model="port"> + <input type="number" min="0" max="23" class="form-control" + ng-model="freq_hours"> hours </div> - </div> - <div class="row" ng-show="show_form('username')"> - <div class="col-xs-3"> - <label for="usrname">Login</label> - <input type="text" id="usrname" ng-model="username"/> + + <div class="col-xs-2"> + <input type="number" min="0" max="59" class="form-control" + ng-model="freq_minutes"> minutes </div> + + </div> + + <div ng-show="items.unit == '%'"> + + <label for="minor_%">Minor notification at {{minor_limit_percent}}% of charge</label> + <input type="range" min="0" max="99" id="minor_%" + ng-model="minor_limit_percent"> + + <label for="major_%">Major notification at {{major_limit_percent}}% of charge</label> + <input type="range" min="{{minor_limit_percent}}" max="100" id="major_%" + ng-model="major_limit_percent"> + </div> - <div class="row" ng-show="show_form('password')"> - <div class="col-xs-3"> - <label for="password">Password</label> - <input type="password" id="password" ng-model="password"/> + + <div ng-show="items.unit == 'bool'"> + + <label for="minor_bool">If down, send a </label> + <div class="radio"> + <label> + <input type="radio" id="minor_bool" value="minor" ng-model="limit_bool"> + minor notification + </label> + </div> + + <div class="radio"> + <label> + <input type="radio" id="major_bool" value="major" ng-model="limit_bool"> + major notification + </label> </div> + </div> + + <div ng-show="items.unit != '%' && items.unit != 'bool'"> + + <label for="minor_unit">Minor notif at {{minor_limit_unit}}</label> + <input type="number" class="form-control" id="minor_unit" min="0" + ng-model="minor_limit_unit"> + + <label for="maj_pack">Major notif at {{major_limit_unit}}</label> + <input type="number" class="form-control" id="maj_pack" min="0" + ng-model="major_limit_unit"> + + </div> + </div> - <div class="modal-footer"> - <button type="button" class="btn btn-default" data-dismiss="modal" ng-click="cancel()">Close</button> - <button type="button" class="btn btn-primary" ng-click="ok()">Save changes</button> - </div> - </script> + </form> + </div> + + <div class="modal-footer"> + + <button type="button" class="btn btn-default" data-dismiss="modal" + ng-click="cancel()">Close</button> - <script type="text/ng-template" id="modal_block_label.html"> - <div class="modal-header"> - <h3 class="modal-title">Activate/Deactivate monitoring blocks</h3> + <button type="button" class="btn btn-primary" ng-click="ok()">Save changes</button> + + </div> + </script> + + <script type="text/ng-template" id="modal_interv_label.html"> + <div class="modal-header"> + <h3 class="modal-title">Add an intervention</h3> + </div> + + <div class="modal-body"> + <form> + <div class="form-group"> + + <label for="username">User</label> + <input type="text" class="form-control" id="username" ng-model="user"> {{user}} + + <label for="date">Date (YYYY-MM-DD HH:MM)</label> + <input type="datetime" class="form-control" id="date" ng-model="date"> + + <label for="interv_detail">Details of this intervention</label> + <textarea class="form-control" rows="3" id="interv_detail" ng-model="details"></textarea> </div> - <div class="modal-body"> + </form> + </div> + + <div class="modal-footer"> + <button type="button" class="btn btn-default" data-dismiss="modal" ng-click="cancel()">Close</button> + <button type="button" class="btn btn-primary" ng-click="ok()">Save changes</button> + </div> + </script> + + <script type="text/ng-template" id="modal_conn_label.html"> + <div class="modal-header"> + <h3 class="modal-title">Connection configuration</h3> + </div> + <div class="modal-body"> + <form> + <div class="form-group"> + <h3>Choose the priority of each avaliable connection. The highest will be used first. + Set at 0 to not use this connection.</h3> <table class="table table-bordered table-hover"> - <tr ng-repeat-start="(blockname, block) in blocks"> - <th>{{blockname}}</th> - <th><button type="button" class="btn" ng-click="select_all(block)">Select all</button> - <button type="button" class="btn" ng-click="select_none(block)">Select none</button> - </th> - <th>Compatible Connections</th> - <th>Compatible OS</th> + <thead> + <tr> + <th>Protocol </th> + <th>Priority </th> + <th>Options </th> </tr> - <tr ng-repeat-end - ng-repeat="mod in block"> - <td>{{mod.modname}}</td> - <td><input type="checkbox" - ng-model="mod.activated" - ng-disabled="is_not_compatible(mod.modname)"></td> - <td>{{block_args.loaded_moni_mod[mod.modname].compatible_conn}}</td> - <td>{{block_args.loaded_moni_mod[mod.modname].compatible_os}}</td> + </thead> + <tbody> + <tr ng-repeat="(modname, modconf) in current_config"> + <td>{{modname}}</td> + <td><input type="number" min="0" ng-model="priorities[modname]" + ng-disabled="isNotConfigured(modname)"></td> + <td> + <button type="button" class="btn btn-primary" + ng-click="open_modal_conf_conn(modname)">Advanced configuration</button> + <button type="button" class="btn btn-success" + ng-click="testConn(modname)">Test</button> + </td> + </tr> + </tbody> </table> </div> - <div class="modal-footer"> - <button type="button" class="btn btn-default" data-dismiss="modal" - ng-click="cancel()">Close</button> - <button type="button" class="btn btn-primary" - ng-click="ok()">Save changes</button> + </form> + </div> + <div class="modal-footer"> + <button type="button" class="btn btn-default" data-dismiss="modal" ng-click="cancel()">Close</button> + <button type="button" class="btn btn-primary" ng-click="ok()">Save changes</button> + </div> + </script> + + + + <script type="text/ng-template" id="modal_conf_conn_label.html"> + <div class="modal-header"> + <h3 class="modal-title">Advanced settings for {{conf_conn_args['modname']}}</h3> + </div> + + <div class="modal-body"> + <!--<input type="file" nv-file-select uploader="uploader"/><br/> + <ul> + <li ng-repeat="item in uploader.queue"> + Upload a new key: <span ng-bind="item.file.name"></span><br/> + <button ng-click="item.upload(item, '\keys')">upload</button> + </li> + </ul>--> + <div class="row" ng-show="show_form('private_key')"> + <div class="col-xs-3"> + <label for="private_key">Select a private key</label> + <select class="form-control input-sm" id="private_key" + ng-model="private_key" + ng-options="key as key for key in keys_list"></select> </div> - </script> + </div> - <script type="text/ng-template" id="modal_confirm_delete_label.html"> - <div class="modal-header"> - <h3 class="modal-title">Are you sure you want to delete {{confirm_delete_args.addr_host}} ?</h3> + <div class="row" ng-show="show_form('private_key')"> + <div class="col-xs-3"> + <form action="/upload" method="post" enctype="multipart/form-data"> + <label for="upload_key">Or upload a new key couple:</label> + <input type="file" id="upload_key" name="upload" /> + <input type="submit" value="Start upload" /> + </form> </div> - <div class="modal-body"> - <p>This action will be permanent.</p> + </div> + + <div class="row" ng-show="show_form('port')"> + <div class="col-xs-2"> + <label for="port">Port used</label> + <input type="number" id="port" min="0" ng-model="port"> </div> - <div class="modal-footer"> - <button type="button" class="btn btn-default" data-dismiss="modal" - ng-click="cancel()">Close</button> - <button type="button" class="btn btn-danger" - ng-click="ok()">Delete this host</button> + </div> + + <div class="row" ng-show="show_form('username')"> + <div class="col-xs-3"> + <label for="usrname">Login</label> + <input type="text" id="usrname" ng-model="username"/> </div> - </script> + </div> - <script type="text/ng-template" id="modal_port_config.html"> - <div class="modal-header"> - <h3 class="modal-title">Add or delete the ports detected</h3> + <div class="row" ng-show="show_form('password')"> + <div class="col-xs-3"> + <label for="password">Password</label> + <input type="password" id="password" ng-model="password"/> </div> - <div class="modal-body"> - <table class="table table-condensed table-hover"> - <thead> + </div> + </div> - <tr> - <th>Portname </th> - <th>Portid </th> - </tr> - </thead> + <div class="modal-footer"> + <button type="button" class="btn btn-default" data-dismiss="modal" ng-click="cancel()">Close</button> + <button type="button" class="btn btn-primary" ng-click="ok()">Save changes</button> + </div> + </script> - <tbody> - <tr ng-repeat="port_dict in port_config_args.port_list"> - <td>{{port_dict.portname}}</td> - <td>{{port_dict.portid}}</td> - <td> - <button type="button" - class="btn btn-danger" - aria-label="Remove port" - ng-click="remove_port(port_dict)"> - <span class="glyphicon glyphicon-minus" aria-hidden="true"></span> - </button> - </td> - </tr> - </tbody> - </table> - <div class="row"> - <div class="col-xs-3"> - <label for="new_portname">Port name</label> - <input type="text" class="form-control" id="new_portname" - ng-model="new_portname"> - </div> - <div class="col-xs-3"> - <label for="new_portid">Port number</label> - <input type="number" min="0" max="65535" class="form-control" id="new_portid" - ng-model="new_portid"> - </div> - <div class="col-xs-3"> - <label for="add_port_btn">Add a new port</label> - <button type="button" - class="btn btn-success" - aria-label="Add port" - id="add_port_btn" - ng-click="add_port()" - ng-disabled="new_portname == null || new_portid == null"> - <span class="glyphicon glyphicon-plus" aria-hidden="true"></span> - </button> - </div> - </div> + <script type="text/ng-template" id="modal_block_label.html"> + <div class="modal-header"> + <h3 class="modal-title">Activate/Deactivate monitoring blocks</h3> + </div> + + <div class="modal-body"> + <table class="table table-bordered table-hover"> + <tr ng-repeat-start="(blockname, block) in blocks"> + <th>{{blockname}}</th> + <th><button type="button" class="btn" ng-click="select_all(block)">Select all</button> + <button type="button" class="btn" ng-click="select_none(block)">Select none</button> + </th> + <th>Compatible Connections</th> + <th>Compatible OS</th> + </tr> + <tr ng-repeat-end + ng-repeat="mod in block"> + <td>{{mod.modname}}</td> + <td><input type="checkbox" + ng-model="mod.activated" + ng-disabled="is_not_compatible(mod.modname)"></td> + <td>{{block_args.loaded_moni_mod[mod.modname].compatible_conn}}</td> + <td>{{block_args.loaded_moni_mod[mod.modname].compatible_os}}</td> + </tr> + </table> + </div> + + <div class="modal-footer"> + <button type="button" class="btn btn-default" data-dismiss="modal" + ng-click="cancel()">Close</button> + <button type="button" class="btn btn-primary" + ng-click="ok()">Save changes</button> + </div> + </script> + + <script type="text/ng-template" id="modal_confirm_delete_label.html"> + <div class="modal-header"> + <h3 class="modal-title">Are you sure you want to delete {{confirm_delete_args.addr_host}} ?</h3> + </div> + + <div class="modal-body"> + <p>This action will be permanent.</p> + </div> + + <div class="modal-footer"> + <button type="button" class="btn btn-default" data-dismiss="modal" + ng-click="cancel()">Close</button> + <button type="button" class="btn btn-danger" + ng-click="ok()">Delete this host</button> + </div> + </script> + + <script type="text/ng-template" id="modal_port_config.html"> + <div class="modal-header"> + <h3 class="modal-title">Add or delete the ports detected</h3> + </div> + <div class="modal-body"> + <table class="table table-condensed table-hover"> + <thead> + + <tr> + <th>Portname </th> + <th>Portid </th> + </tr> + </thead> + + <tbody> + <tr ng-repeat="port_dict in port_config_args.port_list"> + <td>{{port_dict.portname}}</td> + <td>{{port_dict.portid}}</td> + <td> + <button type="button" + class="btn btn-danger" + aria-label="Remove port" + ng-click="remove_port(port_dict)"> + <span class="glyphicon glyphicon-minus" aria-hidden="true"></span> + </button> + </td> + </tr> + </tbody> + </table> + + <div class="row"> + <div class="col-xs-3"> + <label for="new_portname">Port name</label> + <input type="text" class="form-control" id="new_portname" + ng-model="new_portname"> </div> - <div class="modal-footer"> - <button type="button" class="btn btn-default" data-dismiss="modal" - ng-click="cancel()">Discard</button> - <button type="button" class="btn btn-primary" - ng-click="ok()">Save changes</button> + + <div class="col-xs-3"> + <label for="new_portid">Port number</label> + <input type="number" min="0" max="65535" class="form-control" id="new_portid" + ng-model="new_portid"> </div> - </script> - </div> \ No newline at end of file + + <div class="col-xs-3"> + <label for="add_port_btn">Add a new port</label> + <button type="button" + class="btn btn-success" + aria-label="Add port" + id="add_port_btn" + ng-click="add_port()" + ng-disabled="new_portname == null || new_portid == null"> + <span class="glyphicon glyphicon-plus" aria-hidden="true"></span> + </button> + </div> + </div> + </div> + + <div class="modal-footer"> + <button type="button" class="btn btn-default" data-dismiss="modal" + ng-click="cancel()">Discard</button> + <button type="button" class="btn btn-primary" + ng-click="ok()">Save changes</button> + </div> + + </script> + +</div> \ No newline at end of file diff --git a/views/notifications.html b/views/notifications.html index 4a21ff2..fbdddcb 100644 --- a/views/notifications.html +++ b/views/notifications.html @@ -1,144 +1,143 @@ +<div class="col-md-offset-2 main"> + <h1 class="page-header">Who to notify? <small>{{subtitle}}</small></h1> + <h3 ng-repeat-start="(username, user) in all_subscriptions">{{username}}</h3> + <dl ng-repeat-end + ng-repeat-start="(addr_host, host) in user.hosts"> + <dt>{{addr_host}}</dt> + <dd ng-show="is_activated(host.major)">Major: {{get_activated(host.major)}}</dd> + <dd ng-show="is_activated(host.minor)">Minor: {{get_activated(host.minor)}}</dd> + </dl> + <dl ng-repeat-end + ng-repeat="(grp_name, grp) in user.groups"> + <dt>{{grp_name}}</dt> + <dd ng-show="is_activated(grp.major)">Major: {{get_activated(grp.major)}}</dd> + <dd ng-show="is_activated(grp.minor)">Minor: {{get_activated(grp.minor)}}</dd> + </dl> + <!--<table class="table table-hover" ng-repeat="(username, user) in all_subscriptions"> - <div class="col-md-offset-2 main"> - <h1 class="page-header">Who to notify? <small>{{subtitle}}</small></h1> - <h3 ng-repeat-start="(username, user) in all_subscriptions">{{username}}</h3> - <dl ng-repeat-end - ng-repeat-start="(addr_host, host) in user.hosts"> - <dt>{{addr_host}}</dt> - <dd ng-show="is_activated(host.major)">Major: {{get_activated(host.major)}}</dd> - <dd ng-show="is_activated(host.minor)">Minor: {{get_activated(host.minor)}}</dd> - </dl> - <dl ng-repeat-end - ng-repeat="(grp_name, grp) in user.groups"> - <dt>{{grp_name}}</dt> - <dd ng-show="is_activated(grp.major)">Major: {{get_activated(grp.major)}}</dd> - <dd ng-show="is_activated(grp.minor)">Minor: {{get_activated(grp.minor)}}</dd> - </dl> - <!--<table class="table table-hover" ng-repeat="(username, user) in all_subscriptions"> - - <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 all_subscriptions.user.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> - {{notif_mod.gzkf}} - {{notif_mod.priority}} - </td> - <td> - {{user_subscriptions.hosts[addr_host].major[notif_mod_name].priority}} - </td> - </tr> - </tbody> - </table>--> - <form> - <div class="row"> - <div class="col-lg-6"> - <div class="input-group"> - <span class="input-group-addon"> - <input type="radio" ng-model="option_selected" value="grp" - ng-change="selected_host=''"> - </span> - <label for="grp_choice">Select one group :</label> - <select class="form-control input-sm" id="grp_choice" - ng-model="selected_grp" - ng-options="item for item in allGroups() | unique:'group'" - ng-disabled="option_selected!='grp'" - ng-change="get_group_subscribers()"></select> - </div> - </div> - <div class="col-lg-6"> - <div class="input-group"> - <span class="input-group-addon"> - <input type="radio" ng-model="option_selected" value="host" - ng-change="selected_grp=''"> - </span> - <label for="host_choice">or one host :</label> - <select class="form-control input-sm" id="host_choice" - ng-model="selected_host" - ng-options="host.addr group by host.group for host in items" - ng-disabled="option_selected!='host'" - ng-change="get_host_subscribers()"></select> - </div> - </div> + <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 all_subscriptions.user.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> + {{notif_mod.gzkf}} + {{notif_mod.priority}} + </td> + <td> + {{user_subscriptions.hosts[addr_host].major[notif_mod_name].priority}} + </td> + </tr> + </tbody> + </table>--> + <form> + <div class="row"> + <div class="col-lg-6"> + <div class="input-group"> + <span class="input-group-addon"> + <input type="radio" ng-model="option_selected" value="grp" + ng-change="selected_host=''"> + </span> + <label for="grp_choice">Select one group :</label> + <select class="form-control input-sm" id="grp_choice" + ng-model="selected_grp" + ng-options="item for item in allGroups() | unique:'group'" + ng-disabled="option_selected!='grp'" + ng-change="get_group_subscribers()"></select> + </div> + </div> + <div class="col-lg-6"> + <div class="input-group"> + <span class="input-group-addon"> + <input type="radio" ng-model="option_selected" value="host" + ng-change="selected_grp=''"> + </span> + <label for="host_choice">or one host :</label> + <select class="form-control input-sm" id="host_choice" + ng-model="selected_host" + ng-options="host.addr group by host.group for host in items" + ng-disabled="option_selected!='host'" + ng-change="get_host_subscribers()"></select> </div> - </form> - <div ng-show="selected_host!='' || selected_grp!=''"> - <p>Check the box if you want the user to be notified by the correspondent service.</p> - <p>The value represents the numbers of notifications that should occure since the last login of the user.</p> - <p>The notification will be sent to the user, by this service, once this value is reached.</p> - <table class="table table-bordered"> - <thead> - <tr> - <th>User - <button type="button" class="btn btn-primary btn-xs" - ng-click="open_modal_add_subscriber()">Add... - </button> - </th> - <th>Notification service </th> - <th>Minor notifications</th> - <th>Major notifications</th> - </tr> - </thead> - <tbody> - <tr ng-repeat-start="(username, user) in subscriber_data"> - <td>{{username}}<br/> - <button type="button" class="btn btn-danger btn-xs" - ng-click="unsubscribe(username)">Unsubscribe - </button> - </td> - </tr> - <tr ng-repeat-end - ng-repeat="(mod_name, mod_param) in user.minor"> - <td></td> - <td>{{mod_name}}</td> - <td> - <div class="input-group"> - <span class="input-group-addon"> - <input type="checkbox" ng-model="mod_param.activated"> - </span> - <input type="number" min="1" class="form-control" ng-model="mod_param.priority"> - </div> - </td> - <td> - <div class="input-group"> - <span class="input-group-addon"> - <input type="checkbox" ng-model="subscriber_data[username].major[mod_name].activated"> - </span> - <input type="number" min="1" class="form-control" ng-model="subscriber_data[username].major[mod_name].priority"> - </div> - </td> - </tr> - </tbody> - </table> - <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> + </form> + <div ng-show="selected_host!='' || selected_grp!=''"> + <p>Check the box if you want the user to be notified by the correspondent service.</p> + <p>The value represents the numbers of notifications that should occure since the last login of the user.</p> + <p>The notification will be sent to the user, by this service, once this value is reached.</p> + <table class="table table-bordered"> + <thead> + <tr> + <th>User + <button type="button" class="btn btn-primary btn-xs" + ng-click="open_modal_add_subscriber()">Add... + </button> + </th> + <th>Notification service </th> + <th>Minor notifications</th> + <th>Major notifications</th> + </tr> + </thead> + <tbody> + <tr ng-repeat-start="(username, user) in subscriber_data"> + <td>{{username}}<br/> + <button type="button" class="btn btn-danger btn-xs" + ng-click="unsubscribe(username)">Unsubscribe + </button> + </td> + </tr> + <tr ng-repeat-end + ng-repeat="(mod_name, mod_param) in user.minor"> + <td></td> + <td>{{mod_name}}</td> + <td> + <div class="input-group"> + <span class="input-group-addon"> + <input type="checkbox" ng-model="mod_param.activated"> + </span> + <input type="number" min="1" class="form-control" ng-model="mod_param.priority"> + </div> + </td> + <td> + <div class="input-group"> + <span class="input-group-addon"> + <input type="checkbox" ng-model="subscriber_data[username].major[mod_name].activated"> + </span> + <input type="number" min="1" class="form-control" ng-model="subscriber_data[username].major[mod_name].priority"> + </div> + </td> + </tr> + </tbody> + </table> + <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> - <script type="text/ng-template" id="modal_add_subscriber_label.html"> - <div class="modal-header"> - <h3 class="modal-title">{{modal_title}}</h3> - </div> - <div class="modal-body"> - <select multiple class="form-control" - ng-model="selected_users" - ng-options="user as user for user in users"> - </select> - </div> - <div class="modal-footer"> - <button type="button" class="btn btn-default" data-dismiss="modal" ng-click="cancel()">Close</button> - <button type="button" class="btn btn-primary" ng-click="ok()" ng-disabled="selected_users.length==0">Add selected</button> - </div> - </script> \ No newline at end of file +<script type="text/ng-template" id="modal_add_subscriber_label.html"> + <div class="modal-header"> + <h3 class="modal-title">{{modal_title}}</h3> + </div> + <div class="modal-body"> + <select multiple class="form-control" + ng-model="selected_users" + ng-options="user as user for user in users"> + </select> + </div> + <div class="modal-footer"> + <button type="button" class="btn btn-default" data-dismiss="modal" ng-click="cancel()">Close</button> + <button type="button" class="btn btn-primary" ng-click="ok()" ng-disabled="selected_users.length==0">Add selected</button> + </div> +</script> \ No newline at end of file diff --git a/views/profile.html b/views/profile.html index bccf9c6..2c4137a 100644 --- a/views/profile.html +++ b/views/profile.html @@ -1,145 +1,144 @@ +<div class="col-md-offset-2 main"> + <h1 class="page-header">Your account</h1> + <select class="form-control input-sm" id="usrlist" + ng-model="selected_user" + 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> - <div class="col-md-offset-2 main"> - <h1 class="page-header">Your account</h1> - <select class="form-control input-sm" id="usrlist" - ng-model="selected_user" - 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 ng-show="selected_user!=''"> + <div class="row"> + <div class="col-xs-3"> + <label for="username">Username</label> + <input type="text" class="form-control" id="username" + disabled + ng-model="selected_user"> + </div> + <div class="row"></div> + <div class="col-xs-3"> + <label for="pswd">Change password</label> + <input type="password" class="form-control" id="pswd" disabled> + </div> + <div class="col-xs-3"> + <label for="pswd2">Repeat new password</label> + <input type="password" class="form-control" id="pswd2" disabled> + </div> + <div class="row"></div> + <div class="col-xs-4"> + <label for="mail">Email address</label> + <input type="email" class="form-control" id="mail" ng-model="email"> + </div> + <div class="row"></div> + <div class="col-xs-8"> + <label for="cellphone">SMS URL (put #message# on the message parameter)</label> + <input type="text" class="form-control" id="cellphone" ng-model="sms_url"> + </div> + </div> - <!--<h2 class="sub-header">They will be applied on each new host you will add.</h2>--> - <form ng-show="selected_user!=''"> - <div class="row"> - <div class="col-xs-3"> - <label for="username">Username</label> - <input type="text" class="form-control" id="username" - disabled - ng-model="selected_user"> - </div> - <div class="row"></div> - <div class="col-xs-3"> - <label for="pswd">Change password</label> - <input type="password" class="form-control" id="pswd" disabled> - </div> - <div class="col-xs-3"> - <label for="pswd2">Repeat new password</label> - <input type="password" class="form-control" id="pswd2" disabled> - </div> - <div class="row"></div> - <div class="col-xs-4"> - <label for="mail">Email address</label> - <input type="email" class="form-control" id="mail" ng-model="email"> - </div> - <div class="row"></div> - <div class="col-xs-8"> - <label for="cellphone">SMS URL (put #message# on the message parameter)</label> - <input type="text" class="form-control" id="cellphone" ng-model="sms_url"> - </div> - </div> + <button type="button" class="btn btn-primary" ng-click="save_settings()">Save changes</button> + <!--<h3>Preferences</h3> - <button type="button" class="btn btn-primary" ng-click="save_settings()">Save changes</button> - <!--<h3>Preferences</h3> + <div class="checkbox"> + <label for="minornotif">Send minor notifications by :</label> + <label> + <input type="checkbox" value="" id="minornotif"> + Browser notification + </label> + <label> + <input type="checkbox" value=""> + E-mail + </label> + <label> + <input type="checkbox" value=""> + SMS + </label> + </div> - <div class="checkbox"> - <label for="minornotif">Send minor notifications by :</label> - <label> - <input type="checkbox" value="" id="minornotif"> - Browser notification - </label> - <label> - <input type="checkbox" value=""> - E-mail - </label> - <label> - <input type="checkbox" value=""> - SMS - </label> - </div> - - <div class="checkbox"> - <label for="majornotif">Send major notifications by :</label> - <label> - <input type="checkbox" value="" id="majornotif"> - Browser notification - </label> - <label> - <input type="checkbox" value=""> - E-mail - </label> - <label> - <input type="checkbox" value=""> - SMS - </label> - </div> + <div class="checkbox"> + <label for="majornotif">Send major notifications by :</label> + <label> + <input type="checkbox" value="" id="majornotif"> + Browser notification + </label> + <label> + <input type="checkbox" value=""> + E-mail + </label> + <label> + <input type="checkbox" value=""> + SMS + </label> + </div> --> - </form> + </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 2 logins</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> - </div> \ No newline at end of file + <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 2 logins</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> +</div> \ No newline at end of file diff --git a/views/scan.html b/views/scan.html index b47c2ec..6beb234 100644 --- a/views/scan.html +++ b/views/scan.html @@ -1,30 +1,29 @@ +<div class="col-md-offset-2 main"> + <h1 class="page-header">Scan for new machines</h1> + <div ng-show="!validated" class="ng-hide"> + <form class="form-inline" ng_submit="post_val()"> + <label for="input_ip_range">Enter a hostname, a single IP or an IP range to scan (example : 198.116.0.1-10)</label> + <input type="text" class="form-control" id="input_ip_range" ng-model="ip_range"/><br/> + <button type="button" + class="btn btn-danger" + ng-click="show_opt = !show_opt">Show nmap options (careful)</button> + <input type="text" class="form-control" ng-show="show_opt" ng-model="nmap_options"/> + <button type="submit" + class="btn btn-primary" + ng-click="validated = true" + ng-disabled="ip_range == ''">Scan now</button> + <p>If you have trouble scanning with nmap on your server, you can add here a host manually, by + indicating its IP address :</p> + <input type="text" class="form-control" ng-model="ip_manual_field"/> + <button type="button" + class="btn btn-primary" + ng-click="create_empty_host()" + ng-disabled="ip_manual_field == ''">Add a host without scan</button> + </form> - <div class="col-md-offset-2 main"> - <h1 class="page-header">Scan for new machines</h1> - <div ng-show="!validated" class="ng-hide"> - <form class="form-inline" ng_submit="post_val()"> - <label for="input_ip_range">Enter a hostname, a single IP or an IP range to scan (example : 198.116.0.1-10)</label> - <input type="text" class="form-control" id="input_ip_range" ng-model="ip_range"/><br/> - <button type="button" - class="btn btn-danger" - ng-click="show_opt = !show_opt">Show nmap options (careful)</button> - <input type="text" class="form-control" ng-show="show_opt" ng-model="nmap_options"/> - <button type="submit" - class="btn btn-primary" - ng-click="validated = true" - ng-disabled="ip_range == ''">Scan now</button> - <p>If you have trouble scanning with nmap on your server, you can add here a host manually, by - indicating its IP address :</p> - <input type="text" class="form-control" ng-model="ip_manual_field"/> - <button type="button" - class="btn btn-primary" - ng-click="create_empty_host()" - ng-disabled="ip_manual_field == ''">Add a host without scan</button> - </form> - - </div> - <div ng-show="validated"> - <p>{{state}}</p> - <p>Scanned IP : {{ip_scanned}}</p> - </div> - </div> + </div> + <div ng-show="validated"> + <p>{{state}}</p> + <p>Scanned IP : {{ip_scanned}}</p> + </div> +</div> diff --git a/views/settings.html b/views/settings.html index 42cb1ec..f77c156 100644 --- a/views/settings.html +++ b/views/settings.html @@ -1,104 +1,103 @@ +<div class="col-md-offset-2 main"> + <h1 class="page-header">Configure the default settings</h1> + <p>The default parameters here will be automatically applied for each host you will add in the future.</p> + <accordion close-others="false"> + <accordion-group heading="{{block}}" ng-repeat="block in all_blocks()"> + <div class="row" ng-repeat="(modname, mod) in settings" + ng-show="mod.block == block"> + <a ng-click="open_modal_global_conf(modname)">{{modname}}</a> + </div> + </accordion-group> + </accordion> +</div> - <div class="col-md-offset-2 main"> - <h1 class="page-header">Configure the default settings</h1> - <p>The default parameters here will be automatically applied for each host you will add in the future.</p> - <accordion close-others="false"> - <accordion-group heading="{{block}}" ng-repeat="block in all_blocks()"> - <div class="row" ng-repeat="(modname, mod) in settings" - ng-show="mod.block == block"> - <a ng-click="open_modal_global_conf(modname)">{{modname}}</a> +<script type="text/ng-template" id="modal_global_conf_label.html"> + <div class="modal-header"> + <h3 class="modal-title">Configure {{global_conf_args.mod_name}}</h3> + </div> + <div class="modal-body"> + <form> + <div class="form-group"> + <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" + ng-model="arch_min"> minute </div> - </accordion-group> - </accordion> - </div> - - <script type="text/ng-template" id="modal_global_conf_label.html"> - <div class="modal-header"> - <h3 class="modal-title">Configure {{global_conf_args.mod_name}}</h3> - </div> - <div class="modal-body"> - <form> - <div class="form-group"> - <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" - ng-model="arch_min"> minute - </div> - <div class="col-xs-2"> - <input type="number" min="0" max="59" class="form-control" - ng-model="arch_hour"> hour - </div> - <div class="col-xs-2"> - <input type="number" min="0" max="23" class="form-control" - ng-model="arch_day"> day - </div> - <div class="col-xs-2"> - <input type="number" min="0" max="7" class="form-control" - ng-model="arch_week"> week - </div> - <div class="col-xs-2"> - <input type="number" min="0" max="31" class="form-control" - ng-model="arch_month"> month - </div> - <div class="col-xs-2"> - <input type="number" min="0" class="form-control" - ng-model="arch_year"> year - </div> - </div> - <label for="freq">Frequency check: each</label> - <div class="row" id="freq"> - <div class="col-xs-2"> - <input type="number" min="0" class="form-control" - ng-model="freq_days"> days - </div> - <div class="col-xs-2"> - <input type="number" min="0" max="23" class="form-control" - ng-model="freq_hours"> hours - </div> - <div class="col-xs-2"> - <input type="number" min="0" max="59" class="form-control" - ng-model="freq_minutes"> minutes - </div> - </div> - <div ng-show="global_conf_args.conf_mod.unit == '%'"> - <label for="minor_%">Minor notification at {{minor_limit_percent}}% of charge</label> - <input type="range" min="0" max="99" id="minor_%" - ng-model="minor_limit_percent"> - <label for="major_%">Major notification at {{major_limit_percent}}% of charge</label> - <input type="range" min="{{minor_limit_percent}}" max="100" id="major_%" - ng-model="major_limit_percent"> - </div> - <div ng-show="global_conf_args.conf_mod.unit == 'bool'"> - <label for="minor_bool">If down, send a </label> - <div class="radio"> - <label> - <input type="radio" id="minor_bool" value="minor" ng-model="limit_bool"> - minor notification - </label> - </div> - <div class="radio"> - <label> - <input type="radio" id="major_bool" value="major" ng-model="limit_bool"> - major notification - </label> - </div> - </div> - <div ng-show="global_conf_args.conf_mod.unit != '%' && global_conf_args.conf_mod.unit != 'bool'"> - <label for="minor_unit">Minor notif at {{minor_limit_unit}} {{global_conf_args.conf_mod.unit}}</label> - <input type="number" class="form-control" id="minor_unit" min="0" - ng-model="minor_limit_unit"> - <label for="maj_pack">Major notif at {{major_limit_unit}} {{global_conf_args.conf_mod.unit}}</label> - <input type="number" class="form-control" id="maj_pack" min="0" - ng-model="major_limit_unit"> - </div> + <div class="col-xs-2"> + <input type="number" min="0" max="59" class="form-control" + ng-model="arch_hour"> hour </div> - </form> - </div> - <div class="modal-footer"> - <button type="button" class="btn btn-default" data-dismiss="modal" - ng-click="cancel()">Close</button> - <button type="button" class="btn btn-primary" ng-click="ok()">Save changes</button> + <div class="col-xs-2"> + <input type="number" min="0" max="23" class="form-control" + ng-model="arch_day"> day + </div> + <div class="col-xs-2"> + <input type="number" min="0" max="7" class="form-control" + ng-model="arch_week"> week + </div> + <div class="col-xs-2"> + <input type="number" min="0" max="31" class="form-control" + ng-model="arch_month"> month + </div> + <div class="col-xs-2"> + <input type="number" min="0" class="form-control" + ng-model="arch_year"> year + </div> + </div> + <label for="freq">Frequency check: each</label> + <div class="row" id="freq"> + <div class="col-xs-2"> + <input type="number" min="0" class="form-control" + ng-model="freq_days"> days + </div> + <div class="col-xs-2"> + <input type="number" min="0" max="23" class="form-control" + ng-model="freq_hours"> hours + </div> + <div class="col-xs-2"> + <input type="number" min="0" max="59" class="form-control" + ng-model="freq_minutes"> minutes + </div> + </div> + <div ng-show="global_conf_args.conf_mod.unit == '%'"> + <label for="minor_%">Minor notification at {{minor_limit_percent}}% of charge</label> + <input type="range" min="0" max="99" id="minor_%" + ng-model="minor_limit_percent"> + <label for="major_%">Major notification at {{major_limit_percent}}% of charge</label> + <input type="range" min="{{minor_limit_percent}}" max="100" id="major_%" + ng-model="major_limit_percent"> + </div> + <div ng-show="global_conf_args.conf_mod.unit == 'bool'"> + <label for="minor_bool">If down, send a </label> + <div class="radio"> + <label> + <input type="radio" id="minor_bool" value="minor" ng-model="limit_bool"> + minor notification + </label> + </div> + <div class="radio"> + <label> + <input type="radio" id="major_bool" value="major" ng-model="limit_bool"> + major notification + </label> + </div> + </div> + <div ng-show="global_conf_args.conf_mod.unit != '%' && global_conf_args.conf_mod.unit != 'bool'"> + <label for="minor_unit">Minor notif at {{minor_limit_unit}} {{global_conf_args.conf_mod.unit}}</label> + <input type="number" class="form-control" id="minor_unit" min="0" + ng-model="minor_limit_unit"> + <label for="maj_pack">Major notif at {{major_limit_unit}} {{global_conf_args.conf_mod.unit}}</label> + <input type="number" class="form-control" id="maj_pack" min="0" + ng-model="major_limit_unit"> + </div> </div> + </form> + </div> + <div class="modal-footer"> + <button type="button" class="btn btn-default" data-dismiss="modal" + ng-click="cancel()">Close</button> + <button type="button" class="btn btn-primary" ng-click="ok()">Save changes</button> + </div> - </script> \ No newline at end of file +</script> \ No newline at end of file diff --git a/views/stats.html b/views/stats.html index d816bb1..f76beb8 100644 --- a/views/stats.html +++ b/views/stats.html @@ -1,58 +1,57 @@ - - <div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main"> - <h1 class="page-header">Statistics</h1> - <select ng-model="selected_host" - ng-options="host for host in host_list" - ng-change="get_stats()"> - </select> - <!-- - <div class="row"> - <div class="col-xs-2" - ng-repeat="(mod, val) in selected_mod"> - {{mod}} <input type="checkbox" ng_model="selected_mod[mod]"> - </div> - </div> - --> - <select ng-model="selected_mod" - ng-options="mod for mod in mod_list" - ng-show="selected_host != ''" - ng-change="update_subpart_list()"> - </select> - <select ng-model="selected_subpart" - ng-options="subpart for subpart in subpart_list" - ng-show="selected_mod != ''" - ng-change="update_stats()"> - </select> - <select ng-model="selected_period" - ng-show="selected_mod != ''" - ng-change="refresh_chart_data()"> - <option value="min">By minute</option> - <option value="hour">By hour</option> - <option value="day">By day</option> - <option value="week">By week</option> - <option value="month">By month</option> - <option value="year">By year</option> - </select> - <div class="row" - ng-show="selected_mod != ''"> - <div class="col-xs-2" - ng-show="!value_is_NaN(mean_value)"> - Mean value : {{mean_value}} - </div> - <div class="col-xs-2" - ng-show="!value_is_NaN(standard_derivation)"> - Standard derivation : {{standard_derivation}} - </div> - <div class="col-xs-2" - ng-show="!value_is_NaN(slope_lr)"> - Slope of linear regression : {{slope_lr}} - </div> - </div> - <div - ng-show="selected_period != ''" - data-ac-chart="'line'" - data-ac-data="data" - data-ac-config="config" - class="chart"> - </div> +<div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main"> + <h1 class="page-header">Statistics</h1> + <select ng-model="selected_host" + ng-options="host for host in host_list" + ng-change="get_stats()"> + </select> + <!-- + <div class="row"> + <div class="col-xs-2" + ng-repeat="(mod, val) in selected_mod"> + {{mod}} <input type="checkbox" ng_model="selected_mod[mod]"> </div> + </div> + --> + <select ng-model="selected_mod" + ng-options="mod for mod in mod_list" + ng-show="selected_host != ''" + ng-change="update_subpart_list()"> + </select> + <select ng-model="selected_subpart" + ng-options="subpart for subpart in subpart_list" + ng-show="selected_mod != ''" + ng-change="update_stats()"> + </select> + <select ng-model="selected_period" + ng-show="selected_mod != ''" + ng-change="refresh_chart_data()"> + <option value="min">By minute</option> + <option value="hour">By hour</option> + <option value="day">By day</option> + <option value="week">By week</option> + <option value="month">By month</option> + <option value="year">By year</option> + </select> + <div class="row" + ng-show="selected_mod != ''"> + <div class="col-xs-2" + ng-show="!value_is_NaN(mean_value)"> + Mean value : {{mean_value}} + </div> + <div class="col-xs-2" + ng-show="!value_is_NaN(standard_derivation)"> + Standard derivation : {{standard_derivation}} + </div> + <div class="col-xs-2" + ng-show="!value_is_NaN(slope_lr)"> + Slope of linear regression : {{slope_lr}} + </div> + </div> + <div + ng-show="selected_period != ''" + data-ac-chart="'line'" + data-ac-data="data" + data-ac-config="config" + class="chart"> + </div> +</div> \ No newline at end of file diff --git a/views/users.html b/views/users.html index 60a8d7b..aeb348c 100644 --- a/views/users.html +++ b/views/users.html @@ -1,81 +1,80 @@ - - <div class="col-md-offset-2 main"> - <h1 class="page-header">Users <small>{{selected_user}}</small></h1> - <div class="row"> - <div class="col-xs-4"> - <label for="usrlist">Registered users</label> - <select class="form-control input-sm" id="usrlist" - ng-model="selected_user" - ng-options="user as user for user in users" - ng-change="get_user_subscriptions()"></select> - </div> - </div> - <button type="button" class="btn btn-primary" data-toggle="popover" - data-placement="bottom" title="Add user..." data-content="ger" - ng-click="show_new_user=!show_new_user">Add user</button> - <input type="text" ng-show="show_new_user" ng-model="new_username"> - <button type="button" class="btn btn-primary" - ng-show="show_new_user && new_username!=''" - ng-click="addUser()">Create user - </button> - <button type="button" class="btn btn-danger" - ng-show="selected_user!='' && selected_user!=null" - ng-click="removeUser()">Remove {{selected_user}} - </button> - - <div ng-show="selected_user!=''"> - <p>Subscriptions summary:</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="col-md-offset-2 main"> + <h1 class="page-header">Users <small>{{selected_user}}</small></h1> + <div class="row"> + <div class="col-xs-4"> + <label for="usrlist">Registered users</label> + <select class="form-control input-sm" id="usrlist" + ng-model="selected_user" + ng-options="user as user for user in users" + ng-change="get_user_subscriptions()"></select> </div> + </div> + <button type="button" class="btn btn-primary" data-toggle="popover" + data-placement="bottom" title="Add user..." data-content="ger" + ng-click="show_new_user=!show_new_user">Add user</button> + <input type="text" ng-show="show_new_user" ng-model="new_username"> + <button type="button" class="btn btn-primary" + ng-show="show_new_user && new_username!=''" + ng-click="addUser()">Create user + </button> + <button type="button" class="btn btn-danger" + ng-show="selected_user!='' && selected_user!=null" + ng-click="removeUser()">Remove {{selected_user}} + </button> + + <div ng-show="selected_user!=''"> + <p>Subscriptions summary:</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> \ 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 f5637be14655522df9b84671f345586779cd0242 Author: Alexis Guilbaud <guilbaud@codelutin.com> Date: Wed May 13 15:27:26 2015 +0200 statistics by module on hostpage --- static/js/controllers/hostPageCtrl.js | 154 ++++++++++++++++++++++++++++++++++ static/js/controllers/statsCtrl.js | 53 ++++++++---- views/hostpage.html | 50 +++++++++++ 3 files changed, 241 insertions(+), 16 deletions(-) diff --git a/static/js/controllers/hostPageCtrl.js b/static/js/controllers/hostPageCtrl.js index 14ee7f4..294faea 100644 --- a/static/js/controllers/hostPageCtrl.js +++ b/static/js/controllers/hostPageCtrl.js @@ -271,6 +271,21 @@ mumApp.controller('hostPageCtrl', function ($scope, $rootScope, $route, $routePa } }); }; + + $scope.open_modal_stats = function (addr_host, modname, subpart) { + var modalInstance = $modal.open({ + templateUrl: 'modal_stats.html', + controller: 'ModalStatsCtrl', + size: 'lg', + resolve: { + stats_args: function () { + return {'addr_host' : addr_host, + 'mod': modname, + 'subpart': subpart}; + } + } + }); + }; }); // modals controllers @@ -733,4 +748,143 @@ mumApp.controller('ModalPortConfigInstanceCtrl', function ($scope, $rootScope, $ $modalInstance.close(); $route.reload(); }; +}); + +mumApp.controller('ModalStatsCtrl', function ($scope, $rootScope, $modalInstance, $route, $timeout, stats_args) { + $scope.selected_host = stats_args.addr_host; + $scope.selected_mod = stats_args.mod; + $scope.selected_subpart = stats_args.subpart; + $scope.selected_period = 'min'; + + //data + $scope.stats = {}; + $scope.archive = {}; + + //calculated statistics + $scope.mean_value = 0; + $scope.standard_derivation = 0; + $scope.slope_lr = 0; + + $scope.get_stats = function() { + if ($scope.selected_host != null && $scope.selected_host != '') { + var args = {}; + args['addr_host'] = $scope.selected_host; + $rootScope.$broadcast("sendViaWs", JSON.stringify({"CALL_FUNC_DB": {'func': 'get_stats', 'args': args}})); + } + }; + + $scope.get_stats(); + + $scope.$on("resCall", function (event, args) { + if (args.func == 'get_stats') { + $timeout(function () { + $scope.stats = args.res.stats; + $scope.archive = args.res.archive; + $scope.update_stats(); + $scope.refresh_chart_data(); + }, 0); + } + }); + + $scope.update_stats = function() { + update_mean(); + update_standard_derivation(); + update_slope_of_linear_regression(); + }; + + $scope.refresh_chart_data = function() { + $scope.config.title = $scope.selected_host; + $scope.data.data = []; + var archive_list = $scope.archive[$scope.selected_mod][$scope.selected_period]; + // need to test if this achive have a subpart (= if its value is an object) + var first_entry = archive_list[0]; + if (typeof(first_entry.value) == "object") { + // if this archive have subparts + // will get the archives for the selected subpart + $scope.data.series = [$scope.selected_mod + ' on ' + $scope.selected_subpart]; + for (var i = 0; i<archive_list.length; i++) { + var current_arch = archive_list[i]; + if (current_arch.value.hasOwnProperty($scope.selected_subpart)) { + $scope.data.data.push({'x': i, + 'y': [current_arch.value[$scope.selected_subpart]], + 'tooltip': current_arch.value[$scope.selected_subpart] + " @ " + + current_arch.date.split('.')[0] + } + ) + } + } + } + else { + // there is no subpart + $scope.data.series = [$scope.selected_mod]; + var archive_list = $scope.archive[$scope.selected_mod][$scope.selected_period] + for (var i = 0; i < archive_list.length; i++) { + var current_arch = archive_list[i]; + $scope.data.data.push({'x': i, + 'y': [current_arch.value], + 'tooltip': current_arch.value + " @ " + + current_arch.date.split('.')[0] + } + ) + } + } + }; + + $scope.value_is_NaN = function (value) { + return value !== value; + }; + + var update_mean = function () { + var total = $scope.stats[$scope.selected_mod][$scope.selected_subpart].total; + var nb_check = $scope.stats[$scope.selected_mod][$scope.selected_subpart].nb_check; + + $scope.mean_value = total / nb_check; + }; + + var update_standard_derivation = function () { + var m2 = $scope.stats[$scope.selected_mod][$scope.selected_subpart].M2; + var nb_check = $scope.stats[$scope.selected_mod][$scope.selected_subpart].nb_check; + var variance = m2 / Math.max(1, nb_check + 1); + + $scope.standard_derivation = Math.sqrt(variance); + }; + + var update_slope_of_linear_regression = function () { + var nb_check = $scope.stats[$scope.selected_mod][$scope.selected_subpart].nb_check; + var total = $scope.stats[$scope.selected_mod][$scope.selected_subpart].total; + var lin_reg = $scope.stats[$scope.selected_mod][$scope.selected_subpart].lin_reg; + + var mX = (nb_check + 1) / 2; + var mY = total / nb_check; + var mX2 = (nb_check + 1) * (2 * nb_check + 1) / 6; + var mXY = lin_reg / nb_check; + + $scope.slope_lr = (mXY - mX * mY) / (mX2 - mX * mX); + }; + + // angular_charts fields : + $scope.config = { + title: '', + tooltips: true, + labels: false, + mouseover: function () {}, + mouseout: function () {}, + click: function () {}, + legend: { + display: true, + //could be 'left, right' + position: 'right' + }, + waitForHeightAndWidth: true + }; + + $scope.data = { + series: [], + data: [] + }; + + $scope.close = function () { + $modalInstance.close(); + $route.reload(); + }; }); \ No newline at end of file diff --git a/static/js/controllers/statsCtrl.js b/static/js/controllers/statsCtrl.js index 10c49a1..fedad18 100644 --- a/static/js/controllers/statsCtrl.js +++ b/static/js/controllers/statsCtrl.js @@ -61,26 +61,35 @@ mumApp.controller('statsCtrl', function ($scope, $rootScope, $timeout, DataHosts $scope.refresh_chart_data = function() { $scope.config.title = $scope.selected_host; $scope.data.data = []; - if (typeof($scope.archive[$scope.selected_mod][$scope.selected_period][0].value) == "object") { + var archive_list = $scope.archive[$scope.selected_mod][$scope.selected_period]; + // need to test if this achive have a subpart (= if its value is an object) + var first_entry = archive_list[0]; + if (typeof(first_entry.value) == "object") { + // if this archive have subparts + // will get the archives for the selected subpart $scope.data.series = [$scope.selected_mod + ' on ' + $scope.selected_subpart]; - for (var i = 0; i<$scope.archive[$scope.selected_mod][$scope.selected_period].length; i++) { - if ($scope.archive[$scope.selected_mod][$scope.selected_period][i].value.hasOwnProperty($scope.selected_subpart)) { + for (var i = 0; i<archive_list.length; i++) { + var current_arch = archive_list[i]; + if (current_arch.value.hasOwnProperty($scope.selected_subpart)) { $scope.data.data.push({'x': i, - 'y': [$scope.archive[$scope.selected_mod][$scope.selected_period][i].value[$scope.selected_subpart]], - 'tooltip': $scope.archive[$scope.selected_mod][$scope.selected_period][i].value[$scope.selected_subpart] + " @ " + - $scope.archive[$scope.selected_mod][$scope.selected_period][i].date.split('.')[0] + 'y': [current_arch.value[$scope.selected_subpart]], + 'tooltip': current_arch.value[$scope.selected_subpart] + " @ " + + current_arch.date.split('.')[0] } ) } } } else { + // there is no subpart $scope.data.series = [$scope.selected_mod]; - for (var i = 0; i<$scope.archive[$scope.selected_mod][$scope.selected_period].length; i++) { + var archive_list = $scope.archive[$scope.selected_mod][$scope.selected_period] + for (var i = 0; i < archive_list.length; i++) { + var current_arch = archive_list[i]; $scope.data.data.push({'x': i, - 'y': [$scope.archive[$scope.selected_mod][$scope.selected_period][i].value], - 'tooltip': $scope.archive[$scope.selected_mod][$scope.selected_period][i].value + " @ " + - $scope.archive[$scope.selected_mod][$scope.selected_period][i].date.split('.')[0] + 'y': [current_arch.value], + 'tooltip': current_arch.value + " @ " + + current_arch.date.split('.')[0] } ) } @@ -92,22 +101,34 @@ mumApp.controller('statsCtrl', function ($scope, $rootScope, $timeout, DataHosts }; var update_mean = function () { - $scope.mean_value = $scope.stats[$scope.selected_mod][$scope.selected_subpart].total / $scope.stats[$scope.selected_mod][$scope.selected_subpart].nb_check; + var total = $scope.stats[$scope.selected_mod][$scope.selected_subpart].total; + var nb_check = $scope.stats[$scope.selected_mod][$scope.selected_subpart].nb_check; + + $scope.mean_value = total / nb_check; }; var update_standard_derivation = function () { - var variance = $scope.stats[$scope.selected_mod][$scope.selected_subpart].M2 / Math.max(1, $scope.stats[$scope.selected_mod][$scope.selected_subpart].nb_check + 1); + var m2 = $scope.stats[$scope.selected_mod][$scope.selected_subpart].M2; + var nb_check = $scope.stats[$scope.selected_mod][$scope.selected_subpart].nb_check; + var variance = m2 / Math.max(1, nb_check + 1); + $scope.standard_derivation = Math.sqrt(variance); }; var update_slope_of_linear_regression = function () { - var mX = ($scope.stats[$scope.selected_mod][$scope.selected_subpart].nb_check + 1) / 2; - var mY = $scope.stats[$scope.selected_mod][$scope.selected_subpart].total / $scope.stats[$scope.selected_mod][$scope.selected_subpart].nb_check; - var mX2 = ($scope.stats[$scope.selected_mod][$scope.selected_subpart].nb_check + 1) * (2 * $scope.stats[$scope.selected_mod][$scope.selected_subpart].nb_check + 1) / 6; - var mXY = $scope.stats[$scope.selected_mod][$scope.selected_subpart].lin_reg / $scope.stats[$scope.selected_mod][$scope.selected_subpart].nb_check; + var nb_check = $scope.stats[$scope.selected_mod][$scope.selected_subpart].nb_check; + var total = $scope.stats[$scope.selected_mod][$scope.selected_subpart].total; + var lin_reg = $scope.stats[$scope.selected_mod][$scope.selected_subpart].lin_reg; + + var mX = (nb_check + 1) / 2; + var mY = total / nb_check; + var mX2 = (nb_check + 1) * (2 * nb_check + 1) / 6; + var mXY = lin_reg / nb_check; + $scope.slope_lr = (mXY - mX * mY) / (mX2 - mX * mX); }; + // angular_charts fields : $scope.config = { title: '', tooltips: true, diff --git a/views/hostpage.html b/views/hostpage.html index c0cfc8b..91d55d5 100644 --- a/views/hostpage.html +++ b/views/hostpage.html @@ -57,6 +57,8 @@ <td>{{item.date.split('.')[0]}}</td> <td><button type="button" class="btn btn-primary btn-xs" ng-click="open_modal_conf(itemname)">Configure</button></td> + <td><button type="button" class="btn btn-primary btn-xs" + ng-click="open_modal_stats(addr_host, itemname, '')">Archives</button></td> <td><button type="button" class="btn btn-info btn-xs" ng-click="check(itemname)">Check now</button></td> </tr> @@ -65,6 +67,8 @@ collapse="collapsed[itemname]"> <td>{{valname}}</td> <td>{{val}} {{get_unit(itemname)}}</td> + <td><button type="button" class="btn btn-primary btn-xs" + ng-click="open_modal_stats(addr_host, itemname, valname)">Archives</button></td> </tr> </tbody> @@ -542,4 +546,50 @@ </script> + <script type="text/ng-template" id="modal_stats.html"> + <div class="modal-header"> + <h3 class="modal-title">Statistics for {{selected_host}} on {{selected_mod}}</h3> + </div> + <div class="modal-body"> + <select ng-model="selected_period" + ng-show="selected_mod != ''" + ng-change="refresh_chart_data()"> + <option value="min">By minute</option> + <option value="hour">By hour</option> + <option value="day">By day</option> + <option value="week">By week</option> + <option value="month">By month</option> + <option value="year">By year</option> + </select> + <div class="row" + ng-show="selected_mod != ''"> + <div class="col-xs-2" + ng-show="!value_is_NaN(mean_value)"> + Mean value : {{mean_value}} + </div> + <div class="col-xs-2" + ng-show="!value_is_NaN(standard_derivation)"> + Standard derivation : {{standard_derivation}} + </div> + <div class="col-xs-2" + ng-show="!value_is_NaN(slope_lr)"> + Slope of linear regression : {{slope_lr}} + </div> + </div> + <div + style="" + ng-show="selected_period != ''" + data-ac-chart="'line'" + data-ac-data="data" + data-ac-config="config" + class="chart"> + </div> + </div> + <div class="modal-footer"> + <button type="button" class="btn btn-default" data-dismiss="modal" + ng-click="close()">Close</button> + </div> + + </script> + </div> \ No newline at end of file -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.
participants (1)
-
chorem.org scm