From 725cc76ac2af5167f212e2438bd24896aa8a46cf Mon Sep 17 00:00:00 2001 From: Cindy Chang Date: Fri, 30 Aug 2024 11:16:03 +0800 Subject: [PATCH] refine default highlight for all six views --- src/components/Button.vue | 17 ++++++++++++ src/stores/cytoscapeStore.ts | 1 - src/stores/mapPathStore.ts | 51 ++++++++++++++++++++++++++++------ src/views/Discover/Map/Map.vue | 18 ++++++------ 4 files changed, 69 insertions(+), 18 deletions(-) create mode 100644 src/components/Button.vue diff --git a/src/components/Button.vue b/src/components/Button.vue new file mode 100644 index 0000000..1e6b613 --- /dev/null +++ b/src/components/Button.vue @@ -0,0 +1,17 @@ + + + \ No newline at end of file diff --git a/src/stores/cytoscapeStore.ts b/src/stores/cytoscapeStore.ts index 949448c..d2b86e2 100644 --- a/src/stores/cytoscapeStore.ts +++ b/src/stores/cytoscapeStore.ts @@ -50,7 +50,6 @@ export default defineStore('useCytoscapeStore', { this.nodePositions[this.currentGraphId].push({id: nodeId, position: position}); localStorage.setItem(SAVE_KEY_NAME, JSON.stringify(this.nodePositions)); } - console.log('', ); this.savePositionsToStorage(); }, /** diff --git a/src/stores/mapPathStore.ts b/src/stores/mapPathStore.ts index ffabc8d..15fea82 100644 --- a/src/stores/mapPathStore.ts +++ b/src/stores/mapPathStore.ts @@ -18,7 +18,32 @@ export default defineStore('useMapPathStore', { clickedPath: [], insights: {}, insightWithPath: {}, - cytoscape: null, + cytoscape: { + process: + { + curved:{ + horizontal:null, + vertical:null, + }, + elbow:{ + horizontal:null, + vertical:null, + } + }, + bpmn: { + curved:{ + horizontal:null, + vertical:null, + }, + elbow:{ + horizontal:null, + vertical:null, + } + } + }, + processOrBPMN: 'process', + curveType: 'curved', + directionType: 'horizontal', allPaths: [], allPathsByEdge: [], startNode: null, @@ -29,13 +54,21 @@ export default defineStore('useMapPathStore', { isBPMNOn: false, }), actions: { - setCytoscape(cytoscape) { - this.cytoscape = cytoscape; + async setCytoscape(cytoscape, processOrBPMN = 'process', curveType = 'curved', directionType = 'horizontal') { + this.processOrBPMN = processOrBPMN; + this.curveType = curveType; + this.directionType = directionType; + this.cytoscape[processOrBPMN][curveType][directionType] = cytoscape; + await this.createInsightWithPath(); + if(processOrBPMN === 'process') { + await this.highlightMostFrequentPath(); + } }, async createInsightWithPath() { const { insights } = AllMapData(); this.insights = {...insights}; - this.startNode = this.cytoscape?.nodes().filter(function(elem) { + this.startNode = this.cytoscape[this.processOrBPMN][this.curveType][this.directionType]?.nodes() + .filter(function(elem) { return elem.data('label').toLocaleLowerCase() === 'start'; }); for(let i = 0; i < INSIGHTS_FIELDS_AND_LABELS.length; i++) { @@ -79,7 +112,8 @@ export default defineStore('useMapPathStore', { } }, async createPaths() { - this.startNode = this.cytoscape?.nodes().filter(function(elem) { + this.startNode = this.cytoscape[this.processOrBPMN][this.curveType][this.directionType]?.nodes() + .filter(function(elem) { return elem.data('label').toLocaleLowerCase() === 'start'; }); // Depth First Search from the starting node @@ -202,9 +236,9 @@ export default defineStore('useMapPathStore', { }) }, clearAllHighlight() { - this.cytoscape?.edges().removeClass('highlight-edge'); - this.cytoscape?.nodes().removeClass('highlight-node'); - this.cytoscape?.nodes().forEach(nodeToReset => { + this.cytoscape[this.processOrBPMN][this.curveType][this.directionType]?.edges().removeClass('highlight-edge'); + this.cytoscape[this.processOrBPMN][this.curveType][this.directionType]?.nodes().removeClass('highlight-node'); + this.cytoscape[this.processOrBPMN][this.curveType][this.directionType]?.nodes().forEach(nodeToReset => { nodeToReset.data('nodeImageUrl', ImgCapsules[nodeToReset.data('level')]) }); }, @@ -231,6 +265,7 @@ export default defineStore('useMapPathStore', { clickedEdge.addClass('highlight-edge'); }, async highlightMostFrequentPath() { + console.log('highlightMostFrequentPath', this.insightWithPath['most_freq_traces'][0]); const LIST_INDEX = 0; this.insightWithPath['most_freq_traces'][LIST_INDEX].nodes.map(nodeToHighlight => { nodeToHighlight.data('nodeImageUrl', ImgCapsulesGlow[nodeToHighlight.data('level')]); diff --git a/src/views/Discover/Map/Map.vue b/src/views/Discover/Map/Map.vue index ffae6e8..529abc3 100644 --- a/src/views/Discover/Map/Map.vue +++ b/src/views/Discover/Map/Map.vue @@ -53,7 +53,7 @@