From ff1a95822078b848f093583c3ec6a0dc09dd0b46 Mon Sep 17 00:00:00 2001 From: Pierre-Olivier Mercier Date: Fri, 24 Oct 2025 15:37:39 +0700 Subject: [PATCH] Add a menu to results page --- web/src/lib/components/ScoreCard.svelte | 43 +++++---- web/src/routes/test/[test]/+page.svelte | 116 +++++++++++++++++++++--- 2 files changed, 129 insertions(+), 30 deletions(-) diff --git a/web/src/lib/components/ScoreCard.svelte b/web/src/lib/components/ScoreCard.svelte index 11e5396..523940f 100644 --- a/web/src/lib/components/ScoreCard.svelte +++ b/web/src/lib/components/ScoreCard.svelte @@ -5,10 +5,11 @@ interface Props { grade: string; score: number; + reanalyzing?: boolean; summary?: ScoreSummary; } - let { grade, score, summary }: Props = $props(); + let { grade, score, reanalyzing, summary }: Props = $props(); function getScoreLabel(score: number): string { if (score >= 90) return "Excellent"; @@ -19,25 +20,22 @@ } - -
- + {#if reanalyzing} +
+ {:else} + + {/if}
-

{getScoreLabel(score)}

+

+ {#if reanalyzing} + Analyzing in progress… + {:else} + {getScoreLabel(score)} + {/if} +

Overall Deliverability Score

{#if summary} @@ -94,3 +92,16 @@ {/if}
+ + diff --git a/web/src/routes/test/[test]/+page.svelte b/web/src/routes/test/[test]/+page.svelte index 98fb3a1..c801bac 100644 --- a/web/src/routes/test/[test]/+page.svelte +++ b/web/src/routes/test/[test]/+page.svelte @@ -24,6 +24,7 @@ let pollInterval: ReturnType | null = null; let nextfetch = $state(23); let nbfetch = $state(0); + let menuOpen = $state(false); async function fetchTest() { if (nbfetch > 0) { @@ -85,6 +86,7 @@ async function handleReanalyze() { if (!testId || reanalyzing) return; + menuOpen = false; reanalyzing = true; error = null; @@ -99,6 +101,18 @@ reanalyzing = false; } } + + function handleExportJSON() { + const dataStr = JSON.stringify(report, null, 2); + const dataBlob = new Blob([dataStr], { type: 'application/json' }); + const url = URL.createObjectURL(dataBlob); + const link = document.createElement('a'); + link.href = url; + link.download = `report-${testId}.json`; + link.click(); + URL.revokeObjectURL(url); + menuOpen = false; + } @@ -135,7 +149,47 @@
- +
+
+ +
+
+
@@ -233,19 +287,6 @@