From e83150f6e18820453ec5126614a1a6de20702254 Mon Sep 17 00:00:00 2001 From: Chris Houseknecht Date: Sat, 16 Aug 2014 02:52:11 -0400 Subject: [PATCH] Projects Fixed https://trello.com/c/qJ1vWQeQ/317-project-sync-icon-enabled-while-project-update-inprogress Project update status was not reflected correctly. Issue was PostRefresh not handling success/failed status correctly. --- awx/ui/static/js/controllers/Projects.js | 25 +++++++++++------------- awx/ui/static/js/helpers/search.js | 12 ++++++++---- 2 files changed, 19 insertions(+), 18 deletions(-) diff --git a/awx/ui/static/js/controllers/Projects.js b/awx/ui/static/js/controllers/Projects.js index 5f7e1ba0c3..826ab0756a 100644 --- a/awx/ui/static/js/controllers/Projects.js +++ b/awx/ui/static/js/controllers/Projects.js @@ -45,18 +45,23 @@ function ProjectsList ($scope, $rootScope, $location, $log, $routeParams, Rest, } $scope.removePostRefresh = $scope.$on('PostRefresh', function () { Wait('stop'); - if ($scope.projects) { + console.log('here'); $scope.projects.forEach(function(project, i) { - $scope.projects[i].statusIcon = GetProjectIcon(project.status); $scope.projects[i].statusTip = GetProjectToolTip(project.status); + $scope.projects[i].scm_update_tooltip = "Start an SCM update"; + $scope.projects[i].scm_schedule_tooltip = "Schedule future SCM updates"; + $scope.projects[i].scm_type_class = ""; if (project.status === 'failed' && project.summary_fields.last_update && project.summary_fields.last_update.status === 'canceled') { $scope.projects[i].statusTip = 'Canceled. Click for details'; } + console.log('project: ' + project.name + ' status: ' + project.status); if (project.status === 'running' || project.status === 'updating') { + $scope.projects[i].scm_update_tooltip = "SCM update currently running"; + $scope.projects[i].scm_type_class = "btn-disabled"; } $scope.project_scm_type_options.forEach(function(type) { @@ -68,14 +73,6 @@ function ProjectsList ($scope, $rootScope, $location, $log, $routeParams, Rest, $scope.projects[i].scm_type_class = 'btn-disabled'; $scope.projects[i].statusTip = 'Not configured for SCM'; $scope.projects[i].statusIcon = 'none'; - } else if (type.label === "Running" || type.label === "Updating") { - $scope.projects[i].scm_update_tooltip = "SCM update currently running"; - $scope.projects[i].scm_type_class = 'btn-disabled'; - $scope.projects[i].scm_schedule_tooltip = "Schedule future SCM updates"; - } else { - $scope.projects[i].scm_update_tooltip = "Start an SCM update"; - $scope.projects[i].scm_schedule_tooltip = "Schedule future SCM updates"; - $scope.projects[i].scm_type_class = ""; } } }); @@ -89,7 +86,6 @@ function ProjectsList ($scope, $rootScope, $location, $log, $routeParams, Rest, } $rootScope.removeJobStatusChange = $rootScope.$on('JobStatusChange', function(e, data) { var project; - Wait('stop'); $log.debug(data); if ($scope.projects) { // Assuming we have a list of projects available @@ -99,7 +95,7 @@ function ProjectsList ($scope, $rootScope, $location, $log, $routeParams, Rest, $log.debug('Received event for project: ' + project.name); $log.debug('Status changed to: ' + data.status); if (data.status === 'successful' || data.status === 'failed') { - $scope.refresh(); + $scope.search(list.iterator, null, null, null, null, false); } else { project.scm_update_tooltip = "SCM update currently running"; @@ -340,14 +336,15 @@ function ProjectsList ($scope, $rootScope, $location, $log, $routeParams, Rest, }; $scope.refresh = function () { - Wait('start'); + /*Wait('start'); $scope.projectLoading = false; Refresh({ scope: $scope, set: 'projects', iterator: 'project', url: $scope.current_url - }); + });*/ + $scope.search(list.iterator); }; $scope.SCMUpdate = function (project_id, event) { diff --git a/awx/ui/static/js/helpers/search.js b/awx/ui/static/js/helpers/search.js index 697d17ff7e..78e6bdc5b9 100644 --- a/awx/ui/static/js/helpers/search.js +++ b/awx/ui/static/js/helpers/search.js @@ -298,12 +298,14 @@ angular.module('SearchHelper', ['RestServices', 'Utilities', 'RefreshHelper']) if (scope.removePrepareSearch) { scope.removePrepareSearch(); } - scope.removePrepareSearch = scope.$on('prepareSearch', function (e, iterator, page, load, calcOnly, deferWaitStop) { + scope.removePrepareSearch = scope.$on('prepareSearch', function (e, iterator, page, load, calcOnly, deferWaitStop, spinner) { // // Start building the search key/value pairs. This will process each search widget, if the // selected field is an object type (used on activity stream). // - Wait('start'); + if (spinner) { + Wait('start'); + } scope[iterator + 'SearchParams'] = ''; var i, modifier, widgets = (list.searchWidgets) ? list.searchWidgets : 1; @@ -456,16 +458,18 @@ angular.module('SearchHelper', ['RestServices', 'Utilities', 'RefreshHelper']) * @calcOnly: optional, set to true when you want to calc or figure out search params without executing the search * @deferWaitStop: optional, when true refresh.js will NOT issue Wait('stop'), thus leaving the spinner. Caller is then * responsible for stopping the spinner post refresh. + * @spinner: optional, if false, don't show the spinner. */ - scope.search = function (iterator, page, load, calcOnly, deferWaitStop) { + scope.search = function (iterator, page, load, calcOnly, deferWaitStop, spinner) { page = page || null; load = (load || !scope[set] || scope[set].length === 0) ? true : false; calcOnly = (calcOnly) ? true : false; deferWaitStop = (deferWaitStop) ? true : false; + spinner = (spinner === undefined) ? true : spinner; if (load) { scope[set] = []; //clear the list array to make sure 'Loading' is the only thing visible on the list } - scope.$emit('prepareSearch', iterator, page, load, calcOnly, deferWaitStop); + scope.$emit('prepareSearch', iterator, page, load, calcOnly, deferWaitStop, spinner); };