fix: update components, save templates (#35)

This commit is contained in:
Fine0830
2022-03-23 19:06:20 +08:00
committed by GitHub
parent 93161b6ec9
commit 33365f2a14
11 changed files with 114 additions and 57 deletions

View File

@@ -293,7 +293,7 @@ export const dashboardStore = defineStore({
return res.data;
}
const data = res.data.data.getAllTemplates;
const list = [];
let list = [];
for (const t of data) {
const c = JSON.parse(t.configuration);
const key = [c.layer, c.entity, c.name].join("_");
@@ -310,6 +310,17 @@ export const dashboardStore = defineStore({
JSON.stringify({ id: t.id, configuration: c })
);
}
list = list.sort((a, b) => {
const nameA = a.name.toUpperCase();
const nameB = b.name.toUpperCase();
if (nameA < nameB) {
return -1;
}
if (nameA > nameB) {
return 1;
}
return 0;
});
sessionStorage.setItem("dashboards", JSON.stringify(list));
return res.data;
},

View File

@@ -101,6 +101,7 @@ export const selectorStore = defineStore({
keyword?: string;
serviceId?: string;
isRelation?: boolean;
limit?: number;
}): Promise<Nullable<AxiosResponse>> {
if (!params) {
params = {};
@@ -113,6 +114,7 @@ export const selectorStore = defineStore({
serviceId,
duration: this.durationTime,
keyword: params.keyword || "",
limit: params.limit,
});
if (!res.data.errors) {
if (params.isRelation) {