From 7d6a43f21852a1f9048371c3d44e32d030787d45 Mon Sep 17 00:00:00 2001 From: Athou Date: Wed, 3 Apr 2013 09:07:54 +0200 Subject: [PATCH] auto refresh every 30s (fixes #6) --- src/main/webapp/js/controllers.js | 64 ++++++++++++++++++------------- 1 file changed, 37 insertions(+), 27 deletions(-) diff --git a/src/main/webapp/js/controllers.js b/src/main/webapp/js/controllers.js index 335a1433..850fe41d 100644 --- a/src/main/webapp/js/controllers.js +++ b/src/main/webapp/js/controllers.js @@ -10,7 +10,7 @@ module.run(function($rootScope) { }); }); -module.controller('CategoryTreeCtrl', function($scope, $stateParams, $location, +module.controller('CategoryTreeCtrl', function($scope, $timeout, $stateParams, $location, $state, $route, SubscriptionService) { $scope.$on('$stateChangeSuccess', function() { @@ -18,6 +18,12 @@ module.controller('CategoryTreeCtrl', function($scope, $stateParams, $location, $scope.selectedId = $stateParams._id; }); + $timeout(function refreshTree() { + SubscriptionService.init(function() { + $timeout(refreshTree, 30000); + }); + }, 30000); + $scope.SubscriptionService = SubscriptionService; var unreadCount = function(category) { @@ -253,34 +259,36 @@ module.controller('FeedListCtrl', function($scope, $stateParams, $http, $route, }); }); -module.controller('ManageUsersCtrl', - function($scope, $state, $location, AdminUsersService) { - $scope.users = AdminUsersService.getAll(); - $scope.selection = []; - $scope.gridOptions = { - data : 'users', - selectedItems : $scope.selection, - multiSelect : false, - afterSelectionChange : function(item) { - $state.transitionTo('admin.useredit', { - _id : item.entity.id - }); - } - }; +module.controller('ManageUsersCtrl', function($scope, $state, $location, + AdminUsersService) { + $scope.users = AdminUsersService.getAll(); + $scope.selection = []; + $scope.gridOptions = { + data : 'users', + selectedItems : $scope.selection, + multiSelect : false, + afterSelectionChange : function(item) { + $state.transitionTo('admin.useredit', { + _id : item.entity.id + }); + } + }; - $scope.addUser = function() { - $state.transitionTo('admin.useradd'); - }; - $scope.back = function() { - $location.path('/'); - }; - }); + $scope.addUser = function() { + $state.transitionTo('admin.useradd'); + }; + $scope.back = function() { + $location.path('/'); + }; +}); module.controller('ManageUserCtrl', function($scope, $state, $stateParams, AdminUsersService) { $scope.user = $stateParams._id ? AdminUsersService.get({ id : $stateParams._id - }) : {enabled: true}; + }) : { + enabled : true + }; $scope.alerts = []; $scope.closeAlert = function(index) { $scope.alerts.splice(index, 1); @@ -288,11 +296,11 @@ module.controller('ManageUserCtrl', function($scope, $state, $stateParams, var alertFunction = function(data) { $scope.alerts.push({ msg : data.data, - type: 'error' + type : 'error' }); }; - $scope.cancel = function(){ + $scope.cancel = function() { $state.transitionTo('admin.userlist'); }; $scope.save = function() { @@ -302,8 +310,10 @@ module.controller('ManageUserCtrl', function($scope, $state, $stateParams, }, alertFunction); }; $scope.remove = function() { - AdminUsersService.remove({id: $scope.user.id}, function() { + AdminUsersService.remove({ + id : $scope.user.id + }, function() { $state.transitionTo('admin.userlist'); - },alertFunction); + }, alertFunction); }; }); \ No newline at end of file