fixed project update canceling

This commit is contained in:
John Mitchell
2015-10-27 14:42:10 -04:00
parent 0f68ead0b3
commit 32962bcadc

View File

@@ -309,29 +309,37 @@ export function ProjectsList ($scope, $rootScope, $location, $log, $routeParams,
}); });
$scope.cancelUpdate = function (id, name) { $scope.cancelUpdate = function (id, name) {
// Start the cancel process // // Start the cancel process
var i, project, found = false; // var i, project, found = false;
for (i = 0; i < $scope.projects.length; i++) { // for (i = 0; i < $scope.projects.length; i++) {
if ($scope.projects[i].id === id) { // if ($scope.projects[i].id === id) {
project = $scope.projects[i]; // project = $scope.projects[i];
found = true; // found = true;
break; // break;
} // }
} // }
if (found && project.related.current_update) { Rest.setUrl(GetBasePath("projects") + id);
Rest.setUrl(project.related.current_update); Rest.get()
Rest.get() .success(function (data) {
.success(function (data) { if (data.related.current_update) {
$scope.$emit('Check_Cancel', data); Rest.setUrl(data.related.current_update);
}) Rest.get()
.error(function (data, status) { .success(function (data) {
ProcessErrors($scope, data, status, null, { hdr: 'Error!', $scope.$emit('Check_Cancel', data);
msg: 'Call to ' + project.related.current_update + ' failed. GET status: ' + status }); })
}); .error(function (data, status) {
} else { ProcessErrors($scope, data, status, null, { hdr: 'Error!',
Alert('Update Not Found', 'An SCM update does not appear to be running for project: ' + $filter('sanitize')(name) + '. Click the <em>Refresh</em> ' + msg: 'Call to ' + data.related.current_update + ' failed. GET status: ' + status });
'button to view the latest status.', 'alert-info',undefined,undefined,undefined,undefined,true); });
} } else {
Alert('Update Not Found', 'An SCM update does not appear to be running for project: ' + $filter('sanitize')(name) + '. Click the <em>Refresh</em> ' +
'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 () { $scope.refresh = function () {