generated from Dicken/dickendock
round19: Startseite aufgeraeumt, Favicon-Fallback ueber Ports, Favicon-Picker, Live-Status per Ping
This commit is contained in:
@@ -8,12 +8,20 @@ export async function settingsRoutes(app: FastifyInstance): Promise<void> {
|
||||
recentVisitsLimit: Number(all.recentVisitsLimit ?? 5),
|
||||
readLaterLimit: Number(all.readLaterLimit ?? 5),
|
||||
staleDeviceThresholdDays: Number(all.staleDeviceThresholdDays ?? 7),
|
||||
liveStatusEnabled: all.liveStatusEnabled === "true",
|
||||
liveStatusIntervalMinutes: Number(all.liveStatusIntervalMinutes ?? 5),
|
||||
};
|
||||
});
|
||||
|
||||
app.patch("/api/settings", async (request, reply) => {
|
||||
const body = request.body as
|
||||
| { recentVisitsLimit?: number; readLaterLimit?: number; staleDeviceThresholdDays?: number }
|
||||
| {
|
||||
recentVisitsLimit?: number;
|
||||
readLaterLimit?: number;
|
||||
staleDeviceThresholdDays?: number;
|
||||
liveStatusEnabled?: boolean;
|
||||
liveStatusIntervalMinutes?: number;
|
||||
}
|
||||
| undefined;
|
||||
|
||||
if (body?.recentVisitsLimit !== undefined) {
|
||||
@@ -40,11 +48,25 @@ export async function settingsRoutes(app: FastifyInstance): Promise<void> {
|
||||
settingsRepo.setSetting("staleDeviceThresholdDays", String(Math.round(value)));
|
||||
}
|
||||
|
||||
if (body?.liveStatusEnabled !== undefined) {
|
||||
settingsRepo.setSetting("liveStatusEnabled", body.liveStatusEnabled ? "true" : "false");
|
||||
}
|
||||
|
||||
if (body?.liveStatusIntervalMinutes !== undefined) {
|
||||
const value = Number(body.liveStatusIntervalMinutes);
|
||||
if (!Number.isFinite(value) || value < 1 || value > 1440) {
|
||||
return reply.code(400).send({ error: "liveStatusIntervalMinutes muss zwischen 1 und 1440 liegen" });
|
||||
}
|
||||
settingsRepo.setSetting("liveStatusIntervalMinutes", String(Math.round(value)));
|
||||
}
|
||||
|
||||
const all = settingsRepo.listSettings();
|
||||
return {
|
||||
recentVisitsLimit: Number(all.recentVisitsLimit ?? 5),
|
||||
readLaterLimit: Number(all.readLaterLimit ?? 5),
|
||||
staleDeviceThresholdDays: Number(all.staleDeviceThresholdDays ?? 7),
|
||||
liveStatusEnabled: all.liveStatusEnabled === "true",
|
||||
liveStatusIntervalMinutes: Number(all.liveStatusIntervalMinutes ?? 5),
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user