Skip to content
Snippets Groups Projects
Commit b6cf596a authored by Vink, S.A. (Sjoerd)'s avatar Vink, S.A. (Sjoerd) Committed by Leonardo Christino
Browse files

feat(searchResultsNodeLink): search results in nodelink

parent a444cf5a
No related branches found
Tags v1.114.0
1 merge request!88feat(searchResultsNodeLink): search results in nodelink
Pipeline #127625 failed
......@@ -7,7 +7,7 @@ import { select, zoom as d3zoom, drag as d3drag } from 'd3';
import * as force from './NLForce';
import { Viewport } from 'pixi-viewport';
import { GraphQueryResult, GraphQueryResultFromBackendPayload } from '@graphpolaris/shared/lib/data-access/store/graphQueryResultSlice';
import { useAppDispatch, useML } from '@graphpolaris/shared/lib/data-access';
import { useAppDispatch, useML, useSearchResultData } from '@graphpolaris/shared/lib/data-access';
import { ML, setShortestPathSource, setShortestPathTarget } from '@graphpolaris/shared/lib/data-access/store/mlSlice';
import { parseQueryResult } from './query2NL';
import { NLPopup } from './NLPopup';
......@@ -43,6 +43,7 @@ export const NLPixi = (props: Props) => {
const dragging = useRef<{ node: NodeType; gfx: Graphics } | null>(null);
const onlyClicked = useRef(false);
const dispatch = useAppDispatch();
const searchResults = useSearchResultData();
const imperative = useRef<any>(null);
......@@ -337,6 +338,24 @@ export const NLPixi = (props: Props) => {
}
}, [props.graph]);
useEffect(() => {
if (props.graph) {
props.graph.nodes.forEach((node: NodeType) => {
const gfx = nodeMap.current.get(node.id);
if (!gfx) return;
const isNodeInSearchResults = searchResults.nodes.some((resultNode) => resultNode.id === node.id);
gfx.alpha = isNodeInSearchResults || searchResults.nodes.length === 0 ? 1 : 0.05;
});
props.graph.links.forEach((link: LinkType) => {
const gfx = linkMap.current.get(link.id);
if (!gfx) return;
const isLinkInSearchResults = searchResults.edges.some((resultEdge) => resultEdge.id === link.id);
gfx.alpha = isLinkInSearchResults || searchResults.edges.length === 0 ? 1 : 0.05;
});
}
}, [searchResults]);
const tick = (delta: number) => {
if (props.graph) {
props.graph.nodes.forEach((node: NodeType) => {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment