diff --git a/src/store/modules/dashboard.ts b/src/store/modules/dashboard.ts index 8fa03d5e..d00a43e3 100644 --- a/src/store/modules/dashboard.ts +++ b/src/store/modules/dashboard.ts @@ -19,6 +19,7 @@ import { store } from "@/store"; import { LayoutConfig } from "@/types/dashboard"; import graphql from "@/graphql"; import query from "@/graphql/fetch"; +import { DashboardItem } from "@/types/dashboard"; // import { // ServiceLayout, // AllLayout, @@ -45,13 +46,8 @@ interface DashboardState { selectorStore: any; showTopology: boolean; currentTabItems: LayoutConfig[]; - dashboards: { name: string; layer: string; entity: string; id: string }[]; - currentDashboard: Nullable<{ - name: string; - layer: string; - entity: string; - id: string; - }>; + dashboards: DashboardItem[]; + currentDashboard: Nullable; } export const dashboardStore = defineStore({ @@ -74,24 +70,11 @@ export const dashboardStore = defineStore({ setLayout(data: LayoutConfig[]) { this.layout = data; }, - resetDashboards( - list: { - name: string; - layer: string; - entity: string; - id: string; - isRoot: boolean; - }[] - ) { + resetDashboards(list: DashboardItem[]) { this.dashboards = list; sessionStorage.setItem("dashboards", JSON.stringify(list)); }, - setCurrentDashboard(item: { - name: string; - layer: string; - entity: string; - id: string; - }) { + setCurrentDashboard(item: DashboardItem) { this.currentDashboard = item; }, addControl(type: string) { @@ -402,7 +385,7 @@ export const dashboardStore = defineStore({ json = res.data.changeTemplate; } else { const index = this.dashboards.findIndex( - (d: { name: string; entity: string; layer: string; id: string }) => + (d: DashboardItem) => d.name === this.currentDashboard.name && d.entity === this.currentDashboard.entity && d.layer === this.currentDashboard.layerId diff --git a/src/types/dashboard.ts b/src/types/dashboard.ts index b9f1a817..b0104a75 100644 --- a/src/types/dashboard.ts +++ b/src/types/dashboard.ts @@ -14,6 +14,14 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + +export type DashboardItem = { + id: string; + entity: string; + layer: string; + isRoot: string; + name: string; +}; export interface LayoutConfig { x: number; y: number; diff --git a/src/views/dashboard/List.vue b/src/views/dashboard/List.vue index ec10fb71..6f7ce640 100644 --- a/src/views/dashboard/List.vue +++ b/src/views/dashboard/List.vue @@ -38,7 +38,7 @@ limitations under the License. --> @@ -83,11 +83,12 @@ limitations under the License. -->