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 111b8f996fcb84a07f77e8f7bad9c37edbd7f48b Author: Alexis Guilbaud <guilbaud@codelutin.com> Date: Wed Jun 24 11:31:24 2015 +0200 dashboard : all filters update the url --- static/js/controllers/dashboardCtrl.js | 36 +++++++++++++++++++++++++--------- static/js/mumApp.js | 13 +++++++----- views/dashboard.html | 21 ++++++++++++++++---- 3 files changed, 52 insertions(+), 18 deletions(-) diff --git a/static/js/controllers/dashboardCtrl.js b/static/js/controllers/dashboardCtrl.js index 98e9acc..8e3d839 100644 --- a/static/js/controllers/dashboardCtrl.js +++ b/static/js/controllers/dashboardCtrl.js @@ -47,38 +47,56 @@ mumApp.controller('dashboardCtrl', function ($scope, $routeParams, $location, $r $scope.host_filter = ''; // input field $scope.addr_filter = ''; // input field $scope.name_filter = ''; // input field + $scope.group_filter = ''; $scope.order_val = 'status'; // select field $scope.view = 'host_view'; - if ($routeParams.param == null) { + if (Object.keys($location.search()).length == 0) { // if no status filter in parameters, show all status $scope.status_filter = ["success", "warning", "danger", "idling", ""]; } else { // multiple params should be separated by ',' - $scope.status_filter = []; - tab_params = $routeParams.param.split(','); - for (var i = 0; i<tab_params.length; i++) { - $scope.status_filter.push(tab_params[i]); + for (var key in $location.search()){ + + if ( key == 'status_filter' ){ + $scope.status_filter = []; + status_tab = $location.search()[key].split(','); + for (var i = 0; i<status_tab.length; i++) { + $scope.status_filter.push(status_tab[i]); + } + } + else{ + $scope[key] = $location.search()[key]; + } } } $scope.update_url = function () { - var url = "/dashboard/"; + var url = ""; + + url += "host_filter=" + $scope.host_filter + "&"; + + url += "addr_filter=" + $scope.addr_filter + "&"; + + url += "name_filter=" + $scope.name_filter + "&"; + + url += "group_filter=" + $scope.group_filter + "&"; + var nb_attr = $scope.status_filter.length; var i = 0; + url += "status_filter=" while ( i<nb_attr - 1 ) { url += $scope.status_filter[i] + ','; i++; } url += $scope.status_filter[i]; - $location.path(url); - } - $scope.group_filter = ''; + $location.search(url); + } $scope.status = ''; diff --git a/static/js/mumApp.js b/static/js/mumApp.js index b3688ae..a1001fc 100644 --- a/static/js/mumApp.js +++ b/static/js/mumApp.js @@ -8,15 +8,18 @@ mumApp.config(function ($routeProvider) { $routeProvider .when('/',{ templateUrl : 'dashboard.html', - controller : 'dashboardCtrl' + controller : 'dashboardCtrl', + reloadOnSearch: false }) .when('/dashboard/',{ templateUrl : 'dashboard.html', - controller : 'dashboardCtrl' + controller : 'dashboardCtrl', + reloadOnSearch: false }) .when('/dashboard/:param/',{ templateUrl : 'dashboard.html', - controller : 'dashboardCtrl' + controller : 'dashboardCtrl', + reloadOnSearch: false }) .when('/hostpage/:param/',{ templateUrl : 'hostpage.html', @@ -59,9 +62,9 @@ mumApp.config(function ($routeProvider) { }); }); -/*mumApp.config(function($locationProvider)){ +mumApp.config(function($locationProvider){ $locationProvider.html5Mode(false); -});*/ +}); mumApp.$inject = ['$scope', '$filter']; diff --git a/views/dashboard.html b/views/dashboard.html index 7be0830..0e2203f 100644 --- a/views/dashboard.html +++ b/views/dashboard.html @@ -13,17 +13,29 @@ <div class="col-xs-3"> <label for="host_f">Host filter</label> - <input class="form-control" type="text" id="host_f" ng-model="host_filter"> + <input class="form-control" + type="text" + id="host_f" + ng-model="host_filter" + ng-change="update_url()"> </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"> + <input class="form-control" + type="text" + id="addr_f" + ng-model="addr_filter" + ng-change="update_url()"> </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"> + <input class="form-control" + type="text" + id="name_f" + ng-model="name_filter" + ng-change="update_url()"> </div> <div class="col-xs-2"> @@ -44,7 +56,8 @@ <select class="form-control input-sm" id="group_f" ng-model="group_filter" - ng-options="group for group in allGroups() | unique:'group'"> + ng-options="group for group in allGroups() | unique:'group'" + ng-change="update_url()"> </select> <!--<ui-select multiple tagging="tag_transform" -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.