diff --git a/src/locales/lang/en.ts b/src/locales/lang/en.ts index 4bc27589..609c05ea 100644 --- a/src/locales/lang/en.ts +++ b/src/locales/lang/en.ts @@ -29,7 +29,7 @@ const msg = { events: "Events", alerts: "Alerts", settings: "Settings", - dashboards: "Dashboard", + dashboards: "Dashboards", profiles: "Profiles", database: "Database", serviceName: "Service Name", @@ -149,7 +149,7 @@ const msg = { dashboard: "Dashboard", topology: "Topology", trace: "Trace", - alarm: "Alarm", + alarm: "Alarms", event: "Event", auto: "Auto", reload: "Reload", diff --git a/src/store/modules/dashboard.ts b/src/store/modules/dashboard.ts index a0f0147c..c498adaf 100644 --- a/src/store/modules/dashboard.ts +++ b/src/store/modules/dashboard.ts @@ -77,9 +77,13 @@ export const dashboardStore = defineStore({ }, addControl(type: string) { 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 = { ...NewControl, - i: String(Math.max(...arr) + 1), + i: index, type, metricTypes: [""], metrics: [""], @@ -148,9 +152,13 @@ export const dashboardStore = defineStore({ const tabIndex = this.layout[idx].activedTabIndex || 0; const { children } = this.layout[idx].children[tabIndex]; const arr = children.map((d: any) => Number(d.i)); + let index = String(Math.max(...arr) + 1); + if (!children.length) { + index = "0"; + } const newItem: LayoutConfig = { ...NewControl, - i: String(Math.max(...arr) + 1), + i: index, type, metricTypes: [""], metrics: [""],