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 d3db22cb8dab8a498e038bc096c948f6315de18d Author: Alexis Guilbaud <guilbaud@codelutin.com> Date: Fri Jun 19 11:12:00 2015 +0200 sub number on group view --- static/js/controllers/dashboardCtrl.js | 31 ++++++++++++++++++++++++++++++- views/dashboard.html | 7 ++++--- 2 files changed, 34 insertions(+), 4 deletions(-) diff --git a/static/js/controllers/dashboardCtrl.js b/static/js/controllers/dashboardCtrl.js index a210f3d..ea383cc 100644 --- a/static/js/controllers/dashboardCtrl.js +++ b/static/js/controllers/dashboardCtrl.js @@ -1,4 +1,4 @@ -mumApp.controller('dashboardCtrl', function ($scope, $routeParams, $location, $rootScope, $modal, DataHosts) { +mumApp.controller('dashboardCtrl', function ($scope, $routeParams, $location, $rootScope, $modal, $timeout, DataHosts) { /* Host view functions */ $scope.param = $routeParams.param; // parameter in URL, null if none @@ -30,12 +30,18 @@ mumApp.controller('dashboardCtrl', function ($scope, $routeParams, $location, $r $scope.$on("hostsUpdate", function (event) { $scope.items = DataHosts.Items; + $rootScope.$broadcast("sendViaWs", JSON.stringify({"CALL_FUNC_DB": {'func': 'get_groups','args': null}})); }); $scope.$on("resCall", function (event, args) { if (args.func == 'remove_host_list_to_group' || args.func == 'add_host_list_to_group') { $rootScope.$broadcast("sendViaWs", JSON.stringify({"GET_HOSTS": ""})); } + if (args.func == 'get_groups') { + $timeout(function () { + $scope.groups = args.res; + }, 0); + } }); $scope.host_filter = ''; // input field @@ -149,9 +155,32 @@ mumApp.controller('dashboardCtrl', function ($scope, $routeParams, $location, $r }; /* Group view functions */ + $scope.groups = {};/*{ grp_name: { 'hosts': [host1, ...], 'subscribers': + { usr: { 'minor': int, 'major': int }, ... + } } + */ + $scope.group_obj = {}; /* {group_name:{"hosts":[addr1, ...],"status":"success"}, ...} */ + $scope.get_group_sub_num = function(grp_name){ + if(grp_name != 'all'){ + res = {}; + res.nb_sub = Object.keys($scope.groups[grp_name].subscribers).length; + if (res.nb_sub == 0){ + res.btn_type = 'default'; + } + else{ + res.btn_type = 'primary'; + } + } + else{ + res.nb_sub = null; + res.btn_type = 'default' + } + return res; + }; + $scope.update_group_obj = function (){ var allGroups = $scope.allGroups(); for (var i=0, l=allGroups.length ; i<l ; i++){ diff --git a/views/dashboard.html b/views/dashboard.html index bd1091f..e08a364 100644 --- a/views/dashboard.html +++ b/views/dashboard.html @@ -174,11 +174,12 @@ </td> <td>{{group.status}}</td> <td> - <button type="button" class="btn btn-primary btn-xs" aria-label="Subscribers" + <button type="button" class="btn btn-{{get_group_sub_num(groupname).btn_type}} btn-xs" aria-label="Subscribers" popover-placement="left" - popover="Subscribers" + popover="{{get_group_sub_num(groupname).nb_sub}} subscribers" popover-trigger="mouseenter" - ng-click="open_modal_notif(null, groupname)"> + ng-click="open_modal_notif(null, groupname)" + ng-show="groupname != 'all'"> <span class="glyphicon glyphicon-user" aria-hidden="true"> </span> </button> -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.