docs: rewrite README and AGENTS.md, add admin sync button
This commit is contained in:
parent
94f353d773
commit
9acdbaa453
4 changed files with 177 additions and 11 deletions
|
|
@ -5,6 +5,7 @@ export interface FlowDefinition {
|
|||
name: string;
|
||||
description: string;
|
||||
status: string;
|
||||
source_path: string | null;
|
||||
continuation_flow_id: string | null;
|
||||
created_at: string;
|
||||
}
|
||||
|
|
@ -60,6 +61,14 @@ export interface Decision {
|
|||
continuation_run: Run | null;
|
||||
}
|
||||
|
||||
export interface SyncReport {
|
||||
added: string[];
|
||||
updated: string[];
|
||||
deleted: string[];
|
||||
skipped: string[];
|
||||
errors: Record<string, string>;
|
||||
}
|
||||
|
||||
export class ApiError extends Error {
|
||||
status: number;
|
||||
constructor(status: number, message: string) {
|
||||
|
|
@ -135,4 +144,8 @@ export const api = {
|
|||
),
|
||||
listLangflow: () =>
|
||||
req<{ id: string; name: string }[]>("/api/flows/langflow/available"),
|
||||
syncFlows: () =>
|
||||
req<SyncReport>("/api/flows/sync", {
|
||||
method: "POST",
|
||||
}),
|
||||
};
|
||||
|
|
|
|||
|
|
@ -64,6 +64,26 @@ export default function AdminTab() {
|
|||
}
|
||||
}
|
||||
|
||||
async function onSync() {
|
||||
setError("");
|
||||
setInfo("");
|
||||
try {
|
||||
const r = await api.syncFlows();
|
||||
const parts = [
|
||||
`+${r.added.length}`,
|
||||
`~${r.updated.length}`,
|
||||
`-${r.deleted.length}`,
|
||||
].join(" ");
|
||||
const errs = Object.entries(r.errors)
|
||||
.map(([f, e]) => `${f}: ${e}`)
|
||||
.join("; ");
|
||||
setInfo(`Sync ${parts}${errs ? ` — Fehler: ${errs}` : ""}`);
|
||||
await load();
|
||||
} catch (e) {
|
||||
setError(e instanceof ApiError ? `${e.status}: ${e.message}` : String(e));
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<div>
|
||||
<h2>Administration</h2>
|
||||
|
|
@ -93,11 +113,19 @@ export default function AdminTab() {
|
|||
</button>
|
||||
</div>
|
||||
<h3>Flows + Versionen</h3>
|
||||
<div style={{ marginBottom: 12 }}>
|
||||
<button onClick={() => void onSync()}>
|
||||
Aus backend/flows synchronisieren
|
||||
</button>
|
||||
</div>
|
||||
{flows.length === 0 && <p>Keine Flows vorhanden.</p>}
|
||||
<ul>
|
||||
{flows.map((f) => (
|
||||
<li key={f.id} style={{ marginBottom: 8 }}>
|
||||
<strong>{f.name}</strong>
|
||||
<strong>{f.name}</strong>{" "}
|
||||
<span style={{ fontFamily: "monospace", fontSize: "0.85em" }}>
|
||||
{f.source_path ? `(${f.source_path})` : "(API)"}
|
||||
</span>
|
||||
<ul>
|
||||
{(versions[f.id] ?? []).map((v) => (
|
||||
<li key={v.id}>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue