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

View File

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

View File

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