From 2e82d52e7108e0776e2a8e1a28b1c9d4b3313225 Mon Sep 17 00:00:00 2001 From: Qiuxia Fan Date: Tue, 18 Jan 2022 15:53:43 +0800 Subject: [PATCH] feat: add list components config --- src/locales/lang/en.ts | 1 + src/locales/lang/zh.ts | 1 + src/types/dashboard.ts | 27 +++++++- .../dashboard/configuration/ConfigEdit.vue | 42 +++++++++++-- .../graph-styles/EndpointList.vue | 63 +++++++++++++++++++ .../graph-styles/InstanceList.vue | 63 +++++++++++++++++++ .../graph-styles/ServiceList.vue | 63 +++++++++++++++++++ .../configuration/graph-styles/index.ts | 6 ++ src/views/dashboard/data.ts | 11 ++++ src/views/dashboard/graphs/EndpointList.vue | 26 +++++--- src/views/dashboard/graphs/InstanceList.vue | 26 +++++--- src/views/dashboard/graphs/ServiceList.vue | 26 +++++--- 12 files changed, 318 insertions(+), 37 deletions(-) create mode 100644 src/views/dashboard/configuration/graph-styles/EndpointList.vue create mode 100644 src/views/dashboard/configuration/graph-styles/InstanceList.vue create mode 100644 src/views/dashboard/configuration/graph-styles/ServiceList.vue diff --git a/src/locales/lang/en.ts b/src/locales/lang/en.ts index 462109d8..a57b3d19 100644 --- a/src/locales/lang/en.ts +++ b/src/locales/lang/en.ts @@ -73,6 +73,7 @@ const msg = { showBackground: "Show Background", areaOpacity: "Area Opacity", editGraph: "Edit Graph Options", + dashboardName: "Select Dashboard Name", hourTip: "Select Hour", minuteTip: "Select Minute", secondTip: "Select Second", diff --git a/src/locales/lang/zh.ts b/src/locales/lang/zh.ts index 93ebc760..d2a2a7a5 100644 --- a/src/locales/lang/zh.ts +++ b/src/locales/lang/zh.ts @@ -71,6 +71,7 @@ const msg = { showBackground: "显示背景", areaOpacity: "透明度", editGraph: "编辑图表选项", + dashboardName: "选择仪表板名称", hourTip: "选择小时", minuteTip: "选择分钟", secondTip: "选择秒数", diff --git a/src/types/dashboard.ts b/src/types/dashboard.ts index 1680dc34..1bd2e6b7 100644 --- a/src/types/dashboard.ts +++ b/src/types/dashboard.ts @@ -47,7 +47,14 @@ export interface StandardConfig { seconds?: string; } -export type GraphConfig = BarConfig | LineConfig | CardConfig | TableConfig; +export type GraphConfig = + | BarConfig + | LineConfig + | CardConfig + | TableConfig + | EndpointListConfig + | ServiceListConfig + | InstanceListConfig; export interface BarConfig { type?: string; showBackground?: boolean; @@ -81,3 +88,21 @@ export interface TopListConfig { type?: string; topN: number; } + +export interface ServiceListConfig { + type?: string; + dashboardName: string; + fontSize: number; +} + +export interface InstanceListConfig { + type?: string; + dashboardName: string; + fontSize: number; +} + +export interface EndpointListConfig { + type?: string; + dashboardName: string; + fontSize: number; +} diff --git a/src/views/dashboard/configuration/ConfigEdit.vue b/src/views/dashboard/configuration/ConfigEdit.vue index db821c0c..ae70e0fe 100644 --- a/src/views/dashboard/configuration/ConfigEdit.vue +++ b/src/views/dashboard/configuration/ConfigEdit.vue @@ -50,8 +50,21 @@ limitations under the License. --> - -
+ +
+ +
+
:value="states.valueType" :options="states.valueTypes" size="mini" - placeholder="Select a metric" @change="changeValueType" class="selectors" v-loading="loading" @@ -117,6 +129,7 @@ import { ChartTypes, DefaultGraphConfig, PodsChartTypes, + TableChartTypes, } from "../data"; import { Option } from "@/types/app"; import { WidgetConfig, GraphConfig, StandardConfig } from "@/types/dashboard"; @@ -148,10 +161,11 @@ export default defineComponent({ activeNames: string; source: any; index: string; - graph: GraphConfig; + graph: GraphConfig | any; widget: WidgetConfig | any; standard: StandardConfig; visType: Option[]; + isTable: boolean; }>({ metrics: selectedGrid.metrics || [], valueTypes: [], @@ -164,17 +178,27 @@ export default defineComponent({ widget: selectedGrid.widget, standard: selectedGrid.standard, visType: [], + isTable: false, }); + + states.isTable = TableChartTypes.includes(states.graph.type || ""); + if (states.metrics[0]) { queryMetricType(states.metrics[0]); } if (params.entity === "service") { - states.visType = ChartTypes; - } else { + states.visType = ChartTypes.filter( + (d: Option) => d.value !== "serviceList" + ); + } else if (params.entity === "all") { states.visType = ChartTypes.filter( (d: Option) => !PodsChartTypes.includes(d.value) ); + } else { + states.visType = ChartTypes.filter( + (d: Option) => !TableChartTypes.includes(d.value) + ); } async function changeMetrics(arr: Option[]) { @@ -213,6 +237,11 @@ export default defineComponent({ states.graph = { ...DefaultGraphConfig[item.value], }; + states.isTable = TableChartTypes.includes(states.graph.type || ""); + } + + function changeDashboard(item: Option[]) { + states.graph.dashboardName = item[0].value; } const metricOpts = [ @@ -302,6 +331,7 @@ export default defineComponent({ updateGraphOptions, updateStandardOptions, applyConfig, + changeDashboard, loading, }; }, diff --git a/src/views/dashboard/configuration/graph-styles/EndpointList.vue b/src/views/dashboard/configuration/graph-styles/EndpointList.vue new file mode 100644 index 00000000..e6c86101 --- /dev/null +++ b/src/views/dashboard/configuration/graph-styles/EndpointList.vue @@ -0,0 +1,63 @@ + + + + diff --git a/src/views/dashboard/configuration/graph-styles/InstanceList.vue b/src/views/dashboard/configuration/graph-styles/InstanceList.vue new file mode 100644 index 00000000..8d80e992 --- /dev/null +++ b/src/views/dashboard/configuration/graph-styles/InstanceList.vue @@ -0,0 +1,63 @@ + + + + diff --git a/src/views/dashboard/configuration/graph-styles/ServiceList.vue b/src/views/dashboard/configuration/graph-styles/ServiceList.vue new file mode 100644 index 00000000..f419209d --- /dev/null +++ b/src/views/dashboard/configuration/graph-styles/ServiceList.vue @@ -0,0 +1,63 @@ + + + + diff --git a/src/views/dashboard/configuration/graph-styles/index.ts b/src/views/dashboard/configuration/graph-styles/index.ts index 8e487cc6..a1b673d2 100644 --- a/src/views/dashboard/configuration/graph-styles/index.ts +++ b/src/views/dashboard/configuration/graph-styles/index.ts @@ -18,9 +18,15 @@ import AreaConfig from "./Area.vue"; import LineConfig from "./Line.vue"; import BarConfig from "./Bar.vue"; +import InstanceListConfig from "./InstanceList.vue"; +import EndpointListConfig from "./EndpointList.vue"; +import ServiceListConfig from "./ServiceList.vue"; export default { AreaConfig, LineConfig, BarConfig, + InstanceListConfig, + EndpointListConfig, + ServiceListConfig, }; diff --git a/src/views/dashboard/data.ts b/src/views/dashboard/data.ts index 5404fc90..40053266 100644 --- a/src/views/dashboard/data.ts +++ b/src/views/dashboard/data.ts @@ -16,6 +16,8 @@ */ export const PodsChartTypes = ["EndpointList", "InstanceList"]; +export const TableChartTypes = ["EndpointList", "InstanceList", "ServiceList"]; + export const ChartTypes = [ { label: "Bar", value: "Bar" }, { label: "Line", value: "Line" }, @@ -60,9 +62,18 @@ export const DefaultGraphConfig: { [key: string]: any } = { }, InstanceList: { type: "InstanceList", + dashboardName: "", + fontSize: 12, }, EndpointList: { type: "EndpointList", + dashboardName: "", + fontSize: 12, + }, + ServiceList: { + type: "ServiceList", + dashboardName: "", + fontSize: 12, }, }; diff --git a/src/views/dashboard/graphs/EndpointList.vue b/src/views/dashboard/graphs/EndpointList.vue index 4547f7e5..7594d5f8 100644 --- a/src/views/dashboard/graphs/EndpointList.vue +++ b/src/views/dashboard/graphs/EndpointList.vue @@ -14,46 +14,52 @@ See the License for the specific language governing permissions and limitations under the License. -->