From 90c6e1ca36a464a64b46355bd31b30608fc3f3e5 Mon Sep 17 00:00:00 2001 From: Jared Tabor Date: Wed, 27 Apr 2016 15:32:30 -0700 Subject: [PATCH] Fixing extra vars for inv-sync schedules and projects --- awx/ui/client/src/helpers/Schedules.js | 10 ++++++++-- .../src/scheduler/schedulerAdd.controller.js | 20 ++++++++++++++----- 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/awx/ui/client/src/helpers/Schedules.js b/awx/ui/client/src/helpers/Schedules.js index 0a800b5483..6babbe21c8 100644 --- a/awx/ui/client/src/helpers/Schedules.js +++ b/awx/ui/client/src/helpers/Schedules.js @@ -245,7 +245,7 @@ export default url = params.url; } } - else if (base == 'system_job_templates') { + else if (base === 'system_job_templates') { url = GetBasePath(base) + $stateParams.id + '/schedules/'; if($stateParams.id == 4){ scope.isFactCleanup = true; @@ -325,7 +325,9 @@ export default }; }]) - .factory('SchedulePost', ['Rest', 'ProcessErrors', 'RRuleToAPI', 'Wait', function(Rest, ProcessErrors, RRuleToAPI, Wait) { + .factory('SchedulePost', ['Rest', 'ProcessErrors', 'RRuleToAPI', 'Wait', + 'ToJSON', + function(Rest, ProcessErrors, RRuleToAPI, Wait, ToJSON) { return function(params) { var scope = params.scope, url = params.url, @@ -357,6 +359,10 @@ export default else if (scope.serializedExtraVars){ schedule.extra_data = scope.serializedExtraVars; } + else if(scope.extraVars){ + schedule.extra_data = ToJSON(scope.parseType, + scope.extraVars, false); + } Rest.setUrl(url); if (mode === 'add') { Rest.post(schedule) diff --git a/awx/ui/client/src/scheduler/schedulerAdd.controller.js b/awx/ui/client/src/scheduler/schedulerAdd.controller.js index 14dd7d3113..c88f7dbc5e 100644 --- a/awx/ui/client/src/scheduler/schedulerAdd.controller.js +++ b/awx/ui/client/src/scheduler/schedulerAdd.controller.js @@ -62,15 +62,15 @@ export default ['$compile', '$state', '$stateParams', 'AddSchedule', 'Wait', $scope.parseType = 'yaml'; var defaultUrl = GetBasePath('job_templates') + $stateParams.id + '/'; Rest.setUrl(defaultUrl); - Rest.get().then(function(res){ + Rest.get().then(function(res){ // sanitize var data = JSON.parse(JSON.stringify(res.data.extra_vars)); $scope.extraVars = data === '' ? '---' : data; - ParseTypeChange({ - scope: $scope, - variable: 'extraVars', + ParseTypeChange({ + scope: $scope, + variable: 'extraVars', parse_variable: 'parseType', - field_id: 'SchedulerForm-extraVars' + field_id: 'SchedulerForm-extraVars' }); }); $scope.$watch('extraVars', function(){ @@ -98,6 +98,16 @@ export default ['$compile', '$state', '$stateParams', 'AddSchedule', 'Wait', field_id: 'SchedulerForm-extraVars' }); } + else if ($state.current.name === 'inventoryManageSchedules.add'){ + $scope.extraVars = '---'; + $scope.parseType = 'yaml'; + ParseTypeChange({ + scope: $scope, + variable: 'extraVars', + parse_variable: 'parseType', + field_id: 'SchedulerForm-extraVars' + }); + } AddSchedule({ scope: $scope,