Add Artifacts CodeMirror field to job details.

This commit is contained in:
kialam 2019-02-06 10:17:27 -07:00
parent 902fb83493
commit 07aae8cefc
No known key found for this signature in database
GPG Key ID: 2D0E60E4B8C7EA0F
8 changed files with 67 additions and 22 deletions

View File

@ -381,7 +381,7 @@
flex-wrap: wrap;
}
.JobResults-resultRow #cm-variables-container {
.JobResults-resultRow div[id$='variables-container'] {
width: 100%;
}

View File

@ -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();

View File

@ -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 }}">
</at-code-mirror>
<!-- ARTIFACTS DETAIL -->
<at-code-mirror
class="JobResults-resultRow"
ng-if="vm.artifacts"
variables="{{ vm.artifacts.value }}"
tooltip="{{ vm.artifacts.tooltip }}"
label="{{ vm.artifacts.label }}"
name="{{ vm.artifacts.name }}"
disabled="{{ vm.artifacts.disabled }}">
</at-code-mirror>
<!-- LABELS DETAIL -->
<div class="JobResults-resultRow" ng-show="vm.labels">
<div class="JobResults-resultRow">

View File

@ -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'),

View File

@ -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: '='
}
};

View File

@ -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')}}
</label>
@ -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')}}
</label>
@ -47,9 +47,10 @@
ng-model="variables"
name="variables"
class="form-control Form-textArea"
id="codemirror-extra-vars">
id="{{ vm.name }}">
</textarea>
<at-code-mirror-modal
name="{{ vm.modalName }}"
ng-if="vm.expanded"
variables="{{ variables }}"
tooltip="{{ tooltip || vm.strings.get('code_mirror.tooltip.TOOLTIP') }}"

View File

@ -1,9 +1,7 @@
const templateUrl = require('~components/code-mirror/modal/code-mirror-modal.partial.html');
const CodeMirrorModalID = '#CodeMirror-modal';
const CodeMirrorID = 'codemirror-extra-vars-modal';
const ParseVariable = 'parseType';
const CodeMirrorVar = 'extra_variables';
const ParseType = 'yaml';
const ModalHeight = '#CodeMirror-modal .modal-dialog';
const ModalHeader = '.atCodeMirror-label';
@ -16,6 +14,7 @@ function atCodeMirrorModalController (
ParseVariableString
) {
const vm = this;
const variables = `${$scope.name}_variables`;
function resize () {
if ($scope.disabled === 'true') {
$scope.disabled = true;
@ -29,24 +28,24 @@ function atCodeMirrorModalController (
}
function toggle () {
$scope.parseTypeChange('parseType', 'extra_variables');
$scope.parseTypeChange('parseType', variables);
setTimeout(resize, 0);
}
function init () {
function init (vars, name) {
if ($scope.disabled === 'true') {
$scope.disabled = true;
} else if ($scope.disabled === 'false') {
$scope.disabled = false;
}
$(CodeMirrorModalID).modal('show');
$scope.extra_variables = ParseVariableString(_.cloneDeep($scope.variables));
$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);
@ -59,9 +58,16 @@ function atCodeMirrorModalController (
$(`${CodeMirrorModalID} .modal-dialog`).on('resize', resize);
}
vm.variables = variables;
vm.name = $scope.name;
vm.strings = strings;
vm.toggle = toggle;
init();
if ($scope.init) {
$scope.init = init;
}
angular.element(document).ready(() => {
init($scope.variables, $scope.name);
});
}
atCodeMirrorModalController.$inject = [
@ -85,6 +91,7 @@ function atCodeMirrorModal () {
labelClass: '@',
tooltip: '@',
variables: '@',
name: '@',
closeFn: '&'
}
};

View File

@ -58,7 +58,7 @@
ng-model="extra_variables"
name="extra_variables"
class="form-control Form-textArea"
id="codemirror-extra-vars-modal">
id="{{ vm.name }}">
</textarea>
</div>
<div class="modal-footer">