diff --git a/awx/ui/static/js/controllers/Home.js b/awx/ui/static/js/controllers/Home.js index 87ec893b1b..a37914892f 100644 --- a/awx/ui/static/js/controllers/Home.js +++ b/awx/ui/static/js/controllers/Home.js @@ -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' ]; diff --git a/awx/ui/static/js/controllers/Inventories.js b/awx/ui/static/js/controllers/Inventories.js index cb9f16478c..d294d66842 100644 --- a/awx/ui/static/js/controllers/Inventories.js +++ b/awx/ui/static/js/controllers/Inventories.js @@ -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) { diff --git a/awx/ui/static/js/helpers/Groups.js b/awx/ui/static/js/helpers/Groups.js index 7898372d5a..b31c3d1abc 100644 --- a/awx/ui/static/js/helpers/Groups.js +++ b/awx/ui/static/js/helpers/Groups.js @@ -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 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.
' + - 'Click the button to view the latest status.', 'alert-info'); + Alert('Cancel Inventory Sync', 'The sync process completed. Click the 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); diff --git a/awx/ui/static/js/helpers/JobSubmission.js b/awx/ui/static/js/helpers/JobSubmission.js index e9fd445d23..3a6cc4c1f9 100644 --- a/awx/ui/static/js/helpers/JobSubmission.js +++ b/awx/ui/static/js/helpers/JobSubmission.js @@ -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) { diff --git a/awx/ui/static/js/helpers/Jobs.js b/awx/ui/static/js/helpers/Jobs.js index 14ea1bf153..4f06d1e506 100644 --- a/awx/ui/static/js/helpers/Jobs.js +++ b/awx/ui/static/js/helpers/Jobs.js @@ -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: "
Are you sure you want to " + action_label + " job " + id + " " + job.name + "?
", - action: action + if (scope.removeCancelNotAllowed) { + scope.removeCancelNotAllowed(); + } + scope.removeCancelNotAllowed = scope.$on('CancelNotAllowed', function() { + Alert('Job Completed', 'The job completed. Click the button to view ' + + 'the latest status.', 'alert-info'); }); + if (scope.removeCancelJob) { + scope.removeCancelJob(); + } + scope.removeCancelJob = scope.$on('CancelJob', function() { + Prompt({ + hdr: hdr, + body: "
Submit the request to " + action_label + " job #" + id + " " + job.name + "?
", + 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'); + } + }; }]) diff --git a/awx/ui/static/js/helpers/LogViewer.js b/awx/ui/static/js/helpers/LogViewer.js index f7c324f5cc..f72931b363 100644 --- a/awx/ui/static/js/helpers/LogViewer.js +++ b/awx/ui/static/js/helpers/LogViewer.js @@ -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(); diff --git a/awx/ui/static/lib/ansible/Modal.js b/awx/ui/static/lib/ansible/Modal.js index 61d50fb1c7..66f680e445 100644 --- a/awx/ui/static/lib/ansible/Modal.js +++ b/awx/ui/static/lib/ansible/Modal.js @@ -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(' ' + 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(' ' + btn.label); + } } - } + }); }); - }); + }, 300); setTimeout(function() { scope.$apply(function() {