Add basic UI controls for start, stop, logs and show status
This commit is contained in:
+23
-3
@@ -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);
|
||||
}]);
|
||||
|
||||
Reference in New Issue
Block a user