mirror of
https://github.com/apache/skywalking-booster-ui.git
synced 2025-05-13 08:17:33 +00:00
feat: add expressions for instance list
This commit is contained in:
parent
aeea5b6241
commit
0de66abb3b
@ -87,6 +87,7 @@ limitations under the License. -->
|
|||||||
import type { InstanceListConfig } from "@/types/dashboard";
|
import type { InstanceListConfig } from "@/types/dashboard";
|
||||||
import type { Instance } from "@/types/selector";
|
import type { Instance } from "@/types/selector";
|
||||||
import { useQueryPodsMetrics, usePodsSource } from "@/hooks/useMetricsProcessor";
|
import { useQueryPodsMetrics, usePodsSource } from "@/hooks/useMetricsProcessor";
|
||||||
|
import { useExpressionsQueryPodsMetrics } from "@/hooks/useExpressionsProcessor";
|
||||||
import { EntityType } from "../data";
|
import { EntityType } from "../data";
|
||||||
import router from "@/router";
|
import router from "@/router";
|
||||||
import getDashboard from "@/hooks/useDashboardsSession";
|
import getDashboard from "@/hooks/useDashboardsSession";
|
||||||
@ -102,6 +103,9 @@ limitations under the License. -->
|
|||||||
metrics: string[];
|
metrics: string[];
|
||||||
metricTypes: string[];
|
metricTypes: string[];
|
||||||
isEdit: boolean;
|
isEdit: boolean;
|
||||||
|
metricMode: string;
|
||||||
|
expressions: string[];
|
||||||
|
typesOfMQE: string[];
|
||||||
} & { metricConfig: MetricConfigOpt[] }
|
} & { metricConfig: MetricConfigOpt[] }
|
||||||
>,
|
>,
|
||||||
default: () => ({
|
default: () => ({
|
||||||
@ -150,6 +154,10 @@ limitations under the License. -->
|
|||||||
if (!currentInstances.length) {
|
if (!currentInstances.length) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (props.config.metricMode === "Expression") {
|
||||||
|
queryInstanceExpressions(currentInstances);
|
||||||
|
return;
|
||||||
|
}
|
||||||
const metrics = props.config.metrics || [];
|
const metrics = props.config.metrics || [];
|
||||||
const types = props.config.metricTypes || [];
|
const types = props.config.metricTypes || [];
|
||||||
|
|
||||||
@ -174,6 +182,26 @@ limitations under the License. -->
|
|||||||
instances.value = currentInstances;
|
instances.value = currentInstances;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function queryInstanceExpressions(currentInstances: Instance[]) {
|
||||||
|
const expressions = props.config.expressions || [];
|
||||||
|
const typesOfMQE = props.config.typesOfMQE || [];
|
||||||
|
|
||||||
|
if (expressions.length && expressions[0] && typesOfMQE.length && typesOfMQE[0]) {
|
||||||
|
const params = await useExpressionsQueryPodsMetrics(
|
||||||
|
currentInstances,
|
||||||
|
{ ...props.config, metricConfig: metricConfig.value || [], typesOfMQE, expressions },
|
||||||
|
EntityType[3].value,
|
||||||
|
);
|
||||||
|
instances.value = params.data;
|
||||||
|
colMetrics.value = params.names;
|
||||||
|
metricTypes.value = params.metricTypesArr;
|
||||||
|
metricConfig.value = params.metricConfigArr;
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
instances.value = currentInstances;
|
||||||
|
}
|
||||||
|
|
||||||
function clickInstance(scope: any) {
|
function clickInstance(scope: any) {
|
||||||
const { dashboard } = getDashboard({
|
const { dashboard } = getDashboard({
|
||||||
name: props.config.dashboardName,
|
name: props.config.dashboardName,
|
||||||
@ -207,7 +235,12 @@ limitations under the License. -->
|
|||||||
}
|
}
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
() => [...(props.config.metricTypes || []), ...(props.config.metrics || []), ...(props.config.metricConfig || [])],
|
() => [
|
||||||
|
...(props.config.metricTypes || []),
|
||||||
|
...(props.config.metrics || []),
|
||||||
|
...(props.config.metricConfig || []),
|
||||||
|
...(props.config.expressions || []),
|
||||||
|
],
|
||||||
(data, old) => {
|
(data, old) => {
|
||||||
if (JSON.stringify(data) === JSON.stringify(old)) {
|
if (JSON.stringify(data) === JSON.stringify(old)) {
|
||||||
return;
|
return;
|
||||||
|
Loading…
Reference in New Issue
Block a user