feat(scanner): validate elevated live automation
This commit is contained in:
@@ -1,8 +1,7 @@
|
||||
import { useRef, useState, type ChangeEvent } from "react";
|
||||
import { useState } from "react";
|
||||
import { AlertTriangle, Download, Play, Upload, Wrench } from "lucide-react";
|
||||
import type { CaptureResult } from "../../../types/global";
|
||||
import type { ScanViewControllerResult } from "../types";
|
||||
import { goodDatabaseToStoredArtifacts, type GoodImportDatabase } from "../../../lib/goodInterop";
|
||||
import { FieldConfidenceList } from "./ScanResultCards";
|
||||
import { useScanDiagnosticsModalModel } from "./modals/hooks/useScanDiagnosticsModalModel";
|
||||
import { useScanDetailsModalModel } from "./modals/hooks/useScanDetailsModalModel";
|
||||
@@ -59,7 +58,6 @@ export function DiagnosticsView({ controller, latestCapture, captureStatus, onDe
|
||||
});
|
||||
|
||||
const [interopStatus, setInteropStatus] = useState("");
|
||||
const fileInputRef = useRef<HTMLInputElement>(null);
|
||||
|
||||
const handleExportGood = async () => {
|
||||
setInteropStatus("Exportiere GOOD...");
|
||||
@@ -71,27 +69,20 @@ export function DiagnosticsView({ controller, latestCapture, captureStatus, onDe
|
||||
);
|
||||
};
|
||||
|
||||
const handleImportGood = async (event: ChangeEvent<HTMLInputElement>) => {
|
||||
const file = event.target.files?.[0];
|
||||
event.target.value = "";
|
||||
if (!file) return;
|
||||
try {
|
||||
const database = JSON.parse(await file.text()) as GoodImportDatabase;
|
||||
const records = goodDatabaseToStoredArtifacts(database);
|
||||
if (records.length === 0) {
|
||||
setInteropStatus("Keine gueltigen Artifacts in der Datei gefunden.");
|
||||
return;
|
||||
}
|
||||
setInteropStatus(`Importiere ${records.length} Artifacts...`);
|
||||
const result = await controller.importGoodArtifacts(records);
|
||||
setInteropStatus(
|
||||
result.ok
|
||||
? `Importiert: ${result.added} neu, ${result.updated} aktualisiert.`
|
||||
: "Import fehlgeschlagen (App im Electron-Fenster oeffnen).",
|
||||
);
|
||||
} catch {
|
||||
setInteropStatus("Datei ist kein gueltiges GOOD/JSON.");
|
||||
const handleImportGood = async () => {
|
||||
setInteropStatus("Waehle GOOD-Datei...");
|
||||
const result = await controller.importGoodFromFile();
|
||||
if (result.canceled) {
|
||||
setInteropStatus("GOOD-Import abgebrochen.");
|
||||
return;
|
||||
}
|
||||
setInteropStatus(
|
||||
result.ok
|
||||
? `Importiert: ${result.added} neu, ${result.updated} aktualisiert (${result.count} gelesen).`
|
||||
: result.error === "No valid GOOD artifacts found."
|
||||
? "Keine gueltigen Artifacts in der Datei gefunden."
|
||||
: "Import fehlgeschlagen (Datei ist kein gueltiges GOOD/JSON oder Bridge fehlt).",
|
||||
);
|
||||
};
|
||||
|
||||
return (
|
||||
@@ -182,11 +173,10 @@ export function DiagnosticsView({ controller, latestCapture, captureStatus, onDe
|
||||
<Download size={15} />
|
||||
GOOD exportieren
|
||||
</button>
|
||||
<button className="ghost-button" onClick={() => fileInputRef.current?.click()} disabled={!controller.canGoodInterop}>
|
||||
<button className="ghost-button" onClick={handleImportGood} disabled={!controller.canGoodInterop}>
|
||||
<Upload size={15} />
|
||||
GOOD importieren
|
||||
</button>
|
||||
<input ref={fileInputRef} type="file" accept="application/json,.json" hidden onChange={handleImportGood} />
|
||||
</div>
|
||||
</div>
|
||||
<p className="scanner-subcopy">
|
||||
|
||||
Reference in New Issue
Block a user