Discover: add Filter Funnel.

This commit is contained in:
chiayin
2023-04-28 19:57:26 +08:00
parent bf63d0aca4
commit 378d6ea550
6 changed files with 44 additions and 12 deletions

View File

@@ -40,6 +40,7 @@ import LoadingStore from '@/stores/loading.js';
import AllMapDataStore from '@/stores/allMapData.js'; import AllMapDataStore from '@/stores/allMapData.js';
export default { export default {
props:['setRule'],
setup() { setup() {
const loadingStore = LoadingStore(); const loadingStore = LoadingStore();
const allMapDataStore = AllMapDataStore(); const allMapDataStore = AllMapDataStore();

View File

@@ -86,7 +86,7 @@
</div> </div>
</div> </div>
<!-- header: funnel --> <!-- header: funnel -->
<Funnel v-if="tab === 'funnel'" @submit-all="sumbitAll"></Funnel> <Funnel v-if="tab === 'funnel'" @submit-all="sumbitAll" :setRule="setRule"></Funnel>
</Sidebar> </Sidebar>
</template> </template>

View File

@@ -30,10 +30,11 @@ export default defineStore('allMapDataStore', {
allFilterTrace: [], allFilterTrace: [],
httpStatus: 200, httpStatus: 200,
hasResultRule: null, // click Apply 後檢查是否有 Data hasResultRule: null, // click Apply 後檢查是否有 Data
temporaryData: [], // 沒被 apply 的 Data temporaryData: [], // 沒被 apply all 的 Data
postRuleData: [], // has-result API & temp-filters API 的 Data postRuleData: [], // has-result API & temp-filters API 的 Data
ruleData: [], // Funnle view's data ruleData: [], // Funnle view's data
isRuleData: [], // toggle button data isRuleData: [], // toggle button data
allFunnelData: [],
}), }),
getters: { getters: {
processMap: state => { processMap: state => {
@@ -75,6 +76,9 @@ export default defineStore('allMapDataStore', {
filterTrace: state => { filterTrace: state => {
return state.allFilterTrace; return state.allFilterTrace;
}, },
allFunnels: state => {
return state.allFunnelData;
},
}, },
actions: { actions: {
/** /**
@@ -83,12 +87,12 @@ export default defineStore('allMapDataStore', {
async getAllMapData() { async getAllMapData() {
let logId = this.logId; let logId = this.logId;
let tempFilterId = this.tempFilterId; let tempFilterId = this.tempFilterId;
let filterId = this.createFilterId let createfilterId = this.createFilterId
let api = ''; let api = '';
// 先判斷暫存 再判斷 filter 最後 log // 先判斷暫存 再判斷 filter 最後 log
if(tempFilterId != null) api = `/api/temp-filters/${tempFilterId}/discover`; if(tempFilterId != null) api = `/api/temp-filters/${tempFilterId}/discover`;
else if(filterId!= null) api = `/api/filters/${filterId}/discover`; else if(createfilterId!= null) api = `/api/filters/${createfilterId}/discover`;
else api = `/api/logs/${logId}/discover`; else api = `/api/logs/${logId}/discover`;
try { try {
@@ -233,10 +237,9 @@ export default defineStore('allMapDataStore', {
}; };
try { try {
const response = await this.$axios.post(api, createFilterObj) const response = await this.$axios.post(api, createFilterObj);
this.createFilterId = response.data.id; this.createFilterId = response.data.id;
this.tempFilterId = null; this.tempFilterId = null;
console.log('this.createFilterId', this.createFilterId);
}catch(error) { }catch(error) {
this.httpStatus = error.request.status; this.httpStatus = error.request.status;
await delay(); await delay();
@@ -246,6 +249,27 @@ export default defineStore('allMapDataStore', {
await delay(500); await delay(500);
$toast.default('Failed to load the Filters.',{position: 'bottom'}); $toast.default('Failed to load the Filters.',{position: 'bottom'});
}; };
} },
/**
* Fetch event logs api
*/
async fetchFunnel(createfilterId) {
const api = `/api/filters/${createfilterId}`;
if(createfilterId){
try {
const response = await this.$axios.get(api);
this.temporaryData = response.data.rules;
}catch(error) {
this.httpStatus = error.request.status;
await delay();
loading.isLoading = true;
await delay(1000);
loading.isLoading = false;
await delay(500);
$toast.default('Failed to load the Filters.',{position: 'bottom'});
}
}
},
}, },
}) })

View File

@@ -49,7 +49,7 @@
<SidebarState v-model:visible="sidebarState" :insights="insights" :stats="stats"></SidebarState> <SidebarState v-model:visible="sidebarState" :insights="insights" :stats="stats"></SidebarState>
<SidebarTraces v-model:visible="sidebarTraces" :traces="traces" :cases="cases" :traceTaskSeq="traceTaskSeq" @switch-Trace-Id="switchTraceId" ref="tracesView"></SidebarTraces> <SidebarTraces v-model:visible="sidebarTraces" :traces="traces" :cases="cases" :traceTaskSeq="traceTaskSeq" @switch-Trace-Id="switchTraceId" ref="tracesView"></SidebarTraces>
<SidebarFilter v-model:visible="sidebarFilter" :filterTasks="filterTasks" :filterStartToEnd="filterStartToEnd" :filterEndToStart="filterEndToStart" :filterTimeframe="filterTimeframe" :filterTrace="filterTrace" <SidebarFilter v-model:visible="sidebarFilter" :filterTasks="filterTasks" :filterStartToEnd="filterStartToEnd" :filterEndToStart="filterEndToStart" :filterTimeframe="filterTimeframe" :filterTrace="filterTrace"
@submit-all="createCy(mapType)"></SidebarFilter> @submit-all="createCy(mapType)" ref="sidevarFilterRef"></SidebarFilter>
</template> </template>
@@ -68,9 +68,9 @@ export default {
const loadingStore = LoadingStore(); const loadingStore = LoadingStore();
const allMapDataStore = AllMapDataStore(); const allMapDataStore = AllMapDataStore();
const { isLoading } = storeToRefs(loadingStore); const { isLoading } = storeToRefs(loadingStore);
const { processMap, bpmn, stats, insights, traces, traceTaskSeq, cases, filterTasks, filterStartToEnd, filterEndToStart, filterTimeframe, filterTrace, } = storeToRefs(allMapDataStore); const { processMap, bpmn, stats, insights, traces, traceTaskSeq, cases, filterTasks, filterStartToEnd, filterEndToStart, filterTimeframe, filterTrace, temporaryData, isRuleData, ruleData, createFilterId } = storeToRefs(allMapDataStore);
return { isLoading, processMap, bpmn, stats, insights, traces, traceTaskSeq, cases, filterTasks, filterStartToEnd, filterEndToStart, filterTimeframe, filterTrace, allMapDataStore} return { isLoading, processMap, bpmn, stats, insights, traces, traceTaskSeq, cases, filterTasks, filterStartToEnd, filterEndToStart, filterTimeframe, filterTrace, createFilterId, temporaryData, isRuleData, ruleData, allMapDataStore}
}, },
components: { components: {
SidebarView, SidebarView,
@@ -300,6 +300,10 @@ export default {
await this.allMapDataStore.getTraceDetail(); await this.allMapDataStore.getTraceDetail();
this.createCy(this.mapType); this.createCy(this.mapType);
await this.allMapDataStore.getFilterParams(); await this.allMapDataStore.getFilterParams();
await this.allMapDataStore.fetchFunnel(this.createFilterId)
this.isRuleData = await Array.from(this.temporaryData);
this.ruleData = await this.isRuleData.map(e => this.$refs.sidevarFilterRef.setRule(e));
this.isLoading = true; this.isLoading = true;
await new Promise(resolve => setTimeout(resolve, 1000)); await new Promise(resolve => setTimeout(resolve, 1000));
this.isLoading = false; this.isLoading = false;

View File

@@ -133,7 +133,10 @@
*/ */
enterDiscover(file){ enterDiscover(file){
let logId; let logId;
if(file.fileType === 'Log') logId = file.id; if(file.fileType === 'Log'){
logId = file.id;
this.createFilterId = null;
}
else if(file.fileType === 'Filter') { else if(file.fileType === 'Filter') {
this.createFilterId = file.id; this.createFilterId = file.id;
logId = file.log.id; logId = file.log.id;

View File

@@ -27,7 +27,7 @@ export default {
const loadingStore = LoadingStore(); const loadingStore = LoadingStore();
const allMapDataStore = AllMapDataStore(); const allMapDataStore = AllMapDataStore();
const { checkLogin } = loginStore; const { checkLogin } = loginStore;
const { tempFilterId, createFilterId, temporaryData, postRuleData } = storeToRefs(allMapDataStore); const { tempFilterId, createFilterId, temporaryData, postRuleData } = storeToRefs(allMapDataStore);
return { checkLogin, loadingStore, temporaryData, tempFilterId, createFilterId, postRuleData, allMapDataStore }; return { checkLogin, loadingStore, temporaryData, tempFilterId, createFilterId, postRuleData, allMapDataStore };
}, },