mirror of
https://github.com/ansible/awx.git
synced 2026-07-28 16:39:56 -02:30
Merge pull request #6977 from gconsidine/ui/add/extra-env-vars
Add support for extra env vars in the configuration view
This commit is contained in:
@@ -55,6 +55,7 @@ export default [
|
|||||||
var formTracker = $scope.$parent.vm.formTracker;
|
var formTracker = $scope.$parent.vm.formTracker;
|
||||||
var dropdownValue = 'azure';
|
var dropdownValue = 'azure';
|
||||||
var activeAuthForm = 'azure';
|
var activeAuthForm = 'azure';
|
||||||
|
let codeInputInitialized = false;
|
||||||
|
|
||||||
// Default active form
|
// Default active form
|
||||||
if ($stateParams.currentTab === '' || $stateParams.currentTab === 'auth') {
|
if ($stateParams.currentTab === '' || $stateParams.currentTab === 'auth') {
|
||||||
@@ -244,8 +245,6 @@ export default [
|
|||||||
// Flag to avoid re-rendering and breaking Select2 dropdowns on tab switching
|
// Flag to avoid re-rendering and breaking Select2 dropdowns on tab switching
|
||||||
var dropdownRendered = false;
|
var dropdownRendered = false;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function populateLDAPGroupType(flag){
|
function populateLDAPGroupType(flag){
|
||||||
if($scope.$parent.AUTH_LDAP_GROUP_TYPE !== null) {
|
if($scope.$parent.AUTH_LDAP_GROUP_TYPE !== null) {
|
||||||
$scope.$parent.AUTH_LDAP_GROUP_TYPE = _.find($scope.$parent.AUTH_LDAP_GROUP_TYPE_options, { value: $scope.$parent.AUTH_LDAP_GROUP_TYPE });
|
$scope.$parent.AUTH_LDAP_GROUP_TYPE = _.find($scope.$parent.AUTH_LDAP_GROUP_TYPE_options, { value: $scope.$parent.AUTH_LDAP_GROUP_TYPE });
|
||||||
@@ -292,12 +291,24 @@ export default [
|
|||||||
populateTacacsProtocol(flag);
|
populateTacacsProtocol(flag);
|
||||||
});
|
});
|
||||||
|
|
||||||
$scope.$on('codeMirror_populated', function(e, key) {
|
$scope.$on('$locationChangeStart', (event, url) => {
|
||||||
startCodeMirrors(key);
|
let parts = url.split('/');
|
||||||
|
let tab = parts[parts.length - 1];
|
||||||
|
|
||||||
|
if (tab === 'auth' && !codeInputInitialized) {
|
||||||
|
startCodeMirrors();
|
||||||
|
codeInputInitialized = true;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$scope.$on('populated', function() {
|
$scope.$on('populated', function() {
|
||||||
|
let tab = $stateParams.currentTab;
|
||||||
|
|
||||||
|
if (tab === 'auth') {
|
||||||
startCodeMirrors();
|
startCodeMirrors();
|
||||||
|
codeInputInitialized = true;
|
||||||
|
}
|
||||||
|
|
||||||
populateLDAPGroupType(false);
|
populateLDAPGroupType(false);
|
||||||
populateTacacsProtocol(false);
|
populateTacacsProtocol(false);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -8,28 +8,35 @@ export default [
|
|||||||
'$scope',
|
'$scope',
|
||||||
'$rootScope',
|
'$rootScope',
|
||||||
'$state',
|
'$state',
|
||||||
|
'$stateParams',
|
||||||
'$timeout',
|
'$timeout',
|
||||||
'ConfigurationJobsForm',
|
'ConfigurationJobsForm',
|
||||||
'ConfigurationService',
|
'ConfigurationService',
|
||||||
'ConfigurationUtils',
|
'ConfigurationUtils',
|
||||||
'CreateSelect2',
|
'CreateSelect2',
|
||||||
'GenerateForm',
|
'GenerateForm',
|
||||||
|
'ParseTypeChange',
|
||||||
'i18n',
|
'i18n',
|
||||||
function(
|
function(
|
||||||
$scope,
|
$scope,
|
||||||
$rootScope,
|
$rootScope,
|
||||||
$state,
|
$state,
|
||||||
|
$stateParams,
|
||||||
$timeout,
|
$timeout,
|
||||||
ConfigurationJobsForm,
|
ConfigurationJobsForm,
|
||||||
ConfigurationService,
|
ConfigurationService,
|
||||||
ConfigurationUtils,
|
ConfigurationUtils,
|
||||||
CreateSelect2,
|
CreateSelect2,
|
||||||
GenerateForm,
|
GenerateForm,
|
||||||
|
ParseTypeChange,
|
||||||
i18n
|
i18n
|
||||||
) {
|
) {
|
||||||
var jobsVm = this;
|
|
||||||
var generator = GenerateForm;
|
var generator = GenerateForm;
|
||||||
var form = ConfigurationJobsForm;
|
var form = ConfigurationJobsForm;
|
||||||
|
|
||||||
|
let tab;
|
||||||
|
let codeInputInitialized = false;
|
||||||
|
|
||||||
$scope.$parent.AD_HOC_COMMANDS_options = [];
|
$scope.$parent.AD_HOC_COMMANDS_options = [];
|
||||||
_.each($scope.$parent.configDataResolve.AD_HOC_COMMANDS.default, function(command) {
|
_.each($scope.$parent.configDataResolve.AD_HOC_COMMANDS.default, function(command) {
|
||||||
$scope.$parent.AD_HOC_COMMANDS_options.push({
|
$scope.$parent.AD_HOC_COMMANDS_options.push({
|
||||||
@@ -75,6 +82,18 @@ export default [
|
|||||||
// Flag to avoid re-rendering and breaking Select2 dropdowns on tab switching
|
// Flag to avoid re-rendering and breaking Select2 dropdowns on tab switching
|
||||||
var dropdownRendered = false;
|
var dropdownRendered = false;
|
||||||
|
|
||||||
|
function initializeCodeInput () {
|
||||||
|
let name = 'AWX_TASK_ENV';
|
||||||
|
|
||||||
|
ParseTypeChange({
|
||||||
|
scope: $scope.$parent,
|
||||||
|
variable: name,
|
||||||
|
parseType: 'application/json',
|
||||||
|
field_id: `configuration_jobs_template_${name}`
|
||||||
|
});
|
||||||
|
|
||||||
|
$scope.parseTypeChange('parseType', name);
|
||||||
|
}
|
||||||
|
|
||||||
function populateAdhocCommand(flag){
|
function populateAdhocCommand(flag){
|
||||||
$scope.$parent.AD_HOC_COMMANDS = $scope.$parent.AD_HOC_COMMANDS.toString();
|
$scope.$parent.AD_HOC_COMMANDS = $scope.$parent.AD_HOC_COMMANDS.toString();
|
||||||
@@ -107,22 +126,55 @@ export default [
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$scope.$on('AD_HOC_COMMANDS_populated', function(e, data, flag) {
|
|
||||||
populateAdhocCommand(flag);
|
|
||||||
});
|
|
||||||
|
|
||||||
$scope.$on('populated', function() {
|
|
||||||
populateAdhocCommand(false);
|
|
||||||
});
|
|
||||||
|
|
||||||
// Fix for bug where adding selected opts causes form to be $dirty and triggering modal
|
// Fix for bug where adding selected opts causes form to be $dirty and triggering modal
|
||||||
// TODO Find better solution for this bug
|
// TODO Find better solution for this bug
|
||||||
$timeout(function(){
|
$timeout(function(){
|
||||||
$scope.$parent.configuration_jobs_template_form.$setPristine();
|
$scope.$parent.configuration_jobs_template_form.$setPristine();
|
||||||
}, 1000);
|
}, 1000);
|
||||||
|
|
||||||
angular.extend(jobsVm, {
|
$scope.$on('AD_HOC_COMMANDS_populated', function(e, data, flag) {
|
||||||
|
populateAdhocCommand(flag);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Controllers for each tab are initialized when configuration is opened. A listener
|
||||||
|
* on the URL itself is necessary to determine which tab is active. If a non-active
|
||||||
|
* tab initializes a codemirror, it doesn't display properly until the user navigates
|
||||||
|
* to the tab and it's been clicked.
|
||||||
|
*/
|
||||||
|
$scope.$on('$locationChangeStart', (event, url) => {
|
||||||
|
let parts = url.split('/');
|
||||||
|
tab = parts[parts.length - 1];
|
||||||
|
|
||||||
|
if (tab === 'jobs' && !codeInputInitialized) {
|
||||||
|
initializeCodeInput();
|
||||||
|
codeInputInitialized = true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Necessary to listen for revert clicks and relaunch the codemirror instance.
|
||||||
|
*/
|
||||||
|
$scope.$on('codeMirror_populated', () => {
|
||||||
|
if (tab === 'jobs') {
|
||||||
|
initializeCodeInput();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This event is fired if the user navigates directly to this tab, where the
|
||||||
|
* $locationChangeStart does not. Watching this and location ensure proper display on
|
||||||
|
* direct load of this tab or if the user comes from a different tab.
|
||||||
|
*/
|
||||||
|
$scope.$on('populated', () => {
|
||||||
|
tab = $stateParams.currentTab;
|
||||||
|
|
||||||
|
if (tab === 'jobs') {
|
||||||
|
initializeCodeInput();
|
||||||
|
codeInputInitialized = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
populateAdhocCommand(false);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -9,7 +9,6 @@
|
|||||||
showHeader: false,
|
showHeader: false,
|
||||||
name: 'configuration_jobs_template',
|
name: 'configuration_jobs_template',
|
||||||
showActions: true,
|
showActions: true,
|
||||||
|
|
||||||
fields: {
|
fields: {
|
||||||
AD_HOC_COMMANDS: {
|
AD_HOC_COMMANDS: {
|
||||||
type: 'select',
|
type: 'select',
|
||||||
@@ -59,8 +58,14 @@
|
|||||||
type: 'text',
|
type: 'text',
|
||||||
reset: 'ANSIBLE_FACT_CACHE_TIMEOUT',
|
reset: 'ANSIBLE_FACT_CACHE_TIMEOUT',
|
||||||
},
|
},
|
||||||
|
AWX_TASK_ENV: {
|
||||||
|
type: 'textarea',
|
||||||
|
reset: 'AWX_TASK_ENV',
|
||||||
|
rows: 6,
|
||||||
|
codeMirror: true,
|
||||||
|
class: 'Form-textAreaLabel Form-formGroup--fullWidth'
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
buttons: {
|
buttons: {
|
||||||
reset: {
|
reset: {
|
||||||
ngClick: 'vm.resetAllConfirm()',
|
ngClick: 'vm.resetAllConfirm()',
|
||||||
@@ -77,3 +82,4 @@
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
}];
|
}];
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user