mirror of
https://github.com/ansible/awx.git
synced 2026-02-22 21:46:00 -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:
@@ -29,6 +29,9 @@ function ListJobsController (
|
|||||||
const iterator = 'job';
|
const iterator = 'job';
|
||||||
const key = 'job_dataset';
|
const key = 'job_dataset';
|
||||||
|
|
||||||
|
let launchModalOpen = false;
|
||||||
|
let refreshAfterLaunchClose = false;
|
||||||
|
|
||||||
$scope.list = { iterator, name };
|
$scope.list = { iterator, name };
|
||||||
$scope.collection = { iterator, basePath: 'unified_jobs' };
|
$scope.collection = { iterator, basePath: 'unified_jobs' };
|
||||||
$scope[key] = Dataset.data;
|
$scope[key] = Dataset.data;
|
||||||
@@ -38,10 +41,20 @@ function ListJobsController (
|
|||||||
$scope[name] = dataset.results;
|
$scope[name] = dataset.results;
|
||||||
});
|
});
|
||||||
$scope.$on('ws-jobs', () => {
|
$scope.$on('ws-jobs', () => {
|
||||||
qs.search(unifiedJob.path, $state.params.job_search)
|
if (!launchModalOpen) {
|
||||||
.then(({ data }) => {
|
refreshJobs();
|
||||||
$scope.$emit('updateDataset', data);
|
} else {
|
||||||
});
|
refreshAfterLaunchClose = true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
$scope.$on('launchModalOpen', (evt, isOpen) => {
|
||||||
|
evt.stopPropagation();
|
||||||
|
if (!isOpen && refreshAfterLaunchClose) {
|
||||||
|
refreshAfterLaunchClose = false;
|
||||||
|
refreshJobs();
|
||||||
|
}
|
||||||
|
launchModalOpen = isOpen;
|
||||||
});
|
});
|
||||||
|
|
||||||
if ($state.includes('instanceGroups')) {
|
if ($state.includes('instanceGroups')) {
|
||||||
@@ -164,6 +177,13 @@ function ListJobsController (
|
|||||||
actionText: strings.get('CANCEL')
|
actionText: strings.get('CANCEL')
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function refreshJobs () {
|
||||||
|
qs.search(unifiedJob.path, $state.params.job_search)
|
||||||
|
.then(({ data }) => {
|
||||||
|
$scope.$emit('updateDataset', data);
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ListJobsController.$inject = [
|
ListJobsController.$inject = [
|
||||||
|
|||||||
@@ -30,6 +30,9 @@ function ListTemplatesController(
|
|||||||
const choices = workflowTemplate.options('actions.GET.type.choices')
|
const choices = workflowTemplate.options('actions.GET.type.choices')
|
||||||
.concat(jobTemplate.options('actions.GET.type.choices'));
|
.concat(jobTemplate.options('actions.GET.type.choices'));
|
||||||
|
|
||||||
|
let launchModalOpen = false;
|
||||||
|
let refreshAfterLaunchClose = false;
|
||||||
|
|
||||||
vm.strings = strings;
|
vm.strings = strings;
|
||||||
vm.templateTypes = mapChoices(choices);
|
vm.templateTypes = mapChoices(choices);
|
||||||
vm.activeId = parseInt($state.params.job_template_id || $state.params.workflow_template_id);
|
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);
|
$scope.canAdd = ($scope.canAddJobTemplate || $scope.canAddWorkflowJobTemplate);
|
||||||
|
|
||||||
// smart-search
|
// smart-search
|
||||||
$scope.list = {
|
$scope.list = {
|
||||||
iterator: 'template',
|
iterator: 'template',
|
||||||
name: 'templates'
|
name: 'templates'
|
||||||
};
|
};
|
||||||
@@ -64,12 +67,20 @@ function ListTemplatesController(
|
|||||||
});
|
});
|
||||||
|
|
||||||
$scope.$on(`ws-jobs`, () => {
|
$scope.$on(`ws-jobs`, () => {
|
||||||
let path = GetBasePath('unified_job_templates');
|
if (!launchModalOpen) {
|
||||||
qs.search(path, $state.params.template_search)
|
refreshTemplates();
|
||||||
.then(function(searchResponse) {
|
} else {
|
||||||
$scope.template_dataset = searchResponse.data;
|
refreshAfterLaunchClose = true;
|
||||||
$scope.templates = $scope.template_dataset.results;
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$scope.$on('launchModalOpen', (evt, isOpen) => {
|
||||||
|
evt.stopPropagation();
|
||||||
|
if (!isOpen && refreshAfterLaunchClose) {
|
||||||
|
refreshAfterLaunchClose = false;
|
||||||
|
refreshTemplates();
|
||||||
|
}
|
||||||
|
launchModalOpen = isOpen;
|
||||||
});
|
});
|
||||||
|
|
||||||
vm.isInvalid = (template) => {
|
vm.isInvalid = (template) => {
|
||||||
@@ -163,6 +174,15 @@ function ListTemplatesController(
|
|||||||
return html;
|
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) {
|
function createErrorHandler(path, action) {
|
||||||
return ({ data, status }) => {
|
return ({ data, status }) => {
|
||||||
const hdr = strings.get('error.HEADER');
|
const hdr = strings.get('error.HEADER');
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ function AtModalController ($timeout, eventService, strings) {
|
|||||||
vm.modal = scope[scope.ns].modal;
|
vm.modal = scope[scope.ns].modal;
|
||||||
vm.modal.show = vm.show;
|
vm.modal.show = vm.show;
|
||||||
vm.modal.hide = vm.hide;
|
vm.modal.hide = vm.hide;
|
||||||
|
vm.modal.onClose = scope.onClose;
|
||||||
};
|
};
|
||||||
|
|
||||||
vm.show = (title, message) => {
|
vm.show = (title, message) => {
|
||||||
@@ -48,6 +49,10 @@ function AtModalController ($timeout, eventService, strings) {
|
|||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
overlay.style.display = 'none';
|
overlay.style.display = 'none';
|
||||||
}, DEFAULT_ANIMATION_DURATION);
|
}, DEFAULT_ANIMATION_DURATION);
|
||||||
|
|
||||||
|
if (vm.modal.onClose) {
|
||||||
|
vm.modal.onClose();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
vm.clickToHide = event => {
|
vm.clickToHide = event => {
|
||||||
|
|||||||
@@ -10,35 +10,24 @@ export default ['$scope', '$rootScope','Wait',
|
|||||||
Rest, GetBasePath, ProcessErrors, graphData) {
|
Rest, GetBasePath, ProcessErrors, graphData) {
|
||||||
|
|
||||||
var dataCount = 0;
|
var dataCount = 0;
|
||||||
|
let launchModalOpen = false;
|
||||||
|
let refreshAfterLaunchClose = false;
|
||||||
|
|
||||||
$scope.$on('ws-jobs', function () {
|
$scope.$on('ws-jobs', function () {
|
||||||
Rest.setUrl(GetBasePath('dashboard'));
|
if (!launchModalOpen) {
|
||||||
Rest.get()
|
refreshLists();
|
||||||
.then(({data}) => {
|
} else {
|
||||||
$scope.dashboardData = data;
|
refreshAfterLaunchClose = true;
|
||||||
})
|
}
|
||||||
.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 });
|
|
||||||
});
|
|
||||||
|
|
||||||
|
$scope.$on('launchModalOpen', (evt, isOpen) => {
|
||||||
|
evt.stopPropagation();
|
||||||
|
if (!isOpen && refreshAfterLaunchClose) {
|
||||||
|
refreshAfterLaunchClose = false;
|
||||||
|
refreshLists();
|
||||||
|
}
|
||||||
|
launchModalOpen = isOpen;
|
||||||
});
|
});
|
||||||
|
|
||||||
if ($scope.removeDashboardDataLoadComplete) {
|
if ($scope.removeDashboardDataLoadComplete) {
|
||||||
@@ -119,5 +108,34 @@ export default ['$scope', '$rootScope','Wait',
|
|||||||
|
|
||||||
$scope.refresh();
|
$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;
|
vm.steps.preview.tab.order = order;
|
||||||
modal.show('PROMPT');
|
modal.show('PROMPT');
|
||||||
vm.promptData.triggerModalOpen = false;
|
vm.promptData.triggerModalOpen = false;
|
||||||
|
|
||||||
|
modal.onClose = () => {
|
||||||
|
scope.$emit('launchModalOpen', false);
|
||||||
|
};
|
||||||
|
|
||||||
|
scope.$emit('launchModalOpen', true);
|
||||||
})
|
})
|
||||||
.catch(({data, status}) => {
|
.catch(({data, status}) => {
|
||||||
ProcessErrors(scope, data, status, null, {
|
ProcessErrors(scope, data, status, null, {
|
||||||
|
|||||||
Reference in New Issue
Block a user