Implement specific reboot notification action

This commit is contained in:
Johannes Zellner
2020-03-05 21:08:27 -08:00
parent 0ea2f48d94
commit 1f0965fdf6
3 changed files with 53 additions and 20 deletions

View File

@@ -3,10 +3,42 @@
/* global asyncForEach:false */
/* global angular:false */
angular.module('Application').controller('NotificationsController', ['$scope', 'Client', function ($scope, Client) {
angular.module('Application').controller('NotificationsController', ['$scope', '$timeout', 'Client', function ($scope, $timeout, Client) {
$scope.clearAllBusy = false;
$scope.reboot = {
busy: false,
show: function () {
$scope.reboot.busy = false;
$('#rebootModal').modal('show');
},
waitForReboot: function () {
if (Client.offline) return $scope.reboot.busy = false; // at this point, we are showing the offline banner
Client.getStatus(function (error, status) {
if (error) return $timeout($scope.reboot.waitForReboot, 5000);
$scope.reboot.busy = false;
});
},
submit: function () {
$scope.reboot.busy = true;
Client.reboot(function (error) {
if (error) return Client.error(error);
$('#rebootModal').modal('hide');
// show "busy" indicator for 5 seconds to show some ui activity
$timeout(function () { $scope.reboot.waitForReboot(); }, 5000);
});
}
};
$scope.notifications = {
notifications: [],
activeNotification: null,