Skip to content

Commit

Permalink
fix(dashboard): handle rejection better
Browse files Browse the repository at this point in the history
  • Loading branch information
Benjamin Reed committed Jul 7, 2015
1 parent aa22467 commit dd15194
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 10 deletions.
2 changes: 1 addition & 1 deletion config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,4 @@
<icon src="resources/ios/icon/icon-small@2x.png" width="58" height="58"/>
</platform>
<icon src="resources/android/icon/drawable-xhdpi-icon.png"/>
</widget>
</widget>
3 changes: 1 addition & 2 deletions www/scripts/opennms/controllers/Dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
console.log('DashboardCtrl: Initializing.');

var updateArrows = function(height) {
//console.log('updateArrows(' + height +')');
var arrowOffset = (Math.round(height * 0.5) - 50);

var outageArrow = document.getElementById('outage-arrow');
Expand Down Expand Up @@ -337,7 +336,7 @@
updateLogo();

util.onSettingsUpdated(function(newSettings, oldSettings, changedSettings) {
//console.log('Dashboard: settings changed, refreshing data.');
console.log('Dashboard: settings changed, refreshing data.');
Settings.getServerName().then(function(serverName) {
$scope.serverName = serverName;
$scope.refreshData();
Expand Down
4 changes: 2 additions & 2 deletions www/scripts/opennms/controllers/Settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,12 @@
console.log('SettingsCtrl: checking for availability of onms://');
$window.appAvailability.check('onms://',
function() {
console.log('SettingsCtrl: OpenNMS is available!');
console.log('SettingsCtrl: OpenNMS.app is available!');
$scope.$evalAsync(function() {
$scope.hasOpenNMS = true;
});
}, function() {
console.log('SettingsCtrl: OpenNMS is not available. :(');
console.log('SettingsCtrl: OpenNMS.app is not available. :(');
$scope.$evalAsync(function() {
$scope.hasOpenNMS = false;
});
Expand Down
21 changes: 16 additions & 5 deletions www/scripts/opennms/services/Rest.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,19 @@
var oldReady = ready;
ready = $q.defer();

var done = function() {
var done = function(reject) {
if (oldReady) {
oldReady.resolve(true);
if (reject) {
oldReady.reject(false);
} else {
oldReady.resolve(true);
}
}
if (reject) {
ready.reject(false);
} else {
ready.resolve(true);
}
ready.resolve(true);
return ready.promise;
};

Expand All @@ -80,17 +88,20 @@
//console.log('RestService.updateAuthorization: setting basic auth with username "' + username + '".');
$http.defaults.headers.common['Authorization'] = 'Basic ' + $window.btoa(username + ':' + password);
if (useCordovaHTTP) {
cordovaHTTP.useBasicAuth(username, password).then(function() {
return cordovaHTTP.useBasicAuth(username, password).then(function() {
console.log('RestService.updateAuthorization: configured basic auth with username "' + username + '".');
return done();
}, function(err) {
console.log('RestService.updateAuthorization: failed to configure basic auth with username "' + username + '".');
}, function() {
return done();
});
} else {
return done();
}
}
}, function(err) {
console.log('RestService.updateAuthorization: failed: ' + angular.toJson(err));
return done(true);
});
};

Expand Down

0 comments on commit dd15194

Please sign in to comment.