Show last updated for disks and allow refresh on-demand

This commit is contained in:
Johannes Zellner
2022-10-12 17:05:45 +02:00
parent 7439a13578
commit c9a5e7216a
3 changed files with 28 additions and 8 deletions
+20 -6
View File
@@ -30,16 +30,18 @@ angular.module('Application').controller('SystemController', ['$scope', '$locati
$scope.disks = {
busy: true,
busyRefresh: false,
ts: 0,
disks: [],
refresh: function () {
$scope.disks.busy = true;
Client.refreshDiskUsage(function (error, result) {
show: function () {
Client.diskUsage(function (error, result) {
if (error) return console.error('Failed to refresh disk usage.', error);
$scope.disks.ts = result.usage.ts;
// [ { filesystem, type, size, used, available, capacity, mountpoint }]
$scope.disks.disks = Object.keys(result).map(function (k) { return result[k]; });
$scope.disks.disks = Object.keys(result.usage.disks).map(function (k) { return result.usage.disks[k]; });
$scope.disks.disks.forEach(function (disk) {
var usageOther = disk.occupied;
@@ -77,6 +79,18 @@ angular.module('Application').controller('SystemController', ['$scope', '$locati
$scope.disks.busy = false;
});
},
refresh: function () {
$scope.disks.busyRefresh = true;
Client.refreshDiskUsage(function (error) {
$scope.disks.busyRefresh = false;
if (error) return console.error('Failed to refresh disk usage.', error);
$scope.disks.show();
});
}
};
@@ -224,7 +238,7 @@ angular.module('Application').controller('SystemController', ['$scope', '$locati
volumes.forEach(function (v) { $scope.volumesById[v.id] = v; });
$scope.graphs.refresh();
$scope.disks.refresh();
$scope.disks.show();
});
});
});