Do not redirect to error.html if the angular main application fails to init

We now only show the offline banner and retry the application init until
box comes back up
This commit is contained in:
Johannes Zellner
2019-09-05 22:22:42 +02:00
parent 8b8b137cad
commit b6e00a3107
9 changed files with 154 additions and 222 deletions

View File

@@ -5,7 +5,7 @@
/* global EventSource:false */
/* global asyncForEach:false */
angular.module('Application').service('Client', ['$http', '$interval', 'md5', 'Notification', function ($http, $interval, md5, Notification) {
angular.module('Application').service('Client', ['$http', '$interval', '$timeout', 'md5', 'Notification', function ($http, $interval, $timeout, md5, Notification) {
var client = null;
// variable available only here to avoid this._property pattern
@@ -190,6 +190,13 @@ angular.module('Application').service('Client', ['$http', '$interval', 'md5', 'N
Notification.error({ title: 'Cloudron Error', message: message });
};
// handles application startup errors, mostly only when dashboard is loaded and api endpoint is down
Client.prototype.initError = function (error, initFunction) {
console.error('Application startup error', error);
$timeout(initFunction, 5000); // we will try to re-init the app
};
Client.prototype.clearNotifications = function () {
Notification.clearAll();
};