feat: update

This commit is contained in:
Fine 2024-01-03 18:11:31 +08:00
parent cba01c0b60
commit 1bfa30a54a

View File

@ -75,12 +75,17 @@ limitations under the License. -->
</el-table-column> </el-table-column>
<el-table-column prop="topLevel" label="Top Level" width="80"> <el-table-column prop="topLevel" label="Top Level" width="80">
<template #default="scope"> <template #default="scope">
<el-switch <el-popconfirm
v-model="scope.row.topLevel" :title="t('rootTitle')"
@change="handleTopLevel(scope.row)" @confirm="handleTopLevel(scope.row)"
size="small"
v-if="[EntityType[0].value].includes(scope.row.entity)" v-if="[EntityType[0].value].includes(scope.row.entity)"
/> >
<template #reference>
<el-button size="small" style="width: 50px">
{{ scope.row.topLevel ? "Disable" : "Enable" }}
</el-button>
</template>
</el-popconfirm>
<span v-else> -- </span> <span v-else> -- </span>
</template> </template>
</el-table-column> </el-table-column>
@ -184,7 +189,7 @@ limitations under the License. -->
} }
loading.value = true; loading.value = true;
for (const item of arr) { for (const item of arr) {
const { layer, name, entity, isRoot, children } = item.configuration; const { layer, name, entity, isRoot, children, topLevel } = item.configuration;
const index = dashboardStore.dashboards.findIndex((d: DashboardItem) => d.id === item.id); const index = dashboardStore.dashboards.findIndex((d: DashboardItem) => d.id === item.id);
const p: DashboardItem = { const p: DashboardItem = {
name: name.split(" ").join("-"), name: name.split(" ").join("-"),
@ -196,6 +201,7 @@ limitations under the License. -->
if (index > -1) { if (index > -1) {
p.id = item.id; p.id = item.id;
p.isRoot = isRoot; p.isRoot = isRoot;
p.topLevel = topLevel;
} }
dashboardStore.setCurrentDashboard(p); dashboardStore.setCurrentDashboard(p);
dashboardStore.setLayout(children); dashboardStore.setLayout(children);
@ -338,7 +344,7 @@ limitations under the License. -->
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.status) {
sessionStorage.setItem( sessionStorage.setItem(
key, key,
JSON.stringify({ JSON.stringify({
@ -366,7 +372,7 @@ limitations under the License. -->
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.status) {
sessionStorage.setItem( sessionStorage.setItem(
key, key,
JSON.stringify({ JSON.stringify({
@ -388,7 +394,7 @@ limitations under the License. -->
loading.value = true; loading.value = true;
for (const d of dashboardStore.dashboards) { for (const d of dashboardStore.dashboards) {
if (d.id === row.id) { if (d.id === row.id) {
d.isRoot = row.topLevel; d.topLevel = !row.topLevel;
const key = [d.layer, d.entity, d.name].join("_"); const key = [d.layer, d.entity, d.name].join("_");
const layout = sessionStorage.getItem(key) || "{}"; const layout = sessionStorage.getItem(key) || "{}";
const c = { const c = {
@ -396,13 +402,13 @@ limitations under the License. -->
...d, ...d,
}; };
delete c.id; 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.status) {
sessionStorage.setItem( sessionStorage.setItem(
key, key,
JSON.stringify({ JSON.stringify({
@ -412,12 +418,7 @@ limitations under the License. -->
); );
} }
} else { } else {
if ( if (d.layer === row.layer && [EntityType[0].value].includes(d.entity) && !row.topLevel && d.topLevel) {
d.layer === row.layer &&
[EntityType[0].value].includes(d.entity) &&
row.topLevel === false &&
d.topLevel === true
) {
d.topLevel = false; d.topLevel = false;
const key = [d.layer, d.entity, d.name].join("_"); const key = [d.layer, d.entity, d.name].join("_");
const layout = sessionStorage.getItem(key) || "{}"; const layout = sessionStorage.getItem(key) || "{}";
@ -430,7 +431,7 @@ limitations under the License. -->
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.status) {
sessionStorage.setItem( sessionStorage.setItem(
key, key,
JSON.stringify({ JSON.stringify({