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>.