Usenet streaming with a WebDAV server and a SABnzbd-compatible API
C#
Added health-stats component to top of /health page.
nzbdav-dev4d27652accb5
diff --git a/frontend/app/routes/health/components/health-stats/health-stats.module.css b/frontend/app/routes/health/components/health-stats/health-stats.module.cssnew file mode 100644index 00000000..0094495d--- /dev/null+++ b/frontend/app/routes/health/components/health-stats/health-stats.module.css@@ -0,0 +1,98 @@+.container {+ width: 100%;+ background: hsl(192, 90%, 6%);+ border-radius: 10px;+ padding: 24px;+ border: 1px solid rgba(255, 255, 255, 0.05);+}++.header {+ display: flex;+ justify-content: space-between;+ align-items: center;+ margin-bottom: 24px;+ flex-wrap: wrap;+ gap: 16px;+}++.title {+ color: hsl(180, 30%, 70%);+ margin: 0;+ font-size: 1.5em;+ font-weight: 600;+}++.statusIndicator {+ color: hsl(180, 7%, 55%);+ font-size: 0.9em;+ font-weight: 500;+ background: hsl(196.8, 25%, 14.51%);+ padding: 6px 12px;+ border-radius: 16px;+ border: 1px solid rgba(255, 255, 255, 0.05);+ display: flex;+ align-items: center;+ min-width: fit-content;+}++.statusLabel {+ color: hsl(180, 7%, 55%);+ font-weight: 500;+ font-size: 0.9em;+}++.statsGrid {+ display: grid;+ grid-template-columns: repeat(4, 1fr);+ gap: 20px;+}++.statCard {+ background: hsl(196.8, 25%, 14.51%);+ border-radius: 8px;+ padding: 20px;+ text-align: center;+ border: 1px solid rgba(255, 255, 255, 0.05);+ transition: transform 0.2s ease, box-shadow 0.2s ease;+}++.statCard:hover {+ transform: translateY(-2px);+ box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);+}++.statNumber {+ font-size: 2.5em;+ font-weight: 700;+ color: hsl(180, 7%, 85%);+ margin-bottom: 8px;+ line-height: 1;+}++.statLabel {+ font-size: 0.9em;+ color: hsl(180, 7%, 55%);+ font-weight: 500;+}++/* Mobile responsiveness */+@media (max-width: 600px) {+ .statsGrid {+ grid-template-columns: repeat(2, 1fr);+ gap: 16px;+ }++ .statCard {+ padding: 16px;+ }++ .statNumber {+ font-size: 2em;+ }+}++@media (max-width: 370px) {+ .statsGrid {+ grid-template-columns: 1fr;+ }+}\ No newline at end of filediff --git a/frontend/app/routes/health/components/health-stats/health-stats.tsx b/frontend/app/routes/health/components/health-stats/health-stats.tsxnew file mode 100644index 00000000..c6f88c94--- /dev/null+++ b/frontend/app/routes/health/components/health-stats/health-stats.tsx@@ -0,0 +1,70 @@+import styles from "./health-stats.module.css";+import type { HealthCheckStats } from "~/clients/backend-client.server";++export type HealthStatsProps = {+ stats: HealthCheckStats[];+}++enum HealthResult {+ Healthy = 0,+ Unhealthy = 1,+}++enum RepairAction {+ None = 0,+ Repaired = 1,+ Deleted = 2,+ ActionNeeded = 3,+}++export function HealthStats({ stats }: HealthStatsProps) {+ // Calculate totals from HealthCheckStats array+ const totalChecked = stats+ .reduce((sum, stat) => sum + stat.count, 0);+ const healthy = stats+ .filter(stat => stat.result === HealthResult.Healthy)+ .reduce((sum, stat) => sum + stat.count, 0);+ const repaired = stats+ .filter(stat => stat.repairStatus === RepairAction.Repaired)+ .reduce((sum, stat) => sum + stat.count, 0);+ const deleted = stats+ .filter(stat => stat.repairStatus === RepairAction.Deleted)+ .reduce((sum, stat) => sum + stat.count, 0);++ const getPercentage = (count: number) => {+ return totalChecked > 0 ? Math.round((count / totalChecked) * 100) : 0;+ };++ return (+ <div className={styles.container}>+ <div className={styles.header}>+ <h3 className={styles.title}>System Health Overview</h3>+ <div className={styles.statusIndicator}>+ <span className={styles.statusLabel}>Last 30 Days</span>+ </div>+ </div>++ <div className={styles.statsGrid}>+ <div className={styles.statCard}>+ <div className={styles.statNumber}>{totalChecked}</div>+ <div className={styles.statLabel}>Total Checked</div>+ </div>++ <div className={styles.statCard}>+ <div className={styles.statNumber} style={{ color: '#198754' }}>{healthy}</div>+ <div className={styles.statLabel}>Healthy ({getPercentage(healthy)}%)</div>+ </div>++ <div className={styles.statCard}>+ <div className={styles.statNumber} style={{ color: '#17a2b8' }}>{repaired}</div>+ <div className={styles.statLabel}>Repaired ({getPercentage(repaired)}%)</div>+ </div>++ <div className={styles.statCard}>+ <div className={styles.statNumber} style={{ color: '#dc3545' }}>{deleted}</div>+ <div className={styles.statLabel}>Deleted ({getPercentage(deleted)}%)</div>+ </div>+ </div>+ </div>+ );+}\ No newline at end of filediff --git a/frontend/app/routes/health/route.module.css b/frontend/app/routes/health/route.module.cssindex 0e31c687..98645bc3 100644--- a/frontend/app/routes/health/route.module.css+++ b/frontend/app/routes/health/route.module.css@@ -3,5 +3,13 @@min-height: 100%;padding: 30px 35px 20px 35px;color: #93a1a1;- font-size: 16px;+ font-size: 14px;+}++.section {+ margin-bottom: 40px;+}++.section:last-child {+ margin-bottom: 0;}\ No newline at end of filediff --git a/frontend/app/routes/health/route.module.css.d.ts b/frontend/app/routes/health/route.module.css.d.tsindex 96dc17fa..181741e2 100644--- a/frontend/app/routes/health/route.module.css.d.ts+++ b/frontend/app/routes/health/route.module.css.d.ts@@ -1,4 +1,5 @@declare const styles: {readonly "container": string;+ readonly "section": string;};export = styles;\ No newline at end of filediff --git a/frontend/app/routes/health/route.tsx b/frontend/app/routes/health/route.tsxindex 2a9035ad..e877837a 100644--- a/frontend/app/routes/health/route.tsx+++ b/frontend/app/routes/health/route.tsx@@ -1,6 +1,7 @@import type { Route } from "./+types/route";import styles from "./route.module.css"import { backendClient } from "~/clients/backend-client.server";+import { HealthStats } from "./components/health-stats/health-stats";export async function loader() {const [queueData, historyData] = await Promise.all([@@ -20,7 +21,9 @@ export default function Health({ loaderData }: Route.ComponentProps) {return (<div className={styles.container}>- {/* Health content placeholder */}+ <div className={styles.section}>+ <HealthStats stats={historyStats} />+ </div></div>);}\ No newline at end of file