feat: switch dashboard with entity

This commit is contained in:
Qiuxia Fan
2022-01-24 16:06:27 +08:00
parent 8a2eeae315
commit 21fb053bda
8 changed files with 141 additions and 52 deletions

View File

@@ -35,15 +35,65 @@ export const ConfigData: any = {
w: 8,
h: 12,
i: "0",
metrics: ["service_resp_time", "service_apdex"],
metricTypes: ["readMetricsValues", "readMetricsValues"],
metrics: ["service_resp_time"],
metricTypes: ["readMetricsValues"],
type: "Widget",
widget: {
title: "Title",
title: "service_resp_time",
tips: "Tooltip",
},
graph: {
type: "Line",
showXAxis: true,
showYAxis: true,
},
standard: {
sortOrder: "DEC",
unit: "min",
},
children: [],
};
export const ConfigData1: any = {
x: 0,
y: 0,
w: 8,
h: 12,
i: "0",
metrics: ["service_instance_resp_time"],
metricTypes: ["readMetricsValues"],
type: "Widget",
widget: {
title: "service_instance_resp_time",
tips: "Tooltip",
},
graph: {
type: "Line",
showXAxis: true,
showYAxis: true,
},
standard: {
sortOrder: "DEC",
unit: "min",
},
children: [],
};
export const ConfigData2: any = {
x: 0,
y: 0,
w: 8,
h: 12,
i: "0",
metrics: ["endpoint_avg"],
metricTypes: ["readMetricsValues"],
type: "Widget",
widget: {
title: "endpoint_avg",
tips: "Tooltip",
},
graph: {
type: "Line",
showXAxis: true,
showYAxis: true,
},
standard: {
sortOrder: "DEC",

View File

@@ -18,7 +18,7 @@ import { defineStore } from "pinia";
import { store } from "@/store";
import { LayoutConfig } from "@/types/dashboard";
import graph from "@/graph";
import { ConfigData } from "../data";
import { ConfigData, ConfigData1, ConfigData2 } from "../data";
import { useAppStoreWithOut } from "@/store/modules/app";
import { useSelectorStore } from "@/store/modules/selectors";
import { NewControl } from "../data";
@@ -144,6 +144,12 @@ export const dashboardStore = defineStore({
},
setEntity(type: string) {
this.entity = type;
if (type === "ServiceInstance") {
this.layout = [ConfigData1];
}
if (type === "Endpoint") {
this.layout = [ConfigData2];
}
},
setConfigs(param: { [key: string]: unknown }) {
const actived = this.activedGridItem.split("-");