Skip to content

Commit

Permalink
feat(qseow task-vis): Show count for duplicate, identical triggers in…
Browse files Browse the repository at this point in the history
… task network view

Implements ptarmiganlabs#599
  • Loading branch information
mountaindude committed Jan 4, 2025
1 parent 5821e73 commit 3499df4
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/lib/cmd/qseow/vistask.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ const visOptions = {
arrows: 'to',
width: 5,
smooth: false,
font: {
size: 22, // Increase font size for text edge labels
},
},
layout: {
randomSeed: 5.5,
Expand Down Expand Up @@ -364,6 +367,17 @@ const prepareFile = async (url) => {
})
.concat(nodesNetwork);

// Add a text with edge count for the edges where edgeCount > 1
// No text for edges where edgeCount === 1
// Update the edge label in taskModel.edges[] with the edge count
taskModel.edges.map((edge) => {
if (edge.edgeCount > 1) {
edge.label = `${edge.edgeCount}`;
} else {
edge.label = '';
}
});

const networkTask = { nodes: nodesNetwork, edges: taskModel.edges };

templateData.nodes = JSON.stringify(nodesNetwork);
Expand Down
34 changes: 34 additions & 0 deletions src/lib/task/get_task_sub_graph.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,29 @@ export function extGetTaskSubGraph(_, node, parentTreeLevel, parentNode, logger)
}

duplicateDownstreamNodes.push(tmp);

// Update edge in main task network to reflect that there are multiple downstream nodes with the same ID and the same relationship
_.taskNetwork.edges = _.taskNetwork.edges.map((el) => {
if (el.from === edgeToDownstreamNode.from && el.to === edgeToDownstreamNode.to) {
return {
...el,
edgeCount: tmp.length,
};
}
return el;
});
} else {
// No duplicate downstream nodes
// Update edge in main task network to reflect that there are no multiple downstream nodes with the same ID and the same relationship
_.taskNetwork.edges = _.taskNetwork.edges.map((el) => {
if (el.from === edgeToDownstreamNode.from && el.to === edgeToDownstreamNode.to) {
return {
...el,
edgeCount: 1,
};
}
return el;
});
}
}
}
Expand Down Expand Up @@ -217,6 +240,17 @@ export function extGetTaskSubGraph(_, node, parentTreeLevel, parentNode, logger)
}
}

// Update edges with information about how many instances of the same edge there are.
// This has been temporarily stored in the main task network object's edges property.
// Copy it over to the edges in the subgraphEdges array.
subGraphEdges = subGraphEdges.map((el) => {
const edgeCount = _.taskNetwork.edges.find((edge) => edge.from === el.from && edge.to === el.to).edgeCount;
return {
...el,
edgeCount: edgeCount,
};
});

return {
nodes: subGraphNodes,
edges: subGraphEdges,
Expand Down

0 comments on commit 3499df4

Please sign in to comment.