mirror of
https://github.com/ansible/awx.git
synced 2026-05-18 06:47:41 -02:30
Sets the timezone to the api/v2/schedule/:id -> data.timezone
and moving the data calls from the controller to the route resolve
This commit is contained in:
@@ -10,6 +10,8 @@ import controller from '../../scheduler/schedulerList.controller';
|
|||||||
import addController from '../../scheduler/schedulerAdd.controller';
|
import addController from '../../scheduler/schedulerAdd.controller';
|
||||||
import editController from '../../scheduler/schedulerEdit.controller';
|
import editController from '../../scheduler/schedulerEdit.controller';
|
||||||
import { N_ } from '../../i18n';
|
import { N_ } from '../../i18n';
|
||||||
|
import editScheduleResolve from '../../scheduler/editSchedule.resolve';
|
||||||
|
|
||||||
|
|
||||||
export default
|
export default
|
||||||
angular.module('managementJobScheduler', [])
|
angular.module('managementJobScheduler', [])
|
||||||
@@ -99,6 +101,7 @@ angular.module('managementJobScheduler', [])
|
|||||||
templateUrl: templateUrl('management-jobs/scheduler/schedulerForm'),
|
templateUrl: templateUrl('management-jobs/scheduler/schedulerForm'),
|
||||||
controller: 'managementJobEditController'
|
controller: 'managementJobEditController'
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
resolve: editScheduleResolve()
|
||||||
});
|
});
|
||||||
}]);
|
}]);
|
||||||
|
|||||||
39
awx/ui/client/src/scheduler/editSchedule.resolve.js
Normal file
39
awx/ui/client/src/scheduler/editSchedule.resolve.js
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
function editScheduleResolve () {
|
||||||
|
const resolve = {
|
||||||
|
scheduleResolve: ['Rest', '$stateParams', 'GetBasePath', 'ProcessErrors',
|
||||||
|
(Rest, $stateParams, GetBasePath, ProcessErrors) => {
|
||||||
|
var path = `${GetBasePath('schedules')}${parseInt($stateParams.schedule_id)}/`;
|
||||||
|
// const path = GetBasePath('schedules') + parseInt($stateParams.schedule_id) + '/');
|
||||||
|
Rest.setUrl(path);
|
||||||
|
return Rest.get()
|
||||||
|
.then(function(data) {
|
||||||
|
return (data.data);
|
||||||
|
}).catch(function(response) {
|
||||||
|
ProcessErrors(null, response.data, response.status, null, {
|
||||||
|
hdr: 'Error!',
|
||||||
|
msg: 'Failed to get schedule info. GET returned status: ' +
|
||||||
|
response.status
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
],
|
||||||
|
timezonesResolve: ['Rest', '$stateParams', 'GetBasePath', 'ProcessErrors',
|
||||||
|
(Rest, $stateParams, GetBasePath, ProcessErrors) => {
|
||||||
|
var path = `${GetBasePath('schedules')}/zoneinfo`;
|
||||||
|
Rest.setUrl(path);
|
||||||
|
return Rest.get()
|
||||||
|
.then(function(data) {
|
||||||
|
return (data.data);
|
||||||
|
}).catch(function(response) {
|
||||||
|
ProcessErrors(null, response.data, response.status, null, {
|
||||||
|
hdr: 'Error!',
|
||||||
|
msg: 'Failed to get zoneinfo. GET returned status: ' +
|
||||||
|
response.status
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
]
|
||||||
|
};
|
||||||
|
return resolve;
|
||||||
|
}
|
||||||
|
export default editScheduleResolve;
|
||||||
@@ -16,6 +16,7 @@ import SchedulePost from './factories/schedule-post.factory';
|
|||||||
import ToggleSchedule from './factories/toggle-schedule.factory';
|
import ToggleSchedule from './factories/toggle-schedule.factory';
|
||||||
import SchedulesList from './schedules.list';
|
import SchedulesList from './schedules.list';
|
||||||
import ScheduledJobsList from './scheduled-jobs.list';
|
import ScheduledJobsList from './scheduled-jobs.list';
|
||||||
|
import editScheduleResolve from './editSchedule.resolve';
|
||||||
|
|
||||||
export default
|
export default
|
||||||
angular.module('scheduler', [])
|
angular.module('scheduler', [])
|
||||||
@@ -121,7 +122,8 @@ export default
|
|||||||
ncyBreadcrumb: {
|
ncyBreadcrumb: {
|
||||||
parent: 'jobTemplateSchedules',
|
parent: 'jobTemplateSchedules',
|
||||||
label: '{{schedule_obj.name}}'
|
label: '{{schedule_obj.name}}'
|
||||||
}
|
},
|
||||||
|
resolve: editScheduleResolve()
|
||||||
});
|
});
|
||||||
|
|
||||||
// workflows
|
// workflows
|
||||||
@@ -212,7 +214,8 @@ export default
|
|||||||
ncyBreadcrumb: {
|
ncyBreadcrumb: {
|
||||||
parent: 'workflowJobTemplateSchedules',
|
parent: 'workflowJobTemplateSchedules',
|
||||||
label: '{{schedule_obj.name}}'
|
label: '{{schedule_obj.name}}'
|
||||||
}
|
},
|
||||||
|
resolve: editScheduleResolve()
|
||||||
});
|
});
|
||||||
// projects
|
// projects
|
||||||
$stateExtender.addState({
|
$stateExtender.addState({
|
||||||
@@ -301,7 +304,8 @@ export default
|
|||||||
controller: 'schedulerEditController',
|
controller: 'schedulerEditController',
|
||||||
templateUrl: templateUrl("scheduler/schedulerForm"),
|
templateUrl: templateUrl("scheduler/schedulerForm"),
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
resolve: editScheduleResolve()
|
||||||
});
|
});
|
||||||
// upcoming scheduled jobs
|
// upcoming scheduled jobs
|
||||||
$stateExtender.addState({
|
$stateExtender.addState({
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
export default ['$filter', '$state', '$stateParams', 'Wait', '$scope', 'moment',
|
export default ['$filter', '$state', '$stateParams', 'Wait', '$scope', 'moment',
|
||||||
'$rootScope', '$http', 'CreateSelect2', 'ParseTypeChange', 'ParentObject', 'ProcessErrors', 'Rest',
|
'$rootScope', '$http', 'CreateSelect2', 'ParseTypeChange', 'ParentObject', 'ProcessErrors', 'Rest',
|
||||||
'GetBasePath', 'SchedulerInit', 'SchedulePost', 'JobTemplateModel', '$q', 'Empty', 'PromptService', 'RRuleToAPI',
|
'GetBasePath', 'SchedulerInit', 'SchedulePost', 'JobTemplateModel', '$q', 'Empty', 'PromptService', 'RRuleToAPI',
|
||||||
'WorkflowJobTemplateModel', 'TemplatesStrings',
|
'WorkflowJobTemplateModel', 'TemplatesStrings', 'scheduleResolve', 'timezonesResolve',
|
||||||
function($filter, $state, $stateParams, Wait, $scope, moment,
|
function($filter, $state, $stateParams, Wait, $scope, moment,
|
||||||
$rootScope, $http, CreateSelect2, ParseTypeChange, ParentObject, ProcessErrors, Rest,
|
$rootScope, $http, CreateSelect2, ParseTypeChange, ParentObject, ProcessErrors, Rest,
|
||||||
GetBasePath, SchedulerInit, SchedulePost, JobTemplate, $q, Empty, PromptService, RRuleToAPI,
|
GetBasePath, SchedulerInit, SchedulePost, JobTemplate, $q, Empty, PromptService, RRuleToAPI,
|
||||||
WorkflowJobTemplate, TemplatesStrings
|
WorkflowJobTemplate, TemplatesStrings, scheduleResolve, timezonesResolve
|
||||||
) {
|
) {
|
||||||
|
|
||||||
let schedule, scheduler, scheduleCredentials = [];
|
let schedule, scheduler, scheduleCredentials = [];
|
||||||
@@ -118,41 +118,37 @@ function($filter, $state, $stateParams, Wait, $scope, moment,
|
|||||||
|
|
||||||
Wait('start');
|
Wait('start');
|
||||||
|
|
||||||
// Get the existing record
|
//sets the timezone dropdown to the timezone specified by the API
|
||||||
Rest.setUrl(GetBasePath('schedules') + parseInt($stateParams.schedule_id) + '/');
|
function setTimezone () {
|
||||||
Rest.get()
|
$scope.schedulerTimeZone = _.find($scope.timeZones, function(x) {
|
||||||
.then(({data}) => {
|
return x.name === scheduleResolve.timezone;
|
||||||
schedule = data;
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function init() {
|
||||||
|
schedule = scheduleResolve;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
schedule.extra_data = JSON.parse(schedule.extra_data);
|
schedule.extra_data = JSON.parse(schedule.extra_data);
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
// do nothing
|
// do nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
$scope.extraVars = (data.extra_data === '' || _.isEmpty(data.extra_data)) ? '---' : '---\n' + jsyaml.safeDump(data.extra_data);
|
$scope.extraVars = (scheduleResolve.extra_data === '' || _.isEmpty(scheduleResolve.extra_data)) ? '---' : '---\n' + jsyaml.safeDump(scheduleResolve.extra_data);
|
||||||
|
|
||||||
if (_.has(schedule, 'summary_fields.unified_job_template.unified_job_type') &&
|
if (_.has(schedule, 'summary_fields.unified_job_template.unified_job_type') &&
|
||||||
schedule.summary_fields.unified_job_template.unified_job_type === 'system_job'){
|
schedule.summary_fields.unified_job_template.unified_job_type === 'system_job'){
|
||||||
$scope.cleanupJob = true;
|
$scope.cleanupJob = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
$scope.schedule_obj = data;
|
$scope.schedule_obj = scheduleResolve;
|
||||||
|
|
||||||
$('#form-container').empty();
|
$('#form-container').empty();
|
||||||
scheduler = SchedulerInit({ scope: $scope, requireFutureStartTime: false });
|
scheduler = SchedulerInit({ scope: $scope, requireFutureStartTime: false });
|
||||||
|
|
||||||
$http.get('/api/v2/schedules/zoneinfo/').then(({data}) => {
|
scheduler.scope.timeZones = timezonesResolve;
|
||||||
scheduler.scope.timeZones = data;
|
setTimezone();
|
||||||
scheduler.scope.schedulerTimeZone = _.find(data, function(x) {
|
|
||||||
let tz = $scope.schedule_obj.rrule.match(/TZID=\s*(.*?)\s*:/);
|
|
||||||
if (_.has(tz, '1')) {
|
|
||||||
return x.name === tz[1];
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
|
||||||
});
|
|
||||||
scheduler.inject('form-container', false);
|
scheduler.inject('form-container', false);
|
||||||
scheduler.injectDetail('occurrences', false);
|
scheduler.injectDetail('occurrences', false);
|
||||||
|
|
||||||
@@ -164,6 +160,7 @@ function($filter, $state, $stateParams, Wait, $scope, moment,
|
|||||||
$scope.$on("htmlDetailReady", function() {
|
$scope.$on("htmlDetailReady", function() {
|
||||||
scheduler.setRRule(schedule.rrule);
|
scheduler.setRRule(schedule.rrule);
|
||||||
scheduler.setName(schedule.name);
|
scheduler.setName(schedule.name);
|
||||||
|
setTimezone();
|
||||||
$scope.hideForm = false;
|
$scope.hideForm = false;
|
||||||
|
|
||||||
$scope.$watchGroup(["schedulerName",
|
$scope.$watchGroup(["schedulerName",
|
||||||
@@ -202,7 +199,8 @@ function($filter, $state, $stateParams, Wait, $scope, moment,
|
|||||||
$scope.showRRuleDetail = false;
|
$scope.showRRuleDetail = false;
|
||||||
scheduler.setRRule(schedule.rrule);
|
scheduler.setRRule(schedule.rrule);
|
||||||
scheduler.setName(schedule.name);
|
scheduler.setName(schedule.name);
|
||||||
|
scheduler.scope.timeZones = timezonesResolve;
|
||||||
|
scheduler.scope.schedulerTimeZone = scheduleResolve.timezone;
|
||||||
if ($scope.cleanupJob){
|
if ($scope.cleanupJob){
|
||||||
$scope.schedulerPurgeDays = Number(schedule.extra_data.days);
|
$scope.schedulerPurgeDays = Number(schedule.extra_data.days);
|
||||||
}
|
}
|
||||||
@@ -211,7 +209,7 @@ function($filter, $state, $stateParams, Wait, $scope, moment,
|
|||||||
|
|
||||||
let jobTemplate = new JobTemplate();
|
let jobTemplate = new JobTemplate();
|
||||||
|
|
||||||
Rest.setUrl(data.related.credentials);
|
Rest.setUrl(scheduleResolve.related.credentials);
|
||||||
|
|
||||||
$q.all([jobTemplate.optionsLaunch(ParentObject.id), jobTemplate.getLaunch(ParentObject.id), Rest.get()])
|
$q.all([jobTemplate.optionsLaunch(ParentObject.id), jobTemplate.getLaunch(ParentObject.id), Rest.get()])
|
||||||
.then((responses) => {
|
.then((responses) => {
|
||||||
@@ -242,7 +240,7 @@ function($filter, $state, $stateParams, Wait, $scope, moment,
|
|||||||
let prompts = PromptService.processPromptValues({
|
let prompts = PromptService.processPromptValues({
|
||||||
launchConf: responses[1].data,
|
launchConf: responses[1].data,
|
||||||
launchOptions: responses[0].data,
|
launchOptions: responses[0].data,
|
||||||
currentValues: data
|
currentValues: scheduleResolve
|
||||||
});
|
});
|
||||||
|
|
||||||
let defaultCredsWithoutOverrides = [];
|
let defaultCredsWithoutOverrides = [];
|
||||||
@@ -299,7 +297,7 @@ function($filter, $state, $stateParams, Wait, $scope, moment,
|
|||||||
// Promptable variables will happen in the schedule form
|
// Promptable variables will happen in the schedule form
|
||||||
launchConf.ignore_ask_variables = true;
|
launchConf.ignore_ask_variables = true;
|
||||||
|
|
||||||
if (launchConf.ask_inventory_on_launch && !_.has(launchConf, 'defaults.inventory') && !_.has(data, 'summary_fields.inventory')) {
|
if (launchConf.ask_inventory_on_launch && !_.has(launchConf, 'defaults.inventory') && !_.has(scheduleResolve, 'summary_fields.inventory')) {
|
||||||
$scope.promptModalMissingReqFields = true;
|
$scope.promptModalMissingReqFields = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -310,7 +308,7 @@ function($filter, $state, $stateParams, Wait, $scope, moment,
|
|||||||
|
|
||||||
let processed = PromptService.processSurveyQuestions({
|
let processed = PromptService.processSurveyQuestions({
|
||||||
surveyQuestions: surveyQuestionRes.data.spec,
|
surveyQuestions: surveyQuestionRes.data.spec,
|
||||||
extra_data: _.cloneDeep(data.extra_data)
|
extra_data: _.cloneDeep(scheduleResolve.extra_data)
|
||||||
});
|
});
|
||||||
|
|
||||||
$scope.missingSurveyValue = processed.missingSurveyValue;
|
$scope.missingSurveyValue = processed.missingSurveyValue;
|
||||||
@@ -373,7 +371,7 @@ function($filter, $state, $stateParams, Wait, $scope, moment,
|
|||||||
let prompts = PromptService.processPromptValues({
|
let prompts = PromptService.processPromptValues({
|
||||||
launchConf: responses[1].data,
|
launchConf: responses[1].data,
|
||||||
launchOptions: responses[0].data,
|
launchOptions: responses[0].data,
|
||||||
currentValues: data
|
currentValues: scheduleResolve
|
||||||
});
|
});
|
||||||
|
|
||||||
if(!launchConf.survey_enabled) {
|
if(!launchConf.survey_enabled) {
|
||||||
@@ -388,7 +386,7 @@ function($filter, $state, $stateParams, Wait, $scope, moment,
|
|||||||
|
|
||||||
let processed = PromptService.processSurveyQuestions({
|
let processed = PromptService.processSurveyQuestions({
|
||||||
surveyQuestions: surveyQuestionRes.data.spec,
|
surveyQuestions: surveyQuestionRes.data.spec,
|
||||||
extra_data: _.cloneDeep(data.extra_data)
|
extra_data: _.cloneDeep(scheduleResolve.extra_data)
|
||||||
});
|
});
|
||||||
|
|
||||||
$scope.missingSurveyValue = processed.missingSurveyValue;
|
$scope.missingSurveyValue = processed.missingSurveyValue;
|
||||||
@@ -444,11 +442,8 @@ function($filter, $state, $stateParams, Wait, $scope, moment,
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
}
|
||||||
.catch(({data, status}) => {
|
init();
|
||||||
ProcessErrors($scope, data, status, null, { hdr: 'Error!',
|
|
||||||
msg: 'Failed to retrieve schedule ' + parseInt($stateParams.schedule_id) + ' GET returned: ' + status });
|
|
||||||
});
|
|
||||||
|
|
||||||
callSelect2();
|
callSelect2();
|
||||||
}];
|
}];
|
||||||
|
|||||||
Reference in New Issue
Block a user