From ad1e500c5447c27f91540d0b5497cd536f850082 Mon Sep 17 00:00:00 2001 From: Qiuxia Fan Date: Wed, 12 Jan 2022 11:44:54 +0800 Subject: [PATCH] feat: update config --- src/store/{modules => }/data.ts | 19 +++++-- src/store/modules/dashboard.ts | 19 ++----- src/types/dashboard.ts | 22 +++++--- src/views/dashboard/Edit.vue | 1 + .../dashboard/configuration/ConfigEdit.vue | 51 ++++++++++--------- .../configuration/StandardOptions.vue | 1 - .../dashboard/configuration/WidgetOptions.vue | 9 +++- .../configuration/graph-styles/Area.vue | 42 ++++++++++++++- .../configuration/graph-styles/Bar.vue | 7 +-- .../configuration/graph-styles/Line.vue | 7 +-- src/views/dashboard/data.ts | 18 +++++++ 11 files changed, 130 insertions(+), 66 deletions(-) rename src/store/{modules => }/data.ts (83%) diff --git a/src/store/modules/data.ts b/src/store/data.ts similarity index 83% rename from src/store/modules/data.ts rename to src/store/data.ts index f56c16cf..c09a465f 100644 --- a/src/store/modules/data.ts +++ b/src/store/data.ts @@ -14,6 +14,19 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +export const NewControl = { + x: 0, + y: 0, + w: 24, + h: 12, + i: "0", + type: "Widget", + widget: { + title: "Title", + }, + graph: {}, + standard: {}, +}; export const ConfigData = { x: 0, y: 0, @@ -24,8 +37,8 @@ export const ConfigData = { queryMetricType: "readMetricsValues", type: "Widget", widget: { - title: "Title123", - tips: "Tooltip123", + title: "Title", + tips: "Tooltip", }, graph: { showBackground: true, @@ -34,7 +47,7 @@ export const ConfigData = { }, standard: { sortOrder: "DEC", - unit: "s", + unit: "min", }, children: [], }; diff --git a/src/store/modules/dashboard.ts b/src/store/modules/dashboard.ts index 35f3502c..7897a1aa 100644 --- a/src/store/modules/dashboard.ts +++ b/src/store/modules/dashboard.ts @@ -19,8 +19,9 @@ import { store } from "@/store"; import { LayoutConfig } from "@/types/dashboard"; import graph from "@/graph"; import { AxiosResponse } from "axios"; -import { ConfigData } from "./data"; +import { ConfigData } from "../data"; import { useAppStoreWithOut } from "@/store/modules/app"; +import { NewControl } from "../data"; interface DashboardState { showConfig: boolean; layout: LayoutConfig[]; @@ -29,19 +30,7 @@ interface DashboardState { layerId: string; activedGridItem: string; } -const newControl: LayoutConfig = { - x: 0, - y: 0, - w: 24, - h: 12, - i: "0", - type: "Widget", - widget: { - title: "Title", - }, - graph: {}, - standard: {}, -}; + export const dashboardStore = defineStore({ id: "dashboard", state: (): DashboardState => ({ @@ -58,7 +47,7 @@ export const dashboardStore = defineStore({ }, addControl(type: string) { const newWidget: LayoutConfig = { - ...newControl, + ...NewControl, i: String(this.layout.length), type, }; diff --git a/src/types/dashboard.ts b/src/types/dashboard.ts index c6a99b76..f4fee79b 100644 --- a/src/types/dashboard.ts +++ b/src/types/dashboard.ts @@ -30,14 +30,8 @@ export interface LayoutConfig { } export interface WidgetConfig { - title?: string; - tips?: string; -} - -export interface GraphConfig { - type?: string; - showBackground?: boolean; - barWidth?: number; + title: string; + tips: string; } export interface StandardConfig { @@ -46,3 +40,15 @@ export interface StandardConfig { max?: string; min?: string; } + +export type GraphConfig = BarConfig | LineConfig; +interface BarConfig { + type?: string; + showBackground?: boolean; + barWidth?: number; +} +interface LineConfig { + type?: string; + showBackground?: boolean; + barWidth?: number; +} diff --git a/src/views/dashboard/Edit.vue b/src/views/dashboard/Edit.vue index 34621048..5dda9a57 100644 --- a/src/views/dashboard/Edit.vue +++ b/src/views/dashboard/Edit.vue @@ -20,6 +20,7 @@ limitations under the License. --> v-model="dashboardStore.showConfig" title="Edit Graph Options" fullscreen + :destroy-on-close="true" @closed="dashboardStore.setConfigPanel(false)" > diff --git a/src/views/dashboard/configuration/ConfigEdit.vue b/src/views/dashboard/configuration/ConfigEdit.vue index 48cc055f..337f6614 100644 --- a/src/views/dashboard/configuration/ConfigEdit.vue +++ b/src/views/dashboard/configuration/ConfigEdit.vue @@ -15,7 +15,7 @@ limitations under the License. --> + diff --git a/src/views/dashboard/configuration/graph-styles/Bar.vue b/src/views/dashboard/configuration/graph-styles/Bar.vue index f4ce7a3d..a5ecc100 100644 --- a/src/views/dashboard/configuration/graph-styles/Bar.vue +++ b/src/views/dashboard/configuration/graph-styles/Bar.vue @@ -24,18 +24,13 @@ limitations under the License. -->
Show Background - +