Hold off on refreshing lists when ws-jobs events come in and the launch modal is open to prevent the modal from getting wiped

This commit is contained in:
mabashian 2018-04-25 10:50:09 -04:00
parent c966492222
commit ea80fb8497
5 changed files with 106 additions and 37 deletions

View File

@ -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 = [

View File

@ -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');

View File

@ -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 => {

View File

@ -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 });
});
}
}
];

View File

@ -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, {