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 9913e0eef39a324ebbb3b4e24306d8ef8605ab78 Author: Yannick Martel <martel@©odelutin.com> Date: Mon Jan 18 10:52:47 2016 +0100 refs-50 #7906 add loading on documents --- coselmar-ui/src/main/webapp/index.html | 2 +- .../src/main/webapp/js/coselmar-controllers.js | 29 +++++++++++++++++++--- .../src/main/webapp/js/coselmar-services.js | 16 ++++++------ 3 files changed, 35 insertions(+), 12 deletions(-) diff --git a/coselmar-ui/src/main/webapp/index.html b/coselmar-ui/src/main/webapp/index.html index 652853f..ba09a4f 100644 --- a/coselmar-ui/src/main/webapp/index.html +++ b/coselmar-ui/src/main/webapp/index.html @@ -212,7 +212,7 @@ </div> </footer> - <div id="loading" ng-if="application-loading"> + <div id="loading" ng-if="applicationLoading"> <i class="fa fa-spinner fa-pulse"></i> </div> diff --git a/coselmar-ui/src/main/webapp/js/coselmar-controllers.js b/coselmar-ui/src/main/webapp/js/coselmar-controllers.js index 500f88e..50e420a 100644 --- a/coselmar-ui/src/main/webapp/js/coselmar-controllers.js +++ b/coselmar-ui/src/main/webapp/js/coselmar-controllers.js @@ -105,6 +105,14 @@ coselmarControllers.controller("HomeCtrl", ['$scope', '$http', '$location', '$ro } } + $scope.$on('dataLoading', function(event, args) { + $scope.applicationLoading = true; + }); + + $scope.$on('dataLoaded', function(event, args) { + $scope.applicationLoading = false; + }); + }]); // Controller when got 401 @@ -170,6 +178,7 @@ coselmarControllers.controller("homeConnectedCtrl", ['$scope', 'questionsService coselmarControllers.controller("DocumentsCtrl", ['$scope', '$route', '$routeParams', '$location', 'notify', 'documentService', 'errorService', function($scope, $route, $routeParams, $location, notify, documentService, errorService){ + $scope.$emit('dataLoading'); //manage keywords if given $scope.search = { searchKeywords : []}; $scope.example = { keywords: []}; @@ -190,7 +199,9 @@ coselmarControllers.controller("DocumentsCtrl", ['$scope', '$route', '$routePara documentService.getDocuments($scope.search.searchKeywords, function(documents) { $scope.documents = documents; - }, errorService.defaultFailOnCall); + }, errorService.defaultFailOnCall, function() { + $scope.$emit('dataLoaded'); + }); $scope.deleteDocument = function(documentId){ @@ -230,8 +241,11 @@ coselmarControllers.controller("DocumentsCtrl", ['$scope', '$route', '$routePara $scope.example.publicationBeforeDate = $scope.example.publicationBeforeDate.getTime(); } + $scope.$emit('dataLoading'); documentService.getAdvancedDocuments($scope.example, function(documents){ $scope.documents = documents; + }, errorService.defaultFailOnCall, function() { + $scope.$emit('dataLoaded'); }); }; @@ -304,6 +318,7 @@ coselmarControllers.controller("NewDocumentCtrl", ['$scope', '$location', 'notif $scope.keywordsError = true; } else { // Call service to create a new document + $scope.$emit('dataLoading'); documentService.saveDocument($scope.document, function(document) { if ($scope.upload.file) { @@ -328,7 +343,11 @@ coselmarControllers.controller("NewDocumentCtrl", ['$scope', '$location', 'notif }); $location.path("/documents"); } - }, errorService.defaultFailOnCall); + }, + errorService.defaultFailOnCall, + function() { + $scope.$emit('dataLoaded'); + }); } @@ -449,6 +468,7 @@ coselmarControllers.controller("DocumentViewCtrl", $scope.hasErrors = true; } else if ($scope.isFormValid()) { + $scope.$emit('dataLoading'); $scope.hasErrors = false; // Adapt publicationDate to send a timestamp @@ -479,7 +499,10 @@ coselmarControllers.controller("DocumentViewCtrl", }); $location.search(""); } - }, errorService.defaultFailOnCall); + }, errorService.defaultFailOnCall, + function() { + $scope.$emit('dataLoaded'); + }); } else { $scope.hasErrors = true; diff --git a/coselmar-ui/src/main/webapp/js/coselmar-services.js b/coselmar-ui/src/main/webapp/js/coselmar-services.js index 38e90a8..09d5438 100644 --- a/coselmar-ui/src/main/webapp/js/coselmar-services.js +++ b/coselmar-ui/src/main/webapp/js/coselmar-services.js @@ -34,7 +34,7 @@ function Document(resource, config){ var baseURL = config.BASE_URL + "/documents"; var usersURL = config.BASE_URL + "/users"; - this.saveDocument = function(document, successFunction, failFunction) { + this.saveDocument = function(document, successFunction, failFunction, finallyFunction) { var param = $.param({ 'document': JSON.stringify(document)}); @@ -48,7 +48,7 @@ function Document(resource, config){ 'save': { method: 'POST'} }); - saveDocumentResource.save(null, param, successFunction, failFunction); + saveDocumentResource.save(null, param, successFunction, failFunction).$promise.finally(finallyFunction); }; this.saveDocumentFile = function(documentId, file, successFunction, failFunction) { @@ -92,10 +92,10 @@ function Document(resource, config){ docResource.upload(null, formData, successFunction, failFunction); }; - this.getDocument = function(id, successFunction, failFunction){ + this.getDocument = function(id, successFunction, failFunction, finallyFunction){ // Load the document var docResource = resource(baseURL + '/:documentId', {documentId:'@documentId'}); - docResource.get({documentId:id}, successFunction, failFunction); + docResource.get({documentId:id}, successFunction, failFunction).$promise.finally(finallyFunction); }; this.deleteDocument = function(id, scope, successFunction, failFunction){ @@ -113,10 +113,10 @@ function Document(resource, config){ }); }; - this.getDocuments = function(searchKeywords, successFunction, failFunction){ + this.getDocuments = function(searchKeywords, successFunction, failFunction, finallyFunction){ // Load all documents var docResource = resource(baseURL, {'searchBean' : {'fullTextSearch' : searchKeywords}}); - docResource.query(successFunction, failFunction); + docResource.query(successFunction, failFunction).$promise.finally(finallyFunction); }; this.findAllTypes = function(successFunction){ @@ -135,10 +135,10 @@ function Document(resource, config){ }; - this.getAdvancedDocuments = function(searchExample, successFunction){ + this.getAdvancedDocuments = function(searchExample, successFunction, failFunction, finallyFunction){ // Load documents with search example var docResource = resource(baseURL, {'searchBean' : searchExample}); - docResource.query(successFunction); + docResource.query(successFunction, failFunction).$promise.finally(finallyFunction); }; }; \ No newline at end of file -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.