get previous du task if any

This commit is contained in:
Girish Ramakrishnan
2022-11-09 15:04:21 +01:00
parent 4e35df5567
commit e15024f46c
2 changed files with 38 additions and 21 deletions

View File

@@ -59,6 +59,7 @@ angular.module('Application').controller('SystemController', ['$scope', '$locati
busy: true,
busyRefresh: false,
ts: 0,
taskId: '',
disks: [],
show: function () {
@@ -121,15 +122,44 @@ angular.module('Application').controller('SystemController', ['$scope', '$locati
});
},
checkStatus: function () {
Client.getLatestTaskByType('updateDiskUsage', function (error, task) {
if (error) return console.error(error);
if (!task) return;
$scope.disks.taskId = task.id;
$scope.disks.busyRefresh = true;
$scope.disks.updateStatus();
});
},
updateStatus: function () {
Client.getTask($scope.disks.taskId, function (error, data) {
if (error) return $timeout($scope.disks.updateStatus, 3000);
if (!data.active) {
$scope.disks.busyRefresh = false;
$scope.disks.taskId = '';
$scope.disks.show();
return;
}
$timeout($scope.disks.updateStatus, 3000);
});
},
refresh: function () {
$scope.disks.busyRefresh = true;
Client.refreshDiskUsage(function (error) {
$scope.disks.busyRefresh = false;
Client.refreshDiskUsage(function (error, taskId) {
if (error) {
$scope.disks.busyRefresh = false;
return console.error('Failed to refresh disk usage.', error);
}
if (error) return console.error('Failed to refresh disk usage.', error);
$scope.disks.show();
$scope.disks.taskId = taskId;
$timeout($scope.disks.updateStatus, 3000);
});
}
};
@@ -299,7 +329,9 @@ angular.module('Application').controller('SystemController', ['$scope', '$locati
volumes.forEach(function (v) { $scope.volumesById[v.id] = v; });
$scope.graphs.refresh();
$scope.disks.show();
$scope.disks.checkStatus();
});
});
});