From 59ea77d65cdd20c1ed12530065e56508b1fb6c0d Mon Sep 17 00:00:00 2001 From: Qiuxia Fan Date: Fri, 7 Jan 2022 15:19:30 +0800 Subject: [PATCH] feat: add Tab on the dashboard --- src/assets/icons/all_inbox.svg | 18 +++++ src/assets/icons/insert_image.svg | 18 +++++ src/assets/icons/library_add.svg | 18 +++++ src/store/modules/dashboard.ts | 28 ++++++++ src/store/modules/data.ts | 6 +- src/types/dashboard.ts | 10 +-- .../dashboard/configuration/ConfigEdit.vue | 4 +- .../dashboard/controls/{Tabs.vue => Tab.vue} | 70 ++++++++++++------- .../dashboard/{panel => controls}/Widget.vue | 18 ++--- src/views/dashboard/controls/index.ts | 24 ------- src/views/dashboard/data.ts | 13 +++- src/views/dashboard/panel/Layout.vue | 27 ++++--- src/views/dashboard/panel/Tool.vue | 52 +++++++------- 13 files changed, 201 insertions(+), 105 deletions(-) create mode 100644 src/assets/icons/all_inbox.svg create mode 100644 src/assets/icons/insert_image.svg create mode 100644 src/assets/icons/library_add.svg rename src/views/dashboard/controls/{Tabs.vue => Tab.vue} (57%) rename src/views/dashboard/{panel => controls}/Widget.vue (90%) delete mode 100644 src/views/dashboard/controls/index.ts diff --git a/src/assets/icons/all_inbox.svg b/src/assets/icons/all_inbox.svg new file mode 100644 index 00000000..bcf2fa84 --- /dev/null +++ b/src/assets/icons/all_inbox.svg @@ -0,0 +1,18 @@ + + +all_inbox + + diff --git a/src/assets/icons/insert_image.svg b/src/assets/icons/insert_image.svg new file mode 100644 index 00000000..b3643964 --- /dev/null +++ b/src/assets/icons/insert_image.svg @@ -0,0 +1,18 @@ + + +insert_image + + diff --git a/src/assets/icons/library_add.svg b/src/assets/icons/library_add.svg new file mode 100644 index 00000000..382303c4 --- /dev/null +++ b/src/assets/icons/library_add.svg @@ -0,0 +1,18 @@ + + +library_add + + diff --git a/src/store/modules/dashboard.ts b/src/store/modules/dashboard.ts index 180b5b85..28714e7f 100644 --- a/src/store/modules/dashboard.ts +++ b/src/store/modules/dashboard.ts @@ -49,6 +49,34 @@ export const dashboardStore = defineStore({ w: 24, h: 12, i: String(this.layout.length), + type: "Widget", + widget: {}, + graph: {}, + standard: {}, + }; + this.layout = this.layout.map((d: LayoutConfig) => { + d.y = d.y + newWidget.h; + return d; + }); + this.layout.push(newWidget); + }, + addTab() { + const newWidget: LayoutConfig = { + x: 0, + y: 0, + w: 24, + h: 12, + i: String(this.layout.length), + type: "Tab", + children: [ + { + name: "Tab1", + children: [], + }, + ], + widget: {}, + graph: {}, + standard: {}, }; this.layout = this.layout.map((d: LayoutConfig) => { d.y = d.y + newWidget.h; diff --git a/src/store/modules/data.ts b/src/store/modules/data.ts index 5b1a9892..676a9bd9 100644 --- a/src/store/modules/data.ts +++ b/src/store/modules/data.ts @@ -14,8 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import { LayoutConfig } from "@/types/dashboard"; -export const ConfigData: LayoutConfig = { +export const ConfigData = { x: 0, y: 0, w: 8, @@ -23,7 +22,7 @@ export const ConfigData: LayoutConfig = { i: "0", metrics: ["service_resp_time"], queryMetricType: "readMetricsValues", - chart: "Line", + type: "Widget", widget: { title: "Title123", tips: "Tooltip123", @@ -31,6 +30,7 @@ export const ConfigData: LayoutConfig = { graph: { showBackground: true, barWidth: 30, + type: "Line", }, standard: { sortOrder: "DEC", diff --git a/src/types/dashboard.ts b/src/types/dashboard.ts index f61b9143..35fe7bcc 100644 --- a/src/types/dashboard.ts +++ b/src/types/dashboard.ts @@ -20,12 +20,13 @@ export interface LayoutConfig { w: number; h: number; i: string; - widget?: WidgetConfig; - graph?: GraphConfig; - standard?: StandardConfig; + widget: WidgetConfig; + graph: GraphConfig; + standard: StandardConfig; metrics?: string[]; - chart?: string; + type?: string; queryMetricType?: string; + children?: any[]; } export interface WidgetConfig { @@ -34,6 +35,7 @@ export interface WidgetConfig { } export interface GraphConfig { + type?: string; showBackground?: boolean; barWidth?: number; } diff --git a/src/views/dashboard/configuration/ConfigEdit.vue b/src/views/dashboard/configuration/ConfigEdit.vue index 980f9a2e..5eae0125 100644 --- a/src/views/dashboard/configuration/ConfigEdit.vue +++ b/src/views/dashboard/configuration/ConfigEdit.vue @@ -98,7 +98,6 @@ import { ValuesTypes, MetricQueryTypes, ChartTypes } from "../data"; import { Option } from "@/types/app"; import Loading from "@/utils/loading"; import graphs from "../graphs"; -import controls from "../controls"; import configs from "./graph-styles"; import WidgetOptions from "./WidgetOptions.vue"; import StandardOptions from "./StandardOptions.vue"; @@ -107,7 +106,6 @@ export default defineComponent({ name: "ConfigEdit", components: { ...graphs, - ...controls, ...configs, WidgetOptions, StandardOptions, @@ -135,7 +133,7 @@ export default defineComponent({ valueTypes: [], valueType: "", metricQueryType: "", - chartType: selectedWidget.chart, + chartType: selectedWidget.graph.type, activeNames: "1", source: {}, index: selectedWidget.i, diff --git a/src/views/dashboard/controls/Tabs.vue b/src/views/dashboard/controls/Tab.vue similarity index 57% rename from src/views/dashboard/controls/Tabs.vue rename to src/views/dashboard/controls/Tab.vue index 7ccd35ed..7ea5525b 100644 --- a/src/views/dashboard/controls/Tabs.vue +++ b/src/views/dashboard/controls/Tab.vue @@ -13,47 +13,67 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. -->