branch develop updated (350dcba -> 602155e)
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 350dcba frontend : passage du javascript de bootstrap (qui nécessite JQuery) à un AngularJS bootstrap (pour les modals, accordion, etc.) hostpage : affichage de la conf d'un module new 75634f5 hostpage : modifs de la conf d'un module sauvegardées sur bdd new 5bea208 hostpage : sauvegarde des informations custom du textarea dans bdd new 602155e hostpage : ajout d'intervention possible The 3 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 602155ee469ef8a1fc2ef83429caeeefd0a10ca2 Author: Alexis Guilbaud <guilbaud@codelutin.com> Date: Thu Mar 5 11:22:55 2015 +0100 hostpage : ajout d'intervention possible commit 5bea208acea38f176b1a34d9c208604e7b12ce61 Author: Alexis Guilbaud <guilbaud@codelutin.com> Date: Thu Mar 5 10:13:53 2015 +0100 hostpage : sauvegarde des informations custom du textarea dans bdd commit 75634f507277ea1d7b13f3d8a1e7cf82e3c60ce0 Author: Alexis Guilbaud <guilbaud@codelutin.com> Date: Wed Mar 4 17:30:26 2015 +0100 hostpage : modifs de la conf d'un module sauvegardées sur bdd Summary of changes: app/modules/storage_modules/shelve_db.py | 49 ++++++++----- static/js/controllers/hostPageCtrl.js | 114 +++++++++++++++++++++++++++---- views/hostpage.html | 72 +++++++++---------- 3 files changed, 166 insertions(+), 69 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 75634f507277ea1d7b13f3d8a1e7cf82e3c60ce0 Author: Alexis Guilbaud <guilbaud@codelutin.com> Date: Wed Mar 4 17:30:26 2015 +0100 hostpage : modifs de la conf d'un module sauvegardées sur bdd --- app/modules/storage_modules/shelve_db.py | 17 ++++++++++------- static/js/controllers/hostPageCtrl.js | 22 ++++++++++++++++++++-- 2 files changed, 30 insertions(+), 9 deletions(-) diff --git a/app/modules/storage_modules/shelve_db.py b/app/modules/storage_modules/shelve_db.py index 5439e1d..9da7e16 100644 --- a/app/modules/storage_modules/shelve_db.py +++ b/app/modules/storage_modules/shelve_db.py @@ -414,22 +414,25 @@ class shelve_db: self.close_db() return json.dumps(res) - def set_conf_mod(self, addr_host, mod_name, data): + def set_conf_mod(self, args): """ Save a new configuration for a monitoring module - :param addr_host: the IP address of the host - :param mod_name: the name of the module - :param data: a structure containing the new values : + :param args: a structure containing the values : { + 'addr_host': val, + 'mod_name': val, + 'freq' : val, 'minor_limit' : val, 'major_limit' : val } """ + addr_host = args['addr_host'] + mod_name = args['mod_name'] self.open_db() try: - self.db['hosts'][addr_host]['conf']['monitoring'][mod_name]['minor_limit'] = data['minor_limit'] - self.db['hosts'][addr_host]['conf']['monitoring'][mod_name]['major_limit'] = data['major_limit'] - self.db['hosts'][addr_host]['conf']['monitoring'][mod_name]['check_frequency'] = data['freq'] + self.db['hosts'][addr_host]['conf']['monitoring'][mod_name]['minor_limit'] = args['minor_limit'] + self.db['hosts'][addr_host]['conf']['monitoring'][mod_name]['major_limit'] = args['major_limit'] + self.db['hosts'][addr_host]['conf']['monitoring'][mod_name]['check_frequency'] = args['freq'] finally: self.close_db() diff --git a/static/js/controllers/hostPageCtrl.js b/static/js/controllers/hostPageCtrl.js index bab4040..0d218b1 100644 --- a/static/js/controllers/hostPageCtrl.js +++ b/static/js/controllers/hostPageCtrl.js @@ -84,10 +84,28 @@ mumApp.controller('ModalConfInstanceCtrl', function ($scope, $rootScope, $modalI }); $scope.ok = function () { - $modalInstance.close($scope.selected.item); + args = {}; + args.addr_host = $scope.conf_args.addr_host; + args.mod_name = $scope.conf_args.mod_name; + args.freq = $scope.freq; + if($scope.items.unit == 'bool'){ + args.minor_limit = ($scope.limit_bool == 'minor'); + args.major_limit = ($scope.limit_bool == 'major'); + } + else if($scope.items.unit == '%'){ + args.minor_limit = $scope.minor_limit_percent; + args.major_limit = $scope.major_limit_percent; + } + else{ + args.minor_limit = $scope.minor_limit_unit; + args.major_limit = $scope.major_limit_unit; + } + $rootScope.$broadcast("sendViaWs", JSON.stringify({"15": {'func': 'set_conf_mod', 'args': args}})); + + $modalInstance.close(); }; $scope.cancel = function () { - $modalInstance.dismiss('cancel'); + $modalInstance.close(); }; }); \ 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 5bea208acea38f176b1a34d9c208604e7b12ce61 Author: Alexis Guilbaud <guilbaud@codelutin.com> Date: Thu Mar 5 10:13:53 2015 +0100 hostpage : sauvegarde des informations custom du textarea dans bdd --- app/modules/storage_modules/shelve_db.py | 12 +++++-- static/js/controllers/hostPageCtrl.js | 56 +++++++++++++++++++++++++------- views/hostpage.html | 15 ++++----- 3 files changed, 61 insertions(+), 22 deletions(-) diff --git a/app/modules/storage_modules/shelve_db.py b/app/modules/storage_modules/shelve_db.py index 9da7e16..069bee0 100644 --- a/app/modules/storage_modules/shelve_db.py +++ b/app/modules/storage_modules/shelve_db.py @@ -339,12 +339,18 @@ class shelve_db: finally: self.close_db() - def update_custom_informations(self, addr_host, txt): + def update_custom_informations(self, args): """ Updates the custom informations stored on the host's configuration - :param addr_host: the IP adress of the host - :param txt: the new text to put on custom informations + :param args: a structure containing the values : + { + 'addr_host': val, + 'txt': val + } """ + print args + addr_host = args['addr_host'] + txt = args['txt'] self.open_db() try: self.db["hosts"][addr_host]["conf"]["custom_info"] = txt diff --git a/static/js/controllers/hostPageCtrl.js b/static/js/controllers/hostPageCtrl.js index 0d218b1..ba62faa 100644 --- a/static/js/controllers/hostPageCtrl.js +++ b/static/js/controllers/hostPageCtrl.js @@ -1,30 +1,61 @@ mumApp.controller('hostPageCtrl', function($scope, $rootScope, $routeParams, $modal) { - $scope.host_informations = null; $scope.addr_host = $routeParams.param - $rootScope.$broadcast("sendViaWs", JSON.stringify({"13": $routeParams.param})); - $scope.items = []; + // asks for host informations + $rootScope.$broadcast("sendViaWs", JSON.stringify({"13": $routeParams.param})); - $scope.custom_infos = ''; + $scope.items = [];/* result of get_host_informations => + { + "interventions":list, + "detected": + { + modname: + { + key:val, + ... + } + } + "hostname":val, + "monitoring": + { + modname: + { + "date":val, + "state":val, + "value":val + } + }, + "custom_infos":val + } + */ + $scope.model = {custom_infos : ''}; + + $scope.watch('model.custom_infos', function(){ + console.log($scope.model.custom_infos); + }) $scope.get_addr_host = function(){ return($scope.addr_host); }; - $scope.call_func = function(func, args){ - dict_instr = {'func': func, 'args': args}; - //$rootScope.$broadcast("sendViaWs", JSON.stringify({"15": dict_instr})); - }; - + // receiving the host informations $scope.$on("hostInfos", function (event, args) { $scope.$apply(function(){ $scope.items = args; - $scope.custom_infos = args.custom_infos; + $scope.model.custom_infos = args.custom_infos; }); }); + // save custom informations + $scope.save_custom_infos = function(){ + var args = {}; + args.addr_host = $scope.addr_host; + args.txt = $scope.model.custom_infos; + $rootScope.$broadcast("sendViaWs", JSON.stringify({"15": {'func': 'update_custom_informations', 'args': args}})); + }; + // creation of modals $scope.open = function (mod_name) { var modalInstance = $modal.open({ templateUrl: 'modal_conf_label.html', @@ -53,6 +84,7 @@ mumApp.controller('ModalConfInstanceCtrl', function ($scope, $rootScope, $modalI } */ + // init fields $scope.freq = 0; $scope.minor_limit_percent = 0; @@ -63,6 +95,7 @@ mumApp.controller('ModalConfInstanceCtrl', function ($scope, $rootScope, $modalI $scope.limit_bool = 'minor'; + // when the actual conf of the module is received $scope.$on("resCall", function (event, args) { $scope.$apply(function(){ $scope.items = args; @@ -83,8 +116,9 @@ mumApp.controller('ModalConfInstanceCtrl', function ($scope, $rootScope, $modalI }); }); + // after validation $scope.ok = function () { - args = {}; + var args = {}; args.addr_host = $scope.conf_args.addr_host; args.mod_name = $scope.conf_args.mod_name; args.freq = $scope.freq; diff --git a/views/hostpage.html b/views/hostpage.html index cc97937..f44faaf 100644 --- a/views/hostpage.html +++ b/views/hostpage.html @@ -5,8 +5,7 @@ <button type="button" class="btn btn-primary btn-xs" data-toggle="modal" data-target="#modal_conn">Connection settings</button> <button type="button" class="btn btn-info btn-xs">Launch a new detection</button> <button type="button" class="btn btn-danger btn-xs" ng-click="call_func('remove_host', [addr_host])">Remove this host</button> - {{host_informations}} - <table class="table table-condensed table-hover"> + <table class="table table-condensed table-hover"> <thead> <tr> @@ -44,8 +43,8 @@ <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="custom_infos"></textarea> - <button type="button" class="btn btn-info btn-xs">Save</button> + <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"> @@ -83,21 +82,21 @@ <input type="text" class="form-control" id="freq" ng-model="freq"> <div ng-show="items.unit == '%'"> <label for="minor_%">Minor notification at {{minor_limit}}% of charge</label> - <input type="range" name="cpu_warn" min="0" max="99" id="minor_%" ng-model="minor_limit_percent"> + <input type="range" min="0" max="99" id="minor_%" ng-model="minor_limit_percent"> <label for="major_%">Major notification at {{major_limit}}% of charge</label> - <input type="range" name="cpu_danger" min="{{minor_limit}}" max="100" id="major_%" ng-model="major_limit_percent"> + <input type="range" min="{{minor_limit}}" 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" name="http_crit" id="minor_bool" value="minor" ng-model="limit_bool"> + <input type="radio" id="minor_bool" value="minor" ng-model="limit_bool"> minor notification </label> </div> <div class="radio"> <label> - <input type="radio" name="http_crit" id="major_bool" value="major" ng-model="limit_bool"> + <input type="radio" id="major_bool" value="major" ng-model="limit_bool"> major notification </label> </div> -- 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 602155ee469ef8a1fc2ef83429caeeefd0a10ca2 Author: Alexis Guilbaud <guilbaud@codelutin.com> Date: Thu Mar 5 11:22:55 2015 +0100 hostpage : ajout d'intervention possible --- app/modules/storage_modules/shelve_db.py | 20 ++++++----- static/js/controllers/hostPageCtrl.js | 38 ++++++++++++++++++++- views/hostpage.html | 57 +++++++++++++++----------------- 3 files changed, 76 insertions(+), 39 deletions(-) diff --git a/app/modules/storage_modules/shelve_db.py b/app/modules/storage_modules/shelve_db.py index 069bee0..ed7bdb5 100644 --- a/app/modules/storage_modules/shelve_db.py +++ b/app/modules/storage_modules/shelve_db.py @@ -357,18 +357,22 @@ class shelve_db: finally: self.close_db() - def add_intervention(self, addr_host, date, person, details): + def add_intervention(self, args): """ Add a new intervention, stored on the host's configuration - :param addr_host: the IP adress of the host - :param date: the intervention date - :param person: the username responsible of the intervention - :param details: a string explaining the intervetions + :param args: a structure containing the values : + { + 'addr_host': val, => the IP adress of the host + 'user' : val, => the username responsible of the intervention + 'date' : val, => the intervention's date + 'details' : val => a string explaining the intervetion + } """ + addr_host = args['addr_host'] intervention = {} - intervention['username'] = person - intervention['date'] = date - intervention['details'] = details + intervention['username'] = args['user'] + intervention['date'] = args['date'] + intervention['details'] = args['details'] self.open_db() try: self.db["hosts"][addr_host]["conf"]["interventions"].append(intervention) diff --git a/static/js/controllers/hostPageCtrl.js b/static/js/controllers/hostPageCtrl.js index ba62faa..5ad0fa2 100644 --- a/static/js/controllers/hostPageCtrl.js +++ b/static/js/controllers/hostPageCtrl.js @@ -56,7 +56,7 @@ mumApp.controller('hostPageCtrl', function($scope, $rootScope, $routeParams, $mo }; // creation of modals - $scope.open = function (mod_name) { + $scope.open_modal_conf = function (mod_name) { var modalInstance = $modal.open({ templateUrl: 'modal_conf_label.html', controller: 'ModalConfInstanceCtrl', @@ -67,6 +67,18 @@ mumApp.controller('hostPageCtrl', function($scope, $rootScope, $routeParams, $mo } }); }; + + $scope.open_modal_interv = function () { + var modalInstance = $modal.open({ + templateUrl: 'modal_interv_label.html', + controller: 'ModalIntervInstanceCtrl', + resolve: { + interv_args: function(){ + return {'addr_host' : $scope.addr_host}; + } + } + }); + }; }); // modals controllers @@ -142,4 +154,28 @@ mumApp.controller('ModalConfInstanceCtrl', function ($scope, $rootScope, $modalI $scope.cancel = function () { $modalInstance.close(); }; +}); + +mumApp.controller('ModalIntervInstanceCtrl', function ($scope, $rootScope, $modalInstance, $filter, interv_args) { + $scope.interv_args = interv_args; // {'addr_host' : val} + + $scope.user = ''; + $scope.date = $filter('date')(new Date(), 'yyyy-MM-dd hh:mm'); + $scope.details = ''; + + $scope.ok = function () { + var args = {}; + args.addr_host = $scope.interv_args.addr_host; + args.user = $scope.user; + args.date = $scope.date; + args.details = $scope.details; + + $rootScope.$broadcast("sendViaWs", JSON.stringify({"15": {'func': 'add_intervention', 'args': args}})); + + $modalInstance.close(); + }; + + $scope.cancel = function () { + $modalInstance.close(); + }; }); \ No newline at end of file diff --git a/views/hostpage.html b/views/hostpage.html index f44faaf..6488a79 100644 --- a/views/hostpage.html +++ b/views/hostpage.html @@ -22,7 +22,7 @@ <td>{{item.value}}</td> <td>{{item.state}}</td> <td>{{item.date}}</td> - <td><button type="button" class="btn btn-primary btn-xs" ng-click="open(itemname)">Configure</button></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">Check now</button></td> </tr> </tbody> @@ -48,7 +48,7 @@ </accordion-group> <accordion-group heading="Interventions done"> - <button type="button" class="btn btn-primary btn-xs" data-toggle="modal" data-target="#modal_interv">Add a new intervention</button> + <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> @@ -61,7 +61,7 @@ <tbody> <tr ng-repeat="interv in items.interventions"> <td>{{interv.date}}</td> - <td>{{interv.person}}</td> + <td>{{interv.username}}</td> <td>{{interv.details}}</td> </tr> </tbody> @@ -116,35 +116,32 @@ </div> </script> - <!-- - <div class="modal fade" id="modal_conf" tabindex="-1" role="dialog" aria-labelledby="modal_conf_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_conf_label">Configure</h4> - </div> - <div class="modal-body"> - <form> - <div class="form-group"> - <h3>HTTP</h3> - <label for="http_freq">Frequency check</label> - <select type="http_freq" class="form-control" id="http_freq"> - <option>Every minute</option> - <option selected>Every hour (default)</option> - <option>Every day</option> - </select> - </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> - </div> + <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> + </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_interv" tabindex="-1" role="dialog" aria-labelledby="modal_interv_label" aria-hidden="true"> <div class="modal-dialog"> <div class="modal-content"> -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.
participants (1)
-
chorem.org scm