UI improvements

This commit is contained in:
KingKDot
2026-05-30 22:44:55 -05:00
parent 5933297686
commit 2a90053eee
24 changed files with 1498 additions and 420 deletions
@@ -20,8 +20,8 @@ function acceptsGzip(req: Request): boolean {
return (req.headers.get("accept-encoding") ?? "").includes("gzip");
}
const STATIC_ASSET_CACHE = "public, max-age=86400, stale-while-revalidate=604800";
const MUTABLE_ASSET_CACHE = "public, max-age=3600, stale-while-revalidate=86400";
const STATIC_ASSET_CACHE = "public, max-age=31536000, immutable";
const MUTABLE_ASSET_CACHE = "public, max-age=86400, stale-while-revalidate=604800";
const NO_CACHE = "no-cache";
function assetCacheControl(relativePath: string): string {
@@ -75,7 +75,7 @@ export async function handleClientRoutes(
return new Response("Unauthorized", { status: 401 });
}
const page = Math.max(1, Number(url.searchParams.get("page") || 1));
const pageSize = Math.max(1, Number(url.searchParams.get("pageSize") || 12));
const pageSize = Math.min(200, Math.max(1, Number(url.searchParams.get("pageSize") || 12)));
const search = (url.searchParams.get("q") || "").toLowerCase().trim();
const sort = url.searchParams.get("sort") || "last_seen_desc";
const statusFilter = url.searchParams.get("status") || "all";
@@ -456,6 +456,12 @@ export async function handleWebSocketMessage(
if (typeof v !== "string") return undefined;
return v.replace(/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F]/g, "").slice(0, max);
};
const _percent = (v: unknown): number | undefined => {
if (typeof v !== "number" || !Number.isFinite(v)) return undefined;
const n = Math.round(v);
return n >= 0 && n <= 100 ? n : undefined;
};
const batteryPercent = _percent((payload as any).batteryPercent);
upsertClientRow({
id: resolvedId,
hwid: _s((payload as any).hwid) || resolvedId,
@@ -470,6 +476,8 @@ export async function handleWebSocketMessage(
cpu: _s((payload as any).cpu),
gpu: _s((payload as any).gpu),
ram: _s((payload as any).ram, 64),
batteryPercent,
batteryCharging: batteryPercent !== undefined ? !!(payload as any).batteryCharging : undefined,
country,
lastSeen: Date.now(),
online: 0 as any,