Skip to content
Snippets Groups Projects
Commit 50224a15 authored by Marcos Pieras's avatar Marcos Pieras
Browse files

feat: rebased

parent c4c64166
No related branches found
No related tags found
1 merge request!332feat(vis0D): avoid crash with new query
Pipeline #141731 passed
...@@ -68,15 +68,16 @@ const Vis0D = forwardRef<Vis0DVisHandle, VisualizationPropTypes<Vis0DProps>>(({ ...@@ -68,15 +68,16 @@ const Vis0D = forwardRef<Vis0DVisHandle, VisualizationPropTypes<Vis0DProps>>(({
useEffect(() => { useEffect(() => {
if (settings.selectedEntity != '' && graphMetadata.nodes.types && settings.selectedAttribute != '' && settings.selectedStat != '') { if (settings.selectedEntity != '' && graphMetadata.nodes.types && settings.selectedAttribute != '' && settings.selectedStat != '') {
const nodesLabels = graphMetadata.nodes.labels; const nodesLabels = graphMetadata.nodes.labels;
const edgesLabels = graphMetadata.edges.labels;
let attributes = []; let attributes: string[] = [];
if (nodesLabels.includes(settings.selectedEntity)) { if (nodesLabels.includes(settings.selectedEntity)) {
attributes = Object.keys(graphMetadata.nodes.types[settings.selectedEntity].attributes); attributes = Object.keys(graphMetadata.nodes.types[settings.selectedEntity].attributes);
} else { } else if (edgesLabels.includes(settings.selectedEntity)) {
attributes = Object.keys(graphMetadata.edges.types[settings.selectedEntity].attributes); attributes = Object.keys(graphMetadata.edges.types[settings.selectedEntity].attributes);
} }
if (attributes.includes(settings.selectedAttribute)) { if (attributes.length > 0 && attributes.includes(settings.selectedAttribute)) {
let statsAvailable = []; let statsAvailable = [];
if (nodesLabels.includes(settings.selectedEntity)) { if (nodesLabels.includes(settings.selectedEntity)) {
...@@ -126,7 +127,6 @@ const Vis0D = forwardRef<Vis0DVisHandle, VisualizationPropTypes<Vis0DProps>>(({ ...@@ -126,7 +127,6 @@ const Vis0D = forwardRef<Vis0DVisHandle, VisualizationPropTypes<Vis0DProps>>(({
const Vis0DSettings = ({ settings, graphMetadata, updateSettings }: VisualizationSettingsPropTypes<Vis0DProps>) => { const Vis0DSettings = ({ settings, graphMetadata, updateSettings }: VisualizationSettingsPropTypes<Vis0DProps>) => {
const [attributeOptions, setAttributeOptions] = useState<string[]>([]); const [attributeOptions, setAttributeOptions] = useState<string[]>([]);
const [statsOptions, setStatsOptions] = useState<string[]>([]); const [statsOptions, setStatsOptions] = useState<string[]>([]);
useEffect(() => { useEffect(() => {
if (settings.selectedEntity === '' && graphMetadata && graphMetadata.nodes && graphMetadata.nodes.labels.length > 0) { if (settings.selectedEntity === '' && graphMetadata && graphMetadata.nodes && graphMetadata.nodes.labels.length > 0) {
const firstEntity = graphMetadata.nodes.labels[0]; const firstEntity = graphMetadata.nodes.labels[0];
...@@ -156,18 +156,23 @@ const Vis0DSettings = ({ settings, graphMetadata, updateSettings }: Visualizatio ...@@ -156,18 +156,23 @@ const Vis0DSettings = ({ settings, graphMetadata, updateSettings }: Visualizatio
graphMetadata.nodes.labels.length > 0 graphMetadata.nodes.labels.length > 0
) { ) {
const nodesLabels = graphMetadata.nodes.labels; const nodesLabels = graphMetadata.nodes.labels;
const edgesLabels = graphMetadata.edges.labels;
// attribute management // attribute management
let attributesFirstEntity = []; let attributesFirstEntity: string[] = [];
if (nodesLabels.includes(settings.selectedEntity)) { if (nodesLabels.includes(settings.selectedEntity)) {
attributesFirstEntity = Object.keys(graphMetadata.nodes.types[settings.selectedEntity].attributes); attributesFirstEntity = Object.keys(graphMetadata.nodes.types[settings.selectedEntity].attributes);
} else { } else if (edgesLabels.includes(settings.selectedEntity)) {
attributesFirstEntity = Object.keys(graphMetadata.edges.types[settings.selectedEntity].attributes); attributesFirstEntity = Object.keys(graphMetadata.edges.types[settings.selectedEntity].attributes);
} }
setAttributeOptions(attributesFirstEntity); setAttributeOptions(attributesFirstEntity);
let selectedAttribute = ''; let selectedAttribute = '';
if (settings.selectedAttribute === '' || !attributesFirstEntity.includes(settings.selectedAttribute)) { if (
settings.selectedAttribute === '' ||
!attributesFirstEntity.includes(settings.selectedAttribute) ||
attributesFirstEntity.length === 0
) {
selectedAttribute = attributesFirstEntity[0]; selectedAttribute = attributesFirstEntity[0];
updateSettings({ selectedAttribute: selectedAttribute }); updateSettings({ selectedAttribute: selectedAttribute });
} else { } else {
...@@ -182,7 +187,7 @@ const Vis0DSettings = ({ settings, graphMetadata, updateSettings }: Visualizatio ...@@ -182,7 +187,7 @@ const Vis0DSettings = ({ settings, graphMetadata, updateSettings }: Visualizatio
string, string,
number number
>; >;
} else { } else if (edgesLabels.includes(settings.selectedEntity)) {
attributeSelectedStatistics = graphMetadata.edges.types[settings.selectedEntity].attributes[selectedAttribute].statistics as Record< attributeSelectedStatistics = graphMetadata.edges.types[settings.selectedEntity].attributes[selectedAttribute].statistics as Record<
string, string,
number number
......
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