diff --git a/src/components/Discover/Map/Filter/Funnel.vue b/src/components/Discover/Map/Filter/Funnel.vue index c98eb39..27b0c86 100644 --- a/src/components/Discover/Map/Filter/Funnel.vue +++ b/src/components/Discover/Map/Filter/Funnel.vue @@ -102,6 +102,9 @@ export default { await this.allMapDataStore.addTempFilterId(); await this.allMapDataStore.getAllMapData(); await this.allMapDataStore.getAllTrace(); // SidebarTrace 要連動 + if(this.temporaryData[0]?.type) { + this.allMapDataStore.traceId = await this.allMapDataStore.traces[0]?.id; + } await this.$emit('submit-all'); this.isLoading = false; this.$toast.success('Filter(s) applied.'); diff --git a/src/components/Discover/Map/Filter/Trace.vue b/src/components/Discover/Map/Filter/Trace.vue index 194cd8d..1ee93de 100644 --- a/src/components/Discover/Map/Filter/Trace.vue +++ b/src/components/Discover/Map/Filter/Trace.vue @@ -50,8 +50,8 @@
-
- +
+ @@ -72,10 +72,10 @@ export default { setup() { const allMapDataStore = AllMapDataStore(); const loadingStore = LoadingStore(); - const { traces, traceTaskSeq, cases } = storeToRefs(allMapDataStore); + const { infinit404, infiniteStart, traces, traceTaskSeq, cases } = storeToRefs(allMapDataStore); const { isLoading } = storeToRefs(loadingStore); - return {allMapDataStore, traces, traceTaskSeq, cases, isLoading} + return {allMapDataStore, infinit404, infiniteStart, traces, traceTaskSeq, cases, isLoading} }, data() { return { @@ -84,6 +84,8 @@ export default { edges:[], }, showTraceId: null, + infinitMaxItems: false, + infiniteData: [], chartOptions: null, selectArea: [0, 1] } @@ -136,7 +138,14 @@ export default { selectArea: function(newValue) { let roundValue = Math.round(newValue[1].toFixed()); if(newValue[1] !== roundValue) this.selectArea[1] = roundValue; - } + }, + infinite404: function(newValue) { + if(newValue === 404) this.infinitMaxItems = true; + }, + showTraceId: function(newValue, oldValue) { + let isScrollTop = document.querySelector('.infiniteTable'); + if(isScrollTop && typeof isScrollTop.scrollTop !== 'undefined') if(newValue !== oldValue) isScrollTop.scrollTop = 0; + }, }, methods: { /** @@ -210,9 +219,12 @@ export default { */ async switchCaseData(id, count) { if(count >= 1000) this.isLoading = true; + this.infinit404 = null; + this.infinitMaxItems = false; this.showTraceId = id; + this.infiniteStart = 0; this.allMapDataStore.traceId = id; - await this.allMapDataStore.getTraceDetail(); + this.infiniteData = await this.allMapDataStore.getTraceDetail(); this.createCy(); this.isLoading = false; }, @@ -265,6 +277,30 @@ export default { this.setEdgesData(); cytoscapeMapTrace(this.processMap.nodes, this.processMap.edges, graphId); }, + /** + * 無限滾動: 監聽 scroll 有沒有滾到底部 + * @param {element} event + */ + handleScroll(event) { + if(this.infinitMaxItems || this.cases.length < 20) return; + + const container = event.target; + const overScrollHeight = container.scrollTop + container.clientHeight >= container.scrollHeight; + + if(overScrollHeight) this.fetchData(); + }, + /** + * 無限滾動: 滾到底後,要載入數據 + */ + async fetchData() { + try { + this.infiniteStart += 20; + await this.allMapDataStore.getTraceDetail(); + this.infiniteData = [...this.infiniteData, ...this.cases]; + } catch(error) { + console.error('Failed to load data:', error); + } + } }, mounted() { this.setNodesData(); diff --git a/src/components/Discover/Map/SidebarFilter.vue b/src/components/Discover/Map/SidebarFilter.vue index cd62efe..9be9016 100644 --- a/src/components/Discover/Map/SidebarFilter.vue +++ b/src/components/Discover/Map/SidebarFilter.vue @@ -1,5 +1,5 @@