add widgets

This commit is contained in:
Qiuxia Fan 2022-03-28 20:01:30 +08:00
parent 0a29a86c34
commit 1a78ae6566
2 changed files with 12 additions and 4 deletions

View File

@ -29,7 +29,7 @@ const msg = {
events: "Events", events: "Events",
alerts: "Alerts", alerts: "Alerts",
settings: "Settings", settings: "Settings",
dashboards: "Dashboard", dashboards: "Dashboards",
profiles: "Profiles", profiles: "Profiles",
database: "Database", database: "Database",
serviceName: "Service Name", serviceName: "Service Name",
@ -149,7 +149,7 @@ const msg = {
dashboard: "Dashboard", dashboard: "Dashboard",
topology: "Topology", topology: "Topology",
trace: "Trace", trace: "Trace",
alarm: "Alarm", alarm: "Alarms",
event: "Event", event: "Event",
auto: "Auto", auto: "Auto",
reload: "Reload", reload: "Reload",

View File

@ -77,9 +77,13 @@ export const dashboardStore = defineStore({
}, },
addControl(type: string) { addControl(type: string) {
const arr = this.layout.map((d: any) => Number(d.i)); const arr = this.layout.map((d: any) => Number(d.i));
let index = String(Math.max(...arr) + 1);
if (!this.layout.length) {
index = "0";
}
const newItem: LayoutConfig = { const newItem: LayoutConfig = {
...NewControl, ...NewControl,
i: String(Math.max(...arr) + 1), i: index,
type, type,
metricTypes: [""], metricTypes: [""],
metrics: [""], metrics: [""],
@ -148,9 +152,13 @@ export const dashboardStore = defineStore({
const tabIndex = this.layout[idx].activedTabIndex || 0; const tabIndex = this.layout[idx].activedTabIndex || 0;
const { children } = this.layout[idx].children[tabIndex]; const { children } = this.layout[idx].children[tabIndex];
const arr = children.map((d: any) => Number(d.i)); const arr = children.map((d: any) => Number(d.i));
let index = String(Math.max(...arr) + 1);
if (!children.length) {
index = "0";
}
const newItem: LayoutConfig = { const newItem: LayoutConfig = {
...NewControl, ...NewControl,
i: String(Math.max(...arr) + 1), i: index,
type, type,
metricTypes: [""], metricTypes: [""],
metrics: [""], metrics: [""],