diff --git a/awx/ui/client/features/jobs/jobsList.controller.js b/awx/ui/client/features/jobs/jobsList.controller.js index 6715c84e99..4959d41b5e 100644 --- a/awx/ui/client/features/jobs/jobsList.controller.js +++ b/awx/ui/client/features/jobs/jobsList.controller.js @@ -29,6 +29,9 @@ function ListJobsController ( const iterator = 'job'; const key = 'job_dataset'; + let launchModalOpen = false; + let refreshAfterLaunchClose = false; + $scope.list = { iterator, name }; $scope.collection = { iterator, basePath: 'unified_jobs' }; $scope[key] = Dataset.data; @@ -38,10 +41,20 @@ function ListJobsController ( $scope[name] = dataset.results; }); $scope.$on('ws-jobs', () => { - qs.search(unifiedJob.path, $state.params.job_search) - .then(({ data }) => { - $scope.$emit('updateDataset', data); - }); + if (!launchModalOpen) { + refreshJobs(); + } else { + refreshAfterLaunchClose = true; + } + }); + + $scope.$on('launchModalOpen', (evt, isOpen) => { + evt.stopPropagation(); + if (!isOpen && refreshAfterLaunchClose) { + refreshAfterLaunchClose = false; + refreshJobs(); + } + launchModalOpen = isOpen; }); if ($state.includes('instanceGroups')) { @@ -164,6 +177,13 @@ function ListJobsController ( actionText: strings.get('CANCEL') }); }; + + function refreshJobs () { + qs.search(unifiedJob.path, $state.params.job_search) + .then(({ data }) => { + $scope.$emit('updateDataset', data); + }); + } } ListJobsController.$inject = [ diff --git a/awx/ui/client/features/templates/templatesList.controller.js b/awx/ui/client/features/templates/templatesList.controller.js index 0253fabdb0..6ab8712e40 100644 --- a/awx/ui/client/features/templates/templatesList.controller.js +++ b/awx/ui/client/features/templates/templatesList.controller.js @@ -30,6 +30,9 @@ function ListTemplatesController( const choices = workflowTemplate.options('actions.GET.type.choices') .concat(jobTemplate.options('actions.GET.type.choices')); + let launchModalOpen = false; + let refreshAfterLaunchClose = false; + vm.strings = strings; vm.templateTypes = mapChoices(choices); vm.activeId = parseInt($state.params.job_template_id || $state.params.workflow_template_id); @@ -48,7 +51,7 @@ function ListTemplatesController( $scope.canAdd = ($scope.canAddJobTemplate || $scope.canAddWorkflowJobTemplate); // smart-search - $scope.list = { + $scope.list = { iterator: 'template', name: 'templates' }; @@ -64,12 +67,20 @@ function ListTemplatesController( }); $scope.$on(`ws-jobs`, () => { - let path = GetBasePath('unified_job_templates'); - qs.search(path, $state.params.template_search) - .then(function(searchResponse) { - $scope.template_dataset = searchResponse.data; - $scope.templates = $scope.template_dataset.results; - }); + if (!launchModalOpen) { + refreshTemplates(); + } else { + refreshAfterLaunchClose = true; + } + }); + + $scope.$on('launchModalOpen', (evt, isOpen) => { + evt.stopPropagation(); + if (!isOpen && refreshAfterLaunchClose) { + refreshAfterLaunchClose = false; + refreshTemplates(); + } + launchModalOpen = isOpen; }); vm.isInvalid = (template) => { @@ -163,6 +174,15 @@ function ListTemplatesController( return html; }; + function refreshTemplates() { + let path = GetBasePath('unified_job_templates'); + qs.search(path, $state.params.template_search) + .then(function(searchResponse) { + $scope.template_dataset = searchResponse.data; + $scope.templates = $scope.template_dataset.results; + }); + } + function createErrorHandler(path, action) { return ({ data, status }) => { const hdr = strings.get('error.HEADER'); diff --git a/awx/ui/client/lib/components/modal/modal.directive.js b/awx/ui/client/lib/components/modal/modal.directive.js index f3def99885..3f77d374e7 100644 --- a/awx/ui/client/lib/components/modal/modal.directive.js +++ b/awx/ui/client/lib/components/modal/modal.directive.js @@ -26,6 +26,7 @@ function AtModalController ($timeout, eventService, strings) { vm.modal = scope[scope.ns].modal; vm.modal.show = vm.show; vm.modal.hide = vm.hide; + vm.modal.onClose = scope.onClose; }; vm.show = (title, message) => { @@ -48,6 +49,10 @@ function AtModalController ($timeout, eventService, strings) { setTimeout(() => { overlay.style.display = 'none'; }, DEFAULT_ANIMATION_DURATION); + + if (vm.modal.onClose) { + vm.modal.onClose(); + } }; vm.clickToHide = event => { diff --git a/awx/ui/client/src/home/home.controller.js b/awx/ui/client/src/home/home.controller.js index 42ec5ec5b0..17b6d4e314 100644 --- a/awx/ui/client/src/home/home.controller.js +++ b/awx/ui/client/src/home/home.controller.js @@ -10,35 +10,24 @@ export default ['$scope', '$rootScope','Wait', Rest, GetBasePath, ProcessErrors, graphData) { var dataCount = 0; + let launchModalOpen = false; + let refreshAfterLaunchClose = false; $scope.$on('ws-jobs', function () { - Rest.setUrl(GetBasePath('dashboard')); - Rest.get() - .then(({data}) => { - $scope.dashboardData = data; - }) - .catch(({data, status}) => { - ProcessErrors($scope, data, status, null, { hdr: 'Error!', msg: 'Failed to get dashboard host graph data: ' + status }); - }); - - Rest.setUrl(GetBasePath("unified_jobs") + "?order_by=-finished&page_size=5&finished__isnull=false&type=workflow_job,job"); - Rest.get() - .then(({data}) => { - $scope.dashboardJobsListData = data.results; - }) - .catch(({data, status}) => { - ProcessErrors($scope, data, status, null, { hdr: 'Error!', msg: 'Failed to get dashboard jobs list: ' + status }); - }); - - Rest.setUrl(GetBasePath("unified_job_templates") + "?order_by=-last_job_run&page_size=5&last_job_run__isnull=false&type=workflow_job_template,job_template"); - Rest.get() - .then(({data}) => { - $scope.dashboardJobTemplatesListData = data.results; - }) - .catch(({data, status}) => { - ProcessErrors($scope, data, status, null, { hdr: 'Error!', msg: 'Failed to get dashboard jobs list: ' + status }); - }); + if (!launchModalOpen) { + refreshLists(); + } else { + refreshAfterLaunchClose = true; + } + }); + $scope.$on('launchModalOpen', (evt, isOpen) => { + evt.stopPropagation(); + if (!isOpen && refreshAfterLaunchClose) { + refreshAfterLaunchClose = false; + refreshLists(); + } + launchModalOpen = isOpen; }); if ($scope.removeDashboardDataLoadComplete) { @@ -119,5 +108,34 @@ export default ['$scope', '$rootScope','Wait', $scope.refresh(); + function refreshLists () { + Rest.setUrl(GetBasePath('dashboard')); + Rest.get() + .then(({data}) => { + $scope.dashboardData = data; + }) + .catch(({data, status}) => { + ProcessErrors($scope, data, status, null, { hdr: 'Error!', msg: 'Failed to get dashboard host graph data: ' + status }); + }); + + Rest.setUrl(GetBasePath("unified_jobs") + "?order_by=-finished&page_size=5&finished__isnull=false&type=workflow_job,job"); + Rest.get() + .then(({data}) => { + $scope.dashboardJobsListData = data.results; + }) + .catch(({data, status}) => { + ProcessErrors($scope, data, status, null, { hdr: 'Error!', msg: 'Failed to get dashboard jobs list: ' + status }); + }); + + Rest.setUrl(GetBasePath("unified_job_templates") + "?order_by=-last_job_run&page_size=5&last_job_run__isnull=false&type=workflow_job_template,job_template"); + Rest.get() + .then(({data}) => { + $scope.dashboardJobTemplatesListData = data.results; + }) + .catch(({data, status}) => { + ProcessErrors($scope, data, status, null, { hdr: 'Error!', msg: 'Failed to get dashboard jobs list: ' + status }); + }); + } + } ]; diff --git a/awx/ui/client/src/templates/prompt/prompt.controller.js b/awx/ui/client/src/templates/prompt/prompt.controller.js index 5b6f035dd5..12c1760195 100644 --- a/awx/ui/client/src/templates/prompt/prompt.controller.js +++ b/awx/ui/client/src/templates/prompt/prompt.controller.js @@ -140,6 +140,12 @@ export default [ 'Rest', 'GetBasePath', 'ProcessErrors', 'CredentialTypeModel', vm.steps.preview.tab.order = order; modal.show('PROMPT'); vm.promptData.triggerModalOpen = false; + + modal.onClose = () => { + scope.$emit('launchModalOpen', false); + }; + + scope.$emit('launchModalOpen', true); }) .catch(({data, status}) => { ProcessErrors(scope, data, status, null, {