update selector for events (#26)

This commit is contained in:
Fine0830 2022-03-10 11:41:20 +08:00 committed by GitHub
parent 0f667d967e
commit 24f07cfdb1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 8 deletions

View File

@ -38,7 +38,7 @@ export const eventStore = defineStore({
loading: false,
events: [],
total: 0,
services: [{ value: "", label: "" }],
services: [{ value: "", label: "All" }],
instances: [{ value: "", label: "All" }],
endpoints: [{ value: "", label: "All" }],
condition: {
@ -51,6 +51,10 @@ export const eventStore = defineStore({
this.condition = { ...this.condition, ...data };
},
async getServices(layer: string) {
if (!layer) {
this.services = [{ value: "", label: "All" }];
return new Promise((resolve) => resolve([]));
}
const res: AxiosResponse = await graphql.query("queryServices").params({
layer,
});

View File

@ -124,9 +124,6 @@ getSelectors();
async function getSelectors() {
await getLayers();
if (!state.currentLayer) {
return;
}
getServices();
}
@ -169,10 +166,13 @@ async function getLayers() {
ElMessage.error(resp.errors);
return;
}
state.currentLayer = resp.data.layers[0] || "";
state.layers = resp.data.layers.map((d: string) => {
state.currentLayer = "";
state.layers = [
{ label: "All", value: "" },
...resp.data.layers.map((d: string) => {
return { label: d, value: d };
});
}),
];
}
async function queryEvents() {