mirror of
https://github.com/gethomepage/homepage.git
synced 2025-12-07 09:35:54 -08:00
Feature: UrBackup Widget (#1735)
* Add initial UrBackup widget with counts of ok, errored, and out-of date clients * Add configurable number of days since last backup before a client is considered out-of-date * Don't count a lack of recent (or error free) image backup if image backup isn't supported. * Add support for reporting total disk usage * add support for "fields" from services.yaml * fix field filtering, syntax * Consolidate urbackup code, syntax changes * Revert pnpm changes * re-add urbackup-server-api --------- Co-authored-by: shamoon <4887959+shamoon@users.noreply.github.com>
This commit is contained in:
33
src/widgets/urbackup/proxy.js
Normal file
33
src/widgets/urbackup/proxy.js
Normal file
@@ -0,0 +1,33 @@
|
||||
import {UrbackupServer} from "urbackup-server-api";
|
||||
|
||||
import getServiceWidget from "utils/config/service-helpers";
|
||||
|
||||
export default async function urbackupProxyHandler(req, res) {
|
||||
const {group, service} = req.query;
|
||||
const serviceWidget = await getServiceWidget(group, service);
|
||||
|
||||
const server = new UrbackupServer({
|
||||
url: serviceWidget.url,
|
||||
username: serviceWidget.username,
|
||||
password: serviceWidget.password
|
||||
});
|
||||
|
||||
await (async () => {
|
||||
try {
|
||||
const allClients = await server.getStatus({includeRemoved: false});
|
||||
let diskUsage = false
|
||||
if (serviceWidget.fields?.includes("totalUsed")) {
|
||||
diskUsage = await server.getUsage();
|
||||
}
|
||||
res.status(200).send({
|
||||
clientStatuses: allClients,
|
||||
diskUsage,
|
||||
maxDays: serviceWidget.maxDays
|
||||
});
|
||||
} catch (error) {
|
||||
res.status(500).json({ error: "Something Broke" })
|
||||
}
|
||||
})();
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user