251205:0000 Just start debug backend/frontend
This commit is contained in:
164
frontend/app/(admin)/admin/workflows/[id]/edit/page.tsx
Normal file
164
frontend/app/(admin)/admin/workflows/[id]/edit/page.tsx
Normal file
@@ -0,0 +1,164 @@
|
||||
"use client";
|
||||
|
||||
import { useState, useEffect } from "react";
|
||||
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";
|
||||
import { DSLEditor } from "@/components/workflows/dsl-editor";
|
||||
import { VisualWorkflowBuilder } from "@/components/workflows/visual-builder";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { Label } from "@/components/ui/label";
|
||||
import { Textarea } from "@/components/ui/textarea";
|
||||
import { Card } from "@/components/ui/card";
|
||||
import {
|
||||
Select,
|
||||
SelectContent,
|
||||
SelectItem,
|
||||
SelectTrigger,
|
||||
SelectValue,
|
||||
} from "@/components/ui/select";
|
||||
import { workflowApi } from "@/lib/api/workflows";
|
||||
import { WorkflowType } from "@/types/workflow";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { Loader2 } from "lucide-react";
|
||||
|
||||
export default function WorkflowEditPage({ params }: { params: { id: string } }) {
|
||||
const router = useRouter();
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [saving, setSaving] = useState(false);
|
||||
const [workflowData, setWorkflowData] = useState({
|
||||
workflow_name: "",
|
||||
description: "",
|
||||
workflow_type: "CORRESPONDENCE" as WorkflowType,
|
||||
dsl_definition: "",
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
const fetchWorkflow = async () => {
|
||||
setLoading(true);
|
||||
try {
|
||||
const data = await workflowApi.getWorkflow(parseInt(params.id));
|
||||
if (data) {
|
||||
setWorkflowData({
|
||||
workflow_name: data.workflow_name,
|
||||
description: data.description,
|
||||
workflow_type: data.workflow_type,
|
||||
dsl_definition: data.dsl_definition,
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Failed to fetch workflow", error);
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
fetchWorkflow();
|
||||
}, [params.id]);
|
||||
|
||||
const handleSave = async () => {
|
||||
setSaving(true);
|
||||
try {
|
||||
await workflowApi.updateWorkflow(parseInt(params.id), workflowData);
|
||||
router.push("/admin/workflows");
|
||||
} catch (error) {
|
||||
console.error("Failed to save workflow", error);
|
||||
alert("Failed to save workflow");
|
||||
} finally {
|
||||
setSaving(false);
|
||||
}
|
||||
};
|
||||
|
||||
if (loading) {
|
||||
return (
|
||||
<div className="flex justify-center py-12">
|
||||
<Loader2 className="h-8 w-8 animate-spin text-muted-foreground" />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="p-6 space-y-6">
|
||||
<div className="flex justify-between items-center">
|
||||
<h1 className="text-3xl font-bold">Edit Workflow</h1>
|
||||
<div className="flex gap-2">
|
||||
<Button variant="outline" onClick={() => router.back()}>Cancel</Button>
|
||||
<Button onClick={handleSave} disabled={saving}>
|
||||
{saving && <Loader2 className="mr-2 h-4 w-4 animate-spin" />}
|
||||
Save Workflow
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<Card className="p-6">
|
||||
<div className="grid gap-4">
|
||||
<div>
|
||||
<Label htmlFor="workflow_name">Workflow Name *</Label>
|
||||
<Input
|
||||
id="workflow_name"
|
||||
value={workflowData.workflow_name}
|
||||
onChange={(e) =>
|
||||
setWorkflowData({
|
||||
...workflowData,
|
||||
workflow_name: e.target.value,
|
||||
})
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<Label htmlFor="description">Description</Label>
|
||||
<Textarea
|
||||
id="description"
|
||||
value={workflowData.description}
|
||||
onChange={(e) =>
|
||||
setWorkflowData({
|
||||
...workflowData,
|
||||
description: e.target.value,
|
||||
})
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<Label htmlFor="workflow_type">Workflow Type</Label>
|
||||
<Select
|
||||
value={workflowData.workflow_type}
|
||||
onValueChange={(value) =>
|
||||
setWorkflowData({ ...workflowData, workflow_type: value as WorkflowType })
|
||||
}
|
||||
>
|
||||
<SelectTrigger id="workflow_type">
|
||||
<SelectValue />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value="CORRESPONDENCE">Correspondence</SelectItem>
|
||||
<SelectItem value="RFA">RFA</SelectItem>
|
||||
<SelectItem value="DRAWING">Drawing</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</div>
|
||||
</div>
|
||||
</Card>
|
||||
|
||||
<Tabs defaultValue="dsl">
|
||||
<TabsList>
|
||||
<TabsTrigger value="dsl">DSL Editor</TabsTrigger>
|
||||
<TabsTrigger value="visual">Visual Builder</TabsTrigger>
|
||||
</TabsList>
|
||||
|
||||
<TabsContent value="dsl" className="mt-4">
|
||||
<DSLEditor
|
||||
initialValue={workflowData.dsl_definition}
|
||||
onChange={(value) =>
|
||||
setWorkflowData({ ...workflowData, dsl_definition: value })
|
||||
}
|
||||
/>
|
||||
</TabsContent>
|
||||
|
||||
<TabsContent value="visual" className="mt-4">
|
||||
<VisualWorkflowBuilder />
|
||||
</TabsContent>
|
||||
</Tabs>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
134
frontend/app/(admin)/admin/workflows/new/page.tsx
Normal file
134
frontend/app/(admin)/admin/workflows/new/page.tsx
Normal file
@@ -0,0 +1,134 @@
|
||||
"use client";
|
||||
|
||||
import { useState } from "react";
|
||||
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";
|
||||
import { DSLEditor } from "@/components/workflows/dsl-editor";
|
||||
import { VisualWorkflowBuilder } from "@/components/workflows/visual-builder";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { Label } from "@/components/ui/label";
|
||||
import { Textarea } from "@/components/ui/textarea";
|
||||
import { Card } from "@/components/ui/card";
|
||||
import {
|
||||
Select,
|
||||
SelectContent,
|
||||
SelectItem,
|
||||
SelectTrigger,
|
||||
SelectValue,
|
||||
} from "@/components/ui/select";
|
||||
import { workflowApi } from "@/lib/api/workflows";
|
||||
import { WorkflowType } from "@/types/workflow";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { Loader2 } from "lucide-react";
|
||||
|
||||
export default function NewWorkflowPage() {
|
||||
const router = useRouter();
|
||||
const [saving, setSaving] = useState(false);
|
||||
const [workflowData, setWorkflowData] = useState({
|
||||
workflow_name: "",
|
||||
description: "",
|
||||
workflow_type: "CORRESPONDENCE" as WorkflowType,
|
||||
dsl_definition: "name: New Workflow\nsteps: []",
|
||||
});
|
||||
|
||||
const handleSave = async () => {
|
||||
setSaving(true);
|
||||
try {
|
||||
await workflowApi.createWorkflow(workflowData);
|
||||
router.push("/admin/workflows");
|
||||
} catch (error) {
|
||||
console.error("Failed to create workflow", error);
|
||||
alert("Failed to create workflow");
|
||||
} finally {
|
||||
setSaving(false);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="p-6 space-y-6">
|
||||
<div className="flex justify-between items-center">
|
||||
<h1 className="text-3xl font-bold">New Workflow</h1>
|
||||
<div className="flex gap-2">
|
||||
<Button variant="outline" onClick={() => router.back()}>Cancel</Button>
|
||||
<Button onClick={handleSave} disabled={saving}>
|
||||
{saving && <Loader2 className="mr-2 h-4 w-4 animate-spin" />}
|
||||
Create Workflow
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<Card className="p-6">
|
||||
<div className="grid gap-4">
|
||||
<div>
|
||||
<Label htmlFor="workflow_name">Workflow Name *</Label>
|
||||
<Input
|
||||
id="workflow_name"
|
||||
value={workflowData.workflow_name}
|
||||
onChange={(e) =>
|
||||
setWorkflowData({
|
||||
...workflowData,
|
||||
workflow_name: e.target.value,
|
||||
})
|
||||
}
|
||||
placeholder="e.g., Special RFA Approval"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<Label htmlFor="description">Description</Label>
|
||||
<Textarea
|
||||
id="description"
|
||||
value={workflowData.description}
|
||||
onChange={(e) =>
|
||||
setWorkflowData({
|
||||
...workflowData,
|
||||
description: e.target.value,
|
||||
})
|
||||
}
|
||||
placeholder="Describe the purpose of this workflow"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<Label htmlFor="workflow_type">Workflow Type</Label>
|
||||
<Select
|
||||
value={workflowData.workflow_type}
|
||||
onValueChange={(value) =>
|
||||
setWorkflowData({ ...workflowData, workflow_type: value as WorkflowType })
|
||||
}
|
||||
>
|
||||
<SelectTrigger id="workflow_type">
|
||||
<SelectValue />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value="CORRESPONDENCE">Correspondence</SelectItem>
|
||||
<SelectItem value="RFA">RFA</SelectItem>
|
||||
<SelectItem value="DRAWING">Drawing</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</div>
|
||||
</div>
|
||||
</Card>
|
||||
|
||||
<Tabs defaultValue="dsl">
|
||||
<TabsList>
|
||||
<TabsTrigger value="dsl">DSL Editor</TabsTrigger>
|
||||
<TabsTrigger value="visual">Visual Builder</TabsTrigger>
|
||||
</TabsList>
|
||||
|
||||
<TabsContent value="dsl" className="mt-4">
|
||||
<DSLEditor
|
||||
initialValue={workflowData.dsl_definition}
|
||||
onChange={(value) =>
|
||||
setWorkflowData({ ...workflowData, dsl_definition: value })
|
||||
}
|
||||
/>
|
||||
</TabsContent>
|
||||
|
||||
<TabsContent value="visual" className="mt-4">
|
||||
<VisualWorkflowBuilder />
|
||||
</TabsContent>
|
||||
</Tabs>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
104
frontend/app/(admin)/admin/workflows/page.tsx
Normal file
104
frontend/app/(admin)/admin/workflows/page.tsx
Normal file
@@ -0,0 +1,104 @@
|
||||
"use client";
|
||||
|
||||
import { useState, useEffect } from "react";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Card } from "@/components/ui/card";
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
import { Plus, Edit, Copy, Trash, Loader2 } from "lucide-react";
|
||||
import Link from "next/link";
|
||||
import { Workflow } from "@/types/workflow";
|
||||
import { workflowApi } from "@/lib/api/workflows";
|
||||
|
||||
export default function WorkflowsPage() {
|
||||
const [workflows, setWorkflows] = useState<Workflow[]>([]);
|
||||
const [loading, setLoading] = useState(true);
|
||||
|
||||
useEffect(() => {
|
||||
const fetchWorkflows = async () => {
|
||||
setLoading(true);
|
||||
try {
|
||||
const data = await workflowApi.getWorkflows();
|
||||
setWorkflows(data);
|
||||
} catch (error) {
|
||||
console.error("Failed to fetch workflows", error);
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
fetchWorkflows();
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<div className="p-6 space-y-6">
|
||||
<div className="flex justify-between items-center">
|
||||
<div>
|
||||
<h1 className="text-3xl font-bold">Workflow Configuration</h1>
|
||||
<p className="text-muted-foreground mt-1">
|
||||
Manage workflow definitions and routing rules
|
||||
</p>
|
||||
</div>
|
||||
<Link href="/admin/workflows/new">
|
||||
<Button>
|
||||
<Plus className="mr-2 h-4 w-4" />
|
||||
New Workflow
|
||||
</Button>
|
||||
</Link>
|
||||
</div>
|
||||
|
||||
{loading ? (
|
||||
<div className="flex justify-center py-12">
|
||||
<Loader2 className="h-8 w-8 animate-spin text-muted-foreground" />
|
||||
</div>
|
||||
) : (
|
||||
<div className="grid gap-4">
|
||||
{workflows.map((workflow) => (
|
||||
<Card key={workflow.workflow_id} className="p-6">
|
||||
<div className="flex justify-between items-start">
|
||||
<div className="flex-1">
|
||||
<div className="flex items-center gap-3 mb-2">
|
||||
<h3 className="text-lg font-semibold">
|
||||
{workflow.workflow_name}
|
||||
</h3>
|
||||
<Badge variant={workflow.is_active ? "default" : "secondary"} className={workflow.is_active ? "bg-green-600 hover:bg-green-700" : ""}>
|
||||
{workflow.is_active ? "Active" : "Inactive"}
|
||||
</Badge>
|
||||
<Badge variant="outline">v{workflow.version}</Badge>
|
||||
</div>
|
||||
<p className="text-sm text-muted-foreground mb-3">
|
||||
{workflow.description}
|
||||
</p>
|
||||
<div className="flex gap-6 text-sm text-muted-foreground">
|
||||
<span>Type: {workflow.workflow_type}</span>
|
||||
<span>Steps: {workflow.step_count}</span>
|
||||
<span>
|
||||
Updated:{" "}
|
||||
{new Date(workflow.updated_at).toLocaleDateString()}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="flex gap-2">
|
||||
<Link href={`/admin/workflows/${workflow.workflow_id}/edit`}>
|
||||
<Button variant="outline" size="sm">
|
||||
<Edit className="mr-2 h-4 w-4" />
|
||||
Edit
|
||||
</Button>
|
||||
</Link>
|
||||
<Button variant="outline" size="sm" onClick={() => alert("Clone functionality mocked")}>
|
||||
<Copy className="mr-2 h-4 w-4" />
|
||||
Clone
|
||||
</Button>
|
||||
<Button variant="outline" size="sm" className="text-destructive hover:text-destructive" onClick={() => alert("Delete functionality mocked")}>
|
||||
<Trash className="mr-2 h-4 w-4" />
|
||||
Delete
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</Card>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user