1
0
mirror of https://github.com/ansible/awx.git synced 2024-10-31 23:51:09 +03:00
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.
This commit is contained in:
Chris Houseknecht 2014-08-16 02:52:11 -04:00
parent 8c7c81bebc
commit e83150f6e1
2 changed files with 19 additions and 18 deletions

View File

@ -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) {

View File

@ -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).
//
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);
};