1
0
mirror of https://github.com/ansible/awx.git synced 2024-10-27 09:25:10 +03:00

local_config.js

Look for local_config.js. If not found, load config.js. Set debug_mode to true and make other config changes locally without affecting production builds.
This commit is contained in:
Chris Houseknecht 2014-07-25 10:25:37 -04:00
parent f0cb84d973
commit d872aa1985
5 changed files with 92 additions and 36 deletions

1
.gitignore vendored
View File

@ -7,6 +7,7 @@ awx/job_output
awx/public/media
awx/public/static
awx/ui/static/js/awx.min.js
awx/ui/static/js/local_config.js
awx/ui/static/css/awx.min.css
awx/main/fixtures
awx/tower_warnings.log

View File

@ -5,6 +5,7 @@
*
*/
var urlPrefix = $basePath;
var $AnsibleConfig;
angular.module('Tower', [
'ngRoute',
@ -99,7 +100,8 @@ angular.module('Tower', [
'HostEventsViewerHelper',
'JobDetailHelper',
'SocketIO',
'lrInfiniteScroll'
'lrInfiniteScroll',
'LoadConfigHelper'
])
.constant('AngularScheduler.partials', $basePath + 'lib/angular-scheduler/lib/')
@ -407,12 +409,13 @@ angular.module('Tower', [
}])
.run(['$compile', '$cookieStore', '$rootScope', '$log', 'CheckLicense', '$location', 'Authorization', 'LoadBasePaths', 'ViewLicense',
'Timer', 'ClearScope', 'HideStream', 'Socket',
'Timer', 'ClearScope', 'HideStream', 'Socket', 'LoadConfig',
function ($compile, $cookieStore, $rootScope, $log, CheckLicense, $location, Authorization, LoadBasePaths, ViewLicense,
Timer, ClearScope, HideStream, Socket) {
Timer, ClearScope, HideStream, Socket, LoadConfig) {
var e, html, sock, checkCount;
LoadConfig();
LoadBasePaths();
$rootScope.breadcrumbs = [];

View File

@ -5,49 +5,55 @@
* 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 */
var $AnsibleConfig = {
(function() {
return {
tooltip_delay: {show: 500, hide: 100}, // Default number of milliseconds to delay displaying/hiding tooltips
tooltip_delay: {show: 500, hide: 100}, // Default number of milliseconds to delay displaying/hiding tooltips
debug_mode: false, // Enable console logging messages
debug_mode: false, // Enable console logging messages
password_strength: 45, // User password strength. Integer between 0 and 100, 100 being impossibly strong.
// This value controls progress bar colors:
// 0 to password_strength - 15 = red;
// password_strength - 15 to password_strength = yellow
// > password_strength = green
// It also controls password validation. Passwords are rejected if the score is not > password_strength.
password_strength: 45, // User password strength. Integer between 0 and 100, 100 being impossibly strong.
// This value controls progress bar colors:
// 0 to password_strength - 15 = red;
// password_strength - 15 to password_strength = yellow
// > password_strength = green
// It also controls password validation. Passwords are rejected if the score is not > password_strength.
session_timeout: 1800, // Number of seconds before an inactive session is automatically timed out and forced to log in again.
// Separate from time out value set in API.
session_timeout: 1800, // Number of seconds before an inactive session is automatically timed out and forced to log in again.
// Separate from time out value set in API.
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
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
}
},
json: {
mode: "application/json",
styleActiveLine: true,
matchBrackets: true,
autoCloseBrackets: true,
lineNumbers: true,
gutters: ["CodeMirror-lint-markers"],
lint: true
}
},
websocket_port: 8080
websocket_port: 8080
};
};
})();

View File

@ -0,0 +1,46 @@
/*********************************************
* Copyright (c) 2014 AnsibleWorks, Inc.
*
* LoadConfigHelper
*
* Attempts to load local_config.js. If not found, loads config.js. Then evaluates the loaded
* javascript, putting the result in $AnsibleConfig.
*
*/
/*jshint evil:true */
'use strict';
angular.module('LoadConfigHelper', ['Utilities'])
.factory('LoadConfig', ['$rootScope', '$http', 'ProcessErrors', function($rootScope, $http, ProcessErrors) {
return function() {
if ($rootScope.removeLoadConfig) {
$rootScope.removeLoadConfig();
}
$rootScope.removeLoadConfig = $rootScope.$on('LoadConfig', function() {
// local_config.js not found, so we'll load config.js
$http({ method:'GET', url: $basePath + 'js/config.js' })
.success(function(data) {
$AnsibleConfig = eval(data);
})
.error(function(data, status) {
ProcessErrors($rootScope, data, status, null, { hdr: 'Error!',
msg: 'Failed to load ' + $basePath + '/config.js. GET status: ' + status
});
});
});
// Load js/local_config.js
$http({ method:'GET', url: $basePath + 'js/local_config.js' })
.success(function(data) {
$AnsibleConfig = eval(data);
})
.error(function() {
//local_config.js not found
$rootScope.$emit('LoadConfig');
});
};
}]);

View File

@ -25,7 +25,6 @@
<script>
var $basePath = "{{ STATIC_URL }}";
</script>
<script src="{{ STATIC_URL }}js/config.js"></script>
<script src="{{ STATIC_URL }}lib/jquery/dist/jquery.min.js"></script>
<script src="{{ STATIC_URL }}lib/angular/angular.min.js"></script>
<script src="{{ STATIC_URL }}lib/angular-route/angular-route.min.js"></script>
@ -126,6 +125,7 @@
<script src="{{ STATIC_URL }}js/lists/Hosts.js"></script>
<script src="{{ STATIC_URL }}js/lists/Schedules.js"></script>
<script src="{{ STATIC_URL }}js/lists/ScheduledJobs.js"></script>
<script src="{{ STATIC_URL }}js/helpers/LoadConfig.js"></script>
<script src="{{ STATIC_URL }}js/helpers/refresh-related.js"></script>
<script src="{{ STATIC_URL }}js/helpers/related-search.js"></script>
<script src="{{ STATIC_URL }}js/helpers/refresh.js"></script>