Show busy indicator in reboot button
This commit is contained in:
@@ -139,7 +139,7 @@
|
||||
<div class="row">
|
||||
<div class="col-md-12 text-right">
|
||||
<a class="btn btn-primary" href="/logs.html?id=box" target="_blank">Show Logs</a>
|
||||
<button class="btn btn-danger" ng-click="reboot.show()">Reboot</button>
|
||||
<button class="btn btn-danger" ng-click="reboot.show()" ng-disabled="reboot.busy"><i class="fa fa-circle-notch fa-spin" ng-show="reboot.busy"></i> Reboot</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user