promise function was outdated for $http request of config.js

using .catch instead of .error
This commit is contained in:
Jared Tabor
2015-10-27 20:49:37 -07:00
parent 32962bcadc
commit 12d31c5099
3 changed files with 17 additions and 11 deletions

View File

@@ -57,15 +57,16 @@ angular.module('LoadConfigHelper', ['Utilities'])
// load config.js
$log.info('attempting to load config.js');
$http({ method:'GET', url: $basePath + 'config.js' })
.success(function(data) {
.then(function(data) {
$log.info('loaded config.js');
$AnsibleConfig = eval(data);
Store('AnsibleConfig', $AnsibleConfig);
$rootScope.$emit('LoadConfig');
})
.error(function(data, status) {
ProcessErrors($rootScope, data, status, null, { hdr: 'Error!',
msg: 'Failed to load ' + $basePath + '/config.js. GET status: ' + status
.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.'
});
});
};

View File

@@ -25,7 +25,7 @@
var options = [],
error = "";
function parseGoogle(option, key) {
function parseGoogle(option) {
var newOption = {};
newOption.type = "google";

View File

@@ -252,15 +252,20 @@ angular.module('Utilities', ['RestServices', 'Utilities', 'sanitizeFilter'])
if ((!fieldErrors) && defaultMsg) {
Alert(defaultMsg.hdr, defaultMsg.msg);
}
} else if (typeof data === 'object' && Object.keys(data).length > 0) {
keys = Object.keys(data);
if (Array.isArray(data[keys[0]])) {
msg = data[keys[0]][0];
} else if (typeof data === 'object'){
if(Object.keys(data).length > 0) {
keys = Object.keys(data);
if (Array.isArray(data[keys[0]])) {
msg = data[keys[0]][0];
}
else {
msg = data[keys[0]];
}
Alert(defaultMsg.hdr, msg);
}
else {
msg = data[keys[0]];
Alert(defaultMsg.hdr, defaultMsg.msg);
}
Alert(defaultMsg.hdr, msg);
} else {
Alert(defaultMsg.hdr, defaultMsg.msg);
}