Add basic UI controls for start, stop, logs and show status

This commit is contained in:
Johannes Zellner
2018-11-16 17:21:57 +01:00
parent 699db93b18
commit 50963f00c0
3 changed files with 43 additions and 9 deletions
+23 -3
View File
@@ -1,17 +1,37 @@
'use strict';
/* global angular */
angular.module('Application').controller('AddonsController', ['$scope', '$location', 'Client', function ($scope, $location, Client) {
Client.onReady(function () { if (!Client.getUserInfo().admin) $location.path('/'); });
$scope.ready = false;
$scope.addons = [];
Client.onReady(function () {
function refresh() {
Client.getAddons(function (error, result) {
if (error) return Client.error(error);
$scope.addons = result.map(function (a) { return { name: a }; });
$scope.addons = result.map(function (a) { return { name: a, state: 'active' }; });
$scope.ready = true;
});
});
}
$scope.startAddon = function (addonName) {
Client.startAddon(addonName, function (error) {
if (error) return Client.error(error);
refresh();
});
};
$scope.stopAddon = function (addonName) {
Client.stopAddon(addonName, function (error) {
if (error) return Client.error(error);
refresh();
});
};
Client.onReady(refresh);
}]);