mirror of
https://github.com/ansible/awx.git
synced 2024-11-01 08:21:15 +03:00
adding post-processing for jobs list
This commit is contained in:
parent
9e3b5abc37
commit
db4bb50976
@ -13,7 +13,7 @@
|
||||
|
||||
|
||||
export function JobsListController($state, $rootScope, $log, $scope, $compile, $stateParams,
|
||||
ClearScope, Find, DeleteJob, RelaunchJob, AllJobsList, ScheduledJobsList, GetBasePath, Dataset, GetChoices) {
|
||||
ClearScope, Find, DeleteJob, RelaunchJob, AllJobsList, ScheduledJobsList, GetBasePath, Dataset) {
|
||||
|
||||
ClearScope();
|
||||
|
||||
@ -29,39 +29,68 @@ export function JobsListController($state, $rootScope, $log, $scope, $compile, $
|
||||
|
||||
$scope.showJobType = true;
|
||||
|
||||
_.forEach($scope[list.name], buildTooltips);
|
||||
if ($scope.removeChoicesReady) {
|
||||
$scope.removeChoicesReady();
|
||||
// _.forEach($scope[list.name], buildTooltips);
|
||||
// if ($scope.removeChoicesReady) {
|
||||
// $scope.removeChoicesReady();
|
||||
// }
|
||||
// $scope.removeChoicesReady = $scope.$on('choicesReady', function() {
|
||||
// $scope[list.name].forEach(function(item, item_idx) {
|
||||
// var itm = $scope[list.name][item_idx];
|
||||
// if(item.summary_fields && item.summary_fields.source_workflow_job &&
|
||||
// item.summary_fields.source_workflow_job.id){
|
||||
// item.workflow_result_link = `/#/workflows/${item.summary_fields.source_workflow_job.id}`;
|
||||
// }
|
||||
// // Set the item type label
|
||||
// if (list.fields.type) {
|
||||
// $scope.type_choices.every(function(choice) {
|
||||
// if (choice.value === item.type) {
|
||||
// itm.type_label = choice.label;
|
||||
// return false;
|
||||
// }
|
||||
// return true;
|
||||
// });
|
||||
// }
|
||||
// });
|
||||
// });
|
||||
|
||||
|
||||
}
|
||||
$scope.$on(`${list.iterator}_options`, function(event, data){
|
||||
$scope.options = data.data.actions.GET;
|
||||
optionsRequestDataProcessing();
|
||||
});
|
||||
|
||||
$scope.$watchCollection(`${$scope.list.name}`, function() {
|
||||
optionsRequestDataProcessing();
|
||||
}
|
||||
$scope.removeChoicesReady = $scope.$on('choicesReady', function() {
|
||||
$scope[list.name].forEach(function(item, item_idx) {
|
||||
var itm = $scope[list.name][item_idx];
|
||||
if(item.summary_fields && item.summary_fields.source_workflow_job &&
|
||||
item.summary_fields.source_workflow_job.id){
|
||||
item.workflow_result_link = `/#/workflows/${item.summary_fields.source_workflow_job.id}`;
|
||||
}
|
||||
// Set the item type label
|
||||
if (list.fields.type) {
|
||||
$scope.type_choices.every(function(choice) {
|
||||
if (choice.value === item.type) {
|
||||
itm.type_label = choice.label;
|
||||
);
|
||||
|
||||
// iterate over the list and add fields like type label, after the
|
||||
// OPTIONS request returns, or the list is sorted/paginated/searched
|
||||
function optionsRequestDataProcessing(){
|
||||
|
||||
$scope[list.name].forEach(function(item, item_idx) {
|
||||
var itm = $scope[list.name][item_idx];
|
||||
|
||||
if(item.summary_fields && item.summary_fields.source_workflow_job &&
|
||||
item.summary_fields.source_workflow_job.id){
|
||||
item.workflow_result_link = `/#/workflows/${item.summary_fields.source_workflow_job.id}`;
|
||||
}
|
||||
|
||||
// Set the item type label
|
||||
if (list.fields.type && $scope.options &&
|
||||
$scope.options.hasOwnProperty('type')) {
|
||||
$scope.options.type.choices.every(function(choice) {
|
||||
if (choice[0] === item.type) {
|
||||
itm.type_label = choice[1];
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
GetChoices({
|
||||
scope: $scope,
|
||||
url: GetBasePath('unified_jobs'),
|
||||
field: 'type',
|
||||
variable: 'type_choices',
|
||||
callback: 'choicesReady'
|
||||
buildTooltips(itm);
|
||||
});
|
||||
}
|
||||
|
||||
function buildTooltips(job) {
|
||||
job.status_tip = 'Job ' + job.status + ". Click for details.";
|
||||
}
|
||||
@ -131,5 +160,5 @@ export function JobsListController($state, $rootScope, $log, $scope, $compile, $
|
||||
}
|
||||
|
||||
JobsListController.$inject = ['$state', '$rootScope', '$log', '$scope', '$compile', '$stateParams',
|
||||
'ClearScope', 'Find', 'DeleteJob', 'RelaunchJob', 'AllJobsList', 'ScheduledJobsList', 'GetBasePath', 'Dataset', 'GetChoices'
|
||||
'ClearScope', 'Find', 'DeleteJob', 'RelaunchJob', 'AllJobsList', 'ScheduledJobsList', 'GetBasePath', 'Dataset'
|
||||
];
|
||||
|
@ -37,7 +37,7 @@ export function ProjectsList($scope, $rootScope, $location, $log, $stateParams,
|
||||
_.forEach($scope[list.name], buildTooltips);
|
||||
$rootScope.flashMessage = null;
|
||||
}
|
||||
|
||||
|
||||
$scope.$on(`${list.iterator}_options`, function(event, data){
|
||||
$scope.options = data.data.actions.GET;
|
||||
optionsRequestDataProcessing();
|
||||
@ -66,13 +66,10 @@ export function ProjectsList($scope, $rootScope, $location, $log, $stateParams,
|
||||
});
|
||||
}
|
||||
|
||||
_.forEach($scope[list.name], buildTooltips);
|
||||
buildTooltips(itm);
|
||||
|
||||
});
|
||||
}
|
||||
// $scope.$watch(`${list.name}`, function() {
|
||||
// _.forEach($scope[list.name], buildTooltips);
|
||||
// });
|
||||
|
||||
function buildTooltips(project) {
|
||||
project.statusIcon = GetProjectIcon(project.status);
|
||||
|
Loading…
Reference in New Issue
Block a user