AC-1123 fixed issues related to job submission and cancellation.

This commit is contained in:
Chris Houseknecht 2014-04-05 05:21:19 -04:00
parent 6540380cc9
commit d6237dcfb0
7 changed files with 84 additions and 37 deletions

View File

@ -124,7 +124,7 @@ Home.$inject = ['$scope', '$compile', '$routeParams', '$rootScope', '$location',
function HomeGroups($scope, $filter, $compile, $location, $routeParams, LogViewer, HomeGroupList, GenerateList, ProcessErrors, LoadBreadCrumbs, ReturnToCaller, ClearScope,
GetBasePath, SearchInit, PaginateInit, FormatDate, GetHostsStatusMsg, GetSyncStatusMsg, ViewUpdateStatus, Stream, GroupsEdit, Wait,
Alert, Rest, Empty, InventoryUpdate, Find) {
Alert, Rest, Empty, InventoryUpdate, Find, GroupsCancelUpdate) {
ClearScope('htmlTemplate'); //Garbage collection. Don't leave behind any listeners/watchers from the prior
//scope.
@ -347,7 +347,7 @@ function HomeGroups($scope, $filter, $compile, $location, $routeParams, LogViewe
};
scope.refresh = function () {
scope.search(list.iterator, null, false, true);
scope.search(list.iterator);
};
@ -426,7 +426,7 @@ function HomeGroups($scope, $filter, $compile, $location, $routeParams, LogViewe
if (!Empty(id)) {
group = Find({ list: scope.home_groups, key: 'id', val: id });
status = group.summary_fields.inventory_source.status;
if (status === 'failed' || status === 'error' || status === 'successful') {
if (status === 'running' || status === 'failed' || status === 'error' || status === 'successful') {
Wait('start');
Rest.setUrl(group.related.inventory_sources + '?or__source=ec2&or__source=rax&order_by=-last_job_run&page_size=5');
Rest.get()
@ -479,17 +479,22 @@ function HomeGroups($scope, $filter, $compile, $location, $routeParams, LogViewe
scope.viewJob = function(url) {
LogViewer({
scope: scope,
scope: modal_scope,
url: url
});
};
scope.cancelUpdate = function(id) {
var group = Find({ list: scope.home_groups, key: 'id', val: id });
GroupsCancelUpdate({ scope: scope, group: group });
};
}
HomeGroups.$inject = ['$scope', '$filter', '$compile', '$location', '$routeParams', 'LogViewer', 'HomeGroupList', 'GenerateList', 'ProcessErrors', 'LoadBreadCrumbs', 'ReturnToCaller',
'ClearScope', 'GetBasePath', 'SearchInit', 'PaginateInit', 'FormatDate', 'GetHostsStatusMsg', 'GetSyncStatusMsg', 'ViewUpdateStatus',
'Stream', 'GroupsEdit', 'Wait', 'Alert', 'Rest', 'Empty', 'InventoryUpdate', 'Find'
'Stream', 'GroupsEdit', 'Wait', 'Alert', 'Rest', 'Empty', 'InventoryUpdate', 'Find', 'GroupsCancelUpdate'
];

View File

@ -687,7 +687,7 @@ function InventoriesEdit($scope, $location, $routeParams, $compile, GenerateList
};
$scope.cancelUpdate = function (tree_id) {
GroupsCancelUpdate({ scope: $scope, tree_id: tree_id });
GroupsCancelUpdate({ scope: $scope, id: tree_id });
};
$scope.toggle = function (tree_id) {

View File

@ -251,13 +251,13 @@ angular.module('GroupsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', '
// Cancel a pending or running inventory sync
.factory('GroupsCancelUpdate', ['Rest', 'ProcessErrors', 'Alert', 'Wait', 'Find',
function (Rest, ProcessErrors, Alert, Wait, Find) {
.factory('GroupsCancelUpdate', ['Empty', 'Rest', 'ProcessErrors', 'Alert', 'Wait', 'Find',
function (Empty, Rest, ProcessErrors, Alert, Wait, Find) {
return function (params) {
var scope = params.scope,
id = params.tree_id,
group;
id = params.id,
group = params.group;
if (scope.removeCancelUpdate) {
scope.removeCancelUpdate();
@ -268,7 +268,7 @@ angular.module('GroupsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', '
Rest.post()
.success(function () {
Wait('stop');
Alert('Inventory Sync Cancelled', 'Your request to cancel the sync process was submitted to the task manger. ' +
Alert('Inventory Sync Cancelled', 'Request to cancel the sync process was submitted to the task manger. ' +
'Click the <i class="fa fa-refresh fa-lg"></i> button to monitor the status.', 'alert-info');
})
.error(function (data, status) {
@ -294,8 +294,8 @@ angular.module('GroupsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', '
scope.$emit('CancelUpdate', url);
} else {
Wait('stop');
Alert('Cancel Inventory Sync', 'Either you do not have access or the sync process completed.<br /> ' +
'Click the <i class="fa fa-refresh fa-lg"></i> button to view the latest status.', 'alert-info');
Alert('Cancel Inventory Sync', 'The sync process completed. Click the <i class="fa fa-refresh fa-lg"></i> button to view ' +
'the latest status.', 'alert-info');
}
})
.error(function (data, status) {
@ -308,11 +308,13 @@ angular.module('GroupsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', '
});
// Cancel the update process
group = Find({ list: scope.groups, key: 'id', val: id });
scope.selected_tree_id = group.id;
scope.selected_group_id = group.group_id;
if (Empty(group)) {
group = Find({ list: scope.groups, key: 'id', val: id });
scope.selected_tree_id = group.id;
scope.selected_group_id = group.group_id;
}
if (group && (group.status === 'updating' || group.status === 'pending')) {
if (group && (group.status === 'running' || group.status === 'pending')) {
// We found the group, and there is a running update
Wait('start');
Rest.setUrl(group.related.inventory_source);

View File

@ -214,7 +214,7 @@ function(Wait, GetBasePath, LookUpInit, JobTemplateForm, CredentialList) {
scope.removePlaybookLaunchFinished = scope.$on('PlaybookLaunchFinished', function() {
var base = $location.path().replace(/^\//, '').split('/')[0];
if (base === 'jobs') {
scope.refresh();
scope.refreshJobs();
} else {
$location.path('/jobs');
}
@ -279,7 +279,7 @@ function(Wait, GetBasePath, LookUpInit, JobTemplateForm, CredentialList) {
])
// Sumbit SCM Update request
// Submit SCM Update request
.factory('ProjectUpdate', ['PromptForPasswords', 'LaunchJob', 'Rest', '$location', 'GetBasePath', 'ProcessErrors', 'Alert',
'ProjectsForm', 'Wait',
function (PromptForPasswords, LaunchJob, Rest, $location, GetBasePath, ProcessErrors, Alert, ProjectsForm, Wait) {
@ -357,6 +357,7 @@ function(Wait, GetBasePath, LookUpInit, JobTemplateForm, CredentialList) {
url = params.url,
group_id = params.group_id,
tree_id = params.tree_id,
base = $location.path().replace(/^\//, '').split('/')[0],
inventory_source;
if (scope.removeHostReloadComplete) {
@ -376,7 +377,10 @@ function(Wait, GetBasePath, LookUpInit, JobTemplateForm, CredentialList) {
}
scope.removeUpdateSubmitted = scope.$on('UpdateSubmitted', function () {
setTimeout(function() {
if (scope.refreshGroups) {
if (base === 'jobs') {
scope.refreshJobs();
}
else if (scope.refreshGroups) {
scope.selected_tree_id = tree_id;
scope.selected_group_id = group_id;
scope.refreshGroups();
@ -384,7 +388,7 @@ function(Wait, GetBasePath, LookUpInit, JobTemplateForm, CredentialList) {
scope.refresh();
}
scope.$emit('HostReloadComplete');
}, 2000);
}, 300);
});
if (scope.removePromptForPasswords) {

View File

@ -384,8 +384,8 @@ angular.module('JobsHelper', ['Utilities', 'RestServices', 'FormGenerator', 'Job
};
}])
.factory('DeleteJob', ['Find', 'GetBasePath', 'Rest', 'Wait', 'ProcessErrors', 'Prompt',
function(Find, GetBasePath, Rest, Wait, ProcessErrors, Prompt){
.factory('DeleteJob', ['Find', 'GetBasePath', 'Rest', 'Wait', 'ProcessErrors', 'Prompt', 'Alert',
function(Find, GetBasePath, Rest, Wait, ProcessErrors, Prompt, Alert){
return function(params) {
var scope = params.scope,
@ -441,12 +441,45 @@ function(Find, GetBasePath, Rest, Wait, ProcessErrors, Prompt){
}
};
Prompt({
hdr: hdr,
body: "<div class=\"alert alert-info\">Are you sure you want to " + action_label + " job " + id + " <em>" + job.name + "</em>?</div>",
action: action
if (scope.removeCancelNotAllowed) {
scope.removeCancelNotAllowed();
}
scope.removeCancelNotAllowed = scope.$on('CancelNotAllowed', function() {
Alert('Job Completed', 'The job completed. Click the <i class="fa fa-refresh fa-lg"></i> button to view ' +
'the latest status.', 'alert-info');
});
if (scope.removeCancelJob) {
scope.removeCancelJob();
}
scope.removeCancelJob = scope.$on('CancelJob', function() {
Prompt({
hdr: hdr,
body: "<div class=\"alert alert-info\">Submit the request to " + action_label + " job #" + id + " " + job.name + "?</div>",
action: action
});
});
if (action_label === 'cancel') {
Rest.setUrl(url);
Rest.get()
.success(function(data) {
if (data.can_cancel) {
scope.$emit('CancelJob');
}
else {
scope.$emit('CancelNotAllowed');
}
})
.error(function(data, status) {
ProcessErrors(scope, data, status, null, { hdr: 'Error!', msg: 'Call to ' + url +
' failed. GET returned: ' + status });
});
}
else {
scope.$emit('CancelJob');
}
};
}])

View File

@ -184,6 +184,7 @@ angular.module('LogViewerHelper', ['ModalDialog', 'Utilities', 'FormGenerator',
callback: 'ModalReady',
id: 'logviewer-modal-dialog',
onResizeStop: resizeText,
title: 'Job Results',
onOpen: function() {
$('#logview-tabs a:first').tab('show');
$('#dialog-ok-button').focus();

View File

@ -89,18 +89,20 @@ angular.module('ModalDialog', ['Utilities', 'ParseHelper'])
// Fix the close button
$('.ui-dialog[aria-describedby="' + id + '"]').find('.ui-dialog-titlebar button').empty().attr({'class': 'close'}).text('x');
// Make buttons bootstrapy
$('.ui-dialog[aria-describedby="' + id + '"]').find('.ui-dialog-buttonset button').each(function () {
var txt = $(this).text(), self = $(this);
buttonSet.forEach(function(btn) {
if (txt === btn.label) {
self.attr({ "class": btn['class'], "id": btn.id });
if (btn.icon) {
self.empty().html('<i class="fa ' + btn.icon + '"></i> ' + btn.label);
setTimeout(function() {
// Make buttons bootstrapy
$('.ui-dialog[aria-describedby="' + id + '"]').find('.ui-dialog-buttonset button').each(function () {
var txt = $(this).text(), self = $(this);
buttonSet.forEach(function(btn) {
if (txt === btn.label) {
self.attr({ "class": btn['class'], "id": btn.id });
if (btn.icon) {
self.empty().html('<i class="fa ' + btn.icon + '"></i> ' + btn.label);
}
}
}
});
});
});
}, 300);
setTimeout(function() {
scope.$apply(function() {