A modern platform for visual, flexible, and extensible graph-based investigations. For cybersecurity analysts and investigators.
feat(app): zoom to nodes selection
dextmorgn168cdff191d1
diff --git a/flowsint-app/src/components/graphs/graph-viewer.tsx b/flowsint-app/src/components/graphs/graph-viewer.tsxindex 9b22977a..ab9eb5f3 100644--- a/flowsint-app/src/components/graphs/graph-viewer.tsx+++ b/flowsint-app/src/components/graphs/graph-viewer.tsx@@ -476,6 +476,13 @@ const GraphViewer: React.FC<GraphViewerProps> = ({graphRef.current.zoomToFit(400)}},+ zoomToSelection: () => {+ if (graphRef.current && typeof graphRef.current.zoomToFit === 'function') {+ // Filter only selected nodes+ const nodeFilterFn = (node: any) => selectedNodeIds.has(node.id)+ graphRef.current.zoomToFit(400, 50, nodeFilterFn)+ }+ },centerOnNode: (x: number, y: number) => {if (graphRef.current && typeof graphRef.current.centerAt === 'function') {graphRef.current.centerAt(x, y, 400)@@ -505,7 +512,7 @@ const GraphViewer: React.FC<GraphViewerProps> = ({// Call external ref callbackonGraphRef?.(graphInstance)},- [setActions, onGraphRef, instanceId, regenerateLayout, graphData.nodes.length]+ [setActions, onGraphRef, instanceId, regenerateLayout, graphData.nodes.length, selectedNodeIds])// Initialize graph once ready@@ -519,6 +526,7 @@ const GraphViewer: React.FC<GraphViewerProps> = ({zoomIn: () => { },zoomOut: () => { },zoomToFit: () => { },+ zoomToSelection: () => { },centerOnNode: () => { },regenerateLayout: () => { },getViewportCenter: () => nulldiff --git a/flowsint-app/src/components/graphs/toolbar.tsx b/flowsint-app/src/components/graphs/toolbar.tsxindex b9da3319..d1106ab7 100644--- a/flowsint-app/src/components/graphs/toolbar.tsx+++ b/flowsint-app/src/components/graphs/toolbar.tsx@@ -17,7 +17,8 @@ import {ZoomIn,RectangleHorizontal,ChevronDown,- SquareDashed+ SquareDashed,+ Focus} from 'lucide-react'import { memo, useCallback } from 'react'import { toast } from 'sonner'@@ -86,6 +87,7 @@ export const Toolbar = memo(function Toolbar({ isLoading }: { isLoading: booleanconst view = useGraphControls((s) => s.view)const setView = useGraphControls((s) => s.setView)const zoomToFit = useGraphControls((s) => s.zoomToFit)+ const zoomToSelection = useGraphControls((s) => s.zoomToSelection)const zoomIn = useGraphControls((s) => s.zoomIn)const zoomOut = useGraphControls((s) => s.zoomOut)const regenerateLayout = useGraphControls((s) => s.regenerateLayout)@@ -216,6 +218,12 @@ export const Toolbar = memo(function Toolbar({ isLoading }: { isLoading: booleanonClick={zoomToFit}disabled={view !== 'graph' || isSelectorModeActive}/>+ <ToolbarButton+ icon={<Focus className="h-4 w-4 opacity-70" />}+ tooltip="Zoom to Selection"+ onClick={zoomToSelection}+ disabled={view !== 'graph' || isSelectorModeActive || selectedNodes.length < 2}+ /></div><Separator decorative orientation="vertical" /><div className='flex gap-0.5'>diff --git a/flowsint-app/src/stores/graph-controls-store.ts b/flowsint-app/src/stores/graph-controls-store.tsindex 0e0ecd3e..ce81629e 100644--- a/flowsint-app/src/stores/graph-controls-store.ts+++ b/flowsint-app/src/stores/graph-controls-store.ts@@ -14,6 +14,7 @@ type GraphControlsStore = {zoomToFit: () => voidzoomIn: () => voidzoomOut: () => void+ zoomToSelection: () => voidcenterOnNode: (x: number, y: number) => voidonLayout: (layout: any) => voidsetActions: (actions: Partial<GraphControlsStore>) => void@@ -38,6 +39,7 @@ export const useGraphControls = create<GraphControlsStore>()(zoomToFit: () => { },zoomIn: () => { },zoomOut: () => { },+ zoomToSelection: () => { },centerOnNode: () => { },onLayout: () => { },setActions: (actions) => set(actions),