mirror of
https://github.com/ansible/awx.git
synced 2026-05-07 01:17:37 -02:30
post processing for scheduled jobs list
This commit is contained in:
@@ -65,7 +65,7 @@ GetBasePath, Wait, Find, LoadSchedulesScope, GetChoices) {
|
|||||||
msg: 'Call to ' + url + ' failed. GET returned: ' + status });
|
msg: 'Call to ' + url + ' failed. GET returned: ' + status });
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
debugger;
|
||||||
$scope.refreshJobs = function() {
|
$scope.refreshJobs = function() {
|
||||||
// @issue: OLD SEARCH
|
// @issue: OLD SEARCH
|
||||||
// $scope.search(SchedulesList.iterator);
|
// $scope.search(SchedulesList.iterator);
|
||||||
|
|||||||
@@ -31,8 +31,7 @@ export default
|
|||||||
name: {
|
name: {
|
||||||
label: i18n._('Name'),
|
label: i18n._('Name'),
|
||||||
columnClass: 'col-lg-4 col-md-5 col-sm-5 col-xs-7 List-staticColumnAdjacent',
|
columnClass: 'col-lg-4 col-md-5 col-sm-5 col-xs-7 List-staticColumnAdjacent',
|
||||||
sourceModel: 'unified_job_template',
|
ngBind: 'schedule.summary_fields.unified_job_template.name',
|
||||||
sourceField: 'name',
|
|
||||||
ngClick: "editSchedule(schedule)",
|
ngClick: "editSchedule(schedule)",
|
||||||
awToolTip: "{{ schedule.nameTip | sanitize}}",
|
awToolTip: "{{ schedule.nameTip | sanitize}}",
|
||||||
dataTipWatch: 'schedule.nameTip',
|
dataTipWatch: 'schedule.nameTip',
|
||||||
|
|||||||
@@ -45,7 +45,19 @@ export default
|
|||||||
let path = `${GetBasePath('job_templates')}${$stateParams.id}`;
|
let path = `${GetBasePath('job_templates')}${$stateParams.id}`;
|
||||||
Rest.setUrl(path);
|
Rest.setUrl(path);
|
||||||
return Rest.get(path).then((res) => res.data);
|
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: {
|
views: {
|
||||||
'@': {
|
'@': {
|
||||||
@@ -119,7 +131,19 @@ export default
|
|||||||
let path = `${GetBasePath('workflow_job_templates')}${$stateParams.id}`;
|
let path = `${GetBasePath('workflow_job_templates')}${$stateParams.id}`;
|
||||||
Rest.setUrl(path);
|
Rest.setUrl(path);
|
||||||
return Rest.get(path).then((res) => res.data);
|
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: {
|
views: {
|
||||||
'@': {
|
'@': {
|
||||||
@@ -190,7 +214,19 @@ export default
|
|||||||
let path = `${GetBasePath('projects')}${$stateParams.id}`;
|
let path = `${GetBasePath('projects')}${$stateParams.id}`;
|
||||||
Rest.setUrl(path);
|
Rest.setUrl(path);
|
||||||
return Rest.get(path).then((res) => res.data);
|
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: {
|
views: {
|
||||||
'@': {
|
'@': {
|
||||||
@@ -268,6 +304,18 @@ export default
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
ParentObject: [() =>{return {endpoint:'/api/v1/schedules'}; }],
|
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: {
|
views: {
|
||||||
'list@jobs': {
|
'list@jobs': {
|
||||||
|
|||||||
@@ -14,12 +14,12 @@
|
|||||||
export default [
|
export default [
|
||||||
'$scope', '$compile', '$location', '$stateParams', 'SchedulesList', 'Rest',
|
'$scope', '$compile', '$location', '$stateParams', 'SchedulesList', 'Rest',
|
||||||
'ProcessErrors', 'ReturnToCaller', 'ClearScope', 'GetBasePath', 'Wait', 'rbacUiControlService',
|
'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,
|
function($scope, $compile, $location, $stateParams,
|
||||||
SchedulesList, Rest, ProcessErrors, ReturnToCaller, ClearScope,
|
SchedulesList, Rest, ProcessErrors, ReturnToCaller, ClearScope,
|
||||||
GetBasePath, Wait, rbacUiControlService, Find,
|
GetBasePath, Wait, rbacUiControlService, Find,
|
||||||
ToggleSchedule, DeleteSchedule, GetChoices,
|
ToggleSchedule, DeleteSchedule, GetChoices,
|
||||||
$q, $state, Dataset, ParentObject) {
|
$q, $state, Dataset, ParentObject, UnifiedJobsOptions) {
|
||||||
|
|
||||||
ClearScope();
|
ClearScope();
|
||||||
|
|
||||||
@@ -43,11 +43,45 @@ export default [
|
|||||||
$scope.list = list;
|
$scope.list = list;
|
||||||
$scope[`${list.iterator}_dataset`] = Dataset.data;
|
$scope[`${list.iterator}_dataset`] = Dataset.data;
|
||||||
$scope[list.name] = $scope[`${list.iterator}_dataset`].results;
|
$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) {
|
function buildTooltips(schedule) {
|
||||||
|
var job = schedule.summary_fields.unified_job_template;
|
||||||
if (schedule.enabled) {
|
if (schedule.enabled) {
|
||||||
schedule.play_tip = 'Schedule is active. Click to stop.';
|
schedule.play_tip = 'Schedule is active. Click to stop.';
|
||||||
schedule.status = 'active';
|
schedule.status = 'active';
|
||||||
@@ -57,6 +91,18 @@ export default [
|
|||||||
schedule.status = 'stopped';
|
schedule.status = 'stopped';
|
||||||
schedule.status_tip = 'Schedule is stopped. Click to activate.';
|
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() {
|
$scope.refreshSchedules = function() {
|
||||||
@@ -99,7 +145,7 @@ export default [
|
|||||||
name: 'projectSchedules.edit',
|
name: 'projectSchedules.edit',
|
||||||
params: {
|
params: {
|
||||||
id: schedule.unified_job_template,
|
id: schedule.unified_job_template,
|
||||||
schedule_id: schedule.id
|
schedule_id: schedule.id
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
@@ -109,7 +155,7 @@ export default [
|
|||||||
name: 'managementJobSchedules.edit',
|
name: 'managementJobSchedules.edit',
|
||||||
params: {
|
params: {
|
||||||
id: schedule.unified_job_template,
|
id: schedule.unified_job_template,
|
||||||
schedule_id: schedule.id
|
schedule_id: schedule.id
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
@@ -136,7 +182,7 @@ export default [
|
|||||||
throw err;
|
throw err;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -160,7 +206,7 @@ export default [
|
|||||||
};
|
};
|
||||||
|
|
||||||
base = $location.path().replace(/^\//, '').split('/')[0];
|
base = $location.path().replace(/^\//, '').split('/')[0];
|
||||||
|
|
||||||
if (base === 'management_jobs') {
|
if (base === 'management_jobs') {
|
||||||
$scope.base = base = 'system_job_templates';
|
$scope.base = base = 'system_job_templates';
|
||||||
}
|
}
|
||||||
@@ -175,17 +221,5 @@ export default [
|
|||||||
$scope.formCancel = function() {
|
$scope.formCancel = function() {
|
||||||
$state.go('^', null, { reload: true });
|
$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'
|
|
||||||
// });
|
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|||||||
Reference in New Issue
Block a user