From 32962bcadc9a1d1ee67d3989802f8a9bea056531 Mon Sep 17 00:00:00 2001 From: John Mitchell Date: Tue, 27 Oct 2015 14:42:10 -0400 Subject: [PATCH] fixed project update canceling --- awx/ui/client/src/controllers/Projects.js | 54 +++++++++++++---------- 1 file changed, 31 insertions(+), 23 deletions(-) diff --git a/awx/ui/client/src/controllers/Projects.js b/awx/ui/client/src/controllers/Projects.js index e0a5ce9956..4083dbe2d4 100644 --- a/awx/ui/client/src/controllers/Projects.js +++ b/awx/ui/client/src/controllers/Projects.js @@ -309,29 +309,37 @@ export function ProjectsList ($scope, $rootScope, $location, $log, $routeParams, }); $scope.cancelUpdate = function (id, name) { - // Start the cancel process - var i, project, found = false; - for (i = 0; i < $scope.projects.length; i++) { - if ($scope.projects[i].id === id) { - project = $scope.projects[i]; - found = true; - break; - } - } - if (found && project.related.current_update) { - Rest.setUrl(project.related.current_update); - Rest.get() - .success(function (data) { - $scope.$emit('Check_Cancel', data); - }) - .error(function (data, status) { - ProcessErrors($scope, data, status, null, { hdr: 'Error!', - msg: 'Call to ' + project.related.current_update + ' failed. GET status: ' + status }); - }); - } else { - Alert('Update Not Found', 'An SCM update does not appear to be running for project: ' + $filter('sanitize')(name) + '. Click the Refresh ' + - 'button to view the latest status.', 'alert-info',undefined,undefined,undefined,undefined,true); - } + // // Start the cancel process + // var i, project, found = false; + // for (i = 0; i < $scope.projects.length; i++) { + // if ($scope.projects[i].id === id) { + // project = $scope.projects[i]; + // found = true; + // break; + // } + // } + Rest.setUrl(GetBasePath("projects") + id); + Rest.get() + .success(function (data) { + if (data.related.current_update) { + Rest.setUrl(data.related.current_update); + Rest.get() + .success(function (data) { + $scope.$emit('Check_Cancel', data); + }) + .error(function (data, status) { + ProcessErrors($scope, data, status, null, { hdr: 'Error!', + msg: 'Call to ' + data.related.current_update + ' failed. GET status: ' + status }); + }); + } else { + Alert('Update Not Found', 'An SCM update does not appear to be running for project: ' + $filter('sanitize')(name) + '. Click the Refresh ' + + 'button to view the latest status.', 'alert-info',undefined,undefined,undefined,undefined,true); + } + }) + .error(function (data, status) { + ProcessErrors($scope, data, status, null, { hdr: 'Error!', + msg: 'Call to get project failed. GET status: ' + status }); + }) }; $scope.refresh = function () {