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 b4322a11821943587daec3a27416275779d09d03 Author: Alexis Guilbaud <guilbaud@codelutin.com> Date: Wed Mar 18 17:52:11 2015 +0100 notifications page : select ng-options pour groupes et hôtes OK --- static/js/controllers/notificationsCtrl.js | 34 ++++++++++++++++++++++ static/js/mumApp.js | 4 +-- views/index.html | 13 +++++---- views/notifications.html | 45 ++++++++++++++++++++---------- views/users.html | 2 +- 5 files changed, 75 insertions(+), 23 deletions(-) diff --git a/static/js/controllers/notificationsCtrl.js b/static/js/controllers/notificationsCtrl.js new file mode 100644 index 0000000..95e2cf1 --- /dev/null +++ b/static/js/controllers/notificationsCtrl.js @@ -0,0 +1,34 @@ +mumApp.controller('notificationsCtrl', function($scope, $rootScope, DataHosts) { + $scope.items = DataHosts.Items; /* [ + { + "addr":"192.168.74.1", + "name":"www.example.com", + "status":val, //"success" or "warning" or "danger" or "" + "group":[ "all", ...], + "last_check":val //UNIX time + "subscribers":{ + "uid":val, + "priority":val + } + "warning": [mod_name, ...] + "danger": [mod_name, ...] + }, + ... + ] + */ + + $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++){ + res.push($scope.items[i].group[j]); + } + } + return res; + }; + + $scope.selected_grp = ""; + $scope.selected_host = ""; + + $scope.option_selected = ""; +}); \ No newline at end of file diff --git a/static/js/mumApp.js b/static/js/mumApp.js index 2068b61..3f76c6d 100644 --- a/static/js/mumApp.js +++ b/static/js/mumApp.js @@ -27,8 +27,8 @@ mumApp.config(function($routeProvider){ controller : 'hostPageCtrl' }) .when('/notifications',{ - templateUrl : 'notifications.html' - //controller : 'mainController' + templateUrl : 'notifications.html', + controller : 'notificationsCtrl' }) .when('/profile',{ templateUrl : 'profile.html' diff --git a/views/index.html b/views/index.html index d80e11c..bb44098 100644 --- a/views/index.html +++ b/views/index.html @@ -26,13 +26,14 @@ <script src="bower_components/angular-bootstrap/ui-bootstrap-tpls.min.js"></script> - <script src="static/js/mumApp.js"></script> - <script src="static/js/controllers/dashboardCtrl.js"></script> - <script src="static/js/controllers/headCtrl.js"></script> - <script src="static/js/controllers/scanCtrl.js"></script> - <script src="static/js/controllers/hostPageCtrl.js"></script> - <script src="static/js/controllers/groupCtrl.js"></script> + <script src="static/js/mumApp.js"></script> + <script src="static/js/controllers/dashboardCtrl.js"></script> + <script src="static/js/controllers/headCtrl.js"></script> + <script src="static/js/controllers/scanCtrl.js"></script> + <script src="static/js/controllers/hostPageCtrl.js"></script> + <script src="static/js/controllers/groupCtrl.js"></script> <script src="static/js/controllers/usersCtrl.js"></script> + <script src="static/js/controllers/notificationsCtrl.js"></script> <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries --> <!--[if lt IE 9]><!-- diff --git a/views/notifications.html b/views/notifications.html index 172e172..17bd3ac 100644 --- a/views/notifications.html +++ b/views/notifications.html @@ -3,20 +3,37 @@ <h1 class="page-header">Who to notify?</h1> <!--<h2 class="sub-header">They will be applied on each new host you will add.</h2>--> <form> - <label for="grp_choice">Select one host or one group :</label> - <select class="form-control" id="grp_choice"> - <option value="142.42.13.37" class="optionChild">142.42.13.37 www.nerd.org</option> - <option value="mygroup1" class="optionGroup">mygroup1</option> - <option value="192.168.74.1" class="optionChild">192.168.74.1 www.example.com</option> - <option value="192.168.74.2" class="optionChild">192.168.74.2 www.example.com</option> - <option value="192.168.74.3" class="optionChild">192.168.74.3 www.example.com</option> - <option value="mygroup2" class="optionGroup">mygroup2</option> - <option value="135.47.86.11" class="optionChild">135.47.86.11 www.blabla.fr</option> - <option value="135.47.86.12" class="optionChild">135.47.86.12 www.blabla.fr</option> - <option value="mygroup3" class="optionGroup">mygroup3</option> - <option value="192.147.0.0" class="optionChild">192.147.0.0</option> - <option value="192.147.0.1" class="optionChild">192.147.0.1</option> - </select> + <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'"></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'"></select> + </div> + </div> + </div> + + + </form> <p>Check the box if you want the user to be notified by the correspondant service.</p> diff --git a/views/users.html b/views/users.html index eeb1f4d..dfe9c5c 100644 --- a/views/users.html +++ b/views/users.html @@ -11,5 +11,5 @@ 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!=''" ng-click="removeUser()">Remove {{selected_user}}</button> + <button type="button" class="btn btn-danger" ng-show="selected_user!='' && selected_user!=null" ng-click="removeUser()">Remove {{selected_user}}</button> </div> -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.