From 655c4c41e9293001e2c438fb2c02725fa0c1043f Mon Sep 17 00:00:00 2001 From: Qiuxia Fan Date: Mon, 24 Jan 2022 21:19:57 +0800 Subject: [PATCH] refactor: update MetricOptions --- src/graph/fragments/selector.ts | 3 +- src/hooks/useProcessor.ts | 2 +- src/locales/lang/en.ts | 5 +- src/locales/lang/zh.ts | 3 +- .../dashboard/configuration/ConfigEdit.vue | 76 +---------- .../dashboard/configuration/MetricOptions.vue | 127 ++++++++++++++---- src/views/dashboard/data.ts | 20 +-- src/views/dashboard/graphs/EndpointList.vue | 12 +- src/views/dashboard/graphs/InstanceList.vue | 11 +- src/views/dashboard/graphs/ServiceList.vue | 12 +- src/views/dashboard/panel/Tool.vue | 5 +- 11 files changed, 137 insertions(+), 139 deletions(-) diff --git a/src/graph/fragments/selector.ts b/src/graph/fragments/selector.ts index ada13af2..4b90d4f9 100644 --- a/src/graph/fragments/selector.ts +++ b/src/graph/fragments/selector.ts @@ -93,7 +93,7 @@ export const getInstance = { }; export const getEndpoint = { - variable: "$endpointId: String!", + variable: "$endpointId: ID!", query: ` endpoint: getEndpointInfo(endpointId: $endpointId) { id @@ -101,7 +101,6 @@ export const getEndpoint = { label: name serviceId serviceName - } } `, }; diff --git a/src/hooks/useProcessor.ts b/src/hooks/useProcessor.ts index 5663f24d..c885373b 100644 --- a/src/hooks/useProcessor.ts +++ b/src/hooks/useProcessor.ts @@ -22,7 +22,7 @@ import { useAppStoreWithOut } from "@/store/modules/app"; import { Instance, Endpoint } from "@/types/selector"; export function useQueryProcessor(config: any) { - if (!(config.metrics && config.metrics.length)) { + if (!(config.metrics && config.metrics[0])) { return; } const appStore = useAppStoreWithOut(); diff --git a/src/locales/lang/en.ts b/src/locales/lang/en.ts index a57b3d19..e7b840fa 100644 --- a/src/locales/lang/en.ts +++ b/src/locales/lang/en.ts @@ -30,7 +30,7 @@ const msg = { events: "Events", alerts: "Alerts", settings: "Settings", - dashboards: "Dashboards", + dashboards: "Dashboard", profiles: "Profiles", database: "Database", serviceName: "Service Name", @@ -53,7 +53,8 @@ const msg = { instance: "Instance", create: "Create", loading: "Loading", - selectVisualization: "Select your visualization", + selectVisualization: "Visualize your metrics", + visualization: "Visualization", graphStyles: "Graph styles", widgetOptions: "Widget options", standardOptions: "Standard options", diff --git a/src/locales/lang/zh.ts b/src/locales/lang/zh.ts index d2a2a7a5..42137a22 100644 --- a/src/locales/lang/zh.ts +++ b/src/locales/lang/zh.ts @@ -51,7 +51,8 @@ const msg = { endpoint: "端点", create: "新建", loading: "加载中", - selectVisualization: "选择你的可视化", + selectVisualization: "可视化指标", + visualization: "可视化", graphStyles: "图形样式", widgetOptions: "组件选项", standardOptions: "标准选项", diff --git a/src/views/dashboard/configuration/ConfigEdit.vue b/src/views/dashboard/configuration/ConfigEdit.vue index 579941b3..0ae6fdea 100644 --- a/src/views/dashboard/configuration/ConfigEdit.vue +++ b/src/views/dashboard/configuration/ConfigEdit.vue @@ -40,30 +40,16 @@ limitations under the License. --> v-model="states.activeNames" :style="{ '--el-collapse-header-font-size': '15px' }" > - + - -
- - {{ type.label }} - -
-
- + - + - + @@ -83,13 +69,6 @@ import { reactive, defineComponent, ref } from "vue"; import { useI18n } from "vue-i18n"; import { useDashboardStore } from "@/store/modules/dashboard"; import { useAppStoreWithOut } from "@/store/modules/app"; -import { - ChartTypes, - DefaultGraphConfig, - PodsChartTypes, - TableChartTypes, - EntityType, -} from "../data"; import { Option } from "@/types/app"; import graphs from "../graphs"; import configs from "./graph-styles"; @@ -117,37 +96,12 @@ export default defineComponent({ source: any; index: string; visType: Option[]; - isTable: boolean; }>({ activeNames: "1", source: {}, index: dashboardStore.selectedGrid.i, visType: [], - isTable: false, }); - states.isTable = TableChartTypes.includes( - dashboardStore.selectedGrid.graph.type || "" - ); - - if (dashboardStore.entity === EntityType[0].value) { - states.visType = ChartTypes.filter( - (d: Option) => d.value !== "serviceList" - ); - } else if (dashboardStore.entity === EntityType[1].value) { - states.visType = ChartTypes.filter( - (d: Option) => !PodsChartTypes.includes(d.value) - ); - } else { - states.visType = ChartTypes.filter( - (d: Option) => !TableChartTypes.includes(d.value) - ); - } - - function changeChartType(item: Option) { - const graph = DefaultGraphConfig[item.value]; - states.isTable = TableChartTypes.includes(graph.type); - dashboardStore.selectWidget({ ...dashboardStore.selectedGrid, graph }); - } function getSource(source: unknown) { states.source = source; @@ -160,12 +114,12 @@ export default defineComponent({ function applyConfig() { dashboardStore.setConfigs(dashboardStore.selectedGrid); dashboardStore.setConfigPanel(false); + dashboardStore.selectWidget(null); } return { states, loading, - changeChartType, t, appStoreWithOut, configHeight, @@ -226,32 +180,12 @@ export default defineComponent({ min-width: 1280px; } -.chart-types { - span { - display: inline-block; - padding: 5px 10px; - border: 1px solid #ccc; - background-color: #fff; - border-right: 0; - cursor: pointer; - } - - span:nth-last-child(1) { - border-right: 1px solid #ccc; - } -} - .no-data { font-size: 14px; text-align: center; line-height: 400px; } -span.active { - background-color: #409eff; - color: #fff; -} - .footer { position: fixed; bottom: 0; diff --git a/src/views/dashboard/configuration/MetricOptions.vue b/src/views/dashboard/configuration/MetricOptions.vue index b60cdcd8..7473fc4d 100644 --- a/src/views/dashboard/configuration/MetricOptions.vue +++ b/src/views/dashboard/configuration/MetricOptions.vue @@ -14,17 +14,15 @@ See the License for the specific language governing permissions and limitations under the License. --> diff --git a/src/views/dashboard/data.ts b/src/views/dashboard/data.ts index e643016b..d739217b 100644 --- a/src/views/dashboard/data.ts +++ b/src/views/dashboard/data.ts @@ -32,6 +32,18 @@ export const ChartTypes = [ { label: "Endpoint List", value: "EndpointList" }, { label: "Instance List", value: "InstanceList" }, ]; +export const MetricChartType: any = { + readMetricsValue: [{ label: "Card", value: "Card" }], + readMetricsValues: [ + { label: "Bar", value: "Bar" }, + { label: "Line", value: "Line" }, + { label: "Area", value: "Area" }, + ], + sortMetrics: [{ label: "Top List", value: "TopList" }], + readLabeledMetricsValues: [{ label: "Line", value: "Line" }], + readHeatMap: [{ label: "Heatmap", value: "Heatmap" }], + readSampledRecords: [{ label: "Top List", value: "TopList" }], +}; export const DefaultGraphConfig: { [key: string]: any } = { Bar: { type: "Bar", @@ -113,14 +125,6 @@ export const MetricTypes: { { label: "get sorted topN values", value: "readSampledRecords" }, ], }; -export const MetricChartType: { [key: string]: string } = { - readMetricsValue: "ChartNum", - readMetricsValues: "ChartLine", - sortMetrics: "ChartSlow", - readLabeledMetricsValues: "ChartLine", - readHeatMap: "ChartHeatmap", - readSampledRecords: "ChartSlow", -}; export enum MetricCatalog { SERVICE = "Service", diff --git a/src/views/dashboard/graphs/EndpointList.vue b/src/views/dashboard/graphs/EndpointList.vue index c10ddb57..8e9a06d3 100644 --- a/src/views/dashboard/graphs/EndpointList.vue +++ b/src/views/dashboard/graphs/EndpointList.vue @@ -29,17 +29,12 @@ limitations under the License. --> - + - + - +