Show busy indicator in reboot button

This commit is contained in:
Girish Ramakrishnan
2020-02-25 14:54:29 -08:00
parent afde058a85
commit 303c55dbba
2 changed files with 15 additions and 3 deletions

View File

@@ -3,7 +3,7 @@
/* global angular:false */
/* global $:false */
angular.module('Application').controller('SystemController', ['$scope', '$location', '$interval', 'Client', function ($scope, $location, $interval, Client) {
angular.module('Application').controller('SystemController', ['$scope', '$location', '$timeout', 'Client', function ($scope, $location, $timeout, Client) {
Client.onReady(function () { if (!Client.getUserInfo().isAtLeastAdmin) $location.path('/'); });
$scope.config = Client.getConfig();
@@ -45,14 +45,26 @@ angular.module('Application').controller('SystemController', ['$scope', '$locati
$('#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) {
$scope.reboot.busy = false;
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);
});
}
};