mirror of
https://github.com/apache/skywalking-booster-ui.git
synced 2025-05-13 08:17:33 +00:00
feat: add expressions in independent widget page
This commit is contained in:
parent
95a03ff3df
commit
73f7eb362e
@ -55,9 +55,11 @@ limitations under the License. -->
|
|||||||
import { useSelectorStore } from "@/store/modules/selectors";
|
import { useSelectorStore } from "@/store/modules/selectors";
|
||||||
import { useDashboardStore } from "@/store/modules/dashboard";
|
import { useDashboardStore } from "@/store/modules/dashboard";
|
||||||
import { useQueryProcessor, useSourceProcessor } from "@/hooks/useMetricsProcessor";
|
import { useQueryProcessor, useSourceProcessor } from "@/hooks/useMetricsProcessor";
|
||||||
|
import { useExpressionsQueryProcessor, useExpressionsSourceProcessor } from "@/hooks/useExpressionsProcessor";
|
||||||
import graphs from "./graphs";
|
import graphs from "./graphs";
|
||||||
import { EntityType } from "./data";
|
import { EntityType } from "./data";
|
||||||
import timeFormat from "@/utils/timeFormat";
|
import timeFormat from "@/utils/timeFormat";
|
||||||
|
import { MetricModes } from "./data";
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
name: "WidgetPage",
|
name: "WidgetPage",
|
||||||
@ -125,7 +127,12 @@ limitations under the License. -->
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
async function queryMetrics() {
|
async function queryMetrics() {
|
||||||
const params = await useQueryProcessor({ ...config.value });
|
const isExpression = config.value.metricMode === MetricModes.Expression;
|
||||||
|
const params = isExpression
|
||||||
|
? await useExpressionsQueryProcessor({
|
||||||
|
...config.value,
|
||||||
|
})
|
||||||
|
: await useQueryProcessor({ ...config.value });
|
||||||
if (!params) {
|
if (!params) {
|
||||||
source.value = {};
|
source.value = {};
|
||||||
return;
|
return;
|
||||||
@ -141,7 +148,7 @@ limitations under the License. -->
|
|||||||
metricTypes: config.value.metricTypes || [],
|
metricTypes: config.value.metricTypes || [],
|
||||||
metricConfig: config.value.metricConfig || [],
|
metricConfig: config.value.metricConfig || [],
|
||||||
};
|
};
|
||||||
source.value = useSourceProcessor(json, d);
|
source.value = isExpression ? await useExpressionsSourceProcessor(json, d) : await useSourceProcessor(json, d);
|
||||||
}
|
}
|
||||||
watch(
|
watch(
|
||||||
() => appStoreWithOut.durationTime,
|
() => appStoreWithOut.durationTime,
|
||||||
|
@ -59,6 +59,7 @@ limitations under the License. -->
|
|||||||
import copy from "@/utils/copy";
|
import copy from "@/utils/copy";
|
||||||
import { RefreshOptions } from "@/views/dashboard/data";
|
import { RefreshOptions } from "@/views/dashboard/data";
|
||||||
import { TimeType } from "@/constants/data";
|
import { TimeType } from "@/constants/data";
|
||||||
|
import { MetricModes } from "../data";
|
||||||
|
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
const appStore = useAppStoreWithOut();
|
const appStore = useAppStoreWithOut();
|
||||||
@ -91,7 +92,8 @@ limitations under the License. -->
|
|||||||
step: appStore.durationRow.step,
|
step: appStore.durationRow.step,
|
||||||
utc: appStore.utc,
|
utc: appStore.utc,
|
||||||
});
|
});
|
||||||
const { widget, graph, metrics, metricTypes, metricConfig } = dashboardStore.selectedGrid;
|
const { widget, graph, metrics, metricTypes, metricConfig, metricMode, expressions, typesOfMQE } =
|
||||||
|
dashboardStore.selectedGrid;
|
||||||
const c = (metricConfig || []).map((d: any) => {
|
const c = (metricConfig || []).map((d: any) => {
|
||||||
const t: any = {};
|
const t: any = {};
|
||||||
if (d.label) {
|
if (d.label) {
|
||||||
@ -105,11 +107,17 @@ limitations under the License. -->
|
|||||||
const opt: any = {
|
const opt: any = {
|
||||||
type: dashboardStore.selectedGrid.type,
|
type: dashboardStore.selectedGrid.type,
|
||||||
graph: graph,
|
graph: graph,
|
||||||
metrics: metrics,
|
metricMode,
|
||||||
metricTypes: metricTypes,
|
|
||||||
metricConfig: c,
|
metricConfig: c,
|
||||||
height: dashboardStore.selectedGrid.h * 20 + 60,
|
height: dashboardStore.selectedGrid.h * 20 + 60,
|
||||||
};
|
};
|
||||||
|
if (metricMode === MetricModes.Expression) {
|
||||||
|
opt.expressions = expressions;
|
||||||
|
opt.typesOfMQE = typesOfMQE;
|
||||||
|
} else {
|
||||||
|
opt.metrics = metrics;
|
||||||
|
opt.metricTypes = metricTypes;
|
||||||
|
}
|
||||||
if (widget) {
|
if (widget) {
|
||||||
opt.widget = {
|
opt.widget = {
|
||||||
title: encodeURIComponent(widget.title || ""),
|
title: encodeURIComponent(widget.title || ""),
|
||||||
|
@ -127,6 +127,7 @@ limitations under the License. -->
|
|||||||
queryServices();
|
queryServices();
|
||||||
|
|
||||||
async function queryServices() {
|
async function queryServices() {
|
||||||
|
console.log(props.config);
|
||||||
chartLoading.value = true;
|
chartLoading.value = true;
|
||||||
const resp = await selectorStore.fetchServices(dashboardStore.layerId);
|
const resp = await selectorStore.fetchServices(dashboardStore.layerId);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user