Issue #140:
This commit is contained in:
@@ -1,14 +1,6 @@
|
||||
import { defineStore } from "pinia";
|
||||
import loadingStore from './loading.js';
|
||||
import pinia from '@/stores/main.js'
|
||||
import {useToast} from 'vue-toast-notification';
|
||||
import 'vue-toast-notification/dist/theme-sugar.css';
|
||||
import moment from "moment";
|
||||
|
||||
const loading = loadingStore(pinia);
|
||||
const $toast = useToast();
|
||||
// Delay loading and toast 待模組化
|
||||
let delay = (s = 0) => new Promise((resolve, reject) => setTimeout(resolve, s));
|
||||
import apiError from '@/module/apiError.js';
|
||||
|
||||
export default defineStore('allMapDataStore', {
|
||||
state: () => ({
|
||||
@@ -29,7 +21,6 @@ export default defineStore('allMapDataStore', {
|
||||
allFilterEndToStart: [],
|
||||
allFilterTimeframe: {},
|
||||
allFilterTrace: [],
|
||||
httpStatus: 200,
|
||||
hasResultRule: null, // click Apply 後檢查是否有 Data
|
||||
temporaryData: [], // 沒被 apply all 的 Data
|
||||
postRuleData: [], // has-result API & temp-filters API 的 Data
|
||||
@@ -109,16 +100,8 @@ export default defineStore('allMapDataStore', {
|
||||
this.allBpmn = response.data.bpmn;
|
||||
this.allStats = response.data.stats;
|
||||
this.allInsights = response.data.insights;
|
||||
|
||||
// if(this.httpStatus < 300) loading.isLoading = false;
|
||||
} 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 Map.',{position: 'bottom'});
|
||||
apiError(error, 'Failed to load the Map.');
|
||||
};
|
||||
},
|
||||
/**
|
||||
@@ -139,15 +122,8 @@ export default defineStore('allMapDataStore', {
|
||||
const response = await this.$axios.get(api);
|
||||
this.allTrace = response.data;
|
||||
|
||||
// if(this.httpStatus < 300) loading.isLoading = false;
|
||||
} 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 Trace.',{position: 'bottom'});
|
||||
apiError(error, 'Failed to load the Trace.');
|
||||
}
|
||||
},
|
||||
/**
|
||||
@@ -177,19 +153,9 @@ export default defineStore('allMapDataStore', {
|
||||
return this.allCase;
|
||||
});
|
||||
return this.allCase;
|
||||
|
||||
// if(this.httpStatus < 300) loading.isLoading = false;
|
||||
} catch(error) {
|
||||
if(error.response.status === 404) this.infinite404 = 404;
|
||||
else {
|
||||
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 Trace Detail.',{position: 'bottom'});
|
||||
}
|
||||
apiError(error, 'Failed to load the Trace Detail.');
|
||||
};
|
||||
},
|
||||
/**
|
||||
@@ -206,16 +172,8 @@ export default defineStore('allMapDataStore', {
|
||||
this.allFilterEndToStart = response.data.sinks;
|
||||
this.allFilterTimeframe = response.data.timeframe;
|
||||
this.allFilterTrace = response.data.trace;
|
||||
|
||||
// if(this.httpStatus < 300) loading.isLoading = false;
|
||||
} 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 Filter Parameters.',{position: 'bottom'});
|
||||
apiError(error, 'Failed to load the Filter Parameters.');
|
||||
};
|
||||
},
|
||||
/**
|
||||
@@ -228,16 +186,8 @@ export default defineStore('allMapDataStore', {
|
||||
try {
|
||||
const response = await this.$axios.post(api, this.postRuleData)
|
||||
this.hasResultRule = response.data.result;
|
||||
|
||||
// if(this.httpStatus < 300) loading.isLoading = false;
|
||||
} 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 Has Result.',{position: 'bottom'});
|
||||
apiError(error, 'Failed to load the Has Result.');
|
||||
};
|
||||
},
|
||||
/**
|
||||
@@ -250,16 +200,8 @@ export default defineStore('allMapDataStore', {
|
||||
try {
|
||||
const response = await this.$axios.post(api, this.postRuleData)
|
||||
this.tempFilterId = response.data.id;
|
||||
|
||||
// if(this.httpStatus < 300) loading.isLoading = false;
|
||||
} 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 add the Temporary Filters.',{position: 'bottom'});
|
||||
apiError(error, 'Failed to add the Temporary Filters.');
|
||||
};
|
||||
},
|
||||
/**
|
||||
@@ -278,13 +220,7 @@ export default defineStore('allMapDataStore', {
|
||||
this.createFilterId = response.data.id;
|
||||
this.tempFilterId = null;
|
||||
}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'});
|
||||
apiError(error, 'Failed to load the Filters.');
|
||||
};
|
||||
},
|
||||
/**
|
||||
@@ -300,13 +236,7 @@ export default defineStore('allMapDataStore', {
|
||||
this.logId = response.data.log.id;
|
||||
this.filterName = response.data.name;
|
||||
}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 get Filter Detail.',{position: 'bottom'});
|
||||
apiError(error, 'Failed to get Filter Detail.');
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -322,13 +252,7 @@ export default defineStore('allMapDataStore', {
|
||||
const response = await this.$axios.put(api, data);
|
||||
this.isUpdataFilter = response.status === 200;
|
||||
}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 updata an Existing Filter.',{position: 'bottom'});
|
||||
apiError(error, 'Failed to updata an Existing Filter.');
|
||||
}
|
||||
},
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user