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

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