update topn config

This commit is contained in:
Fine 2022-10-25 11:25:38 +08:00
parent f945d547b4
commit 0bc520e5f5
2 changed files with 25 additions and 19 deletions

View File

@ -63,6 +63,7 @@ import { computed, ref } from "vue";
import copy from "@/utils/copy"; import copy from "@/utils/copy";
import { TextColors } from "@/views/dashboard/data"; import { TextColors } from "@/views/dashboard/data";
import Trace from "@/views/dashboard/related/trace/Index.vue"; import Trace from "@/views/dashboard/related/trace/Index.vue";
import { QueryOrders, Status } from "../data";
/*global defineProps */ /*global defineProps */
const props = defineProps({ const props = defineProps({
data: { data: {
@ -72,7 +73,7 @@ const props = defineProps({
default: () => ({}), default: () => ({}),
}, },
config: { config: {
type: Object as PropType<{ color: string }>, type: Object as PropType<{ color: string; metrics: string[] }>,
default: () => ({ color: "purple" }), default: () => ({ color: "purple" }),
}, },
intervalTime: { type: Array as PropType<string[]>, default: () => [] }, intervalTime: { type: Array as PropType<string[]>, default: () => [] },
@ -99,10 +100,18 @@ const maxValue = computed(() => {
function handleClick(i: string) { function handleClick(i: string) {
copy(i); copy(i);
} }
function viewTrace(item: { name: string; id: string }) { function viewTrace(item: { name: string; id: string; value: unknown }) {
const filters = {
...item,
queryOrder: QueryOrders[1].value,
status: Status[2].value,
metricValue: [
{ label: props.config.metrics[0], data: item.value, value: item.name },
],
};
traceOptions.value = { traceOptions.value = {
...traceOptions.value, ...traceOptions.value,
filters: item, filters,
}; };
showTrace.value = true; showTrace.value = true;
} }

View File

@ -13,7 +13,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and See the License for the specific language governing permissions and
limitations under the License. --> limitations under the License. -->
<template> <template>
<div class="conditions flex-h" v-if="!filters.id"> <div class="conditions flex-h">
<el-radio-group v-model="conditions" @change="changeCondition"> <el-radio-group v-model="conditions" @change="changeCondition">
<el-radio-button <el-radio-button
v-for="(item, index) in items" v-for="(item, index) in items"
@ -126,13 +126,13 @@ const currentLatency = ref<number[]>(
init(); init();
async function init() { async function init() {
if (!filters.id) { for (const d of Object.keys(filters)) {
for (const d of Object.keys(filters)) { if (filters[d] && ["status", "queryOrder", "latency"].includes(d)) {
if (filters[d] && !["metricValue", "duration"].includes(d)) { items.value.push({ label: d, value: FiltersKeys[d] });
items.value.push({ label: d, value: FiltersKeys[d] });
}
} }
conditions.value = (items.value[0] && items.value[0].label) || ""; }
conditions.value = (items.value[0] && items.value[0].label) || "";
if (!filters.id) {
state.service = selectorStore.currentService.id; state.service = selectorStore.currentService.id;
if (dashboardStore.entity === EntityType[2].value) { if (dashboardStore.entity === EntityType[2].value) {
state.instance = selectorStore.currentPod.id; state.instance = selectorStore.currentPod.id;
@ -211,17 +211,14 @@ function setCondition() {
endpointId: state.endpoint || undefined, endpointId: state.endpoint || undefined,
serviceInstanceId: state.instance || undefined, serviceInstanceId: state.instance || undefined,
}; };
// echarts for (const k of items.value) {
if (!filters.id) { if (k.label === conditions.value && FiltersKeys[k.label]) {
for (const k of items.value) { params[k.value] = filters[k.label];
if (k.label === conditions.value && FiltersKeys[k.label]) {
params[k.value] = filters[k.label];
}
}
if (!isNaN(params.minTraceDuration)) {
params.queryOrder = QueryOrders[1].value;
} }
} }
if (!isNaN(params.minTraceDuration)) {
params.queryOrder = QueryOrders[1].value;
}
return params; return params;
} }
async function queryTraces() { async function queryTraces() {