From 73d80f7179041b7e6bfa1804f86e93d7b6db4d17 Mon Sep 17 00:00:00 2001 From: Michael Abashian Date: Mon, 7 Mar 2016 10:32:30 -0500 Subject: [PATCH] Leveraging CodeMirror to display extra variables for management jobs --- .../standard-out-management-jobs.partial.html | 9 ++++----- .../src/standard-out/standard-out.controller.js | 12 ++++++++++-- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/awx/ui/client/src/standard-out/management-jobs/standard-out-management-jobs.partial.html b/awx/ui/client/src/standard-out/management-jobs/standard-out-management-jobs.partial.html index 3e035ddab5..73d2159fac 100644 --- a/awx/ui/client/src/standard-out/management-jobs/standard-out-management-jobs.partial.html +++ b/awx/ui/client/src/standard-out/management-jobs/standard-out-management-jobs.partial.html @@ -49,13 +49,12 @@ - -
EXTRA VARS
-
- {{ job.extra_vars }} -
+
+ +
+
diff --git a/awx/ui/client/src/standard-out/standard-out.controller.js b/awx/ui/client/src/standard-out/standard-out.controller.js index 152d2a8a5d..83345d7132 100644 --- a/awx/ui/client/src/standard-out/standard-out.controller.js +++ b/awx/ui/client/src/standard-out/standard-out.controller.js @@ -11,7 +11,7 @@ */ -export function JobStdoutController ($rootScope, $scope, $state, $stateParams, ClearScope, GetBasePath, Rest, ProcessErrors, Empty, GetChoices, LookUpName) { +export function JobStdoutController ($rootScope, $scope, $state, $stateParams, ClearScope, GetBasePath, Rest, ProcessErrors, Empty, GetChoices, LookUpName, ParseTypeChange, ParseVariableString) { ClearScope(); @@ -36,6 +36,9 @@ export function JobStdoutController ($rootScope, $scope, $state, $stateParams, C // timestamp as well as the run time. }); + // Set the parse type so that CodeMirror knows how to display extra params YAML/JSON + $scope.parseType = 'yaml'; + // Go out and get the job details based on the job type. jobType gets defined // in the data block of the route declaration for each of the different types // of stdout jobs. @@ -132,6 +135,11 @@ export function JobStdoutController ($rootScope, $scope, $state, $stateParams, C }); } + if (!Empty(data.extra_vars)) { + $scope.variables = ParseVariableString(data.extra_vars); + ParseTypeChange({ scope: $scope, field_id: 'pre-formatted-variables' }); + } + // If the job isn't running we want to clear out the interval that goes out and checks for stdout updates. // This interval is defined in the standard out log directive controller. if (data.status === 'successful' || data.status === 'failed' || data.status === 'error' || data.status === 'canceled') { @@ -158,4 +166,4 @@ export function JobStdoutController ($rootScope, $scope, $state, $stateParams, C } -JobStdoutController.$inject = [ '$rootScope', '$scope', '$state', '$stateParams', 'ClearScope', 'GetBasePath', 'Rest', 'ProcessErrors', 'Empty', 'GetChoices', 'LookUpName']; +JobStdoutController.$inject = [ '$rootScope', '$scope', '$state', '$stateParams', 'ClearScope', 'GetBasePath', 'Rest', 'ProcessErrors', 'Empty', 'GetChoices', 'LookUpName', 'ParseTypeChange', 'ParseVariableString'];