This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository coselmar. See http://git.codelutin.com/coselmar.git commit 1c5681c70c094559defaf1bb9ae67734725c1f35 Author: Yannick Martel <martel@©odelutin.com> Date: Mon Jan 18 11:03:38 2016 +0100 refs-70 #7906 add loading on users --- .../src/main/webapp/js/coselmar-controllers.js | 34 +++++++++++++++++----- .../src/main/webapp/js/coselmar-user-services.js | 16 +++++----- 2 files changed, 34 insertions(+), 16 deletions(-) diff --git a/coselmar-ui/src/main/webapp/js/coselmar-controllers.js b/coselmar-ui/src/main/webapp/js/coselmar-controllers.js index 50e420a..a14cbdd 100644 --- a/coselmar-ui/src/main/webapp/js/coselmar-controllers.js +++ b/coselmar-ui/src/main/webapp/js/coselmar-controllers.js @@ -594,7 +594,9 @@ coselmarControllers.directive('ngFileModel', ['$parse', function ($parse) { ///////////////////////////////////////////////// // Controller for All User View -coselmarControllers.controller("UsersCtrl", ['$scope', '$route', '$routeParams', '$location', 'userService', 'notify', function($scope, $route, $routeParams, $location, userService, notify){ +coselmarControllers.controller("UsersCtrl", ['$scope', '$route', '$routeParams', '$location', 'userService', 'errorService', 'notify', function($scope, $route, $routeParams, $location, userService, errorService, notify){ + + $scope.$emit('dataLoading'); //manage keywords if given $scope.example = { fullTextSearch : [], active : "true", role : ''}; @@ -620,8 +622,10 @@ coselmarControllers.controller("UsersCtrl", ['$scope', '$route', '$routeParams', } userService.getUsers($scope.example.fullTextSearch, $scope.example.showDisable, function(users) { - $scope.users = users; - }); + $scope.users = users; + }, errorService.defaultFailOnCall, function() { + $scope.$emit('dataLoaded'); + }); $scope.deleteUser = function(userId){ @@ -682,10 +686,14 @@ coselmarControllers.controller("UsersCtrl", ['$scope', '$route', '$routeParams', // Because "ALL" role is just a hack to select no role, remove it from example delete $scope.example.role; }; + $scope.$emit('dataLoading'); userService.getAdvancedUsers($scope.example, function(users){ - $scope.users = users; - }); + $scope.users = users; + }, errorService.defaultFailOnCall, function() { + $scope.$emit('dataLoaded'); + } + ); }; $scope.searchMode = function(type) { @@ -725,6 +733,7 @@ coselmarControllers.controller("NewUserCtrl", ['$scope', '$route', '$location', // Call service to create a new user if(isValidForm) { + $scope.$emit('dataLoading'); userService.saveUser($scope.user, function() { notify({ message: "user.message.created", @@ -758,7 +767,9 @@ coselmarControllers.controller("NewUserCtrl", ['$scope', '$route', '$location', }); } - }); + }, function() { + $scope.$emit('dataLoaded'); + }); } }; @@ -769,6 +780,8 @@ coselmarControllers.controller("UserViewCtrl", ['$scope', '$route', '$location', 'userService', '$routeParams', 'notify', 'errorService', function($scope, $route, $location, userService, $routeParams, notify, errorService) { + $scope.$emit('dataLoading'); + $scope.editMode = $routeParams.edit; if ($scope.editMode) { $scope.editPassword = true; @@ -779,7 +792,9 @@ coselmarControllers.controller("UserViewCtrl", $scope.user = user; var emailPattern = /^[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+((\.[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+)?)+@(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?\.)+[a-zA-Z0-9](?:[a-zA-Z0-9\-]*[a-zA-Z0-9])?$/; $scope.simpleLogin = !emailPattern.test(user.mail); - }, errorService.defaultFailOnCall); + }, errorService.defaultFailOnCall, function() { + $scope.$emit('dataLoaded'); + }); $scope.deleteUser = function(userId){ @@ -844,6 +859,7 @@ coselmarControllers.controller("UserViewCtrl", // Call service to create a new user if(isValidForm) { + $scope.$emit('dataLoading'); userService.saveUser($scope.user, function() { // Notification @@ -887,7 +903,9 @@ coselmarControllers.controller("UserViewCtrl", }); } - }); + }, function() { + $scope.$emit('dataLoaded'); + }); } }; diff --git a/coselmar-ui/src/main/webapp/js/coselmar-user-services.js b/coselmar-ui/src/main/webapp/js/coselmar-user-services.js index 3f1e1d9..d200bde 100644 --- a/coselmar-ui/src/main/webapp/js/coselmar-user-services.js +++ b/coselmar-ui/src/main/webapp/js/coselmar-user-services.js @@ -33,7 +33,7 @@ function User(resource, config){ var baseURL = config.BASE_URL + "/users"; var exportURL = config.BASE_URL + "/export/users"; - this.saveUser = function(user, successFunction, failFunction){ + this.saveUser = function(user, successFunction, failFunction, finallyFunction){ var param = $.param({ 'user': JSON.stringify(user)}); @@ -47,13 +47,13 @@ function User(resource, config){ method:'POST' } }); - userResource.save(null, param, successFunction, failFunction); + userResource.save(null, param, successFunction, failFunction).$promise.finally(finallyFunction); } - this.getUser = function(id, successFunction, failFunction){ + this.getUser = function(id, successFunction, failFunction, finallyFunction){ // Load the User var userResource = resource(baseURL + '/:userId', {userId:'@userId'}); - userResource.get({userId:id}, successFunction, failFunction); + userResource.get({userId:id}, successFunction, failFunction).$promise.finally(finallyFunction); } this.deleteUser = function(id, scope, successFunction){ @@ -62,16 +62,16 @@ function User(resource, config){ userResource.delete({userId:id}, successFunction); } - this.getUsers = function(searchKeywords, showDisable, successFunction){ + this.getUsers = function(searchKeywords, showDisable, successFunction, failFunction, finallyFunction){ // Load all users var userResource = resource(baseURL, {'search' : {'fullTextSearch' : searchKeywords, 'activeAndInactive': showDisable, 'active': true}}); - userResource.query(successFunction); + userResource.query(successFunction, failFunction).$promise.finally(finallyFunction); }; - this.getAdvancedUsers = function(searchExample, successFunction){ + this.getAdvancedUsers = function(searchExample, successFunction, failFunction, finallyFunction){ // Load all users var userResource = resource(baseURL, {'search' : searchExample}); - userResource.query(successFunction); + userResource.query(successFunction, failFunction).$promise.finally(finallyFunction); }; this.login = function(mail, password, successFunction, failFunction){ -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.