Refresh addon status automatically

This commit is contained in:
Johannes Zellner
2018-11-20 14:47:39 +01:00
parent 1e5007ec8b
commit d01c46bfee
+12 -4
View File
@@ -2,7 +2,7 @@
/* global angular */
angular.module('Application').controller('AddonsController', ['$scope', '$location', 'Client', function ($scope, $location, Client) {
angular.module('Application').controller('AddonsController', ['$scope', '$location', '$interval', 'Client', function ($scope, $location, $interval, Client) {
Client.onReady(function () { if (!Client.getUserInfo().admin) $location.path('/'); });
$scope.ready = false;
@@ -16,6 +16,12 @@ angular.module('Application').controller('AddonsController', ['$scope', '$locati
});
}
function refreshAll() {
Object.keys($scope.addons).forEach(function (a) {
refresh(a);
});
}
$scope.startAddon = function (addonName) {
Client.startAddon(addonName, function (error) {
if (error) return Client.error(error);
@@ -38,11 +44,13 @@ angular.module('Application').controller('AddonsController', ['$scope', '$locati
result.forEach(function (a) {
$scope.addons[a] = { name: a };
// just kick off the status fetching
refresh(a);
});
// just kick off the status fetching
refreshAll();
$interval(refreshAll, 5000);
$scope.ready = true;
});
});