mirror of
https://github.com/ansible/awx.git
synced 2026-02-22 05:30:18 -03:30
adding post-processing for jobs list
This commit is contained in:
@@ -13,7 +13,7 @@
|
|||||||
|
|
||||||
|
|
||||||
export function JobsListController($state, $rootScope, $log, $scope, $compile, $stateParams,
|
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();
|
ClearScope();
|
||||||
|
|
||||||
@@ -29,39 +29,68 @@ export function JobsListController($state, $rootScope, $log, $scope, $compile, $
|
|||||||
|
|
||||||
$scope.showJobType = true;
|
$scope.showJobType = true;
|
||||||
|
|
||||||
_.forEach($scope[list.name], buildTooltips);
|
// _.forEach($scope[list.name], buildTooltips);
|
||||||
if ($scope.removeChoicesReady) {
|
// if ($scope.removeChoicesReady) {
|
||||||
$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];
|
// iterate over the list and add fields like type label, after the
|
||||||
if(item.summary_fields && item.summary_fields.source_workflow_job &&
|
// OPTIONS request returns, or the list is sorted/paginated/searched
|
||||||
item.summary_fields.source_workflow_job.id){
|
function optionsRequestDataProcessing(){
|
||||||
item.workflow_result_link = `/#/workflows/${item.summary_fields.source_workflow_job.id}`;
|
|
||||||
}
|
$scope[list.name].forEach(function(item, item_idx) {
|
||||||
// Set the item type label
|
var itm = $scope[list.name][item_idx];
|
||||||
if (list.fields.type) {
|
|
||||||
$scope.type_choices.every(function(choice) {
|
if(item.summary_fields && item.summary_fields.source_workflow_job &&
|
||||||
if (choice.value === item.type) {
|
item.summary_fields.source_workflow_job.id){
|
||||||
itm.type_label = choice.label;
|
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 false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
buildTooltips(itm);
|
||||||
});
|
|
||||||
|
|
||||||
GetChoices({
|
|
||||||
scope: $scope,
|
|
||||||
url: GetBasePath('unified_jobs'),
|
|
||||||
field: 'type',
|
|
||||||
variable: 'type_choices',
|
|
||||||
callback: 'choicesReady'
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function buildTooltips(job) {
|
function buildTooltips(job) {
|
||||||
job.status_tip = 'Job ' + job.status + ". Click for details.";
|
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',
|
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);
|
_.forEach($scope[list.name], buildTooltips);
|
||||||
$rootScope.flashMessage = null;
|
$rootScope.flashMessage = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
$scope.$on(`${list.iterator}_options`, function(event, data){
|
$scope.$on(`${list.iterator}_options`, function(event, data){
|
||||||
$scope.options = data.data.actions.GET;
|
$scope.options = data.data.actions.GET;
|
||||||
optionsRequestDataProcessing();
|
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) {
|
function buildTooltips(project) {
|
||||||
project.statusIcon = GetProjectIcon(project.status);
|
project.statusIcon = GetProjectIcon(project.status);
|
||||||
|
|||||||
Reference in New Issue
Block a user