feat: Performance API done.
This commit is contained in:
39
src/stores/performance.js
Normal file
39
src/stores/performance.js
Normal file
@@ -0,0 +1,39 @@
|
||||
import { defineStore } from "pinia";
|
||||
// import moment from "moment";
|
||||
// import { Decimal } from 'decimal.js';
|
||||
// import abbreviateNumber from '@/module/abbreviateNumber.js';
|
||||
import apiError from '@/module/apiError.js';
|
||||
|
||||
export default defineStore('performanceStore', {
|
||||
state: () => ({
|
||||
allPerformanceData: null,
|
||||
}),
|
||||
getters: {
|
||||
performanceData: state => {
|
||||
return state.allPerformanceData;
|
||||
},
|
||||
},
|
||||
actions: {
|
||||
/**
|
||||
* Get Performance
|
||||
*/
|
||||
async getPerformance(type, id) {
|
||||
let api = '';
|
||||
|
||||
switch (type) {
|
||||
case 'log':
|
||||
api = `/api/logs/${id}/performance`;
|
||||
break;
|
||||
case 'filter':
|
||||
api = `/api/filters/${id}/performance`;
|
||||
break;
|
||||
}
|
||||
try {
|
||||
const response = await this.$axios.get(api);
|
||||
this.allPerformanceData = response.data;
|
||||
} catch(error) {
|
||||
apiError(error, 'Failed to load the Performance.');
|
||||
}
|
||||
}
|
||||
},
|
||||
})
|
||||
Reference in New Issue
Block a user