Show notification if platform status is not Ready

This commit is contained in:
Johannes Zellner
2022-11-30 20:54:58 +01:00
parent 1848c922c1
commit fc08c45add
2 changed files with 40 additions and 1 deletions

View File

@@ -3,7 +3,7 @@
/* global angular */
/* global $ */
angular.module('Application').controller('MainController', ['$scope', '$route', '$timeout', '$location', '$interval', 'Client', function ($scope, $route, $timeout, $location, $interval, Client) {
angular.module('Application').controller('MainController', ['$scope', '$route', '$timeout', '$location', '$interval', 'Notification', 'Client', function ($scope, $route, $timeout, $location, $interval, Notification, Client) {
$scope.initialized = false; // used to animate the UI
$scope.user = Client.getUserInfo();
$scope.installedApps = Client.getInstalledApps();
@@ -87,6 +87,35 @@ angular.module('Application').controller('MainController', ['$scope', '$route',
if ($scope.initialized) redirectOnMandatory2FA();
});
var gPlatformStatusNotification = null;
function trackPlatformStatus() {
Client.getPlatformStatus(function (error, result) {
if (error) return console.error('Failed to get platform status.', error);
// see box/src/platform.js
if (result.message === 'Ready') {
if (gPlatformStatusNotification) {
gPlatformStatusNotification.kill();
gPlatformStatusNotification = null;
}
return;
}
if (!gPlatformStatusNotification) {
var options = { title: 'Platform status', message: result.message, delay: 'notimeout', replaceMessage: true, closeOnClick: false };
Notification.primary(options).then(function (result) {
gPlatformStatusNotification = result;
$timeout(trackPlatformStatus, 1000);
});
} else {
gPlatformStatusNotification.message = result.message;
$timeout(trackPlatformStatus, 1000);
}
});
}
function init() {
Client.getStatus(function (error, status) {
if (error) return Client.initError(error, init);
@@ -154,6 +183,8 @@ angular.module('Application').controller('MainController', ['$scope', '$route',
$interval(refreshNotifications, 60 * 1000);
refreshNotifications();
trackPlatformStatus();
$scope.updateSubscriptionStatus();
});
});