From cdf12af6725261f366eca35660bbb45449c3e6c2 Mon Sep 17 00:00:00 2001 From: Qiuxia Fan Date: Tue, 29 Mar 2022 15:51:19 +0800 Subject: [PATCH] update top list config --- src/hooks/useProcessor.ts | 2 +- src/types/dashboard.ts | 1 + src/views/dashboard/configuration/Widget.vue | 4 +- .../widget/graph-styles/TopList.vue | 38 ++++++++++++------ .../configuration/widget/metric/Standard.vue | 40 ++++++++++++++----- src/views/dashboard/data.ts | 2 + src/views/dashboard/graphs/TopList.vue | 39 ++++-------------- 7 files changed, 70 insertions(+), 56 deletions(-) diff --git a/src/hooks/useProcessor.ts b/src/hooks/useProcessor.ts index 8a646336..e928b300 100644 --- a/src/hooks/useProcessor.ts +++ b/src/hooks/useProcessor.ts @@ -66,7 +66,7 @@ export function useQueryProcessor(config: any) { ? selectorStore.currentService.normal : true, scope: config.catalog || dashboardStore.entity, - topN: 10, + topN: c.topN || 10, order: c.sortOrder || "DES", }; } else { diff --git a/src/types/dashboard.ts b/src/types/dashboard.ts index 3a1fe7e1..fc56a4d1 100644 --- a/src/types/dashboard.ts +++ b/src/types/dashboard.ts @@ -45,6 +45,7 @@ export type MetricConfigOpt = { calculation: string; labelsIndex: string; sortOrder: string; + topN?: number; }; export interface WidgetConfig { diff --git a/src/views/dashboard/configuration/Widget.vue b/src/views/dashboard/configuration/Widget.vue index f10981b7..13239a6e 100644 --- a/src/views/dashboard/configuration/Widget.vue +++ b/src/views/dashboard/configuration/Widget.vue @@ -16,9 +16,9 @@ limitations under the License. -->
- {{ dashboardStore.selectedGrid.widget.title }} + {{ dashboardStore.selectedGrid.widget.title || "" }}
- +
diff --git a/src/views/dashboard/configuration/widget/graph-styles/TopList.vue b/src/views/dashboard/configuration/widget/graph-styles/TopList.vue index 6c315ba2..27f7a94f 100644 --- a/src/views/dashboard/configuration/widget/graph-styles/TopList.vue +++ b/src/views/dashboard/configuration/widget/graph-styles/TopList.vue @@ -13,17 +13,15 @@ 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. --> @@ -35,14 +33,24 @@ import { useDashboardStore } from "@/store/modules/dashboard"; const { t } = useI18n(); const dashboardStore = useDashboardStore(); const { selectedGrid } = dashboardStore; -const topN = ref(selectedGrid.graph.topN); +const color = ref(selectedGrid.graph.color || "purple"); +const Colors = [ + { label: "Purple", value: "purple" }, + { + label: "Green", + value: "green", + }, + { label: "Blue", value: "blue" }, + { label: "Red", value: "red" }, + { label: "Orange", value: "orange" }, +]; function updateConfig(param: { [key: string]: unknown }) { const graph = { - ...selectedGrid.graph, + ...dashboardStore.selectedGrid.graph, ...param, }; - dashboardStore.selectWidget({ ...selectedGrid, graph }); + dashboardStore.selectWidget({ ...dashboardStore.selectedGrid, graph }); } diff --git a/src/views/dashboard/configuration/widget/metric/Standard.vue b/src/views/dashboard/configuration/widget/metric/Standard.vue index 499fd59a..6f873d8d 100644 --- a/src/views/dashboard/configuration/widget/metric/Standard.vue +++ b/src/views/dashboard/configuration/widget/metric/Standard.vue @@ -56,10 +56,7 @@ limitations under the License. --> :clearable="true" />
-
+
{{ t("sortOrder") }} @change="changeConfigs(index, { sortOrder: $event })" />
+
+ {{ t("maxItemNum") }} + +
diff --git a/src/views/dashboard/data.ts b/src/views/dashboard/data.ts index 4e89cae9..9c579027 100644 --- a/src/views/dashboard/data.ts +++ b/src/views/dashboard/data.ts @@ -77,6 +77,7 @@ export const DefaultGraphConfig: { [key: string]: any } = { }, TopList: { type: "TopList", + color: "purple", }, InstanceList: { type: "InstanceList", @@ -263,6 +264,7 @@ export const TextColors: { [key: string]: string } = { white: "#fff", black: "#000", orange: "#E6A23C", + purple: "#bf99f8", }; export const CalculationOpts = [ diff --git a/src/views/dashboard/graphs/TopList.vue b/src/views/dashboard/graphs/TopList.vue index d22a5773..0b2fc18e 100644 --- a/src/views/dashboard/graphs/TopList.vue +++ b/src/views/dashboard/graphs/TopList.vue @@ -15,12 +15,12 @@ limitations under the License. -->