From 5c03f6ea0341c9e4293d98772449e3d775d7bf6c Mon Sep 17 00:00:00 2001 From: Markus Unterwaditzer Date: Sat, 2 Aug 2025 20:15:01 +0200 Subject: [PATCH] Add reanalyze button Add a reanalyze button for individual recordings in the analysis dropdown As part of this, split out ApiRequestButton so that state transitions (clickable -> loading/disabled -> done) can be shared across start/stop recording and this new button. Other buttons might benefit from this as well. Also fix a broken checkbox while we're here. --- daemon/web/src/lib/analysisManager.svelte.ts | 8 +- .../src/lib/components/AnalysisStatus.svelte | 40 +++++- .../src/lib/components/AnalysisView.svelte | 11 ++ .../lib/components/ApiRequestButton.svelte | 91 +++++++++++++ .../web/src/lib/components/ConfigForm.svelte | 2 +- .../src/lib/components/ManifestCard.svelte | 5 +- .../src/lib/components/ManifestTable.svelte | 8 +- .../lib/components/ManifestTableRow.svelte | 5 +- .../src/lib/components/ReAnalyzeButton.svelte | 47 +++++++ .../lib/components/RecordingControls.svelte | 125 ++++++------------ daemon/web/src/lib/manifest.svelte.ts | 4 + daemon/web/src/routes/+page.svelte | 9 +- 12 files changed, 249 insertions(+), 106 deletions(-) create mode 100644 daemon/web/src/lib/components/ApiRequestButton.svelte create mode 100644 daemon/web/src/lib/components/ReAnalyzeButton.svelte diff --git a/daemon/web/src/lib/analysisManager.svelte.ts b/daemon/web/src/lib/analysisManager.svelte.ts index e813f71..5e868f5 100644 --- a/daemon/web/src/lib/analysisManager.svelte.ts +++ b/daemon/web/src/lib/analysisManager.svelte.ts @@ -23,11 +23,9 @@ export type AnalysisResult = { }; export class AnalysisManager { - public status: Map = new Map(); - public reports: Map = new Map(); - - public async run_analysis(name: string) { - await req('POST', `/api/analysis/${name}`); + public status: Map = $state(new Map()); + public reports: Map = $state(new Map()); + public set_queued_status(name: string) { this.status.set(name, AnalysisStatus.Queued); this.reports.delete(name); } diff --git a/daemon/web/src/lib/components/AnalysisStatus.svelte b/daemon/web/src/lib/components/AnalysisStatus.svelte index 815795f..139c884 100644 --- a/daemon/web/src/lib/components/AnalysisStatus.svelte +++ b/daemon/web/src/lib/components/AnalysisStatus.svelte @@ -35,15 +35,43 @@ return finished && report_available; }); - let button_class = $derived(ready ? 'text-blue-600 border rounded-full px-2' : ''); + let button_class = $derived.by(() => { + if (!ready) { + return 'text-gray-700'; + } else if ((entry.get_num_warnings() || 0) < 1) { + return 'text-green-700 border-green-500 bg-green-200 text-blue-600 border rounded-full px-2'; + } else { + return 'text-red-700 border-red-500 bg-red-200 text-blue-600 border rounded-full px-2'; + } + }); diff --git a/daemon/web/src/lib/components/ConfigForm.svelte b/daemon/web/src/lib/components/ConfigForm.svelte index 7696d86..9423b14 100644 --- a/daemon/web/src/lib/components/ConfigForm.svelte +++ b/daemon/web/src/lib/components/ConfigForm.svelte @@ -203,7 +203,7 @@ bind:checked={config.analyzers.incomplete_sib} class="h-4 w-4 text-rayhunter-blue focus:ring-rayhunter-blue border-gray-300 rounded" /> -