Populate JT schedule add with default extra vars when promptable. Hide schedule vars for everything except JT's with promptable extra vars

This commit is contained in:
mabashian
2018-04-23 15:27:52 -04:00
parent d5c2af0492
commit d44d28beba
2 changed files with 42 additions and 49 deletions

View File

@@ -89,7 +89,7 @@ export default ['$filter', '$state', '$stateParams', '$http', 'Wait',
// extra_data field is not manifested in the UI when scheduling a Management Job // extra_data field is not manifested in the UI when scheduling a Management Job
if ($state.current.name === 'jobTemplateSchedules.add'){ if ($state.current.name === 'jobTemplateSchedules.add'){
$scope.parseType = 'yaml'; $scope.parseType = 'yaml';
$scope.extraVars = '---'; $scope.extraVars = ParentObject.extra_vars === '' ? '---' : ParentObject.extra_vars;
ParseTypeChange({ ParseTypeChange({
scope: $scope, scope: $scope,
@@ -187,8 +187,7 @@ export default ['$filter', '$state', '$stateParams', '$http', 'Wait',
watchForPromptChanges(); watchForPromptChanges();
}); });
} } else {
else {
$scope.promptData = { $scope.promptData = {
launchConf: responses[1].data, launchConf: responses[1].data,
launchOptions: responses[0].data, launchOptions: responses[0].data,
@@ -272,18 +271,18 @@ export default ['$filter', '$state', '$stateParams', '$http', 'Wait',
} }
}); });
} }
else if ($state.current.name === 'projectSchedules.add'){
$scope.noVars = true; if ($state.current.name === 'workflowJobTemplateSchedules.add' ||
} $state.current.name === 'projectSchedules.add' ||
else if ($state.current.name === 'inventories.edit.inventory_sources.edit.schedules.add'){ $state.current.name === 'inventories.edit.inventory_sources.edit.schedules.add'
){
$scope.noVars = true; $scope.noVars = true;
} }
job_type = $scope.parentObject.job_type; job_type = $scope.parentObject.job_type;
if (!Empty($stateParams.id) && base !== 'system_job_templates' && base !== 'inventories' && !schedule_url) { if (!Empty($stateParams.id) && base !== 'system_job_templates' && base !== 'inventories' && !schedule_url) {
schedule_url = GetBasePath(base) + $stateParams.id + '/schedules/'; schedule_url = GetBasePath(base) + $stateParams.id + '/schedules/';
} } else if (base === "inventories"){
else if(base === "inventories"){
if (!schedule_url){ if (!schedule_url){
Rest.setUrl(GetBasePath('groups') + $stateParams.id + '/'); Rest.setUrl(GetBasePath('groups') + $stateParams.id + '/');
Rest.get() Rest.get()
@@ -297,8 +296,7 @@ export default ['$filter', '$state', '$stateParams', '$http', 'Wait',
}); });
}); });
} }
} } else if (base === 'system_job_templates') {
else if (base === 'system_job_templates') {
schedule_url = GetBasePath(base) + $stateParams.id + '/schedules/'; schedule_url = GetBasePath(base) + $stateParams.id + '/schedules/';
if (job_type === "cleanup_facts"){ if (job_type === "cleanup_facts"){
$scope.isFactCleanup = true; $scope.isFactCleanup = true;
@@ -330,8 +328,7 @@ export default ['$filter', '$state', '$stateParams', '$http', 'Wait',
$scope.prompt_for_days_facts_form.granularity_keep_amount.$setViewValue(1); $scope.prompt_for_days_facts_form.granularity_keep_amount.$setViewValue(1);
$scope.keep_unit = $scope.keep_unit_choices[0]; $scope.keep_unit = $scope.keep_unit_choices[0];
$scope.granularity_keep_unit = $scope.granularity_keep_unit_choices[1]; $scope.granularity_keep_unit = $scope.granularity_keep_unit_choices[1];
} } else {
else {
$scope.cleanupJob = true; $scope.cleanupJob = true;
} }
} }
@@ -353,8 +350,7 @@ export default ['$filter', '$state', '$stateParams', '$http', 'Wait',
if ($scope.schedulerUTCTime) { if ($scope.schedulerUTCTime) {
// The UTC time is already set // The UTC time is already set
processSchedulerEndDt(); processSchedulerEndDt();
} } else {
else {
// We need to wait for it to be set by angular-scheduler because the following function depends // We need to wait for it to be set by angular-scheduler because the following function depends
// on it // on it
var schedulerUTCTimeWatcher = $scope.$watch('schedulerUTCTime', function(newVal) { var schedulerUTCTimeWatcher = $scope.$watch('schedulerUTCTime', function(newVal) {

View File

@@ -204,8 +204,7 @@ function($filter, $state, $stateParams, Wait, $scope, moment,
if ($scope.cleanupJob){ if ($scope.cleanupJob){
$scope.schedulerPurgeDays = Number(schedule.extra_data.days); $scope.schedulerPurgeDays = Number(schedule.extra_data.days);
} } else if ($scope.isFactCleanup){
else if($scope.isFactCleanup){
$scope.keep_unit_choices = [{ $scope.keep_unit_choices = [{
"label" : "Days", "label" : "Days",
"value" : "d" "value" : "d"
@@ -387,8 +386,7 @@ function($filter, $state, $stateParams, Wait, $scope, moment,
watchForPromptChanges(); watchForPromptChanges();
}); });
} } else {
else {
$scope.promptData = { $scope.promptData = {
launchConf: launchConf, launchConf: launchConf,
launchOptions: launchOptions, launchOptions: launchOptions,
@@ -472,13 +470,12 @@ function($filter, $state, $stateParams, Wait, $scope, moment,
// extra_data field is not manifested in the UI when scheduling a Management Job // extra_data field is not manifested in the UI when scheduling a Management Job
if ($state.current.name !== 'managementJobsList.schedule.add' && $state.current.name !== 'managementJobsList.schedule.edit'){ if ($state.current.name !== 'managementJobsList.schedule.add' && $state.current.name !== 'managementJobsList.schedule.edit'){
if ($state.current.name === 'projectSchedules.edit'){ if ($state.current.name === 'projectSchedules.edit' ||
$state.current.name === 'inventories.edit.inventory_sources.edit.schedules.edit' ||
$state.current.name === 'workflowJobTemplateSchedules.add'
){
$scope.noVars = true; $scope.noVars = true;
} } else {
else if ($state.current.name === 'inventories.edit.inventory_sources.edit.schedules.edit'){
$scope.noVars = true;
}
else {
ParseTypeChange({ ParseTypeChange({
scope: $scope, scope: $scope,
variable: 'extraVars', variable: 'extraVars',