1
0
mirror of https://github.com/ansible/awx.git synced 2024-11-01 16:51:11 +03:00

Hard coded config.js values, auto return promises

Removed config.js file
This commit is contained in:
Ken Hoes 2016-11-15 09:23:56 -05:00
parent 1a96b66f00
commit ea62500c5e
2 changed files with 52 additions and 109 deletions

View File

@ -1,59 +0,0 @@
/*************************************************
* Copyright (c) 2015 Ansible, Inc.
*
* All Rights Reserved
*************************************************/
/**********************************************************************
* config.js
*
* Gobal configuration variables for controlling application behavior.
*
* Do NOT change this file, unless the changes should be included in
* production builds. For development, copy this file to local_config.js,
* and make changes. git will ignore local_config.js
*
*/
/*jshint unused:false */
(function() {
//$.fn.modal.Constructor.DEFAULTS.backdrop = 'static';
return {
// custom_logo: true // load /var/lib/awx/public/static/assets/custom_console_logo.png as the login modal header. if false, will load the standard tower console logo
// custom_login_info: "example notice" // have a notice displayed in the login modal for users. note that, as a security measure, custom html is not supported and will be escaped.
password_length: 8, // Minimum user password length. Set to 0 to not set a limit
password_hasLowercase: true, // require a lowercase letter in the password
password_hasUppercase: false, // require an uppercase letter in the password
password_hasNumber: true, // require a number in the password
password_hasSymbol: false, // require one of these symbols to be
// in the password: -!$%^&*()_+|~=`{}[]:";'<>?,./
variable_edit_modes: { // Options we pass to ControlMirror for editing YAML/JSON variables
yaml: {
mode: "text/x-yaml",
matchBrackets: true,
autoCloseBrackets: true,
styleActiveLine: true,
lineNumbers: true,
gutters: ["CodeMirror-lint-markers"],
lint: true
},
json: {
mode: "application/json",
styleActiveLine: true,
matchBrackets: true,
autoCloseBrackets: true,
lineNumbers: true,
gutters: ["CodeMirror-lint-markers"],
lint: true
}
},
};
})();

View File

@ -27,56 +27,58 @@ angular.module('LoadConfigHelper', ['Utilities'])
function($log, $rootScope, $http, $location, ProcessErrors, Store) {
return function() {
if ($rootScope.removeLoadConfig) {
$rootScope.removeLoadConfig();
// These ettings used to be found in config.js, hardcoded now.
var configSettings = {
// custom_logo: true, // load /var/lib/awx/public/static/assets/custom_console_logo.png as the login modal header. if false, will load the standard tower console logo
// custom_login_info: "example notice", // have a notice displayed in the login modal for users. note that, as a security measure, custom html is not supported and will be escaped.
"tooltip_delay": {
"show": 500,
"hide": 100
},
"password_length": 8,
"password_hasLowercase": true,
"password_hasUppercase": false,
"password_hasNumber": true,
"password_hasSymbol": false,
"variable_edit_modes": {
"yaml": {
"mode": "text/x-yaml",
"matchBrackets": true,
"autoCloseBrackets": true,
"styleActiveLine": true,
"lineNumbers": true,
"gutters": ["CodeMirror-lint-markers"],
"lint": true
},
"json": {
"mode": "application/json",
"styleActiveLine": true,
"matchBrackets": true,
"autoCloseBrackets": true,
"lineNumbers": true,
"gutters": ["CodeMirror-lint-markers"],
"lint": true
}
$rootScope.removeLoadConfig = $rootScope.$on('LoadConfig', function() {
$rootScope.enteredPath = $location.path();
// Load js/local_settings.json
$http({ method:'GET', url: $basePath + 'local_settings.json' })
.then(function(response) {
$log.info('loaded local_settings.json');
if(angular.isObject(response.data)){
global.$AnsibleConfig = _.extend($AnsibleConfig, response.data);
Store('AnsibleConfig', global.$AnsibleConfig);
},
};
// Auto-resolving what used to be found when attempting to load local_setting.json
if ($rootScope.loginConfig) {
$rootScope.loginConfig.resolve('config loaded');
}
$rootScope.$emit('ConfigReady');
}
else {
$log.info('local_settings.json is not a valid object');
if ($rootScope.loginConfig) {
$rootScope.loginConfig.resolve('config loaded');
}
$rootScope.$emit('ConfigReady');
}
}, function() {
//local_settings.json not found
$log.info('local_settings.json not found');
if ($rootScope.loginConfig) {
$rootScope.loginConfig.resolve('config loaded');
}
$rootScope.$emit('ConfigReady');
});
});
// Load new hardcoded settings from above
// TODO Add a check for a custom image to add to the settings.
// Update flag to true
// in loginModal.controller load the base64 src
// change partial to use base65 in the img src
// load config.js
$log.info('attempting to load config.js');
$http({ method:'GET', url: $basePath + 'config.js' })
.then(function(response) {
$log.info('loaded config.js');
global.$AnsibleConfig = eval(response.data);
global.$AnsibleConfig = configSettings;
Store('AnsibleConfig', global.$AnsibleConfig);
$rootScope.$emit('LoadConfig');
})
.catch(function(response) {
response.data = 'Failed to load ' + $basePath + '/config.js';
ProcessErrors($rootScope, response, response.status, null, { hdr: 'Error!',
msg: 'Failed to load ' + $basePath + '/config.js.'
});
});
};
}]);
}
]);