Handle addon state correctly
This commit is contained in:
+20
-8
@@ -6,14 +6,13 @@ angular.module('Application').controller('AddonsController', ['$scope', '$locati
|
||||
Client.onReady(function () { if (!Client.getUserInfo().admin) $location.path('/'); });
|
||||
|
||||
$scope.ready = false;
|
||||
$scope.addons = [];
|
||||
$scope.addons = {};
|
||||
|
||||
function refresh() {
|
||||
Client.getAddons(function (error, result) {
|
||||
function refresh(addonName) {
|
||||
Client.getAddon(addonName, function (error, result) {
|
||||
if (error) return Client.error(error);
|
||||
|
||||
$scope.addons = result.map(function (a) { return { name: a, state: 'active' }; });
|
||||
$scope.ready = true;
|
||||
$scope.addons[addonName] = result;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -21,7 +20,7 @@ angular.module('Application').controller('AddonsController', ['$scope', '$locati
|
||||
Client.startAddon(addonName, function (error) {
|
||||
if (error) return Client.error(error);
|
||||
|
||||
refresh();
|
||||
refresh(addonName);
|
||||
});
|
||||
};
|
||||
|
||||
@@ -29,9 +28,22 @@ angular.module('Application').controller('AddonsController', ['$scope', '$locati
|
||||
Client.stopAddon(addonName, function (error) {
|
||||
if (error) return Client.error(error);
|
||||
|
||||
refresh();
|
||||
refresh(addonName);
|
||||
});
|
||||
};
|
||||
|
||||
Client.onReady(refresh);
|
||||
Client.onReady(function () {
|
||||
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
|
||||
refresh(a);
|
||||
});
|
||||
|
||||
$scope.ready = true;
|
||||
});
|
||||
});
|
||||
}]);
|
||||
|
||||
Reference in New Issue
Block a user