mirror of
https://github.com/ansible/awx.git
synced 2026-07-28 16:39:56 -02:30
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:
46
awx/ui/static/js/helpers/LoadConfig.js
Normal file
46
awx/ui/static/js/helpers/LoadConfig.js
Normal 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');
|
||||
});
|
||||
};
|
||||
}]);
|
||||
Reference in New Issue
Block a user