diff --git a/src/js/modules/viewports/graph_viewport/graph_ui.js b/src/js/modules/viewports/graph_viewport/graph_ui.js index 855ee86..0d890cd 100644 --- a/src/js/modules/viewports/graph_viewport/graph_ui.js +++ b/src/js/modules/viewports/graph_viewport/graph_ui.js @@ -210,7 +210,7 @@ var addNodeCallback = function (data) { var updateSearchParam = function(event, data, instance){ var selectedUuid =state.getSearchParam("selected") if (selectedUuid) { - data.graph.getNodeManager().setFocus(selectedUuid) + data.graph.getNodeManager().setFocus(selectedUuid, {mode:undefined,extendToRelations:true}) } } diff --git a/src/js/vendor/stellae/stellae_nodes.js b/src/js/vendor/stellae/stellae_nodes.js index 3192f0f..16cb6cc 100644 --- a/src/js/vendor/stellae/stellae_nodes.js +++ b/src/js/vendor/stellae/stellae_nodes.js @@ -566,9 +566,9 @@ var createNodeManager = function ({ return ui.getSelected(params) } } - var setFocus= function (params) { + var setFocus= function (params, options) { if (ui) { - return ui.setFocus(params) + return ui.setFocus(params, options) } } diff --git a/src/js/vendor/stellae/stellae_ui.js b/src/js/vendor/stellae/stellae_ui.js index e263363..3fbf922 100644 --- a/src/js/vendor/stellae/stellae_ui.js +++ b/src/js/vendor/stellae/stellae_ui.js @@ -675,17 +675,86 @@ export default function createStellaeUi({ return obj } - var setFocus = function (uuid) { - for (let i = 0; i < state.nodes.length; i++) { - if (state.nodes[i].edata.uuid == uuid) { + //TODO move to other files + + var findNodeDirectRelations = function (uuid, recursions) { + var nodesRelatedUuids = { + list:[], + objects:{}, + arrowList:[], + arrowObjects:[] + } + var seen = {} + // var mapping = { + // in:{}, + // out:{}, + // } + for (let i = 0; i < state.links.length; i++) { + + if ( state.links[i].edata.from == uuid && !seen[state.links[i].edata.to]) { + nodesRelatedUuids.list.push(state.links[i].edata.to) + nodesRelatedUuids.arrowList.push(state.links[i].edata.uuid) + nodesRelatedUuids.objects[state.links[i].edata.to]= true + nodesRelatedUuids.arrowObjects[state.links[i].edata.uuid]= true + seen[state.links[i].edata.to] =true + } + if ( state.links[i].edata.to == uuid && !seen[state.links[i].edata.from]) { + nodesRelatedUuids.list.push(state.links[i].edata.from) + nodesRelatedUuids.arrowList.push(state.links[i].edata.uuid) + nodesRelatedUuids.objects[state.links[i].edata.from] = true + nodesRelatedUuids.arrowObjects[state.links[i].edata.uuid] = true + seen[state.links[i].edata.from] =true + } + // mapping.in[state.links[i].edata.from] = mapping.in[state.links[i].edata.from] + } + return nodesRelatedUuids + } + + var setFocus = function (uuid, options) { + var extendToRelations = options?.extendToRelations || false + var mode = options?.mode || undefined + var visibleNodes = {[uuid]:true} + var arrowObjects = undefined + + if (extendToRelations) { + var otherLevels = findNodeDirectRelations(uuid) + visibleNodes = Object.assign({},visibleNodes, otherLevels.objects ) + arrowObjects = otherLevels.arrowObjects + console.log(otherLevels); + } + + if (!mode) { + for (let i = 0; i < state.nodes.length; i++) { + if (visibleNodes[state.nodes[i].edata.uuid]) { // nodeList[i].visible = true unFadeNode(state.nodes[i]) }else{ // nodeList[i].visible = false fadeNode(state.nodes[i]) } + } + } else{ + for (let i = 0; i < state.nodes.length; i++) { + if ( visibleNodes[state.nodes[i].edata.uuid]) { + state.nodes[i].visible = true + // unFadeNode(state.nodes[i]) + }else{ + state.nodes[i].visible = false + // fadeNode(state.nodes[i]) + } + } + if (arrowObjects) { + for (let i = 0; i < state.links.length; i++) { + if ( arrowObjects[state.links[i].edata.uuid]) { + state.links[i].visible = true + }else{ + state.links[i].visible = false + } + } + } } + }