feat(xo-server/rest-api/dashboard): add backup repositories info (#7882)

This commit is contained in:
Mathieu
2024-08-06 17:51:20 +02:00
committed by GitHub
parent 895a551c7b
commit 4dfd77b2d2
2 changed files with 24 additions and 0 deletions

View File

@@ -11,6 +11,8 @@
> Users must be able to say: “Nice enhancement, I'm eager to test it”
- [REST API] Add backup repository information in the `/rest/v0/dashboard` endpoint (PR [#7882](https://github.com/vatesfr/xen-orchestra/pull/7882))
### Bug fixes
> Users must be able to say: “I had this issue, happy to know it's fixed”

View File

@@ -208,6 +208,28 @@ async function _getDashboardStats(app) {
dashboard.missingPatches = missingPatches
}
try {
const backupRepositoriesSize = Object.values(await app.getAllRemotesInfo()).reduce(
(prev, remoteInfo) => ({
available: prev.available + remoteInfo.available,
backups: 0, // @TODO: compute the space used by backups
other: 0, // @TODO: compute the space used by everything that is not a backup
total: prev.total + remoteInfo.size,
used: prev.used + remoteInfo.used,
}),
{
available: 0,
backups: 0,
other: 0,
total: 0,
used: 0,
}
)
dashboard.backupRepositories = { size: backupRepositoriesSize }
} catch (error) {
console.error(error)
}
return dashboard
}
const getDashboardStats = throttle(_getDashboardStats, 6e4, { trailing: false, leading: true })