store log กับ type
This commit is contained in:
parent
b4b64a1267
commit
3f225d2d58
2 changed files with 82 additions and 2 deletions
|
|
@ -11,4 +11,17 @@ interface ResRound {
|
||||||
startDate: Date;
|
startDate: Date;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type { ResRound };
|
interface ResLog {
|
||||||
|
endTimeStamp: Date;
|
||||||
|
endpoint: string;
|
||||||
|
host: string;
|
||||||
|
logType: string;
|
||||||
|
method: string;
|
||||||
|
processTime: number;
|
||||||
|
responseCode: number;
|
||||||
|
startTimeStamp: Date;
|
||||||
|
systemName: string;
|
||||||
|
tId: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export type { ResRound, ResLog };
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,72 @@
|
||||||
import { defineStore } from "pinia";
|
import { defineStore } from "pinia";
|
||||||
|
import http from "@/plugins/http";
|
||||||
|
import config from "@/app.config";
|
||||||
|
import { useQuasar } from "quasar";
|
||||||
|
|
||||||
|
import { useCounterMixin } from "@/stores/mixin";
|
||||||
|
|
||||||
|
import type { ResLog } from "@/modules/03_logs/interface/response/Main";
|
||||||
|
const $q = useQuasar();
|
||||||
|
import { ref } from "vue";
|
||||||
|
|
||||||
|
const mixin = useCounterMixin();
|
||||||
|
const {
|
||||||
|
dialogRemove,
|
||||||
|
messageError,
|
||||||
|
showLoader,
|
||||||
|
hideLoader,
|
||||||
|
success,
|
||||||
|
dialogConfirm,
|
||||||
|
} = mixin;
|
||||||
|
|
||||||
export const useDataStore = defineStore("storeData", () => {
|
export const useDataStore = defineStore("storeData", () => {
|
||||||
return {};
|
const size = ref<number>(30);
|
||||||
|
const logData = ref<ResLog[]>([]);
|
||||||
|
const systemName = ref<string>("");
|
||||||
|
const searchAfter = ref<number>();
|
||||||
|
async function fetchLog(
|
||||||
|
opts?: {
|
||||||
|
size?: number;
|
||||||
|
search?: string;
|
||||||
|
searchAfter?: number;
|
||||||
|
systemName?: string;
|
||||||
|
},
|
||||||
|
isBottom?: boolean
|
||||||
|
) {
|
||||||
|
const params = new URLSearchParams();
|
||||||
|
|
||||||
|
for (const [k, v] of Object.entries(opts || {})) {
|
||||||
|
v !== undefined && params.append(k, v.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
const query = params.toString();
|
||||||
|
showLoader();
|
||||||
|
await http
|
||||||
|
.get(config.API.log + `${(params && "?".concat(query)) || ""}`)
|
||||||
|
.then((res) => {
|
||||||
|
const data = res.data;
|
||||||
|
if (isBottom) {
|
||||||
|
const test = data.map((v: any) => v._source);
|
||||||
|
logData.value.push(...test);
|
||||||
|
} else {
|
||||||
|
logData.value = data.map((v: any) => v._source);
|
||||||
|
}
|
||||||
|
|
||||||
|
const lastDataSort = data[data.length - 1].sort;
|
||||||
|
if (lastDataSort) {
|
||||||
|
searchAfter.value = lastDataSort[0];
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.finally(() => {
|
||||||
|
hideLoader();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
size,
|
||||||
|
logData,
|
||||||
|
searchAfter,
|
||||||
|
systemName,
|
||||||
|
fetchLog,
|
||||||
|
};
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue