Skip to content

A modern platform for visual, flexible, and extensible graph-based investigations. For cybersecurity analysts and investigators.

feat: nodes panel filters

dextmorgn7cd0f1c40a73
diff --git a/flowsint-web/src/app/dashboard/projects/[project_id]/investigations/[investigation_id]/table/data-table.tsx b/flowsint-web/src/app/dashboard/projects/[project_id]/investigations/[investigation_id]/table/data-table.tsx
index 51055f09..488448f3 100644
--- a/flowsint-web/src/app/dashboard/projects/[project_id]/investigations/[investigation_id]/table/data-table.tsx
+++ b/flowsint-web/src/app/dashboard/projects/[project_id]/investigations/[investigation_id]/table/data-table.tsx
@@ -153,7 +153,7 @@ const columns: ColumnDef<any>[] = [
},
{
accessorKey: "full_name",
- header: "Full Name",
+ header: "Label",
cell: ({ row }: any) => {
return (
<TableCellViewer item={row.original.data}>
diff --git a/flowsint-web/src/components/download-button.tsx b/flowsint-web/src/components/download-button.tsx
new file mode 100644
index 00000000..a5195909
--- /dev/null
+++ b/flowsint-web/src/components/download-button.tsx
@@ -0,0 +1,40 @@
+// components/DownloadButton.tsx
+"use client";
+
+import { Download } from "lucide-react";
+import { Button } from "@/components/ui/button";
+import { toast } from "sonner";
+import { useState } from "react";
+import Loader from "./loader";
+export const DownloadButton = ({ endpoint, name = "sketch" }: { endpoint: string, name?: string }) => {
+ const [loading, setLoading] = useState(false)
+ const handleDownload = async () => {
+ try {
+ setLoading(true)
+ const response = await fetch(endpoint);
+ if (!response.ok) {
+ toast.error("Could not download data. Try again later.");
+ setLoading(false)
+ }
+ const blob = await response.blob();
+ const url = window.URL.createObjectURL(blob);
+ const a = document.createElement("a");
+ a.href = url;
+ a.download = `${name}-${new Date().toISOString()}.json`; // à adapter selon ton format
+ document.body.appendChild(a);
+ a.click();
+ a.remove();
+ window.URL.revokeObjectURL(url);
+ setLoading(false)
+ toast.success("Download complete.");
+ } catch (error) {
+ toast.error("Could not download data. Try again later.");
+ setLoading(false)
+ }
+ };
+ return (
+ <Button variant={"ghost"} disabled={loading} onClick={handleDownload} className="flex gap-2 h-full text-sm rounded-none">
+ <Download /> {loading ? <>Loading...</> : <>Download</>}
+ </Button>
+ );
+};
diff --git a/flowsint-web/src/components/investigations/investigation-navigation.tsx b/flowsint-web/src/components/investigations/investigation-navigation.tsx
index 2afd70d2..8a9631f2 100644
--- a/flowsint-web/src/components/investigations/investigation-navigation.tsx
+++ b/flowsint-web/src/components/investigations/investigation-navigation.tsx
@@ -8,6 +8,7 @@ import { Fragment, memo, useMemo } from "react"
import MoreMenu from "./more-menu"
import { ScanButton } from "./scans-drawer/scan-button"
import { Badge } from "../ui/badge"
+import { DownloadButton } from "../download-button"
function InvestigationNavigation({ project_id, investigation_id }: { project_id: string, investigation_id: string }) {
const pathname = usePathname()
@@ -69,6 +70,7 @@ function InvestigationNavigation({ project_id, investigation_id }: { project_id:
))}
</div>
<div className="flex items-center">
+ <DownloadButton endpoint={`/api/projects/${project_id}/investigations/${investigation_id}/table`} name={project_id} />
<MoreMenu />
<ScanButton />
</div>
diff --git a/flowsint-web/src/components/investigations/new-actions.tsx b/flowsint-web/src/components/investigations/new-actions.tsx
index c58a5b17..ab73bb7e 100644
--- a/flowsint-web/src/components/investigations/new-actions.tsx
+++ b/flowsint-web/src/components/investigations/new-actions.tsx
@@ -202,7 +202,7 @@ function ActionCard({ item, onSelect }: ActionCardProps) {
return (
<Card
className={cn(
- "cursor-pointer transition-all hover:scale-105 hover:shadow-md",
+ "cursor-pointer transition-all bg-accent hover:scale-105 hover:shadow-md",
item.disabled && "opacity-50 cursor-not-allowed",
"h-full",
)}
diff --git a/flowsint-web/src/components/investigations/panel-context-menu.tsx b/flowsint-web/src/components/investigations/panel-context-menu.tsx
index d95d0f8f..6bca9723 100644
--- a/flowsint-web/src/components/investigations/panel-context-menu.tsx
+++ b/flowsint-web/src/components/investigations/panel-context-menu.tsx
@@ -191,7 +191,7 @@ function ActionCard({ item, onSelect }: ActionCardProps) {
return (
<Card
className={cn(
- "cursor-pointer transition-all hover:scale-105 hover:shadow-md",
+ "cursor-pointer transition-all bg-accent hover:scale-105 hover:shadow-md",
item.disabled && "opacity-50 cursor-not-allowed",
"h-full",
)}
diff --git a/flowsint-web/src/components/investigations/sketch/nodes-panel.tsx b/flowsint-web/src/components/investigations/sketch/nodes-panel.tsx
index 97cc801c..bee11a90 100644
--- a/flowsint-web/src/components/investigations/sketch/nodes-panel.tsx
+++ b/flowsint-web/src/components/investigations/sketch/nodes-panel.tsx
@@ -4,11 +4,12 @@ import { useFlowStore } from '@/store/flow-store'
import { Button } from '@/components/ui/button'
import { Badge } from '@/components/ui/badge'
import { TypeBadge } from '@/components/type-badge'
-import { Search, HelpCircle } from "lucide-react"
+import { Search, HelpCircle, FilterIcon, XIcon } from "lucide-react"
import { usePlatformIcons } from '@/lib/hooks/use-platform-icons'
import { Input } from '@/components/ui/input'
import { actionItems } from '@/lib/action-items'
import { cn } from '@/lib/utils'
+import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuLabel, DropdownMenuSeparator, DropdownMenuTrigger } from '@/components/ui/dropdown-menu'
// Mémoiser le composant SocialNode
const SocialNode = memo(({ node, setCurrentNode, currentNodeId }: {
@@ -93,23 +94,44 @@ const NodesPanel = memo(({ nodes }: { nodes: Node[] }) => {
const setCurrentNode = useFlowStore(state => state.setCurrentNode)
const currentNodeId = useFlowStore(state => state.currentNode?.id)
const [searchQuery, setSearchQuery] = useState("")
+ const [filters, setFilters] = useState<null | string[]>(null) // 'individual', 'email', etc.
- // Mémoiser la fonction de filtrage pour éviter de recalculer à chaque rendu
const filteredNodes = useMemo(() => {
const searchText = searchQuery.toLowerCase()
return nodes?.filter((node) => {
- return (
+ const matchesSearch =
//@ts-ignore
node?.data?.label?.toLowerCase().includes(searchText) ||
node.id.toLowerCase().includes(searchText)
- )
+
+ const matchesFilter = !filters || filters.includes(node?.data?.type as string)
+
+ return matchesSearch && matchesFilter
})
- }, [nodes, searchQuery])
+ }, [nodes, searchQuery, filters])
+
+ const toggleFilter = useCallback((filter: string | null) => {
+ if (filter === null) {
+ setFilters(null)
+ } else {
+ setFilters(prev => {
+ if (prev === null) return [filter]
+ const next = prev.includes(filter)
+ ? prev.filter(f => f !== filter)
+ : [...prev, filter]
+ return next.length === 0 ? null : next
+ })
+ }
+ }, [])
const handleSearchChange = useCallback((e: React.ChangeEvent<HTMLInputElement>) => {
setSearchQuery(e.target.value)
}, [])
+ const clearFilters = useCallback(() => {
+ setFilters(null)
+ }, [])
+
return (
<div className="overflow-auto h-full flex flex-col w-full !p-0 !m-0">
<div className="sticky border-b top-0 p-2 bg-background z-10">
@@ -126,6 +148,22 @@ const NodesPanel = memo(({ nodes }: { nodes: Node[] }) => {
onChange={handleSearchChange}
/>
</div>
+ <DropdownMenu>
+ <DropdownMenuTrigger asChild>
+ <Button variant={"outline"} className="h-7 w-8 relative" size={"icon"}>
+ <FilterIcon className={cn("opacity-60 h-3 w-3", filters && 'opacity-100')} />
+ {filters && <Badge className='absolute -top-2 -right-1 text-xs rounded-full h-4 w-4' variant={"default"}>{filters.length}</Badge>}
+ </Button>
+ </DropdownMenuTrigger>
+ <DropdownMenuContent className="w-48 max-h-[50vh] space-y-1 overflow-y-auto">
+ <DropdownMenuLabel>{filters ? <Badge variant={"outline"} className='flex items-center gap-1 pr-1'>{filters?.length} filter(s)<Button size={"icon"} variant={"ghost"} className='h-5 w-5 rounded-full' onClick={clearFilters}><XIcon className='h-3 w-3' /></Button></Badge> : "filters"}</DropdownMenuLabel>
+ <DropdownMenuSeparator />
+ <DropdownMenuItem className={cn(filters == null && "bg-primary")} onClick={() => toggleFilter(null)}>All</DropdownMenuItem>
+ {actionItems.map((item) => (
+ <DropdownMenuItem className={cn(filters?.includes(item.type) && "bg-primary/30")} key={item.id} onClick={() => toggleFilter(item.type)}>{item.type}</DropdownMenuItem>
+ ))}
+ </DropdownMenuContent>
+ </DropdownMenu>
</div>
</div>
{filteredNodes?.length === 0 && searchQuery === "" && (
diff --git a/flowsint-web/src/components/ui/tooltip.tsx b/flowsint-web/src/components/ui/tooltip.tsx
index 4d82556e..6f94c8b8 100644
--- a/flowsint-web/src/components/ui/tooltip.tsx
+++ b/flowsint-web/src/components/ui/tooltip.tsx
@@ -46,7 +46,7 @@ function TooltipContent({
data-slot="tooltip-content"
sideOffset={sideOffset}
className={cn(
- "bg-background text-primary-foreground animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 max-w-sm rounded-md px-3 py-1.5 text-xs",
+ "bg-background animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 max-w-sm rounded-md px-3 py-1.5 text-xs",
className
)}
{...props}