A modern platform for visual, flexible, and extensible graph-based investigations. For cybersecurity analysts and investigators.
feat: global metrics
dextmorgna47279ff83a1
diff --git a/flowsint-web/src/app/api/metrics/global/route.ts b/flowsint-web/src/app/api/metrics/global/route.tsnew file mode 100644index 00000000..b293f87f--- /dev/null+++ b/flowsint-web/src/app/api/metrics/global/route.ts@@ -0,0 +1,34 @@+import { createClient } from "@/lib/supabase/server"+import { NextRequest, NextResponse } from "next/server"++export async function GET(request: NextRequest) {+ try {+ const supabase = await createClient()+ const now = new Date();+ const oneMonthAgo = new Date();+ oneMonthAgo.setMonth(now.getMonth() - 1);+ now.setDate(now.getDate() + 1); // Ajoute un jour à "today"+ let start = request.nextUrl.searchParams.get("start") || oneMonthAgo.toISOString().split("T")[0];+ let end = request.nextUrl.searchParams.get("end") || now.toISOString().split("T")[0];++ const {+ data: { user },+ error: userError,+ } = await supabase.auth.getUser();+ if (!user || userError) {+ return NextResponse.json({ error: "Unauthorized" }, { status: 401 })+ }+ const { data, error } = await supabase.rpc('get_global_metrics', {+ start_date: start,+ end_date: end+ }).single();++ if (error) {+ return NextResponse.json({ error: error.message }, { status: 500 })+ }+ return NextResponse.json(data)+ } catch (error) {+ return NextResponse.json({ error: "Internal Server Error" }, { status: 500 })+ }+}+diff --git a/flowsint-web/src/app/dashboard/investigations/page.tsx b/flowsint-web/src/app/dashboard/investigations/page.tsxindex dc86a708..babdbd66 100644--- a/flowsint-web/src/app/dashboard/investigations/page.tsx+++ b/flowsint-web/src/app/dashboard/investigations/page.tsx@@ -19,8 +19,7 @@ import { cn } from "@/lib/utils"import { SubNav } from "@/components/dashboard/sub-nav"import { Card } from "@/components/ui/card"import StatusBadge from "@/components/investigations/status-badge"-import { Profile } from "@/types"-import { SectionCards } from "@/components/investigations/section-cards"+const DashboardPage = () => {const [searchQuery, setSearchQuery] = useState("")const [viewMode, setViewMode] = useState<"grid" | "list">("grid")@@ -48,14 +47,16 @@ const DashboardPage = () => {</div><div className="w-full space-y-8 container mx-auto py-12 px-8"><div className="flex items-center justify-between w-full gap-4">- <div className="relative flex-1">+ <Card className="relative flex-1 rounded-md max-w-xl"><div className="absolute inset-y-0 left-0 flex items-center pl-3 pointer-events-none"><Search className="h-4 w-4 " /></div><Inputtype="text"+ value={searchQuery}+ onChange={(e) => setSearchQuery(e.target.value)}placeholder="Search investigations and investigations..."- className="pl-10 pr-16 py-2 h-10 text-sm bg-card"+ className="pl-10 pr-16 py-2 h-10 text-sm shadow-none border-none"/><div className="absolute inset-y-0 right-0 flex items-center pr-3 pointer-events-none"><div className="flex items-center gap-1 text-xs">@@ -63,22 +64,8 @@ const DashboardPage = () => {<kbd className="px-1.5 py-0.5 bg-background border rounded">K</kbd></div></div>- </div>+ </Card><div className="flex items-center gap-2">- <DropdownMenu>- <DropdownMenuTrigger asChild>- <Button variant="outline" className="flex items-center bg-card gap-2 h-10">- <span>Sort by activity</span>- <ChevronDown className="h-4 w-4" />- </Button>- </DropdownMenuTrigger>- <DropdownMenuContent align="end">- <DropdownMenuItem>Sort by name</DropdownMenuItem>- <DropdownMenuItem>Sort by date created</DropdownMenuItem>- <DropdownMenuItem>Sort by last updated</DropdownMenuItem>- <DropdownMenuItem>Sort by activity</DropdownMenuItem>- </DropdownMenuContent>- </DropdownMenu><div className="flex items-center border bg-card rounded-md overflow-hidden"><Buttonvariant="ghost"diff --git a/flowsint-web/src/app/dashboard/page.tsx b/flowsint-web/src/app/dashboard/page.tsxindex feb6d8ed..27414dd2 100644--- a/flowsint-web/src/app/dashboard/page.tsx+++ b/flowsint-web/src/app/dashboard/page.tsx@@ -23,6 +23,7 @@ import { InvestigationGraph } from "@/components/dashboard/charts/investigation-import { Badge } from "@/components/ui/badge"import { MetricsChart } from "@/components/dashboard/charts/metrics-chart"import { SectionCards } from "@/components/investigations/section-cards"+import { DateRangePicker } from "@/components/date-range-picker"const DashboardPage = () => {const [searchQuery, setSearchQuery] = useState("")const [viewMode, setViewMode] = useState<"grid" | "list">("grid")@@ -51,11 +52,14 @@ const DashboardPage = () => {<div className="w-full space-y-4 container mx-auto py-12 px-8"><div className="flex grow items-center justify-between w-full gap-4"><h1 className="font-bold text-2xl">Overview</h1>- <NewInvestigation>- <Button className="gap-2">- <PlusIcon className="h-4 w-4" /> New- </Button>- </NewInvestigation>+ <div className="flex items-center gap-2">+ <DateRangePicker />+ <NewInvestigation>+ <Button className="gap-2">+ <PlusIcon className="h-4 w-4" /> New+ </Button>+ </NewInvestigation>+ </div></div><SectionCards /><div className="grid lg:grid-cols-5 gap-4 w-full">diff --git a/flowsint-web/src/app/layout.tsx b/flowsint-web/src/app/layout.tsxindex 3f037661..abe5f86a 100644--- a/flowsint-web/src/app/layout.tsx+++ b/flowsint-web/src/app/layout.tsx@@ -36,12 +36,12 @@ export default function RootLayout({return (<html suppressHydrationWarning lang="en"><head>- {/* {process.env.NODE_ENV === "development" && (+ {process.env.NODE_ENV === "development" && (<scriptcrossOrigin="anonymous"src="//unpkg.com/react-scan/dist/auto.global.js"/>- )} */}+ )}</head><bodyclassName={clsx(diff --git a/flowsint-web/src/components/date-range-picker.tsx b/flowsint-web/src/components/date-range-picker.tsxnew file mode 100644index 00000000..c7c2d1b1--- /dev/null+++ b/flowsint-web/src/components/date-range-picker.tsx@@ -0,0 +1,99 @@+"use client"++import * as React from "react"+import { addDays, format, subMonths } from "date-fns"+import { CalendarIcon } from "lucide-react"+import type { DateRange } from "react-day-picker"+import { useQueryState } from "nuqs"++import { cn } from "@/lib/utils"+import { Button } from "@/components/ui/button"+import { Calendar } from "@/components/ui/calendar"+import { Popover, PopoverContent, PopoverTrigger } from "@/components/ui/popover"++export function DateRangePicker({ className }: React.HTMLAttributes<HTMLDivElement>) {+ // Use nuqs to store the date range in the URL+ const [fromParam, setFromParam] = useQueryState("start")+ const [toParam, setToParam] = useQueryState("end")++ // Parse the date from URL or use defaults+ const initialDateRange: DateRange = {+ from: fromParam ? new Date(fromParam) : subMonths(new Date(), 1),+ to: toParam ? new Date(toParam) : addDays(new Date(), 1),+ }++ const [date, setDate] = React.useState<DateRange | undefined>(initialDateRange)++ // Update URL when date range changes+ const handleDateChange = (range: DateRange | undefined) => {+ setDate(range)++ if (range?.from) {+ setFromParam(format(range.from, "yyyy-MM-dd"))+ } else {+ setFromParam(null)+ }++ if (range?.to) {+ setToParam(format(range.to, "yyyy-MM-dd"))+ } else {+ setToParam(null)+ }+ }++ return (+ <div className={cn("grid gap-2", className)}>+ <Popover>+ <PopoverTrigger asChild>+ <Button+ id="date"+ variant={"outline"}+ className={cn("w-full justify-start text-left font-normal", !date && "text-muted-foreground")}+ >+ <CalendarIcon className="mr-2 h-4 w-4" />+ {date?.from ? (+ date.to ? (+ <>+ {format(date.from, "LLL dd, y")} - {format(date.to, "LLL dd, y")}+ </>+ ) : (+ format(date.from, "LLL dd, y")+ )+ ) : (+ <span>Pick a date range</span>+ )}+ </Button>+ </PopoverTrigger>+ <PopoverContent className="w-auto p-0" align="start">+ <Calendar+ initialFocus+ mode="range"+ defaultMonth={date?.from}+ selected={date}+ onSelect={handleDateChange}+ numberOfMonths={2}+ />+ <div className="p-3 border-t border-border">+ <Button+ variant="outline"+ size="sm"+ className="w-full text-xs"+ onClick={() => {+ const defaultFrom = subMonths(new Date(), 1)+ const defaultTo = addDays(new Date(), 1)+ setDate({+ from: defaultFrom,+ to: defaultTo,+ })+ setFromParam(format(defaultFrom, "yyyy-MM-dd"))+ setToParam(format(defaultTo, "yyyy-MM-dd"))+ }}+ >+ Reset+ </Button>+ </div>+ </PopoverContent>+ </Popover>+ </div>+ )+}diff --git a/flowsint-web/src/components/investigations/section-cards.tsx b/flowsint-web/src/components/investigations/section-cards.tsxindex a8206884..4cb05c98 100644--- a/flowsint-web/src/components/investigations/section-cards.tsx+++ b/flowsint-web/src/components/investigations/section-cards.tsx@@ -8,26 +8,41 @@ import {CardHeader,CardTitle,} from "@/components/ui/card"+import { useQuery } from "@tanstack/react-query"+import { Skeleton } from "../ui/skeleton"+import { useQueryState } from "nuqs"export function SectionCards() {+ const [fromParam] = useQueryState("start", { defaultValue: "" })+ const [toParam] = useQueryState("end", { defaultValue: "" })++ const { data, isLoading: initialLoading, isRefetching } = useQuery({+ queryKey: ["dashboard", "metrics", "global", fromParam, toParam],+ queryFn: async () => {+ const res = await fetch(`/api/metrics/global?from=${fromParam}&end=${toParam}`)+ if (!res.ok || res.status === 404) {+ return+ }+ return res.json()+ },+ refetchOnWindowFocus: true,+ })+ const isLoading = initialLoading || isRefetchingreturn (- <div className="shadow-xs grid-cols-2 xl:grid-cols-4 grid grid-cols-1 gap-4">+ <div className="grid-cols-2 xl:grid-cols-4 grid grid-cols-1 gap-4"><Card className="bg-card"><CardHeader className="relative"><CardDescription>Active investigations</CardDescription><CardTitle className="md:text-4xl text-2xl font-semibold tabular-nums">- 23+ {isLoading ? <Skeleton className="h-10 w-12 rounded-lg" /> : data.active_investigations}</CardTitle><div className="absolute right-4 top-4">- <Badge variant="outline" className="flex gap-1 rounded-lg text-xs">- <TrendingUpIcon className="size-3" />- +3- </Badge>+ <CustomBadge isLoading={isLoading} value={data?.active_investigations_string} /></div></CardHeader><CardFooter className="flex-col items-start gap-1 text-sm"><div className="line-clamp-1 flex gap-2 font-medium">- Trending up this month <TrendingUpIcon className="size-4" />+ Trending {data?.active_investigations_delta_string.startsWith("+") ? "up" : "down"} this month <TrendingUpIcon className="size-4" /></div><div className="text-muted-foreground">New investigations created@@ -38,13 +53,10 @@ export function SectionCards() {<CardHeader className="relative"><CardDescription>Total investigations</CardDescription><CardTitle className="md:text-4xl text-2xl font-semibold tabular-nums">- 237+ {isLoading ? <Skeleton className="h-10 w-12 rounded-lg" /> : data.total_investigations}</CardTitle><div className="absolute right-4 top-4">- <Badge variant="outline" className="flex gap-1 rounded-lg text-xs">- <TrendingDownIcon className="size-3" />- -20%- </Badge>+ <CustomBadge isLoading={isLoading} value={data?.total_investigations_delta_string} /></div></CardHeader><CardFooter className="flex-col items-start gap-1 text-sm">@@ -58,15 +70,12 @@ export function SectionCards() {</Card><Card className="bg-card"><CardHeader className="relative">- <CardDescription>Nodes created</CardDescription>+ <CardDescription>Individuals registered</CardDescription><CardTitle className="md:text-4xl text-2xl font-semibold tabular-nums">- 4 532+ {isLoading ? <Skeleton className="h-10 w-12 rounded-lg" /> : data?.total_nodes_created}</CardTitle><div className="absolute right-4 top-4">- <Badge variant="outline" className="flex gap-1 rounded-lg text-xs">- <TrendingUpIcon className="size-3" />- +12.5%- </Badge>+ <CustomBadge isLoading={isLoading} value={data?.total_nodes_created_delta_string} /></div></CardHeader><CardFooter className="flex-col items-start gap-1 text-sm">@@ -78,24 +87,35 @@ export function SectionCards() {</Card><Card className="bg-card"><CardHeader className="relative">- <CardDescription>Collaborators</CardDescription>+ <CardDescription>Successfull scans</CardDescription><CardTitle className="md:text-4xl text-2xl font-semibold tabular-nums">- 8+ {isLoading ? <Skeleton className="h-10 w-12 rounded-lg" /> : data?.total_succeeded_scans}</CardTitle><div className="absolute right-4 top-4">- <Badge variant="outline" className="flex gap-1 rounded-lg text-xs">- <TrendingUpIcon className="size-3" />- +2- </Badge>+ <CustomBadge isLoading={isLoading} value={data?.succeeded_scans_delta_string} /></div></CardHeader><CardFooter className="flex-col items-start gap-1 text-sm"><div className="line-clamp-1 flex gap-2 font-medium">- Active collaborators <TrendingUpIcon className="size-4" />+ Successful scans <TrendingUpIcon className="size-4" /></div>- <div className="text-muted-foreground">Collaborators actively participating</div>+ <div className="text-muted-foreground">Scans with success output.</div></CardFooter></Card></div>)}++const CustomBadge = ({ isLoading, value }: { isLoading: boolean, value: string }) => {+ const Icon = value?.startsWith("+") ? TrendingUpIcon : TrendingUpIcon+ if (isLoading) return (+ <Badge variant="outline" className="flex gap-1 rounded-lg text-xs">+ <TrendingUpIcon className="size-3" />+ {isLoading ? <Skeleton className="h-4 w-6 rounded-lg" /> : value}+ </Badge>+ )+ return (<Badge variant="outline" className="flex gap-1 rounded-lg text-xs">+ <Icon className="size-3" />+ {isLoading ? <Skeleton className="h-4 w-6 rounded-lg" /> : value}+ </Badge>)+}\ No newline at end of filediff --git a/flowsint-web/src/components/organigrams/graph.tsx b/flowsint-web/src/components/organigrams/graph.tsxindex 5fdd8f00..5a1a3b15 100644--- a/flowsint-web/src/components/organigrams/graph.tsx+++ b/flowsint-web/src/components/organigrams/graph.tsx@@ -35,7 +35,6 @@ import { useFlowStore } from "@/store/flow-store"import Loader from "@/components/loader"import { useQueryState } from "nuqs"import { ContextMenu, ContextMenuContent, ContextMenuItem, ContextMenuTrigger } from "@/components/ui/context-menu"-import PanelContextMenu from "../sketches/panel-context-menu"import { memo } from "react"import { shallow } from "zustand/shallow"import { TooltipProvider } from "@/components/ui/tooltip"@@ -314,39 +313,36 @@ const LayoutFlow = memo(({ refetch, theme }: any) => {<ResizablePanelGroup autoSaveId="persistence" direction="horizontal" className="w-screen grow relative overflow-hidden"><ResizablePanel defaultSize={80}><TooltipProvider>- <Dialog>- <ContextMenu>- <ContextMenuTrigger className="h-full w-full">- <ReactFlow {...reactFlowProps}>- <FlowControls- onLayout={onLayout}- fitView={fitView}- handleRefetch={handleRefetch}- reloading={reloading}- setView={setView}- zoomIn={zoomIn}- zoomOut={zoomOut}- addNodes={addNodes}- />- <Background className="dark:bg-background bg-background" />- {showMiniMap && <MiniMap className="!z-40" pannable />}- </ReactFlow>- </ContextMenuTrigger>- <ContextMenuContent className="w-32">- <DialogTrigger asChild>- <ContextMenuItem>- <PlusIcon className="h-4 w-4 opacity-60" />- <span>New node</span>- </ContextMenuItem>- </DialogTrigger>- <ContextMenuItem disabled>- <GroupIcon className="h-4 w-4 opacity-60" />- <span>New group</span>+ <ContextMenu>+ <ContextMenuTrigger className="h-full w-full">+ <ReactFlow {...reactFlowProps}>+ <FlowControls+ onLayout={onLayout}+ fitView={fitView}+ handleRefetch={handleRefetch}+ reloading={reloading}+ setView={setView}+ zoomIn={zoomIn}+ zoomOut={zoomOut}+ addNodes={addNodes}+ />+ <Background className="dark:bg-background bg-background" />+ {showMiniMap && <MiniMap className="!z-40" pannable />}+ </ReactFlow>+ </ContextMenuTrigger>+ <ContextMenuContent className="w-32">+ <DialogTrigger asChild>+ <ContextMenuItem>+ <PlusIcon className="h-4 w-4 opacity-60" />+ <span>New node</span></ContextMenuItem>- </ContextMenuContent>- </ContextMenu>- <PanelContextMenu addNodes={addNodes} />- </Dialog>+ </DialogTrigger>+ <ContextMenuItem disabled>+ <GroupIcon className="h-4 w-4 opacity-60" />+ <span>New group</span>+ </ContextMenuItem>+ </ContextMenuContent>+ </ContextMenu></TooltipProvider></ResizablePanel><ResizableHandle withHandle />diff --git a/flowsint-web/src/components/sketches/new-actions.tsx b/flowsint-web/src/components/sketches/new-actions.tsxindex 6880a066..77a55fe2 100644--- a/flowsint-web/src/components/sketches/new-actions.tsx+++ b/flowsint-web/src/components/sketches/new-actions.tsx@@ -5,7 +5,7 @@ import { useParams } from "next/navigation"import { supabase } from "@/lib/supabase/client"import { Button } from "@/components/ui/button"import { Input } from "@/components/ui/input"-import { AlertCircle, ArrowLeft, ArrowRight, PlusIcon } from "lucide-react"+import { AlertCircle, ArrowLeft, ArrowRight } from "lucide-react"import { toast } from "sonner"import { cn, nodesTypes } from "@/lib/utils"import { Alert, AlertTitle, AlertDescription } from "../ui/alert"@@ -19,8 +19,7 @@ import { AnimatePresence, motion } from "framer-motion"export default function NewActions({ addNodes, children }: { addNodes: any, children: React.ReactNode }) {const { sketch_id } = useParams()const [openAddNodeModal, setOpenNodeModal] = useState(false)- const [openActionDialog, setOpenActionDialog] = useState(false)- const { setCurrentNode } = useSketchStore((state) => state)+ const { setCurrentNode, openActionDialog, setOpenActionDialog } = useSketchStore((state) => state)const [currentNodeType, setCurrentNodeType] = useState<any | null>(null)const [error, setError] = useState<string | null>(null)const [loading, setLoading] = useState(false)@@ -203,7 +202,7 @@ function ActionCard({ item, onSelect }: ActionCardProps) {return (<CardclassName={cn(- "cursor-pointer transition-all bg-background hover:border-primary border border-transparent hover:shadow-md",+ "cursor-pointer transition-all bg-card hover:border-primary border border-transparent hover:shadow-md",item.disabled && "opacity-50 cursor-not-allowed","h-full",)}diff --git a/flowsint-web/src/components/sketches/panel-context-menu.tsx b/flowsint-web/src/components/sketches/panel-context-menu.tsxdeleted file mode 100644index 753ac10f..00000000--- a/flowsint-web/src/components/sketches/panel-context-menu.tsx+++ /dev/null@@ -1,215 +0,0 @@-"use client"--import { useState } from "react"-import { useParams } from "next/navigation"-import { supabase } from "@/lib/supabase/client"-import { Button } from "@/components/ui/button"-import { Input } from "@/components/ui/input"-import { AlertCircle, ArrowLeft, ArrowRight, PlusIcon } from "lucide-react"-import { toast } from "sonner"-import { cn, nodesTypes } from "@/lib/utils"-import { Alert, AlertTitle, AlertDescription } from "../ui/alert"-import { Badge } from "../ui/badge"-import { Dialog, DialogClose, DialogContent, DialogDescription, DialogTitle } from "../ui/dialog"-import { actionItems, type ActionItem } from "@/lib/action-items"-import { useSketchStore } from "@/store/sketch-store"-import { Card, CardContent } from "@/components/ui/card"-import { AnimatePresence, motion } from "framer-motion"--export default function PanelContextMenu({ addNodes }: { addNodes: any }) {- const { sketch_id } = useParams()- const [openAddNodeModal, setOpenNodeModal] = useState(false)- const [_, setOpenActionDialog] = useState(false)- const { setCurrentNode } = useSketchStore((state) => state)- const [currentNodeType, setCurrentNodeType] = useState<any | null>(null)- const [error, setError] = useState<string | null>(null)- const [loading, setLoading] = useState(false)- const [currentParent, setCurrentParent] = useState<ActionItem | null>(null)- const [navigationHistory, setNavigationHistory] = useState<ActionItem[]>([])- const handleOpenAddNodeModal = (key: string) => {- if (!nodesTypes[key as keyof typeof nodesTypes]) {- toast.error("Invalid node type.")- return- }- setCurrentNodeType(nodesTypes[key as keyof typeof nodesTypes])- setError(null)- setOpenActionDialog(false)- setOpenNodeModal(true)- }- const onSubmitNewNodeModal = async (e: {- preventDefault: () => void- currentTarget: HTMLFormElement | undefined- }) => {- e.preventDefault()- const data = Object.fromEntries(new FormData(e.currentTarget))- await handleAddNode(data)- }- const handleAddNode = async (data: any) => {- try {- setLoading(true)- const dataToInsert = { ...data, sketch_id }- const { data: nodeData, error: insertError } = await supabase- .from(currentNodeType.table)- .insert(dataToInsert)- .select("*")- .single()- if (insertError) {- toast.error("Failed to create node.")- setLoading(false)- return- }- if (!nodeData) {- toast.error("Failed to create node.")- setLoading(false)- return- }- const newNode = {- id: nodeData.id,- type: "custom",- data: {- ...nodeData, label: data[currentNodeType.fields[0]], type: currentNodeType.type,- },- position: { x: 0, y: 0 },- }- addNodes(newNode)- setCurrentNode(newNode)- setError(null)- toast.success("Node successfully created.")- } catch (error) {- toast.error("An unexpected error occurred.")- } finally {- setLoading(false)- setOpenNodeModal(false)- }- }- const navigateToSubItems = (item: ActionItem) => {- setNavigationHistory([...navigationHistory, item])- setCurrentParent(item)- }- const navigateBack = () => {- const newHistory = [...navigationHistory]- newHistory.pop()- setNavigationHistory(newHistory)- setCurrentParent(newHistory.length > 0 ? newHistory[newHistory.length - 1] : null)- }-- const renderActionCards = () => {- const items = currentParent ? currentParent.children || [] : actionItems-- return (- <AnimatePresence mode="wait">- <motion.div- key={currentParent?.id || "root"}- initial={{ opacity: 0, x: 20 }}- animate={{ opacity: 1, x: 0 }}- exit={{ opacity: 0, x: -20 }}- transition={{ duration: 0.2 }}- className="grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 gap-3 p-1 pb-2"- >- {items.map((item) => (- <ActionCard- key={item.id}- item={item}- onSelect={item.children ? () => navigateToSubItems(item) : () => handleOpenAddNodeModal(item.key)}- />- ))}- </motion.div>- </AnimatePresence>- )- }- return (- <>- <DialogContent className="sm:max-w-[700px] h-[80vh] overflow-hidden flex flex-col">- <DialogTitle className="flex items-center">- {currentParent && (- <Button variant="ghost" size="icon" className="mr-2" onClick={navigateBack}>- <ArrowLeft className="h-4 w-4" />- </Button>- )}- {currentParent ? currentParent.label : "Select action"}- </DialogTitle>- <DialogDescription>- {currentParent- ? `Select a ${currentParent.label} type to add`- : "Choose an action to add to your investigation"}- </DialogDescription>-- <div className="overflow-y-auto overflow-x-hidden pr-1 -mr-1 flex-grow">{renderActionCards()}</div>- </DialogContent>- {/* Node Creation Dialog */}- <Dialog open={openAddNodeModal && currentNodeType} onOpenChange={setOpenNodeModal}>- <DialogContent>- <DialogTitle>New {currentNodeType?.type}</DialogTitle>- <DialogDescription>Add a new related {currentNodeType?.type}.</DialogDescription>- <form onSubmit={onSubmitNewNodeModal}>- <div className="flex flex-col gap-3">- {currentNodeType?.fields.map((field: any, i: number) => {- const [key, value] = field.split(":")- return (- <label key={i}>- <p className="my-2">{key}</p>- <Input defaultValue={value || ""} name={key} placeholder={`Your value here (${key})`} />- </label>- )- })}- </div>- {error && (- <Alert variant="destructive">- <AlertCircle className="h-4 w-4" />- <AlertTitle>Error</AlertTitle>- <AlertDescription>{error}</AlertDescription>- </Alert>- )}- <div className="flex items-center gap-2 justify-end mt-4">- <DialogClose asChild>- <Button type="button" variant="outline">- Cancel- </Button>- </DialogClose>- <Button disabled={loading} type="submit">- Save- </Button>- </div>- </form>- </DialogContent>- </Dialog>- </>- )-}--interface ActionCardProps {- item: ActionItem- onSelect: () => void-}--function ActionCard({ item, onSelect }: ActionCardProps) {- const Icon = item.icon-- return (- <Card- className={cn(- "cursor-pointer transition-all bg-background hover:scale-105 hover:shadow-md",- item.disabled && "opacity-50 cursor-not-allowed",- "h-full",- )}- onClick={item.disabled ? undefined : onSelect}- >- <CardContent className="p-4 relative flex flex-col items-center text-center h-full">- <div- className="w-8 h-8 rounded-full flex items-center justify-center mb-3 mt-2"- style={{ backgroundColor: `${item.color}20` }} // Light background based on item color- >- <Icon style={{ color: item.color }} className="h-6 w-6 opacity-60 text-primary" />- </div>- <div className="font-medium text-sm">{item.label}</div>- {item.comingSoon && (- <Badge variant="outline" className="mt-2 absolute top-2 left-2">- soon- </Badge>- )}- {item.children && <div className="absolute top-3 right-4 text-xs text-muted-foreground mt-1"><ArrowRight className="h-4 w-4" /></div>}- {item.children && <div className="text-xs text-muted-foreground mt-1">{item.children.length} options</div>}- </CardContent>- </Card>- )-}diff --git a/flowsint-web/src/components/sketches/sketch/graph.tsx b/flowsint-web/src/components/sketches/sketch/graph.tsxindex 1e043e8d..0acc4a38 100644--- a/flowsint-web/src/components/sketches/sketch/graph.tsx+++ b/flowsint-web/src/components/sketches/sketch/graph.tsx@@ -36,12 +36,10 @@ import { useFlowStore } from "@/store/flow-store"import Loader from "@/components/loader"import { useQueryState } from "nuqs"import { ContextMenu, ContextMenuContent, ContextMenuItem, ContextMenuTrigger } from "@/components/ui/context-menu"-import PanelContextMenu from "../panel-context-menu"import { memo } from "react"import { shallow } from "zustand/shallow"import { TooltipProvider } from "@/components/ui/tooltip"import NodeContextMenu from "./nodes/node-context-menu"-import CustomEdge from "../../ui/custom-edge"import {ResizableHandle,ResizablePanel,@@ -50,7 +48,6 @@ import {import NodesPanel from "./nodes-panel"import ProfilePanel from "./profile-panel"import CustomNode from "./nodes/custom-node"-import { Dialog, DialogTrigger } from "@/components/ui/dialog"import FullscreenButton from "@/components/full-screen-button"import FloatingEdge from "./simple-floating-edge"@@ -173,9 +170,10 @@ const FlowControls = memo(({});const LayoutFlow = memo(({ refetch, theme }: any) => {- const { fitView, zoomIn, zoomOut, addNodes, getNode, setCenter, getNodes } = useReactFlow();+ const { fitView, zoomIn, zoomOut, addNodes, getNode, setCenter } = useReactFlow();const { sketch_id } = useParams();const showMiniMap = useSketchStore(state => state.settings.showMiniMap);+ const setOpenActionDialog = useSketchStore(state => state.setOpenActionDialog);const [_, setView] = useQueryState("view", { defaultValue: "flow-graph" });// Use a ref for context menu state to avoid re-renders on position changes@@ -221,17 +219,10 @@ const LayoutFlow = memo(({ refetch, theme }: any) => {fitView();}, [refetch, onLayout, fitView]);- // Handle current node changesuseEffect(() => {if (!currentNode) return;const internalNode = getNode(currentNode.id);if (!internalNode) return;- updateNode(internalNode.id, {- ...internalNode,- zIndex: 5000,- data: { ...internalNode.data, forceToolbarVisible: true },- style: { ...internalNode.style, opacity: 1 },- });const nodeWidth = internalNode.measured?.width ?? 0;const nodeHeight = internalNode.measured?.height ?? 0;setCenter(@@ -242,7 +233,7 @@ const LayoutFlow = memo(({ refetch, theme }: any) => {zoom: 1.5,});- }, [currentNode?.id]); // Only depend on currentNode.id, not the whole object+ }, [currentNode?.id]);const handleConnect = useCallback((params: any) => onConnect(params, sketch_id),@@ -316,39 +307,34 @@ const LayoutFlow = memo(({ refetch, theme }: any) => {<ResizablePanelGroup autoSaveId="persistence" direction="horizontal" className="w-screen grow relative overflow-hidden"><ResizablePanel defaultSize={80}><TooltipProvider>- <Dialog>- <ContextMenu>- <ContextMenuTrigger className="h-full w-full">- <ReactFlow {...reactFlowProps}>- <FlowControls- onLayout={onLayout}- fitView={fitView}- handleRefetch={handleRefetch}- reloading={reloading}- setView={setView}- zoomIn={zoomIn}- zoomOut={zoomOut}- addNodes={addNodes}- />- <Background bgColor="var(--background)" />- {showMiniMap && <MiniMap className="!z-40 !bg-card" pannable />}- </ReactFlow>- </ContextMenuTrigger>- <ContextMenuContent className="w-32">- <DialogTrigger asChild>- <ContextMenuItem>- <PlusIcon className="h-4 w-4 opacity-60" />- <span>New node</span>- </ContextMenuItem>- </DialogTrigger>- <ContextMenuItem disabled>- <GroupIcon className="h-4 w-4 opacity-60" />- <span>New group</span>- </ContextMenuItem>- </ContextMenuContent>- </ContextMenu>- <PanelContextMenu addNodes={addNodes} />- </Dialog>+ <ContextMenu>+ <ContextMenuTrigger className="h-full w-full">+ <ReactFlow {...reactFlowProps}>+ <FlowControls+ onLayout={onLayout}+ fitView={fitView}+ handleRefetch={handleRefetch}+ reloading={reloading}+ setView={setView}+ zoomIn={zoomIn}+ zoomOut={zoomOut}+ addNodes={addNodes}+ />+ <Background bgColor="var(--background)" />+ {showMiniMap && <MiniMap className="!z-40 !bg-card" pannable />}+ </ReactFlow>+ </ContextMenuTrigger>+ <ContextMenuContent className="w-32">+ <ContextMenuItem onClick={() => setOpenActionDialog(true)}>+ <PlusIcon className="h-4 w-4 opacity-60" />+ <span>New node</span>+ </ContextMenuItem>+ <ContextMenuItem disabled>+ <GroupIcon className="h-4 w-4 opacity-60" />+ <span>New group</span>+ </ContextMenuItem>+ </ContextMenuContent>+ </ContextMenu><NodeContextMenux={nodeContextMenu?.x}y={nodeContextMenu?.y}diff --git a/flowsint-web/src/components/ui/card.tsx b/flowsint-web/src/components/ui/card.tsxindex 19460930..d0b904b9 100644--- a/flowsint-web/src/components/ui/card.tsx+++ b/flowsint-web/src/components/ui/card.tsx@@ -7,7 +7,7 @@ function Card({ className, ...props }: React.ComponentProps<"div">) {<divdata-slot="card"className={cn(- "bg-background text-card-foreground rounded-xl border shadow-sm",+ "bg-card text-card-foreground rounded-xl border shadow-xs",className)}{...props}diff --git a/flowsint-web/src/store/sketch-store.ts b/flowsint-web/src/store/sketch-store.tsindex 906f733d..726bfe17 100644--- a/flowsint-web/src/store/sketch-store.ts+++ b/flowsint-web/src/store/sketch-store.ts@@ -26,9 +26,9 @@ interface SketchState {currentNode: anypanelOpen: booleanopenNewNode: boolean,+ openActionDialog: boolean,sketch: Sketch | nullisRefetching: boolean-setFilters: (filters: any) => voidsetSettings: (settings: any) => voidsetOpenSettingsModal: (open: boolean) => void@@ -36,14 +36,11 @@ interface SketchState {setCurrentNode: (node: any) => voidsetPanelOpen: (open: boolean) => voidsetSketch: (sketch: Sketch | null) => void-- // Modal HandlershandleOpenIndividualModal: (id: string) => voidsetHandleOpenIndividualModal: (handler: (id: string) => void) => voidhandleDeleteSketch: () => Promise<void>setHandleDeleteSketch: (handler: () => Promise<void>) => void-- // Query Hooks+ setOpenActionDialog: (open: boolean) => voiduseSketchData: (investigationId: string, sketchId: string) => SketchResults & {refetchAll: () => Promise<void>}@@ -69,7 +66,7 @@ export const useSketchStore = create(panelOpen: false,sketch: null,isRefetching: false,- // UI Actions+ openActionDialog: false,setFilters: (filters) => set({ filters }),setSettings: (settings) => set({ settings }),setOpenSettingsModal: (open) => set({ openSettingsModal: open }),@@ -77,6 +74,7 @@ export const useSketchStore = create(setCurrentNode: (node) => set({ currentNode: node }),setPanelOpen: (open) => set({ panelOpen: open }),setSketch: (sketch) => set({ sketch }),+ setOpenActionDialog: (open) => set({ openActionDialog: open }),handleOpenIndividualModal: () => { },setHandleOpenIndividualModal: (handler) => set({ handleOpenIndividualModal: handler }),handleDeleteSketch: async () => { },