mirror of
https://github.com/ansible/awx.git
synced 2026-03-22 11:25:08 -02:30
Merge pull request #5500 from jaredevantabor/ctit-reset
[CTiT] Reverting All The Things
This commit is contained in:
@@ -171,26 +171,36 @@ export default [
|
|||||||
form.buttons.save.disabled = $rootScope.user_is_system_auditor;
|
form.buttons.save.disabled = $rootScope.user_is_system_auditor;
|
||||||
});
|
});
|
||||||
|
|
||||||
function startCodeMirrors(){
|
function startCodeMirrors(key){
|
||||||
// Attach codemirror to fields that need it
|
var form = _.find(authForms, function(f){
|
||||||
let form = _.find(authForms, function(form){
|
return f.name === $scope.authVm.activeAuthForm;
|
||||||
return form.name === $scope.authVm.activeAuthForm;
|
|
||||||
});
|
|
||||||
_.each(form.formDef.fields, function(field) {
|
|
||||||
// Codemirror balks at empty values so give it one
|
|
||||||
if($scope.$parent[field.name] === null && field.codeMirror) {
|
|
||||||
$scope.$parent[field.name] = '{}';
|
|
||||||
}
|
|
||||||
if(field.codeMirror) {
|
|
||||||
ParseTypeChange({
|
|
||||||
scope: $scope.$parent,
|
|
||||||
variable: field.name,
|
|
||||||
parse_variable: 'parseType',
|
|
||||||
field_id: form.formDef.name + '_' + field.name
|
|
||||||
});
|
|
||||||
$scope.parseTypeChange('parseType', field.name);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if(!key){
|
||||||
|
// Attach codemirror to fields that need it
|
||||||
|
_.each(form.formDef.fields, function(field) {
|
||||||
|
// Codemirror balks at empty values so give it one
|
||||||
|
if($scope.$parent[field.name] === null && field.codeMirror) {
|
||||||
|
$scope.$parent[field.name] = '{}';
|
||||||
|
}
|
||||||
|
if(field.codeMirror) {
|
||||||
|
createIt(field.name);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else if(key){
|
||||||
|
createIt(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
function createIt(name){
|
||||||
|
ParseTypeChange({
|
||||||
|
scope: $scope.$parent,
|
||||||
|
variable: name,
|
||||||
|
parse_variable: 'parseType',
|
||||||
|
field_id: form.formDef.name + '_' + name
|
||||||
|
});
|
||||||
|
$scope.parseTypeChange('parseType', name);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function addFieldInfo(form, key) {
|
function addFieldInfo(form, key) {
|
||||||
@@ -227,16 +237,15 @@ 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;
|
||||||
|
|
||||||
$scope.$on('populated', function() {
|
|
||||||
startCodeMirrors();
|
|
||||||
|
|
||||||
// Create Select2 fields
|
|
||||||
var opts = [];
|
function populateLDAPGroupType(flag){
|
||||||
if($scope.$parent.AUTH_LDAP_GROUP_TYPE !== null) {
|
if($scope.$parent.AUTH_LDAP_GROUP_TYPE !== null) {
|
||||||
opts.push({
|
$scope.$parent.AUTH_LDAP_GROUP_TYPE = _.find($scope.$parent.AUTH_LDAP_GROUP_TYPE_options, { value: $scope.$parent.AUTH_LDAP_GROUP_TYPE });
|
||||||
id: $scope.$parent.AUTH_LDAP_GROUP_TYPE,
|
}
|
||||||
text: $scope.$parent.AUTH_LDAP_GROUP_TYPE
|
|
||||||
});
|
if(flag !== undefined){
|
||||||
|
dropdownRendered = flag;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!dropdownRendered) {
|
if(!dropdownRendered) {
|
||||||
@@ -245,15 +254,21 @@ export default [
|
|||||||
element: '#configuration_ldap_template_AUTH_LDAP_GROUP_TYPE',
|
element: '#configuration_ldap_template_AUTH_LDAP_GROUP_TYPE',
|
||||||
multiple: false,
|
multiple: false,
|
||||||
placeholder: i18n._('Select group types'),
|
placeholder: i18n._('Select group types'),
|
||||||
opts: opts
|
|
||||||
});
|
});
|
||||||
// Fix for bug where adding selected opts causes form to be $dirty and triggering modal
|
|
||||||
// TODO Find better solution for this bug
|
|
||||||
$timeout(function(){
|
|
||||||
$scope.$parent.configuration_ldap_template_form.$setPristine();
|
|
||||||
}, 1000);
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$scope.$on('AUTH_LDAP_GROUP_TYPE_populated', function(e, data, flag) {
|
||||||
|
populateLDAPGroupType(flag);
|
||||||
|
});
|
||||||
|
|
||||||
|
$scope.$on('codeMirror_populated', function(e, key) {
|
||||||
|
startCodeMirrors(key);
|
||||||
|
});
|
||||||
|
|
||||||
|
$scope.$on('populated', function() {
|
||||||
|
startCodeMirrors();
|
||||||
|
populateLDAPGroupType();
|
||||||
});
|
});
|
||||||
|
|
||||||
angular.extend(authVm, {
|
angular.extend(authVm, {
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ export default [
|
|||||||
// we want the options w/o a space, and
|
// we want the options w/o a space, and
|
||||||
// the ConfigurationUtils.arrayToList()
|
// the ConfigurationUtils.arrayToList()
|
||||||
// does a string.split(', ') w/ an extra space
|
// does a string.split(', ') w/ an extra space
|
||||||
// behind the comma.
|
// behind the comma.
|
||||||
if(key === "AD_HOC_COMMANDS"){
|
if(key === "AD_HOC_COMMANDS"){
|
||||||
$scope[key] = data[key].toString();
|
$scope[key] = data[key].toString();
|
||||||
}
|
}
|
||||||
@@ -295,9 +295,20 @@ export default [
|
|||||||
ConfigurationService.patchConfiguration(payload)
|
ConfigurationService.patchConfiguration(payload)
|
||||||
.then(function() {
|
.then(function() {
|
||||||
$scope[key] = $scope.configDataResolve[key].default;
|
$scope[key] = $scope.configDataResolve[key].default;
|
||||||
if(key === "AD_HOC_COMMANDS"){
|
if($scope[key + '_field'].type === "select"){
|
||||||
$scope.AD_HOC_COMMANDS = $scope.AD_HOC_COMMANDS.toString();
|
// We need to re-instantiate the Select2 element
|
||||||
$scope.$broadcast('adhoc_populated', null, false);
|
// after resetting the value. Example:
|
||||||
|
$scope.$broadcast(key+'_populated', null, false);
|
||||||
|
}
|
||||||
|
else if($scope[key + '_field'].reset === "CUSTOM_LOGO"){
|
||||||
|
$scope.$broadcast(key+'_reverted');
|
||||||
|
}
|
||||||
|
else if($scope[key + '_field'].type === "textarea" && _.isArray($scope.configDataResolve[key].default)){
|
||||||
|
$scope[key] = ConfigurationUtils.arrayToList($scope[key], key);
|
||||||
|
}
|
||||||
|
else if($scope[key + '_field'].hasOwnProperty('codeMirror')){
|
||||||
|
$scope[key] = '{}';
|
||||||
|
$scope.$broadcast('codeMirror_populated', key);
|
||||||
}
|
}
|
||||||
loginUpdate();
|
loginUpdate();
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -77,6 +77,7 @@ export default [
|
|||||||
|
|
||||||
|
|
||||||
function populateAdhocCommand(flag){
|
function populateAdhocCommand(flag){
|
||||||
|
$scope.$parent.AD_HOC_COMMANDS = $scope.$parent.AD_HOC_COMMANDS.toString();
|
||||||
var ad_hoc_commands = $scope.$parent.AD_HOC_COMMANDS.split(',');
|
var ad_hoc_commands = $scope.$parent.AD_HOC_COMMANDS.split(',');
|
||||||
$scope.$parent.AD_HOC_COMMANDS = _.map(ad_hoc_commands, (item) => _.find($scope.$parent.AD_HOC_COMMANDS_options, { value: item }));
|
$scope.$parent.AD_HOC_COMMANDS = _.map(ad_hoc_commands, (item) => _.find($scope.$parent.AD_HOC_COMMANDS_options, { value: item }));
|
||||||
|
|
||||||
@@ -94,7 +95,7 @@ export default [
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$scope.$on('adhoc_populated', function(e, data, flag) {
|
$scope.$on('AD_HOC_COMMANDS_populated', function(e, data, flag) {
|
||||||
populateAdhocCommand(flag);
|
populateAdhocCommand(flag);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -152,16 +152,21 @@ export default [
|
|||||||
|
|
||||||
var dropdownRendered = false;
|
var dropdownRendered = false;
|
||||||
|
|
||||||
$scope.$on('populated', function() {
|
$scope.$on('populated', function(e, data, flag) {
|
||||||
|
populateLogAggregator(flag);
|
||||||
|
});
|
||||||
|
|
||||||
var opts = [];
|
$scope.$on('LOG_AGGREGATOR_TYPE_populated', function(e, data, flag) {
|
||||||
|
populateLogAggregator(flag);
|
||||||
|
});
|
||||||
|
|
||||||
|
function populateLogAggregator(flag){
|
||||||
if($scope.$parent.LOG_AGGREGATOR_TYPE !== null) {
|
if($scope.$parent.LOG_AGGREGATOR_TYPE !== null) {
|
||||||
_.each(ConfigurationUtils.listToArray($scope.$parent.LOG_AGGREGATOR_TYPE), function(type) {
|
$scope.$parent.LOG_AGGREGATOR_TYPE = _.find($scope.$parent.LOG_AGGREGATOR_TYPE_options, { value: $scope.$parent.LOG_AGGREGATOR_TYPE });
|
||||||
opts.push({
|
}
|
||||||
id: type,
|
|
||||||
text: type
|
if(flag !== undefined){
|
||||||
});
|
dropdownRendered = flag;
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!dropdownRendered) {
|
if(!dropdownRendered) {
|
||||||
@@ -170,11 +175,10 @@ export default [
|
|||||||
element: '#configuration_logging_template_LOG_AGGREGATOR_TYPE',
|
element: '#configuration_logging_template_LOG_AGGREGATOR_TYPE',
|
||||||
multiple: false,
|
multiple: false,
|
||||||
placeholder: i18n._('Select types'),
|
placeholder: i18n._('Select types'),
|
||||||
opts: opts
|
|
||||||
});
|
});
|
||||||
|
$scope.$parent.configuration_logging_template_form.LOG_AGGREGATOR_TYPE.$setPristine();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
});
|
|
||||||
|
|
||||||
// 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
|
||||||
|
|||||||
@@ -78,24 +78,31 @@
|
|||||||
// 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;
|
||||||
|
|
||||||
$scope.$on('populated', function(){
|
function populatePendoTrackingState(flag){
|
||||||
|
if($scope.$parent.PENDO_TRACKING_STATE !== null) {
|
||||||
|
$scope.$parent.PENDO_TRACKING_STATE = _.find($scope.$parent.PENDO_TRACKING_STATE_options, { value: $scope.$parent.PENDO_TRACKING_STATE });
|
||||||
|
}
|
||||||
|
|
||||||
|
if(flag !== undefined){
|
||||||
|
dropdownRendered = flag;
|
||||||
|
}
|
||||||
|
|
||||||
if(!dropdownRendered) {
|
if(!dropdownRendered) {
|
||||||
dropdownRendered = true;
|
dropdownRendered = true;
|
||||||
CreateSelect2({
|
CreateSelect2({
|
||||||
element: '#configuration_ui_template_PENDO_TRACKING_STATE',
|
element: '#configuration_ui_template_PENDO_TRACKING_STATE',
|
||||||
multiple: false,
|
multiple: false,
|
||||||
placeholder: i18n._('Select commands'),
|
placeholder: i18n._('Select commands')
|
||||||
opts: [{
|
|
||||||
id: $scope.$parent.PENDO_TRACKING_STATE,
|
|
||||||
text: $scope.$parent.PENDO_TRACKING_STATE
|
|
||||||
}]
|
|
||||||
});
|
});
|
||||||
// Fix for bug where adding selected opts causes form to be $dirty and triggering modal
|
|
||||||
// TODO Find better solution for this bug
|
|
||||||
$timeout(function(){
|
|
||||||
$scope.$parent.configuration_ui_template_form.$setPristine();
|
|
||||||
}, 1000);
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$scope.$on('PENDO_TRACKING_STATE_populated', function(e, data, flag) {
|
||||||
|
populatePendoTrackingState(flag);
|
||||||
|
});
|
||||||
|
|
||||||
|
$scope.$on('populated', function(e, data, flag){
|
||||||
|
populatePendoTrackingState(flag);
|
||||||
});
|
});
|
||||||
|
|
||||||
angular.extend(uiVm, {
|
angular.extend(uiVm, {
|
||||||
|
|||||||
@@ -159,6 +159,7 @@ function(ConfigurationUtils, i18n, $rootScope) {
|
|||||||
var filePickerText = angular.element(document.getElementById('filePickerText'));
|
var filePickerText = angular.element(document.getElementById('filePickerText'));
|
||||||
var filePickerError = angular.element(document.getElementById('filePickerError'));
|
var filePickerError = angular.element(document.getElementById('filePickerError'));
|
||||||
var filePickerButton = angular.element(document.getElementById('filePickerButton'));
|
var filePickerButton = angular.element(document.getElementById('filePickerButton'));
|
||||||
|
var filePicker = angular.element(document.getElementById('filePicker'));
|
||||||
|
|
||||||
scope.imagePresent = global.$AnsibleConfig.custom_logo || false;
|
scope.imagePresent = global.$AnsibleConfig.custom_logo || false;
|
||||||
scope.imageData = $rootScope.custom_logo;
|
scope.imageData = $rootScope.custom_logo;
|
||||||
@@ -168,12 +169,18 @@ function(ConfigurationUtils, i18n, $rootScope) {
|
|||||||
scope.imageData = $rootScope.custom_logo;
|
scope.imageData = $rootScope.custom_logo;
|
||||||
});
|
});
|
||||||
|
|
||||||
scope.update = function(e) {
|
scope.$on(fieldKey+'_reverted', function(e) {
|
||||||
if(scope.$parent[fieldKey]) {
|
scope.update(e, true);
|
||||||
|
});
|
||||||
|
|
||||||
|
scope.update = function(e, flag) {
|
||||||
|
if(scope.$parent[fieldKey] || flag ) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
scope.$parent[fieldKey] = '';
|
scope.$parent[fieldKey] = '';
|
||||||
filePickerButton.html(browseText);
|
filePickerButton.html(browseText);
|
||||||
filePickerText.val('');
|
filePickerText.val('');
|
||||||
|
filePicker.value = "";
|
||||||
|
scope.imagePresent = false;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// Nothing exists so open file picker
|
// Nothing exists so open file picker
|
||||||
|
|||||||
@@ -679,7 +679,7 @@ angular.module('FormGenerator', [GeneratorHelpers.name, 'Utilities', listGenerat
|
|||||||
|
|
||||||
if(field.reset && !field.disabled) {
|
if(field.reset && !field.disabled) {
|
||||||
var resetValue = "'" + field.reset+ "'";
|
var resetValue = "'" + field.reset+ "'";
|
||||||
var resetMessage = i18n._('Reset');
|
var resetMessage = i18n._('Revert');
|
||||||
html+= `<a class="Form-resetValue" ng-click="resetValue(${resetValue})">${resetMessage}</a>`;
|
html+= `<a class="Form-resetValue" ng-click="resetValue(${resetValue})">${resetMessage}</a>`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user