Add ui bits to be able to reboot the server

This commit is contained in:
Johannes Zellner
2018-11-26 09:24:58 +01:00
parent 1ed45656e4
commit ae488312a1
2 changed files with 83 additions and 18 deletions

View File

@@ -8,6 +8,7 @@ angular.module('Application').controller('SystemController', ['$scope', '$locati
$scope.config = Client.getConfig();
$scope.ready = false;
$scope.addons = {};
$scope.isRebootRequired = false;
function refresh(addonName, callback) {
callback = callback || function () {};
@@ -26,6 +27,27 @@ angular.module('Application').controller('SystemController', ['$scope', '$locati
});
}
$scope.reboot = {
busy: false,
show: function () {
$scope.reboot.busy = false;
$('#rebootModal').modal('show');
},
submit: function () {
$scope.reboot.busy = true;
Client.reboot(function (error) {
$scope.reboot.busy = false;
if (error) return Client.error(error);
$('#rebootModal').modal('hide');
});
}
};
$scope.restartAddon = function (addonName) {
function waitForActive(addonName) {
refresh(addonName, function () {
@@ -103,17 +125,23 @@ angular.module('Application').controller('SystemController', ['$scope', '$locati
};
Client.onReady(function () {
Client.getAddons(function (error, result) {
if (error) return Client.error(error);
Client.isRebootRequired(function (error, result) {
if (error) console.error(error);
result.forEach(function (a) {
$scope.addons[a] = { name: a };
$scope.isRebootRequired = !!result;
Client.getAddons(function (error, result) {
if (error) return Client.error(error);
result.forEach(function (a) {
$scope.addons[a] = { name: a };
});
// just kick off the status fetching
refreshAll();
$scope.ready = true;
});
// just kick off the status fetching
refreshAll();
$scope.ready = true;
});
});
}]);