fix metric config

This commit is contained in:
Fine 2022-10-30 15:43:42 +08:00
parent b75010c46c
commit 0683789fbb
3 changed files with 11 additions and 6 deletions

View File

@ -242,7 +242,10 @@ async function setMetricType(chart?: any) {
}
function setDashboards(type?: string) {
const chart = type || dashboardStore.selectedGrid.graph || {};
const chart =
type ||
(dashboardStore.selectedGrid.graph &&
dashboardStore.selectedGrid.graph.type);
const list = JSON.parse(sessionStorage.getItem("dashboards") || "[]");
const arr = list.reduce(
(
@ -251,9 +254,9 @@ function setDashboards(type?: string) {
) => {
if (d.layer === dashboardStore.layerId) {
if (
(d.entity === EntityType[0].value && chart.type === "ServiceList") ||
(d.entity === EntityType[2].value && chart.type === "EndpointList") ||
(d.entity === EntityType[3].value && chart.type === "InstanceList")
(d.entity === EntityType[0].value && chart === "ServiceList") ||
(d.entity === EntityType[2].value && chart === "EndpointList") ||
(d.entity === EntityType[3].value && chart === "InstanceList")
) {
prev.push({
...d,

View File

@ -115,7 +115,9 @@ const currentMetric = ref<MetricConfigOpt>({
topN: props.currentMetricConfig.topN || 10,
});
const metricTypes = dashboardStore.selectedGrid.metricTypes || [];
const metricType = computed(() => metricTypes[props.index]);
const metricType = computed(
() => (dashboardStore.selectedGrid.metricTypes || [])[props.index]
);
const hasLabel = computed(() => {
const graph = dashboardStore.selectedGrid.graph || {};
return (

View File

@ -211,7 +211,7 @@ async function queryServiceMetrics(currentServices: Service[]) {
if (metrics.length && metrics[0] && types.length && types[0]) {
const params = await useQueryPodsMetrics(
currentServices,
props.config,
{ ...props.config, metricConfig: metricConfig.value || [] },
EntityType[0].value
);
const json = await dashboardStore.fetchMetricValue(params);