add latency in filters

This commit is contained in:
Fine 2022-10-13 15:57:06 +08:00
parent 44316a4f16
commit 7a48d96e7f
3 changed files with 19 additions and 14 deletions

View File

@ -49,17 +49,13 @@ import type { PropType } from "vue";
import { useI18n } from "vue-i18n"; import { useI18n } from "vue-i18n";
import { EventParams } from "@/types/app"; import { EventParams } from "@/types/app";
import { useECharts } from "@/hooks/useEcharts"; import { useECharts } from "@/hooks/useEcharts";
import { useAppStoreWithOut } from "@/store/modules/app";
import { addResizeListener, removeResizeListener } from "@/utils/event"; import { addResizeListener, removeResizeListener } from "@/utils/event";
import Trace from "@/views/dashboard/controls/Trace.vue"; import Trace from "@/views/dashboard/controls/Trace.vue";
import dateFormatStep from "@/utils/dateFormat";
import getLocalTime from "@/utils/localtime";
import associateProcessor from "@/hooks/useAssociateProcessor"; import associateProcessor from "@/hooks/useAssociateProcessor";
/*global Nullable, defineProps, defineEmits*/ /*global Nullable, defineProps, defineEmits*/
const emits = defineEmits(["select"]); const emits = defineEmits(["select"]);
const { t } = useI18n(); const { t } = useI18n();
const appStore = useAppStoreWithOut();
const chartRef = ref<Nullable<HTMLDivElement>>(null); const chartRef = ref<Nullable<HTMLDivElement>>(null);
const menus = ref<Nullable<HTMLDivElement>>(null); const menus = ref<Nullable<HTMLDivElement>>(null);
const visMenus = ref<boolean>(false); const visMenus = ref<boolean>(false);
@ -153,8 +149,8 @@ function updateOptions() {
return; return;
} }
if (props.filters.isRange) { if (props.filters.isRange) {
const { eventAssociate } = associateProcessor(); const { eventAssociate } = associateProcessor(props);
const options = eventAssociate(props); const options = eventAssociate();
setOptions(options || props.option); setOptions(options || props.option);
} else { } else {
instance.dispatchAction({ instance.dispatchAction({
@ -166,8 +162,7 @@ function updateOptions() {
} }
function viewTrace() { function viewTrace() {
const item = associateProcessor().traceFilters(currentParams.value); const item = associateProcessor(props).traceFilters(currentParams.value);
console.log(item);
traceOptions.value = { traceOptions.value = {
...traceOptions.value, ...traceOptions.value,
filters: item, filters: item,
@ -186,8 +181,8 @@ watch(
} }
let options; let options;
if (props.filters && props.filters.isRange) { if (props.filters && props.filters.isRange) {
const { eventAssociate } = associateProcessor(); const { eventAssociate } = associateProcessor(props);
options = eventAssociate(props); options = eventAssociate();
} }
setOptions(options || props.option); setOptions(options || props.option);
} }

View File

@ -1,3 +1,4 @@
import { Option } from "@/types/app";
/** /**
* Licensed to the Apache Software Foundation (ASF) under one or more * Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with * contributor license agreements. See the NOTICE file distributed with
@ -18,9 +19,10 @@ import { useAppStoreWithOut } from "@/store/modules/app";
import dateFormatStep from "@/utils/dateFormat"; import dateFormatStep from "@/utils/dateFormat";
import getLocalTime from "@/utils/localtime"; import getLocalTime from "@/utils/localtime";
import { QueryOrders } from "@/views/dashboard/data"; import { QueryOrders } from "@/views/dashboard/data";
import { EventParams } from "@/types/app";
export default function associateProcessor() { export default function associateProcessor(props: any) {
function eventAssociate(props: any) { function eventAssociate() {
if (!props.filters) { if (!props.filters) {
return; return;
} }
@ -64,7 +66,7 @@ export default function associateProcessor() {
}; };
return options; return options;
} }
function traceFilters(currentParams: any) { function traceFilters(currentParams: Nullable<EventParams>) {
const appStore = useAppStoreWithOut(); const appStore = useAppStoreWithOut();
if (!currentParams) { if (!currentParams) {
@ -92,6 +94,7 @@ export default function associateProcessor() {
} }
let queryOrder = QueryOrders[1].value; let queryOrder = QueryOrders[1].value;
let status = undefined; let status = undefined;
let latency = undefined;
if (currentParams.seriesName.includes("_sla")) { if (currentParams.seriesName.includes("_sla")) {
queryOrder = QueryOrders[0].value; queryOrder = QueryOrders[0].value;
status = "ERROR"; status = "ERROR";
@ -99,10 +102,18 @@ export default function associateProcessor() {
if (currentParams.seriesName.includes("_apdex")) { if (currentParams.seriesName.includes("_apdex")) {
status = "ERROR"; status = "ERROR";
} }
if (props.option.series) {
latency = props.option.series.map(
(d: { name: string; data: number[][] }) => {
return { [d.name]: d.data[currentParams.dataIndex] };
}
);
}
const item = { const item = {
duration, duration,
queryOrder, queryOrder,
status, status,
latency,
}; };
return item; return item;
} }

View File

@ -57,7 +57,6 @@ export const traceStore = defineStore({
actions: { actions: {
setTraceCondition(data: any) { setTraceCondition(data: any) {
this.conditions = { ...this.conditions, ...data }; this.conditions = { ...this.conditions, ...data };
console.log(this.conditions.queryOrder);
}, },
setCurrentTrace(trace: Trace) { setCurrentTrace(trace: Trace) {
this.currentTrace = trace; this.currentTrace = trace;