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

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');
});
};
}]);