mirror of
https://github.com/apache/skywalking-booster-ui.git
synced 2025-07-16 18:45:23 +00:00
edit dashboard list
This commit is contained in:
parent
bdcaba8828
commit
3985856f97
@ -92,7 +92,6 @@ export const dashboardStore = defineStore({
|
|||||||
entity: string;
|
entity: string;
|
||||||
id: string;
|
id: string;
|
||||||
}) {
|
}) {
|
||||||
console.log(item);
|
|
||||||
this.currentDashboard = item;
|
this.currentDashboard = item;
|
||||||
},
|
},
|
||||||
addControl(type: string) {
|
addControl(type: string) {
|
||||||
@ -343,7 +342,10 @@ export const dashboardStore = defineStore({
|
|||||||
name: c.name,
|
name: c.name,
|
||||||
isRoot: c.isRoot,
|
isRoot: c.isRoot,
|
||||||
});
|
});
|
||||||
sessionStorage.setItem(key, JSON.stringify(t));
|
sessionStorage.setItem(
|
||||||
|
key,
|
||||||
|
JSON.stringify({ id: t.id, configuration: c })
|
||||||
|
);
|
||||||
}
|
}
|
||||||
sessionStorage.setItem("dashboards", JSON.stringify(list));
|
sessionStorage.setItem("dashboards", JSON.stringify(list));
|
||||||
return res.data;
|
return res.data;
|
||||||
|
@ -204,7 +204,8 @@ watch(
|
|||||||
padding: 15px;
|
padding: 15px;
|
||||||
background-color: #fff;
|
background-color: #fff;
|
||||||
margin: 30px 10px;
|
margin: 30px 10px;
|
||||||
border-radius: 3px;
|
box-shadow: 0px 1px 4px 0px #00000029;
|
||||||
|
border-radius: 5px;
|
||||||
max-height: 100%;
|
max-height: 100%;
|
||||||
overflow: auto;
|
overflow: auto;
|
||||||
}
|
}
|
||||||
|
@ -54,7 +54,6 @@ const { t } = useI18n();
|
|||||||
const p = useRoute().params;
|
const p = useRoute().params;
|
||||||
const layoutKey = `${p.layerId}_${p.entity}_${p.name}`;
|
const layoutKey = `${p.layerId}_${p.entity}_${p.name}`;
|
||||||
|
|
||||||
appStore.setPageTitle("Dashboard Name");
|
|
||||||
setTemplate();
|
setTemplate();
|
||||||
|
|
||||||
async function setTemplate() {
|
async function setTemplate() {
|
||||||
@ -62,9 +61,10 @@ async function setTemplate() {
|
|||||||
const c: { configuration: string; id: string } = JSON.parse(
|
const c: { configuration: string; id: string } = JSON.parse(
|
||||||
sessionStorage.getItem(layoutKey) || "{}"
|
sessionStorage.getItem(layoutKey) || "{}"
|
||||||
);
|
);
|
||||||
const layout = JSON.parse(c.configuration || "{}");
|
const layout: any = c.configuration || {};
|
||||||
|
|
||||||
dashboardStore.setLayout(layout.children || []);
|
dashboardStore.setLayout(layout.children || []);
|
||||||
|
appStore.setPageTitle(layout.name);
|
||||||
}
|
}
|
||||||
function handleClick(e: any) {
|
function handleClick(e: any) {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
|
@ -43,8 +43,9 @@ limitations under the License. -->
|
|||||||
v-loading="loading"
|
v-loading="loading"
|
||||||
>
|
>
|
||||||
<el-table-column fixed prop="name" label="Name" />
|
<el-table-column fixed prop="name" label="Name" />
|
||||||
<el-table-column prop="layer" label="Layer" />
|
<el-table-column prop="layer" label="Layer" width="200" />
|
||||||
<el-table-column prop="entity" label="Entity" />
|
<el-table-column prop="entity" label="Entity" width="200" />
|
||||||
|
<el-table-column prop="isRoot" label="Root" width="100" />
|
||||||
<el-table-column label="Operations">
|
<el-table-column label="Operations">
|
||||||
<template #default="scope">
|
<template #default="scope">
|
||||||
<el-button size="small" @click="handleView(scope.row)">
|
<el-button size="small" @click="handleView(scope.row)">
|
||||||
@ -59,7 +60,7 @@ limitations under the License. -->
|
|||||||
>
|
>
|
||||||
<template #reference>
|
<template #reference>
|
||||||
<el-button size="small">
|
<el-button size="small">
|
||||||
{{ scope.row.isRoot ? t("setRoot") : t("setNormal") }}
|
{{ scope.row.isRoot ? t("setNormal") : t("setRoot") }}
|
||||||
</el-button>
|
</el-button>
|
||||||
</template>
|
</template>
|
||||||
</el-popconfirm>
|
</el-popconfirm>
|
||||||
@ -113,11 +114,16 @@ async function setList() {
|
|||||||
await dashboardStore.setDashboards();
|
await dashboardStore.setDashboards();
|
||||||
dashboards.value = dashboardStore.dashboards;
|
dashboards.value = dashboardStore.dashboards;
|
||||||
}
|
}
|
||||||
const handleView = (index: number) => {
|
const handleView = (row: {
|
||||||
const d = dashboards.value[index];
|
entity: string;
|
||||||
dashboardStore.setCurrentDashboard(d);
|
layer: string;
|
||||||
|
name: string;
|
||||||
|
id: string;
|
||||||
|
isRoot: boolean;
|
||||||
|
}) => {
|
||||||
|
dashboardStore.setCurrentDashboard(row);
|
||||||
router.push(
|
router.push(
|
||||||
`/dashboard/${d.layer}/${d.entity}/${d.name.split(" ").join("-")}`
|
`/dashboard/${row.layer}/${row.entity}/${row.name.split(" ").join("-")}`
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
async function setRoot(row: {
|
async function setRoot(row: {
|
||||||
@ -127,7 +133,9 @@ async function setRoot(row: {
|
|||||||
id: string;
|
id: string;
|
||||||
isRoot: boolean;
|
isRoot: boolean;
|
||||||
}) {
|
}) {
|
||||||
const items = dashboardStore.dashboards.map(async (d: any) => {
|
const items: any[] = [];
|
||||||
|
loading.value = true;
|
||||||
|
for (const d of dashboardStore.dashboards) {
|
||||||
if (d.id === row.id) {
|
if (d.id === row.id) {
|
||||||
d.isRoot = !row.isRoot;
|
d.isRoot = !row.isRoot;
|
||||||
const key = [d.layer, d.entity, d.name.split(" ").join("-")].join("_");
|
const key = [d.layer, d.entity, d.name.split(" ").join("-")].join("_");
|
||||||
@ -136,16 +144,22 @@ async function setRoot(row: {
|
|||||||
...JSON.parse(layout).configuration,
|
...JSON.parse(layout).configuration,
|
||||||
...d,
|
...d,
|
||||||
};
|
};
|
||||||
|
delete c.id;
|
||||||
|
|
||||||
const setting = {
|
const setting = {
|
||||||
id: d.id,
|
id: d.id,
|
||||||
configuration: JSON.stringify(c),
|
configuration: JSON.stringify(c),
|
||||||
};
|
};
|
||||||
const res = await dashboardStore.updateDashboard(setting);
|
const res = await dashboardStore.updateDashboard(setting);
|
||||||
if (!res.data.changeTemplate.id) {
|
if (res.data.changeTemplate.id) {
|
||||||
return d;
|
sessionStorage.setItem(
|
||||||
|
key,
|
||||||
|
JSON.stringify({
|
||||||
|
id: d.id,
|
||||||
|
configuration: c,
|
||||||
|
})
|
||||||
|
);
|
||||||
}
|
}
|
||||||
sessionStorage.setItem(key, JSON.stringify(setting));
|
|
||||||
return d;
|
|
||||||
}
|
}
|
||||||
if (
|
if (
|
||||||
d.layer === row.layer &&
|
d.layer === row.layer &&
|
||||||
@ -165,16 +179,21 @@ async function setRoot(row: {
|
|||||||
configuration: JSON.stringify(c),
|
configuration: JSON.stringify(c),
|
||||||
};
|
};
|
||||||
const res = await dashboardStore.updateDashboard(setting);
|
const res = await dashboardStore.updateDashboard(setting);
|
||||||
if (!res.data.changeTemplate.id) {
|
if (res.data.changeTemplate.id) {
|
||||||
return d;
|
sessionStorage.setItem(
|
||||||
|
key,
|
||||||
|
JSON.stringify({
|
||||||
|
id: d.id,
|
||||||
|
configuration: c,
|
||||||
|
})
|
||||||
|
);
|
||||||
}
|
}
|
||||||
sessionStorage.setItem(key, JSON.stringify(setting));
|
|
||||||
return d;
|
|
||||||
}
|
}
|
||||||
return d;
|
items.push(d);
|
||||||
});
|
}
|
||||||
dashboardStore.resetDashboards(items);
|
dashboardStore.resetDashboards(items);
|
||||||
searchDashboards();
|
searchDashboards();
|
||||||
|
loading.value = false;
|
||||||
}
|
}
|
||||||
function handleEdit(row: {
|
function handleEdit(row: {
|
||||||
entity: string;
|
entity: string;
|
||||||
@ -208,11 +227,14 @@ async function updateName(
|
|||||||
...d,
|
...d,
|
||||||
name: value,
|
name: value,
|
||||||
};
|
};
|
||||||
|
delete c.id;
|
||||||
const setting = {
|
const setting = {
|
||||||
id: d.id,
|
id: d.id,
|
||||||
configuration: JSON.stringify(c),
|
configuration: JSON.stringify(c),
|
||||||
};
|
};
|
||||||
|
loading.value = true;
|
||||||
const res = await dashboardStore.updateDashboard(setting);
|
const res = await dashboardStore.updateDashboard(setting);
|
||||||
|
loading.value = false;
|
||||||
if (!res.data.changeTemplate.id) {
|
if (!res.data.changeTemplate.id) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -234,7 +256,13 @@ async function updateName(
|
|||||||
dashboardStore.currentDashboard.entity,
|
dashboardStore.currentDashboard.entity,
|
||||||
dashboardStore.currentDashboard.name.split(" ").join("-"),
|
dashboardStore.currentDashboard.name.split(" ").join("-"),
|
||||||
].join("_");
|
].join("_");
|
||||||
sessionStorage.setItem(str, JSON.stringify(setting));
|
sessionStorage.setItem(
|
||||||
|
str,
|
||||||
|
JSON.stringify({
|
||||||
|
id: d.id,
|
||||||
|
configuration: c,
|
||||||
|
})
|
||||||
|
);
|
||||||
searchText.value = "";
|
searchText.value = "";
|
||||||
}
|
}
|
||||||
async function handleDelete(row: {
|
async function handleDelete(row: {
|
||||||
@ -277,6 +305,7 @@ function searchDashboards() {
|
|||||||
.table {
|
.table {
|
||||||
padding: 20px;
|
padding: 20px;
|
||||||
background-color: #fff;
|
background-color: #fff;
|
||||||
border-radius: 3px;
|
box-shadow: 0px 1px 4px 0px #00000029;
|
||||||
|
border-radius: 5px;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
Loading…
Reference in New Issue
Block a user