mirror of
https://github.com/ansible/awx.git
synced 2026-01-15 03:40:42 -03:30
add use code-mirror directive for host variables; fix multiple code-mirrors on page at once
This commit is contained in:
parent
bed63b3690
commit
5d3e39beac
@ -350,7 +350,7 @@
|
||||
<at-code-mirror
|
||||
class="JobResults-resultRow"
|
||||
ng-if="vm.extraVars"
|
||||
variables="{{ vm.extraVars.value }}"
|
||||
variables="vm.extraVars.value"
|
||||
tooltip="{{ vm.extraVars.tooltip }}"
|
||||
label="{{ vm.extraVars.label }}"
|
||||
name="{{ vm.extraVars.name }}"
|
||||
@ -361,7 +361,7 @@
|
||||
<at-code-mirror
|
||||
class="JobResults-resultRow"
|
||||
ng-if="vm.artifacts"
|
||||
variables="{{ vm.artifacts.value }}"
|
||||
variables="vm.artifacts.value"
|
||||
tooltip="{{ vm.artifacts.tooltip }}"
|
||||
label="{{ vm.artifacts.label }}"
|
||||
name="{{ vm.artifacts.name }}"
|
||||
|
||||
@ -9,18 +9,19 @@ function atCodeMirrorController (
|
||||
ParseTypeChange
|
||||
) {
|
||||
const vm = this;
|
||||
const variablesName = `${$scope.name}_variables`;
|
||||
function init () {
|
||||
if ($scope.disabled === 'true') {
|
||||
$scope.disabled = true;
|
||||
} else if ($scope.disabled === 'false') {
|
||||
$scope.disabled = false;
|
||||
}
|
||||
$scope.value = $scope.variables.value;
|
||||
$scope.parseType = ParseType;
|
||||
|
||||
$scope[variablesName] = $scope.variables;
|
||||
ParseTypeChange({
|
||||
scope: $scope,
|
||||
variable: 'variables',
|
||||
variable: variablesName,
|
||||
parse_variable: 'parseType',
|
||||
field_id: `${$scope.name}_variables`,
|
||||
readOnly: $scope.disabled
|
||||
@ -37,10 +38,11 @@ function atCodeMirrorController (
|
||||
// user changes the format from yaml to json in the
|
||||
// modal but CM in the form is set to YAML
|
||||
$scope.variables = varsFromModal;
|
||||
$scope[variablesName] = $scope.variables;
|
||||
// New set of variables from the modal, reinit codemirror
|
||||
ParseTypeChange({
|
||||
scope: $scope,
|
||||
variable: 'variables',
|
||||
variable: variablesName,
|
||||
parse_variable: 'parseType',
|
||||
field_id: `${$scope.name}_variables`,
|
||||
readOnly: $scope.disabled
|
||||
@ -56,6 +58,7 @@ function atCodeMirrorController (
|
||||
vm.expanded = false;
|
||||
vm.close = close;
|
||||
vm.expand = expand;
|
||||
vm.variablesName = variablesName;
|
||||
if ($scope.init) {
|
||||
$scope.init = init;
|
||||
}
|
||||
|
||||
@ -23,7 +23,7 @@
|
||||
type="radio"
|
||||
value="yaml"
|
||||
ng-model="parseType"
|
||||
ng-change="parseTypeChange('parseType', 'variables')"
|
||||
ng-change="parseTypeChange('parseType', vm.variablesName)"
|
||||
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.variablesName)"
|
||||
class="ng-pristine ng-untouched ng-valid ng-not-empty">
|
||||
{{ vm.strings.get('label.JSON')}}
|
||||
</label>
|
||||
|
||||
@ -13,7 +13,7 @@ function atCodeMirrorModalController (
|
||||
ParseTypeChange
|
||||
) {
|
||||
const vm = this;
|
||||
const variablesName = `${$scope.name}_variables`;
|
||||
// const variablesName = `${$scope.name}_variables`;
|
||||
function resize () {
|
||||
if ($scope.disabled === 'true') {
|
||||
$scope.disabled = true;
|
||||
@ -53,8 +53,6 @@ function atCodeMirrorModalController (
|
||||
minWidth: 600
|
||||
});
|
||||
$(`${CodeMirrorModalID} .modal-dialog`).on('resize', resize);
|
||||
|
||||
$scope.foovars = 'testing';
|
||||
}
|
||||
|
||||
vm.strings = strings;
|
||||
|
||||
@ -65,12 +65,15 @@ function(i18n) {
|
||||
type: 'text'
|
||||
},
|
||||
variables: {
|
||||
root: 'host_variables',
|
||||
label: i18n._('Variables'),
|
||||
type: 'textarea',
|
||||
type: 'code_mirror',
|
||||
rows: 6,
|
||||
variables: 'variables',
|
||||
class: 'Form-formGroup--fullWidth',
|
||||
"default": "---",
|
||||
awPopOver: "<p>" + i18n._("Enter inventory variables using either JSON or YAML syntax. Use the radio button to toggle between the two.") + "</p>" +
|
||||
awPopOver: i18n._('Enter inventory variables using either JSON or YAML syntax. Use the radio button to toggle between the two.'),
|
||||
_awPopOver: "<p>" + i18n._("Enter inventory variables using either JSON or YAML syntax. Use the radio button to toggle between the two.") + "</p>" +
|
||||
"JSON:<br />\n" +
|
||||
"<blockquote>{<br /> \"somevar\": \"somevalue\",<br /> \"password\": \"magic\"<br /> }</blockquote>\n" +
|
||||
"YAML:<br />\n" +
|
||||
|
||||
@ -40,11 +40,11 @@
|
||||
$rootScope.breadcrumb.host_name = host.name;
|
||||
$scope.description = host.description;
|
||||
$scope.host_variables = getVars(host.variables);
|
||||
ParseTypeChange({
|
||||
scope: $scope,
|
||||
field_id: 'host_host_variables',
|
||||
variable: 'host_variables',
|
||||
});
|
||||
// ParseTypeChange({
|
||||
// scope: $scope,
|
||||
// field_id: 'host_host_variables',
|
||||
// variable: 'host_variables',
|
||||
// });
|
||||
};
|
||||
|
||||
// Adding this function b/c sometimes extra vars are returned to the
|
||||
|
||||
@ -66,17 +66,35 @@ function(i18n) {
|
||||
},
|
||||
host_variables: {
|
||||
label: i18n._('Variables'),
|
||||
type: 'textarea',
|
||||
type: 'code_mirror',
|
||||
root: 'host_variables',
|
||||
rows: 6,
|
||||
class: 'Form-formGroup--fullWidth',
|
||||
"default": "---",
|
||||
awPopOver: "<p>" + i18n._("Enter inventory variables using either JSON or YAML syntax. Use the radio button to toggle between the two.") + "</p>" +
|
||||
"JSON:<br />\n" +
|
||||
"<blockquote>{<br /> \"somevar\": \"somevalue\",<br /> \"password\": \"magic\"<br /> }</blockquote>\n" +
|
||||
"YAML:<br />\n" +
|
||||
"<blockquote>---<br />somevar: somevalue<br />password: magic<br /></blockquote>\n" +
|
||||
'<p>' + i18n.sprintf(i18n._('View JSON examples at %s'), '<a href="http://www.json.org" target="_blank">www.json.org</a>') + '</p>' +
|
||||
'<p>' + i18n.sprintf(i18n._('View YAML examples at %s'), '<a href="http://docs.ansible.com/YAMLSyntax.html" target="_blank">docs.ansible.com</a>') + '</p>',
|
||||
variables: 'host_variables',
|
||||
awPopOver: `<p>${i18n._("Enter inventory variables using either JSON or YAML syntax. Use the radio button to toggle between the two.")}</p>
|
||||
JSON:<br />
|
||||
<blockquote>
|
||||
{<br /> "somevar": "somevalue",<br /> "password": "magic"<br /> }
|
||||
</blockquote>
|
||||
YAML:<br />
|
||||
<blockquote>
|
||||
---<br />
|
||||
somevar: somevalue<br />
|
||||
password: magic<br />
|
||||
</blockquote>
|
||||
<p>${i18n.sprintf(i18n._(
|
||||
'View JSON examples at %s'),
|
||||
'<a href="http://www.json.org" target="_blank">www.json.org</a>'
|
||||
)}</p>
|
||||
<p>${i18n.sprintf(i18n._('View YAML examples at %s'), '<a href="http://docs.ansible.com/YAMLSyntax.html" target="_blank">docs.ansible.com</a>')}</p>`,
|
||||
// _awPopOver: "<p>" + i18n._("Enter inventory variables using either JSON or YAML syntax. Use the radio button to toggle between the two.") + "</p>" +
|
||||
// "JSON:<br />\n" +
|
||||
// "<blockquote>{<br /> \"somevar\": \"somevalue\",<br /> \"password\": \"magic\"<br /> }</blockquote>\n" +
|
||||
// "YAML:<br />\n" +
|
||||
// "<blockquote>---<br />somevar: somevalue<br />password: magic<br /></blockquote>\n", // +
|
||||
// '<p>' + i18n.sprintf(i18n._('View JSON examples at %s'), '<a href="http://www.json.org" target="_blank">www.json.org</a>') + '</p>' +
|
||||
// '<p>' + i18n.sprintf(i18n._('View YAML examples at %s'), '<a href="http://docs.ansible.com/YAMLSyntax.html" target="_blank">docs.ansible.com</a>') + '</p>',
|
||||
dataTitle: i18n._('Host Variables'),
|
||||
dataPlacement: 'right',
|
||||
dataContainer: 'body',
|
||||
|
||||
@ -66,33 +66,20 @@ function(i18n) {
|
||||
dataContainer: 'body',
|
||||
control: '<instance-groups-multiselect instance-groups="instance_groups" field-is-disabled="!(inventory_obj.summary_fields.user_capabilities.edit || canAdd)"></instance-groups-multiselect>',
|
||||
},
|
||||
// inventory_variables: {
|
||||
// realName: 'variables',
|
||||
// label: i18n._('Variables'),
|
||||
// type: 'textarea',
|
||||
// class: 'Form-formGroup--fullWidth',
|
||||
// rows: 6,
|
||||
// "default": "---",
|
||||
// awPopOver: i18n._('Enter inventory variables using either JSON or YAML syntax. Use the radio button to toggle between the two. Refer to the Ansible Tower documentation for example syntax.'),
|
||||
// dataTitle: i18n._('Variables'),
|
||||
// dataPlacement: 'right',
|
||||
// dataContainer: 'body',
|
||||
// ngDisabled: '!(inventory_obj.summary_fields.user_capabilities.edit || canAdd)' // TODO: get working
|
||||
// },
|
||||
inventory_variables: {
|
||||
realName: 'variables',
|
||||
// realName: 'variables',
|
||||
root: 'inventory',
|
||||
label: i18n._('Variables'),
|
||||
type: 'code_mirror',
|
||||
class: 'Form-formGroup--fullWidth',
|
||||
rows: 6,
|
||||
"default": "---",
|
||||
// rows: 6,
|
||||
// "default": "---",
|
||||
variables: 'inventory_variables',
|
||||
awPopOver: i18n._('Enter inventory variables using either JSON or YAML syntax. Use the radio button to toggle between the two. Refer to the Ansible Tower documentation for example syntax.'),
|
||||
dataTitle: i18n._('Variables'),
|
||||
dataPlacement: 'right',
|
||||
dataContainer: 'body',
|
||||
ngDisabled: '!(inventory_obj.summary_fields.user_capabilities.edit || canAdd)' // TODO: get working
|
||||
// dataTitle: i18n._('Variables'),
|
||||
// dataPlacement: 'right',
|
||||
// dataContainer: 'body',
|
||||
// ngDisabled: '!(inventory_obj.summary_fields.user_capabilities.edit || canAdd)' // TODO: get working
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
@ -1370,7 +1370,7 @@ angular.module('FormGenerator', [GeneratorHelpers.name, 'Utilities', listGenerat
|
||||
html += `class="${field.class}" `;
|
||||
html += `label="${field.label}" `;
|
||||
html += `tooltip="${field.awPopOver}" `;
|
||||
html += `name="${field.root}" `;
|
||||
html += `name="${fld}" `;
|
||||
html += `variables="${field.variables}" `;
|
||||
html += '></at-code-mirror>';
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user