Leveraging CodeMirror to display extra variables for management jobs

This commit is contained in:
Michael Abashian 2016-03-07 10:32:30 -05:00
parent 51cb262a84
commit 73d80f7179
2 changed files with 14 additions and 7 deletions

View File

@ -49,13 +49,12 @@
</div>
</div>
<!-- TODO: figure out how to show the extra vars on different rows like the mockup -->
<div class="StandardOut-detailsRow" ng-show="job.extra_vars">
<div class="StandardOut-detailsLabel">EXTRA VARS</div>
<div class="StandardOut-detailsContent">
{{ job.extra_vars }}
</div>
</div>
<div ng-show="job.extra_vars">
<textarea rows="6" ng-model="variables" name="variables" class="StandardOut-extraVars" id="pre-formatted-variables"></textarea>
</div>
</div>

View File

@ -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'];