fix: change metrics config, fix tab routes (#345)

This commit is contained in:
Fine0830 2023-11-26 13:15:43 +08:00 committed by GitHub
parent ac57b229fc
commit c1c086d999
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 41 additions and 27 deletions

View File

@ -389,7 +389,10 @@ export function useQueryTopologyExpressionsProcessor(metrics: string[], instance
values: [],
};
}
obj[metrics[index]].values.push({ value: resp[k].results[0].values[0].value, id: instances[idx].id });
obj[metrics[index]].values.push({
value: resp[k].results[0] && resp[k].results[0].values[0].value,
id: instances[idx].id,
});
}
}
}

View File

@ -52,7 +52,7 @@ function layerDashboards() {
route.children.push(d);
const tab = {
name: `${child.name}ActiveTabIndex`,
path: `/${child.name}/tab/:activeTabIndex`,
path: `/${child.path}/tab/:activeTabIndex`,
component: () => import("@/views/Layer.vue"),
meta: {
notShow: true,

View File

@ -189,7 +189,9 @@ limitations under the License. -->
onMounted(async () => {
await nextTick();
init();
setTimeout(() => {
init();
}, 10);
});
async function init() {
const dom = document.querySelector(".topology")?.getBoundingClientRect() || {

View File

@ -54,7 +54,6 @@ limitations under the License. -->
</template>
<script lang="ts" setup>
import { ref, computed, watch } from "vue";
import type { PropType } from "vue";
import { useI18n } from "vue-i18n";
import { CalculationOpts, MetricModes } from "../../../data";
import { useDashboardStore } from "@/store/modules/dashboard";
@ -63,15 +62,40 @@ limitations under the License. -->
/*global defineEmits, defineProps */
const props = defineProps({
type: { type: String, default: "" },
metrics: { type: Array as PropType<string[]>, default: () => [] },
isExpression: { type: Boolean, default: true },
});
const { t } = useI18n();
const emit = defineEmits(["update"]);
const dashboardStore = useDashboardStore();
const m = props.metrics.map((d: string) => {
return { label: d, value: d };
const getMetrics = computed(() => {
let metrics = [];
const {
linkServerExpressions,
linkServerMetrics,
linkClientExpressions,
linkClientMetrics,
nodeExpressions,
nodeMetrics,
} = dashboardStore.selectedGrid;
switch (props.type) {
case "linkServerMetricConfig":
metrics = props.isExpression ? linkServerExpressions : linkServerMetrics;
break;
case "linkClientMetricConfig":
metrics = props.isExpression ? linkClientExpressions : linkClientMetrics;
break;
case "nodeMetricConfig":
metrics = props.isExpression ? nodeExpressions : nodeMetrics;
break;
}
return metrics || [];
});
const metricList = computed(() => {
const m = getMetrics.value.map((d: string) => {
return { label: d, value: d };
});
return m.length ? m : [{ label: "", value: "" }];
});
const metricList = ref<Option[]>(m.length ? m : [{ label: "", value: "" }]);
const currentMetric = ref<string>(metricList.value[0].value);
const currentConfig = ref<{ unit: string; calculation: string; label: string }>({
unit: "",
@ -81,6 +105,7 @@ limitations under the License. -->
const currentIndex = ref<number>(0);
const getMetricConfig = computed(() => {
let config = [];
switch (props.type) {
case "linkServerMetricConfig":
config = dashboardStore.selectedGrid.linkServerMetricConfig;
@ -120,10 +145,6 @@ limitations under the License. -->
watch(
() => props.type,
() => {
const m = props.metrics.map((d: string) => {
return { label: d, value: d };
});
metricList.value = m.length ? m : [{ label: "", value: "" }];
currentMetric.value = metricList.value[0].value;
const config = getMetricConfig.value || [];
currentIndex.value = 0;

View File

@ -49,11 +49,7 @@ limitations under the License. -->
<Icon class="cp ml-5" iconName="mode_edit" size="middle" />
</span>
</template>
<Metrics
:type="configType"
:metrics="isExpression ? states.linkServerExpressions : states.linkServerMetrics"
@update="updateSettings"
/>
<Metrics :type="configType" :isExpression="isExpression" @update="updateSettings" />
</el-popover>
</div>
<div v-if="isExpression">
@ -88,11 +84,7 @@ limitations under the License. -->
<Icon class="cp ml-5" iconName="mode_edit" size="middle" />
</span>
</template>
<Metrics
:type="configType"
:metrics="isExpression ? states.linkClientExpressions : states.linkClientMetrics"
@update="updateSettings"
/>
<Metrics :type="configType" :isExpression="isExpression" @update="updateSettings" />
</el-popover>
</div>
<div v-if="isExpression">
@ -168,11 +160,7 @@ limitations under the License. -->
<Icon class="cp ml-5" iconName="mode_edit" size="middle" />
</span>
</template>
<Metrics
:type="configType"
:metrics="isExpression ? states.nodeExpressions : states.nodeMetrics"
@update="updateSettings"
/>
<Metrics :type="configType" :isExpression="isExpression" @update="updateSettings" />
</el-popover>
</div>
<div v-if="isExpression">