mirror of
https://github.com/ansible/awx.git
synced 2026-01-11 18:09:57 -03:30
Merge pull request #1564 from mabashian/1444-prompt-socket-v2
Hold off on refreshing lists when launch prompt modal is open
This commit is contained in:
commit
8f6bb15acf
@ -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 = [
|
||||
|
||||
@ -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');
|
||||
|
||||
@ -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 => {
|
||||
|
||||
@ -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 });
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
];
|
||||
|
||||
@ -173,6 +173,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, {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user