This commit is contained in:
Fine 2024-10-15 11:23:18 +08:00
parent f38e7a1a48
commit fc09a1f6fb
6 changed files with 10 additions and 8 deletions

View File

@ -123,6 +123,7 @@ export interface CardConfig {
fontSize?: number; fontSize?: number;
showUnit?: boolean; showUnit?: boolean;
textAlign?: "center" | "right" | "left"; textAlign?: "center" | "right" | "left";
decorations?: { [key: string]: string };
} }
export interface TextConfig { export interface TextConfig {

View File

@ -32,6 +32,7 @@ limitations under the License. -->
:config="{ :config="{
i: 0, i: 0,
...graph, ...graph,
decorations: graph?.decorations,
metricConfig: config.metricConfig, metricConfig: config.metricConfig,
expressions: config.expressions || [], expressions: config.expressions || [],
typesOfMQE: typesOfMQE || [], typesOfMQE: typesOfMQE || [],

View File

@ -32,7 +32,8 @@ limitations under the License. -->
:data="states.source" :data="states.source"
:config="{ :config="{
...graph, ...graph,
legend: (dashboardStore.selectedGrid.graph || {}).legend, decorations: dashboardStore.selectedGrid.graph?.decorations,
legend: dashboardStore.selectedGrid.graph?.legend,
i: dashboardStore.selectedGrid.i, i: dashboardStore.selectedGrid.i,
metricConfig: dashboardStore.selectedGrid.metricConfig, metricConfig: dashboardStore.selectedGrid.metricConfig,
relatedTrace: dashboardStore.selectedGrid.relatedTrace, relatedTrace: dashboardStore.selectedGrid.relatedTrace,

View File

@ -38,16 +38,12 @@ limitations under the License. -->
import { useDashboardStore } from "@/store/modules/dashboard"; import { useDashboardStore } from "@/store/modules/dashboard";
const dashboardStore = useDashboardStore(); const dashboardStore = useDashboardStore();
const graph = dashboardStore.selectedGrid.graph || {}; const decorations = ref<{ [key: string]: string }>(dashboardStore.selectedGrid.decorations || {});
const decorations = ref<{ [key: string]: string }>(graph.decorations || {}); const keys = ref<string[]>(dashboardStore.selectedGrid.decorations ? Object.keys(decorations.value) : [""]);
const keys = ref<string[]>(graph.decorations ? Object.keys(graph.decorations) : [""]);
function changeKeys(event: any, index: number) { function changeKeys(event: any, index: number) {
const params = event.target.textContent || ""; const params = event.target.textContent || "";
const list = Object.keys(decorations.value); const list = Object.keys(decorations.value);
if (!list[index]) {
return;
}
if (params) { if (params) {
decorations.value[params] = decorations.value[list[index]]; decorations.value[params] = decorations.value[list[index]];
} }

View File

@ -51,6 +51,7 @@ limitations under the License. -->
:data="state.source" :data="state.source"
:config="{ :config="{
...data.graph, ...data.graph,
decorations: data.graph?.decorations,
i: data.i, i: data.i,
id: data.id, id: data.id,
metricConfig: data.metricConfig || [], metricConfig: data.metricConfig || [],

View File

@ -22,7 +22,7 @@ limitations under the License. -->
justifyContent: config.textAlign || 'center', justifyContent: config.textAlign || 'center',
}" }"
> >
{{ singleVal }} {{ decorations[singleVal] || singleVal }}
<span class="unit" v-show="config.showUnit && unit"> <span class="unit" v-show="config.showUnit && unit">
{{ decodeURIComponent(unit) }} {{ decodeURIComponent(unit) }}
</span> </span>
@ -48,11 +48,13 @@ limitations under the License. -->
showUnit: true, showUnit: true,
textAlign: "center", textAlign: "center",
metricConfig: [], metricConfig: [],
decorations: {},
}), }),
}, },
}); });
const { t } = useI18n(); const { t } = useI18n();
const metricConfig = computed(() => props.config.metricConfig || []); const metricConfig = computed(() => props.config.metricConfig || []);
const decorations = computed(() => props.config.decorations || {});
const key = computed(() => Object.keys(props.data)[0]); const key = computed(() => Object.keys(props.data)[0]);
const singleVal = computed(() => const singleVal = computed(() =>
Array.isArray(props.data[key.value]) ? props.data[key.value][0] : props.data[key.value], Array.isArray(props.data[key.value]) ? props.data[key.value][0] : props.data[key.value],