update dashboard list

This commit is contained in:
Qiuxia Fan 2022-03-15 00:05:27 +08:00
parent bcbb3456b2
commit 43dda1b32b
3 changed files with 25 additions and 23 deletions

View File

@ -20,7 +20,6 @@ export const AllLayout = {
name: "All Layout", name: "All Layout",
layer: "GENERAL", layer: "GENERAL",
entity: "All", entity: "All",
date: new Date().getTime(),
isRoot: true, isRoot: true,
children: [ children: [
{ {
@ -178,7 +177,6 @@ export const ServiceLayout = {
name: "Service Layout", name: "Service Layout",
layer: "GENERAL", layer: "GENERAL",
entity: "Service", entity: "Service",
date: new Date().getTime(),
isRoot: true, isRoot: true,
children: [ children: [
{ {
@ -565,7 +563,6 @@ export const EndpointLayout = {
name: "Endpoint Layout", name: "Endpoint Layout",
layer: "GENERAL", layer: "GENERAL",
entity: "Endpoint", entity: "Endpoint",
date: new Date().getTime(),
isRoot: true, isRoot: true,
children: [ children: [
{ {
@ -743,7 +740,6 @@ export const InstanceLayout = {
name: "Instance Layout", name: "Instance Layout",
layer: "GENERAL", layer: "GENERAL",
entity: "ServiceInstance", entity: "ServiceInstance",
date: new Date().getTime(),
isRoot: true, isRoot: true,
children: [ children: [
{ {
@ -896,7 +892,6 @@ export const ServiceRelationLayout = {
name: "Service Relation Layout", name: "Service Relation Layout",
layer: "GENERAL", layer: "GENERAL",
entity: "ServiceRelation", entity: "ServiceRelation",
date: new Date().getTime(),
isRoot: true, isRoot: true,
children: [ children: [
{ {
@ -974,7 +969,6 @@ export const InstanceRelationLayout = {
name: "Service Instance Relation Layout", name: "Service Instance Relation Layout",
layer: "GENERAL", layer: "GENERAL",
entity: "ServiceInstanceRelation", entity: "ServiceInstanceRelation",
date: new Date().getTime(),
isRoot: true, isRoot: true,
children: [ children: [
{ {
@ -1007,7 +1001,6 @@ export const EndpointRelationLayout = {
name: "Endpoint Relation Layout", name: "Endpoint Relation Layout",
layer: "GENERAL", layer: "GENERAL",
entity: "EndpointRelation", entity: "EndpointRelation",
date: new Date().getTime(),
isRoot: true, isRoot: true,
children: [ children: [
{ {

View File

@ -71,7 +71,7 @@ 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 = JSON.parse(c.configuration || "{}");
dashboardStore.setLayout(layout.children || []); dashboardStore.setLayout(layout.children || []);
} }
function handleClick(e: any) { function handleClick(e: any) {

View File

@ -43,13 +43,9 @@ limitations under the License. -->
<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" />
<el-table-column prop="entity" label="Entity" /> <el-table-column prop="entity" label="Entity" />
<el-table-column prop="date" label="Date" />
<el-table-column label="Operations"> <el-table-column label="Operations">
<template #default="scope"> <template #default="scope">
<el-button <el-button size="small" @click="handleEdit(scope.row)">
size="small"
@click="handleEdit(scope.$index, scope.row)"
>
{{ t("view") }} {{ t("view") }}
</el-button> </el-button>
<!-- <el-button <!-- <el-button
@ -58,13 +54,16 @@ limitations under the License. -->
> >
{{ t("edit") }} {{ t("edit") }}
</el-button> --> </el-button> -->
<el-button <el-popconfirm
size="small" title="Are you sure to delete this?"
type="danger" @confirm="handleDelete(scope.$index, scope.row)"
@click="handleDelete(scope.$index, scope.row)"
> >
{{ t("delete") }} <template #reference>
</el-button> <el-button size="small" type="danger">
{{ t("delete") }}
</el-button>
</template>
</el-popconfirm>
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
@ -78,6 +77,7 @@ import { ElTable, ElTableColumn, ElButton, ElInput } from "element-plus";
import { useAppStoreWithOut } from "@/store/modules/app"; import { useAppStoreWithOut } from "@/store/modules/app";
import { useDashboardStore } from "@/store/modules/dashboard"; import { useDashboardStore } from "@/store/modules/dashboard";
import { ElMessage } from "element-plus"; import { ElMessage } from "element-plus";
import router from "@/router";
const appStore = useAppStoreWithOut(); const appStore = useAppStoreWithOut();
const dashboardStore = useDashboardStore(); const dashboardStore = useDashboardStore();
@ -110,11 +110,20 @@ async function setList() {
} }
dashboards.value = JSON.parse(sessionStorage.getItem("dashboards") || ""); dashboards.value = JSON.parse(sessionStorage.getItem("dashboards") || "");
} }
const handleEdit = (index: number, row: any) => { const handleEdit = (row: { name: string; layer: string; entity: string }) => {
console.log(index, row); router.push(
`/dashboard/${row.layer}/${row.entity}/${row.name.split(" ").join("-")}`
);
}; };
const handleDelete = (index: number, row: any) => { const handleDelete = (
console.log(index, row); index: number,
row: { name: string; layer: string; entity: string }
) => {
dashboards.value.splice(index, 1);
sessionStorage.setItem("dashboards", JSON.stringify(dashboards.value));
sessionStorage.removeItem(
`${row.layer}_${row.entity}_${row.name.split(" ").join("-")}`
);
}; };
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>