From 38ac3bc77b312f9138170ca7b92d0146939e6cca Mon Sep 17 00:00:00 2001 From: MarcosPierasNL <pieras.marcos@gmail.com> Date: Wed, 26 Feb 2025 20:45:53 +0100 Subject: [PATCH 1/2] feat: reverse selection panel settigns --- src/lib/vis/components/VisualizationTabBar.tsx | 2 -- src/lib/vis/views/Recommender.tsx | 2 -- 2 files changed, 4 deletions(-) diff --git a/src/lib/vis/components/VisualizationTabBar.tsx b/src/lib/vis/components/VisualizationTabBar.tsx index 5110f6b08..be29baef0 100644 --- a/src/lib/vis/components/VisualizationTabBar.tsx +++ b/src/lib/vis/components/VisualizationTabBar.tsx @@ -15,7 +15,6 @@ import { VisualizationsConfig } from './config'; import { Visualizations } from './VisualizationPanel'; import Sortable from 'sortablejs'; import { VisualizationSettingsType } from '../common'; -import { resultSetFocus } from '@/lib/data-access/store/interactionSlice'; export default function VisualizationTabBar(props: { fullSize: () => void; exportImage: () => void; handleSelect: () => void }) { const { activeVisualizationIndex, openVisualizationArray } = useVisualization(); @@ -107,7 +106,6 @@ export default function VisualizationTabBar(props: { fullSize: () => void; expor label={displayName} className="flex items-center gap-2" onClick={async () => { - dispatch(resultSetFocus({ focusType: 'visualization' })); const component = await Visualizations[id](); dispatch(addVisualization({ ...component.default.settings, name: displayName, id })); setOpen(false); diff --git a/src/lib/vis/views/Recommender.tsx b/src/lib/vis/views/Recommender.tsx index 6d153798e..cc5924fab 100644 --- a/src/lib/vis/views/Recommender.tsx +++ b/src/lib/vis/views/Recommender.tsx @@ -4,7 +4,6 @@ import { addVisualization } from '../../data-access/store/visualizationSlice'; import { useActiveSaveStateAuthorization, useAppDispatch } from '../../data-access'; import { Visualizations } from '../components/VisualizationPanel'; import { VisualizationsConfig } from '../components/config/VisualizationConfig'; -import { resultSetFocus } from '@/lib/data-access/store/interactionSlice'; export function Recommender() { const dispatch = useAppDispatch(); @@ -28,7 +27,6 @@ export function Recommender() { console.debug('User blocked from editing query due to being a viewer'); return; } - dispatch(resultSetFocus({ focusType: 'visualization' })); const component = await Visualizations[id](); dispatch(addVisualization({ ...component.default.settings, name: displayName, id })); }} -- GitLab From 335032ceeb609079b29bf32f227525d8846c1649 Mon Sep 17 00:00:00 2001 From: MarcosPierasNL <pieras.marcos@gmail.com> Date: Thu, 27 Feb 2025 11:32:38 +0100 Subject: [PATCH 2/2] feat: adds checkings --- .../vis/visualizations/tablevis/tablevis.tsx | 109 +++++++++--------- 1 file changed, 57 insertions(+), 52 deletions(-) diff --git a/src/lib/vis/visualizations/tablevis/tablevis.tsx b/src/lib/vis/visualizations/tablevis/tablevis.tsx index 711bf2683..9ce7f0381 100644 --- a/src/lib/vis/visualizations/tablevis/tablevis.tsx +++ b/src/lib/vis/visualizations/tablevis/tablevis.tsx @@ -39,73 +39,78 @@ export const TableVis = forwardRef<TableVisHandle, VisualizationPropTypes<TableP const searchResults = useSearchResultData(); const ref = useRef<HTMLDivElement>(null); - const displayAttributesSorted = useMemo<string[]>(() => { - if (settings.displayAttributes.length != 0) { - return [...settings.displayAttributes].sort((a, b) => a.localeCompare(b)); + const [attributesArray, displayAttributesSorted] = useMemo<[AugmentedNodeAttributes[], string[]]>(() => { + let selectedEntity: string = ''; + let displayAttributes: string[] = []; + + if (settings.selectedEntity != '') { + selectedEntity = settings.selectedEntity; + displayAttributes = settings.displayAttributes; + } else { + if (graphMetadata.nodes.labels.length > 0) { + selectedEntity = graphMetadata.nodes.labels[0]; + displayAttributes = Object.keys(graphMetadata.nodes.types[selectedEntity].attributes); + } } - return settings.displayAttributes; - }, [settings.displayAttributes]); - const attributesArray = useMemo<AugmentedNodeAttributes[]>(() => { - const displayAttributesSorted = [...settings.displayAttributes].sort((a, b) => a.localeCompare(b)); + const displayAttributesSorted = [...displayAttributes].sort((a, b) => a.localeCompare(b)); const nodesLabels = graphMetadata.nodes.labels; let dataNodes = []; - if (nodesLabels.includes(settings.selectedEntity)) { + if (nodesLabels.includes(selectedEntity)) { dataNodes = (searchResults?.nodes?.length ?? 0) === 0 ? data.nodes : searchResults.nodes; } else { dataNodes = data.edges; } - return ( - dataNodes - .filter(node => { - // some dataset do not have label field - let labelNode = ''; - if (node.label !== undefined) { - labelNode = node.label; - } else { - const idParts = node._id.split('/'); - labelNode = idParts[0]; - } - return labelNode === settings.selectedEntity; - }) - ///.filter((obj) => obj.similarity === undefined || obj.similarity >= similiarityThreshold) - .map(node => { - // get attributes filtered and sorted - const filteredAttributes = Object.fromEntries( - Object.entries(node.attributes) - .filter(([attr]) => settings.displayAttributes.includes(attr)) - .sort(([attrA], [attrB]) => settings.displayAttributes.indexOf(attrA) - settings.displayAttributes.indexOf(attrB)), - ); + const attributesArray = dataNodes + .filter(node => { + // some dataset do not have label field + let labelNode = ''; + if (node.label !== undefined) { + labelNode = node.label; + } else { + const idParts = node._id.split('/'); + labelNode = idParts[0]; + } + return labelNode === selectedEntity; + }) + .map(node => { + // get attributes filtered and sorted + const filteredAttributes = Object.fromEntries( + Object.entries(node.attributes) + .filter(([attr]) => displayAttributes.includes(attr)) + .sort(([attrA], [attrB]) => displayAttributes.indexOf(attrA) - displayAttributes.indexOf(attrB)), + ); - // doubled types structure to handle discrepancies in schema object in sb and dev env. + // doubled types structure to handle discrepancies in schema object in sb and dev env. - const types = - schema.nodes.find((n: any) => { - const labelNode = node.label; - return labelNode === n.key; - })?.attributes?.attributes ?? - schema.nodes.find((n: any) => { - const labelNode = node.label; + const types = + schema.nodes.find((n: any) => { + const labelNode = node.label; + return labelNode === n.key; + })?.attributes?.attributes ?? + schema.nodes.find((n: any) => { + const labelNode = node.label; - return labelNode === n.name; - })?.attributes; + return labelNode === n.name; + })?.attributes; + + if (types) { + return { + attribute: filteredAttributes, + type: Object.fromEntries(types.map((t: any) => [t.name, t.type])), + }; + } else { + return { + attribute: filteredAttributes, + type: {}, + }; + } + }); - if (types) { - return { - attribute: filteredAttributes, - type: Object.fromEntries(types.map((t: any) => [t.name, t.type])), - }; - } else { - return { - attribute: filteredAttributes, - type: {}, - }; - } - }) - ); + return [attributesArray, displayAttributesSorted]; }, [data.nodes, settings.selectedEntity, settings.displayAttributes, searchResults]); const exportImageInternal = () => { -- GitLab