mirror of
https://github.com/ansible/awx.git
synced 2026-01-14 19:30:39 -03:30
post processing for scheduled jobs list
This commit is contained in:
parent
817a572674
commit
b78ed36abf
@ -65,7 +65,7 @@ GetBasePath, Wait, Find, LoadSchedulesScope, GetChoices) {
|
||||
msg: 'Call to ' + url + ' failed. GET returned: ' + status });
|
||||
});
|
||||
});
|
||||
|
||||
debugger;
|
||||
$scope.refreshJobs = function() {
|
||||
// @issue: OLD SEARCH
|
||||
// $scope.search(SchedulesList.iterator);
|
||||
|
||||
@ -31,8 +31,7 @@ export default
|
||||
name: {
|
||||
label: i18n._('Name'),
|
||||
columnClass: 'col-lg-4 col-md-5 col-sm-5 col-xs-7 List-staticColumnAdjacent',
|
||||
sourceModel: 'unified_job_template',
|
||||
sourceField: 'name',
|
||||
ngBind: 'schedule.summary_fields.unified_job_template.name',
|
||||
ngClick: "editSchedule(schedule)",
|
||||
awToolTip: "{{ schedule.nameTip | sanitize}}",
|
||||
dataTipWatch: 'schedule.nameTip',
|
||||
|
||||
@ -45,7 +45,19 @@ export default
|
||||
let path = `${GetBasePath('job_templates')}${$stateParams.id}`;
|
||||
Rest.setUrl(path);
|
||||
return Rest.get(path).then((res) => res.data);
|
||||
}]
|
||||
}],
|
||||
UnifiedJobsOptions: ['Rest', 'GetBasePath', '$stateParams', '$q',
|
||||
function(Rest, GetBasePath, $stateParams, $q) {
|
||||
Rest.setUrl(GetBasePath('unified_jobs'));
|
||||
var val = $q.defer();
|
||||
Rest.options()
|
||||
.then(function(data) {
|
||||
val.resolve(data.data);
|
||||
}, function(data) {
|
||||
val.reject(data);
|
||||
});
|
||||
return val.promise;
|
||||
}]
|
||||
},
|
||||
views: {
|
||||
'@': {
|
||||
@ -119,7 +131,19 @@ export default
|
||||
let path = `${GetBasePath('workflow_job_templates')}${$stateParams.id}`;
|
||||
Rest.setUrl(path);
|
||||
return Rest.get(path).then((res) => res.data);
|
||||
}]
|
||||
}],
|
||||
UnifiedJobsOptions: ['Rest', 'GetBasePath', '$stateParams', '$q',
|
||||
function(Rest, GetBasePath, $stateParams, $q) {
|
||||
Rest.setUrl(GetBasePath('unified_jobs'));
|
||||
var val = $q.defer();
|
||||
Rest.options()
|
||||
.then(function(data) {
|
||||
val.resolve(data.data);
|
||||
}, function(data) {
|
||||
val.reject(data);
|
||||
});
|
||||
return val.promise;
|
||||
}]
|
||||
},
|
||||
views: {
|
||||
'@': {
|
||||
@ -190,7 +214,19 @@ export default
|
||||
let path = `${GetBasePath('projects')}${$stateParams.id}`;
|
||||
Rest.setUrl(path);
|
||||
return Rest.get(path).then((res) => res.data);
|
||||
}]
|
||||
}],
|
||||
UnifiedJobsOptions: ['Rest', 'GetBasePath', '$stateParams', '$q',
|
||||
function(Rest, GetBasePath, $stateParams, $q) {
|
||||
Rest.setUrl(GetBasePath('unified_jobs'));
|
||||
var val = $q.defer();
|
||||
Rest.options()
|
||||
.then(function(data) {
|
||||
val.resolve(data.data);
|
||||
}, function(data) {
|
||||
val.reject(data);
|
||||
});
|
||||
return val.promise;
|
||||
}]
|
||||
},
|
||||
views: {
|
||||
'@': {
|
||||
@ -268,6 +304,18 @@ export default
|
||||
}
|
||||
],
|
||||
ParentObject: [() =>{return {endpoint:'/api/v1/schedules'}; }],
|
||||
UnifiedJobsOptions: ['Rest', 'GetBasePath', '$stateParams', '$q',
|
||||
function(Rest, GetBasePath, $stateParams, $q) {
|
||||
Rest.setUrl(GetBasePath('unified_jobs'));
|
||||
var val = $q.defer();
|
||||
Rest.options()
|
||||
.then(function(data) {
|
||||
val.resolve(data.data);
|
||||
}, function(data) {
|
||||
val.reject(data);
|
||||
});
|
||||
return val.promise;
|
||||
}]
|
||||
},
|
||||
views: {
|
||||
'list@jobs': {
|
||||
|
||||
@ -14,12 +14,12 @@
|
||||
export default [
|
||||
'$scope', '$compile', '$location', '$stateParams', 'SchedulesList', 'Rest',
|
||||
'ProcessErrors', 'ReturnToCaller', 'ClearScope', 'GetBasePath', 'Wait', 'rbacUiControlService',
|
||||
'Find', 'ToggleSchedule', 'DeleteSchedule', 'GetChoices', '$q', '$state', 'Dataset', 'ParentObject',
|
||||
'Find', 'ToggleSchedule', 'DeleteSchedule', 'GetChoices', '$q', '$state', 'Dataset', 'ParentObject', 'UnifiedJobsOptions',
|
||||
function($scope, $compile, $location, $stateParams,
|
||||
SchedulesList, Rest, ProcessErrors, ReturnToCaller, ClearScope,
|
||||
GetBasePath, Wait, rbacUiControlService, Find,
|
||||
ToggleSchedule, DeleteSchedule, GetChoices,
|
||||
$q, $state, Dataset, ParentObject) {
|
||||
$q, $state, Dataset, ParentObject, UnifiedJobsOptions) {
|
||||
|
||||
ClearScope();
|
||||
|
||||
@ -43,11 +43,45 @@ export default [
|
||||
$scope.list = list;
|
||||
$scope[`${list.iterator}_dataset`] = Dataset.data;
|
||||
$scope[list.name] = $scope[`${list.iterator}_dataset`].results;
|
||||
$scope.unified_job_options = UnifiedJobsOptions.actions.GET;
|
||||
|
||||
_.forEach($scope[list.name], buildTooltips);
|
||||
// _.forEach($scope[list.name], buildTooltips);
|
||||
}
|
||||
|
||||
$scope.$on(`${list.iterator}_options`, function(event, data){
|
||||
$scope.options = data.data.actions.GET;
|
||||
optionsRequestDataProcessing();
|
||||
});
|
||||
|
||||
$scope.$watchCollection(`${$scope.list.name}`, function() {
|
||||
optionsRequestDataProcessing();
|
||||
}
|
||||
);
|
||||
|
||||
// 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];
|
||||
|
||||
// Set the item type label
|
||||
if (list.fields.type && $scope.unified_job_options &&
|
||||
$scope.unified_job_options.hasOwnProperty('type')) {
|
||||
$scope.unified_job_options.type.choices.every(function(choice) {
|
||||
if (choice[0] === itm.summary_fields.unified_job_template.unified_job_type) {
|
||||
itm.type_label = choice[1];
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
});
|
||||
}
|
||||
buildTooltips(itm);
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
function buildTooltips(schedule) {
|
||||
var job = schedule.summary_fields.unified_job_template;
|
||||
if (schedule.enabled) {
|
||||
schedule.play_tip = 'Schedule is active. Click to stop.';
|
||||
schedule.status = 'active';
|
||||
@ -57,6 +91,18 @@ export default [
|
||||
schedule.status = 'stopped';
|
||||
schedule.status_tip = 'Schedule is stopped. Click to activate.';
|
||||
}
|
||||
|
||||
schedule.nameTip = schedule.name;
|
||||
// include the word schedule if the schedule name does not include the word schedule
|
||||
if (schedule.name.indexOf("schedule") === -1 && schedule.name.indexOf("Schedule") === -1) {
|
||||
schedule.nameTip += " schedule";
|
||||
}
|
||||
schedule.nameTip += " for ";
|
||||
if (job.name.indexOf("job") === -1 && job.name.indexOf("Job") === -1) {
|
||||
schedule.nameTip += "job ";
|
||||
}
|
||||
schedule.nameTip += job.name;
|
||||
schedule.nameTip += ". Click to edit schedule.";
|
||||
}
|
||||
|
||||
$scope.refreshSchedules = function() {
|
||||
@ -99,7 +145,7 @@ export default [
|
||||
name: 'projectSchedules.edit',
|
||||
params: {
|
||||
id: schedule.unified_job_template,
|
||||
schedule_id: schedule.id
|
||||
schedule_id: schedule.id
|
||||
}
|
||||
});
|
||||
break;
|
||||
@ -109,7 +155,7 @@ export default [
|
||||
name: 'managementJobSchedules.edit',
|
||||
params: {
|
||||
id: schedule.unified_job_template,
|
||||
schedule_id: schedule.id
|
||||
schedule_id: schedule.id
|
||||
}
|
||||
});
|
||||
break;
|
||||
@ -136,7 +182,7 @@ export default [
|
||||
throw err;
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
@ -160,7 +206,7 @@ export default [
|
||||
};
|
||||
|
||||
base = $location.path().replace(/^\//, '').split('/')[0];
|
||||
|
||||
|
||||
if (base === 'management_jobs') {
|
||||
$scope.base = base = 'system_job_templates';
|
||||
}
|
||||
@ -175,17 +221,5 @@ export default [
|
||||
$scope.formCancel = function() {
|
||||
$state.go('^', null, { reload: true });
|
||||
};
|
||||
|
||||
// @issue - believe this is no longer necessary now that parent object is resolved prior to controller initilizing
|
||||
|
||||
// Wait('start');
|
||||
|
||||
// GetChoices({
|
||||
// scope: $scope,
|
||||
// url: GetBasePath('unified_jobs'), //'/static/sample/data/types/data.json'
|
||||
// field: 'type',
|
||||
// variable: 'type_choices',
|
||||
// callback: 'choicesReady'
|
||||
// });
|
||||
}
|
||||
];
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user