From 2de9a2b3e64283a043ae47fa7a8f919e7cf77ba0 Mon Sep 17 00:00:00 2001 From: Cindy Chang Date: Mon, 19 Aug 2024 16:19:12 +0800 Subject: [PATCH] WIP: createAllPaths --- src/components/Discover/Map/SidebarState.vue | 13 +++----- src/constants/constants.js | 8 +++++ src/stores/mapPathStore.ts | 34 ++++++++++++++++++++ src/views/Discover/Map/Map.vue | 8 ++++- 4 files changed, 53 insertions(+), 10 deletions(-) create mode 100644 src/stores/mapPathStore.ts diff --git a/src/components/Discover/Map/SidebarState.vue b/src/components/Discover/Map/SidebarState.vue index d17ac56..77e9465 100644 --- a/src/components/Discover/Map/SidebarState.vue +++ b/src/components/Discover/Map/SidebarState.vue @@ -241,16 +241,10 @@ import PageAdmin from '@/stores/pageAdmin'; import { getTimeLabel } from '@/module/timeLabel.js'; import getMoment from 'moment'; import i18next from '@/i18n/i18n'; +import { INSIGHTS_FIELDS_AND_LABELS } from '@/constants/constants'; -const fieldNamesAndLabelNames = [ - ['self_loops', 'Self-Loop'], - ['short_loops', 'Short-Loop'], - ['shortest_traces', 'Shortest Trace'], - ['longest_traces', 'Longest Trace'], - ['most_freq_traces', 'Most Frequent Trace'], -]; // 刪除第一個和第二個元素 -fieldNamesAndLabelNames.splice(0, 2); +const fieldNamesAndLabelNames = [...INSIGHTS_FIELDS_AND_LABELS].splice(0, 2); export default { props:{ sidebarState: { @@ -269,6 +263,7 @@ export default { setup(){ const pageAdmin = PageAdmin(); + const active1 = ref(0); const currentMapFile = computed(() => pageAdmin.currentMapFile); const selectedPath = ref(0); @@ -282,6 +277,7 @@ export default { fieldNamesAndLabelNames, selectedPath, onPathOptionClick, + active1, }; }, data() { @@ -291,7 +287,6 @@ export default { valueTraces: 0, valueTaskInstances: 0, valueTasks: 0, - active1: 0, } }, methods: { diff --git a/src/constants/constants.js b/src/constants/constants.js index 18a347a..344ef8f 100644 --- a/src/constants/constants.js +++ b/src/constants/constants.js @@ -13,6 +13,14 @@ export const SAVE_KEY_NAME = 'CYTOSCAPE_NODE_POSTITION'; export const JUST_CREATE_ACCOUNT_HOT_DURATION_MINS = 2; +export const INSIGHTS_FIELDS_AND_LABELS = [ + ['self_loops', 'Self-Loop'], + ['short_loops', 'Short-Loop'], + ['shortest_traces', 'Shortest Trace'], + ['longest_traces', 'Longest Trace'], + ['most_freq_traces', 'Most Frequent Trace'], + ]; + export const knownLayoutChartOption = { padding: { top: 16, diff --git a/src/stores/mapPathStore.ts b/src/stores/mapPathStore.ts new file mode 100644 index 0000000..f131d71 --- /dev/null +++ b/src/stores/mapPathStore.ts @@ -0,0 +1,34 @@ +import { defineStore } from 'pinia'; +import AllMapData from '@/stores/allMapData.js'; +import { INSIGHTS_FIELDS_AND_LABELS } from '@/constants/constants'; +import { elements } from 'chart.js'; + +export default defineStore('useMapPathStore', { + state: () => ({ + clickedPath: [], + allMapData: AllMapData(), + cytoscape: null, + }), + actions: { + setCytoscape(cytoscape) { + this.cytoscape = cytoscape; + }, + createAllPaths() { + const { insights } = this.allMapData; + for(let i = 0; i < INSIGHTS_FIELDS_AND_LABELS.length; i++) { + const curButton = insights[INSIGHTS_FIELDS_AND_LABELS[i][0]]; + for(let listIndex = 0; listIndex < curButton.length; listIndex++) { + for(let nodeIndex = 0; nodeIndex < curButton[listIndex].length; nodeIndex++){ + if(nodeIndex === 0) { + const startNodes = this.cytoscape.nodes().filter(function(elem) { + return elem.data('label').toLocaleLowerCase() === 'start'; + // highlight between start node and first node + }); + } + + } + } + } + }, + }, +}); \ No newline at end of file diff --git a/src/views/Discover/Map/Map.vue b/src/views/Discover/Map/Map.vue index 03cd436..8b51a04 100644 --- a/src/views/Discover/Map/Map.vue +++ b/src/views/Discover/Map/Map.vue @@ -53,7 +53,7 @@