From 07aae8cefc78b054b6761fbafdd297b12029b76a Mon Sep 17 00:00:00 2001 From: kialam Date: Wed, 6 Feb 2019 10:17:27 -0700 Subject: [PATCH] Add Artifacts CodeMirror field to job details. --- awx/ui/client/features/output/_index.less | 2 +- .../features/output/details.component.js | 20 +++++++++++++++- .../features/output/details.partial.html | 14 ++++++++++- .../client/features/output/output.strings.js | 2 ++ .../code-mirror/code-mirror.directive.js | 19 +++++++++------ .../code-mirror/code-mirror.partial.html | 7 +++--- .../modal/code-mirror-modal.directive.js | 23 ++++++++++++------- .../modal/code-mirror-modal.partial.html | 2 +- 8 files changed, 67 insertions(+), 22 deletions(-) diff --git a/awx/ui/client/features/output/_index.less b/awx/ui/client/features/output/_index.less index 9450862bc8..8d5ac05b31 100644 --- a/awx/ui/client/features/output/_index.less +++ b/awx/ui/client/features/output/_index.less @@ -381,7 +381,7 @@ flex-wrap: wrap; } -.JobResults-resultRow #cm-variables-container { +.JobResults-resultRow div[id$='variables-container'] { width: 100%; } diff --git a/awx/ui/client/features/output/details.component.js b/awx/ui/client/features/output/details.component.js index 896aea0a28..10fbd33655 100644 --- a/awx/ui/client/features/output/details.component.js +++ b/awx/ui/client/features/output/details.component.js @@ -572,8 +572,25 @@ function getExtraVarsDetails () { const tooltip = strings.get('tooltips.EXTRA_VARS'); const value = parse(extraVars); const disabled = true; + const name = 'extra_vars'; - return { label, tooltip, value, disabled }; + return { label, tooltip, value, disabled, name }; +} + +function getArtifactsDetails () { + const artifacts = resource.model.get('artifacts'); + + if (!artifacts) { + return null; + } + + const label = strings.get('labels.ARTIFACTS'); + const tooltip = strings.get('tooltips.ARTIFACTS'); + const value = parse(artifacts); + const disabled = true; + const name = 'artifacts'; + + return { label, tooltip, value, disabled, name }; } function getLabelDetails () { @@ -781,6 +798,7 @@ function JobDetailsController ( vm.jobTags = getJobTagDetails(); vm.skipTags = getSkipTagDetails(); vm.extraVars = getExtraVarsDetails(); + vm.artifacts = getArtifactsDetails(); vm.labels = getLabelDetails(); vm.inventorySource = getInventorySourceDetails(); vm.overwrite = getOverwriteDetails(); diff --git a/awx/ui/client/features/output/details.partial.html b/awx/ui/client/features/output/details.partial.html index b73b0c943e..0e7cc3620a 100644 --- a/awx/ui/client/features/output/details.partial.html +++ b/awx/ui/client/features/output/details.partial.html @@ -332,10 +332,22 @@ ng-if="vm.extraVars" variables="{{ vm.extraVars.value }}" tooltip="{{ vm.extraVars.tooltip }}" - label="{{ vm.extraVars.label}}" + label="{{ vm.extraVars.label }}" + name="{{ vm.extraVars.name }}" disabled="{{ vm.extraVars.disabled }}"> + + + +
diff --git a/awx/ui/client/features/output/output.strings.js b/awx/ui/client/features/output/output.strings.js index 67510d10d7..b47eff0ace 100644 --- a/awx/ui/client/features/output/output.strings.js +++ b/awx/ui/client/features/output/output.strings.js @@ -14,6 +14,7 @@ function OutputStrings (BaseString) { }; ns.tooltips = { + ARTIFACTS: t.s('Read-only view of artifacts added to the job template'), CANCEL: t.s('Cancel'), COLLAPSE_OUTPUT: t.s('Collapse Output'), DELETE: t.s('Delete'), @@ -49,6 +50,7 @@ function OutputStrings (BaseString) { }; ns.labels = { + ARTIFACTS: t.s('Artifacts'), CREDENTIAL: t.s('Credential'), ENVIRONMENT: t.s('Environment'), EXECUTION_NODE: t.s('Execution Node'), diff --git a/awx/ui/client/lib/components/code-mirror/code-mirror.directive.js b/awx/ui/client/lib/components/code-mirror/code-mirror.directive.js index 0c3e908679..2783f0eaa6 100644 --- a/awx/ui/client/lib/components/code-mirror/code-mirror.directive.js +++ b/awx/ui/client/lib/components/code-mirror/code-mirror.directive.js @@ -1,9 +1,7 @@ const templateUrl = require('~components/code-mirror/code-mirror.partial.html'); -const CodeMirrorID = 'codemirror-extra-vars'; const CodeMirrorModalID = '#CodeMirror-modal'; const ParseVariable = 'parseType'; -const CodeMirrorVar = 'variables'; const ParseType = 'yaml'; function atCodeMirrorController ( @@ -13,19 +11,20 @@ function atCodeMirrorController ( ParseVariableString ) { const vm = this; - function init (vars) { + const variables = `${$scope.name}_variables`; + function init (vars, name) { if ($scope.disabled === 'true') { $scope.disabled = true; } else if ($scope.disabled === 'false') { $scope.disabled = false; } - $scope.variables = ParseVariableString(_.cloneDeep(vars)); + $scope[variables] = ParseVariableString(_.cloneDeep(vars)); $scope.parseType = ParseType; const options = { scope: $scope, - variable: CodeMirrorVar, + variable: variables, parse_variable: ParseVariable, - field_id: CodeMirrorID, + field_id: name, readOnly: $scope.disabled }; ParseTypeChange(options); @@ -42,6 +41,9 @@ function atCodeMirrorController ( vm.expanded = false; } + vm.variables = variables; + vm.name = $scope.name; + vm.modalName = `${vm.name}_modal`; vm.strings = strings; vm.expanded = false; vm.close = close; @@ -49,7 +51,9 @@ function atCodeMirrorController ( if ($scope.init) { $scope.init = init; } - init($scope.variables); + angular.element(document).ready(() => { + init($scope.variables, $scope.name); + }); } atCodeMirrorController.$inject = [ @@ -74,6 +78,7 @@ function atCodeMirrorTextarea () { tooltip: '@', tooltipPlacement: '@', variables: '@', + name: '@', init: '=' } }; diff --git a/awx/ui/client/lib/components/code-mirror/code-mirror.partial.html b/awx/ui/client/lib/components/code-mirror/code-mirror.partial.html index 98349fd3a3..7d149af226 100644 --- a/awx/ui/client/lib/components/code-mirror/code-mirror.partial.html +++ b/awx/ui/client/lib/components/code-mirror/code-mirror.partial.html @@ -23,7 +23,7 @@ type="radio" value="yaml" ng-model="parseType" - ng-change="parseTypeChange('parseType', 'variables')" + ng-change="parseTypeChange('parseType', vm.variables)" class="ng-pristine ng-untouched ng-valid ng-not-empty"> {{ vm.strings.get('label.YAML')}} @@ -32,7 +32,7 @@ type="radio" value="json" ng-model="parseType" - ng-change="parseTypeChange('parseType', 'variables')" + ng-change="parseTypeChange('parseType', vm.variables)" class="ng-pristine ng-untouched ng-valid ng-not-empty"> {{ vm.strings.get('label.JSON')}} @@ -47,9 +47,10 @@ ng-model="variables" name="variables" class="form-control Form-textArea" - id="codemirror-extra-vars"> + id="{{ vm.name }}"> { + init($scope.variables, $scope.name); + }); } atCodeMirrorModalController.$inject = [ @@ -85,6 +91,7 @@ function atCodeMirrorModal () { labelClass: '@', tooltip: '@', variables: '@', + name: '@', closeFn: '&' } }; diff --git a/awx/ui/client/lib/components/code-mirror/modal/code-mirror-modal.partial.html b/awx/ui/client/lib/components/code-mirror/modal/code-mirror-modal.partial.html index 86dd87b5a5..9785f439f8 100644 --- a/awx/ui/client/lib/components/code-mirror/modal/code-mirror-modal.partial.html +++ b/awx/ui/client/lib/components/code-mirror/modal/code-mirror-modal.partial.html @@ -58,7 +58,7 @@ ng-model="extra_variables" name="extra_variables" class="form-control Form-textArea" - id="codemirror-extra-vars-modal"> + id="{{ vm.name }}">