mirror of
https://github.com/apache/skywalking-booster-ui.git
synced 2025-05-12 15:52:57 +00:00
feat: update expressions config
This commit is contained in:
parent
55d9df3cbb
commit
ddd24fa769
@ -31,7 +31,7 @@ limitations under the License. -->
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { nextTick, ref } from "vue";
|
import { nextTick, ref, watch } from "vue";
|
||||||
import type { PropType } from "vue";
|
import type { PropType } from "vue";
|
||||||
import { ElInput } from "element-plus";
|
import { ElInput } from "element-plus";
|
||||||
|
|
||||||
@ -69,6 +69,13 @@ limitations under the License. -->
|
|||||||
inputValue.value = "";
|
inputValue.value = "";
|
||||||
emits("change", dynamicTags.value);
|
emits("change", dynamicTags.value);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => props.tags,
|
||||||
|
() => {
|
||||||
|
dynamicTags.value = props.tags || [];
|
||||||
|
},
|
||||||
|
);
|
||||||
</script>
|
</script>
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
.input-name {
|
.input-name {
|
||||||
|
@ -42,7 +42,7 @@ interface TopologyState {
|
|||||||
nodeMetricValue: MetricVal;
|
nodeMetricValue: MetricVal;
|
||||||
linkServerMetrics: MetricVal;
|
linkServerMetrics: MetricVal;
|
||||||
linkClientMetrics: MetricVal;
|
linkClientMetrics: MetricVal;
|
||||||
hierarchyNodeMetrics: MetricVal;
|
hierarchyNodeMetrics: { [key: string]: MetricVal };
|
||||||
hierarchyServiceNode: Nullable<Node>;
|
hierarchyServiceNode: Nullable<Node>;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -185,8 +185,8 @@ export const topologyStore = defineStore({
|
|||||||
this.hierarchyServiceNodes.push(d);
|
this.hierarchyServiceNodes.push(d);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
setHierarchyNodeMetricValue(m: MetricVal) {
|
setHierarchyNodeMetricValue(m: MetricVal, layer: string) {
|
||||||
this.hierarchyNodeMetrics = m;
|
this.hierarchyNodeMetrics[layer] = m;
|
||||||
},
|
},
|
||||||
setLinkServerMetrics(m: MetricVal) {
|
setLinkServerMetrics(m: MetricVal) {
|
||||||
this.linkServerMetrics = m;
|
this.linkServerMetrics = m;
|
||||||
@ -590,19 +590,17 @@ export const topologyStore = defineStore({
|
|||||||
this.setInstanceTopology(res.data.data.hierarchyInstanceTopology || {});
|
this.setInstanceTopology(res.data.data.hierarchyInstanceTopology || {});
|
||||||
return res.data;
|
return res.data;
|
||||||
},
|
},
|
||||||
async queryHierarchyNodeExpressions(expressions: string[]) {
|
async queryHierarchyNodeExpressions(expressions: string[], layer: string) {
|
||||||
|
const nodes = this.hierarchyServiceNodes.filter((n: Node) => n.layer === layer);
|
||||||
if (!expressions.length) {
|
if (!expressions.length) {
|
||||||
this.setHierarchyNodeMetricValue({});
|
this.setHierarchyNodeMetricValue({}, layer);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!this.hierarchyServiceNodes.length) {
|
if (!this.hierarchyServiceNodes.length) {
|
||||||
this.setHierarchyNodeMetricValue({});
|
this.setHierarchyNodeMetricValue({}, layer);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const { getExpressionQuery, handleExpressionValues } = useQueryTopologyExpressionsProcessor(
|
const { getExpressionQuery, handleExpressionValues } = useQueryTopologyExpressionsProcessor(expressions, nodes);
|
||||||
expressions,
|
|
||||||
this.hierarchyServiceNodes,
|
|
||||||
);
|
|
||||||
const param = getExpressionQuery();
|
const param = getExpressionQuery();
|
||||||
const res = await this.getNodeExpressionValue(param);
|
const res = await this.getNodeExpressionValue(param);
|
||||||
if (res.errors) {
|
if (res.errors) {
|
||||||
@ -610,7 +608,7 @@ export const topologyStore = defineStore({
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const metrics = handleExpressionValues(res.data);
|
const metrics = handleExpressionValues(res.data);
|
||||||
this.setHierarchyNodeMetricValue(metrics);
|
this.setHierarchyNodeMetricValue(metrics, layer);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
4
src/types/dashboard.d.ts
vendored
4
src/types/dashboard.d.ts
vendored
@ -83,6 +83,10 @@ export type MetricConfigOpt = {
|
|||||||
detailLabel?: string;
|
detailLabel?: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export interface HierarchyServicesConfigMap {
|
||||||
|
[key: string]: HierarchyServicesConfig;
|
||||||
|
}
|
||||||
|
|
||||||
export interface HierarchyServicesConfig {
|
export interface HierarchyServicesConfig {
|
||||||
layer: string;
|
layer: string;
|
||||||
nodeExpressions: string[];
|
nodeExpressions: string[];
|
||||||
|
@ -32,12 +32,12 @@ limitations under the License. -->
|
|||||||
<Icon class="cp ml-5" iconName="mode_edit" size="middle" />
|
<Icon class="cp ml-5" iconName="mode_edit" size="middle" />
|
||||||
</span>
|
</span>
|
||||||
</template>
|
</template>
|
||||||
<Metrics :type="'hierarchyServicesConfig'" :isExpression="true" @update="updateSettings" />
|
<Metrics :type="'hierarchyServicesConfig'" :layer="currentConfig.layer" @update="updateSettings" />
|
||||||
</el-popover>
|
</el-popover>
|
||||||
</div>
|
</div>
|
||||||
<div v-if="currentConfig.layer">
|
<div v-if="currentConfig.layer">
|
||||||
<Tags
|
<Tags
|
||||||
:tags="currentConfig.nodeExpressions"
|
:tags="currentConfig.nodeExpressions || []"
|
||||||
:vertical="true"
|
:vertical="true"
|
||||||
:text="t('addExpressions')"
|
:text="t('addExpressions')"
|
||||||
@change="(param) => changeNodeExpressions(param)"
|
@change="(param) => changeNodeExpressions(param)"
|
||||||
@ -46,10 +46,10 @@ limitations under the License. -->
|
|||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { onMounted, ref } from "vue";
|
import { onMounted, ref, reactive } from "vue";
|
||||||
import { useI18n } from "vue-i18n";
|
import { useI18n } from "vue-i18n";
|
||||||
import { ElMessage } from "element-plus";
|
import { ElMessage } from "element-plus";
|
||||||
import type { HierarchyServicesConfig } from "@/types/dashboard";
|
import type { HierarchyServicesConfig, MetricConfigOpt } from "@/types/dashboard";
|
||||||
import type { Node } from "@/types/topology";
|
import type { Node } from "@/types/topology";
|
||||||
import type { Option } from "@/types/app";
|
import type { Option } from "@/types/app";
|
||||||
import { useDashboardStore } from "@/store/modules/dashboard";
|
import { useDashboardStore } from "@/store/modules/dashboard";
|
||||||
@ -63,7 +63,7 @@ limitations under the License. -->
|
|||||||
const topologyStore = useTopologyStore();
|
const topologyStore = useTopologyStore();
|
||||||
const selectorStore = useSelectorStore();
|
const selectorStore = useSelectorStore();
|
||||||
const hierarchyServicesConfig = dashboardStore.selectedGrid.hierarchyServicesConfig || [];
|
const hierarchyServicesConfig = dashboardStore.selectedGrid.hierarchyServicesConfig || [];
|
||||||
const currentConfig = ref<HierarchyServicesConfig>(hierarchyServicesConfig[0] || {});
|
const currentConfig = reactive<HierarchyServicesConfig>(hierarchyServicesConfig[0] || {});
|
||||||
const layers = ref<Option[]>([]);
|
const layers = ref<Option[]>([]);
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
@ -72,27 +72,31 @@ limitations under the License. -->
|
|||||||
function changeLayer(opt: Option[]) {
|
function changeLayer(opt: Option[]) {
|
||||||
const hierarchyServicesConfig = dashboardStore.selectedGrid.hierarchyServicesConfig || [];
|
const hierarchyServicesConfig = dashboardStore.selectedGrid.hierarchyServicesConfig || [];
|
||||||
const layer = opt[0].value;
|
const layer = opt[0].value;
|
||||||
|
const config = hierarchyServicesConfig.find((d: HierarchyServicesConfig) => d.layer === layer) || {};
|
||||||
currentConfig.value = hierarchyServicesConfig.find((d: HierarchyServicesConfig) => d.layer === layer) || { layer };
|
currentConfig.layer = layer;
|
||||||
|
currentConfig.nodeExpressions = config.nodeExpressions || [];
|
||||||
}
|
}
|
||||||
|
|
||||||
function changeNodeExpressions(param: string[]) {
|
function changeNodeExpressions(param: string[]) {
|
||||||
currentConfig.value.nodeExpressions = param;
|
currentConfig.nodeExpressions = param;
|
||||||
updateSettings();
|
updateSettings();
|
||||||
if (!param.length) {
|
if (!param.length) {
|
||||||
topologyStore.setHierarchyServiceNode({});
|
topologyStore.setHierarchyServiceNode({}, currentConfig.layer);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
topologyStore.queryHierarchyNodeExpressions(param);
|
topologyStore.queryHierarchyNodeExpressions(param, currentConfig.layer);
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateSettings() {
|
function updateSettings(metricConfig?: { [key: string]: MetricConfigOpt[] }) {
|
||||||
|
if (metricConfig) {
|
||||||
|
currentConfig.expressionsConfig = Object.values(metricConfig)[0];
|
||||||
|
}
|
||||||
const config = dashboardStore.selectedGrid.hierarchyServicesConfig || [];
|
const config = dashboardStore.selectedGrid.hierarchyServicesConfig || [];
|
||||||
const index = config.findIndex((d: HierarchyServicesConfig) => d.layer === currentConfig.value.layer);
|
const index = config.findIndex((d: HierarchyServicesConfig) => d.layer === currentConfig.layer);
|
||||||
if (index < 0) {
|
if (index < 0) {
|
||||||
config.push(currentConfig.value);
|
config.push(JSON.parse(JSON.stringify(currentConfig)));
|
||||||
} else {
|
} else {
|
||||||
config[index] = currentConfig.value;
|
config[index] = JSON.parse(JSON.stringify(currentConfig));
|
||||||
}
|
}
|
||||||
|
|
||||||
const hierarchyServicesConfig = config.filter((d: HierarchyServicesConfig) => d.layer && d.nodeExpressions);
|
const hierarchyServicesConfig = config.filter((d: HierarchyServicesConfig) => d.layer && d.nodeExpressions);
|
||||||
|
@ -63,6 +63,7 @@ limitations under the License. -->
|
|||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
type: { type: String, default: "" },
|
type: { type: String, default: "" },
|
||||||
isExpression: { type: Boolean, default: true },
|
isExpression: { type: Boolean, default: true },
|
||||||
|
layer: { type: String, default: "" },
|
||||||
});
|
});
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
const emit = defineEmits(["update"]);
|
const emit = defineEmits(["update"]);
|
||||||
@ -76,7 +77,12 @@ limitations under the License. -->
|
|||||||
linkClientMetrics,
|
linkClientMetrics,
|
||||||
nodeExpressions,
|
nodeExpressions,
|
||||||
nodeMetrics,
|
nodeMetrics,
|
||||||
|
hierarchyServicesConfig,
|
||||||
} = dashboardStore.selectedGrid;
|
} = dashboardStore.selectedGrid;
|
||||||
|
let item: any = {};
|
||||||
|
if (hierarchyServicesConfig && props.layer) {
|
||||||
|
item = hierarchyServicesConfig.find((d: any) => d.layer === props.layer) || {};
|
||||||
|
}
|
||||||
switch (props.type) {
|
switch (props.type) {
|
||||||
case "linkServerMetricConfig":
|
case "linkServerMetricConfig":
|
||||||
metrics = props.isExpression ? linkServerExpressions : linkServerMetrics;
|
metrics = props.isExpression ? linkServerExpressions : linkServerMetrics;
|
||||||
@ -87,6 +93,9 @@ limitations under the License. -->
|
|||||||
case "nodeMetricConfig":
|
case "nodeMetricConfig":
|
||||||
metrics = props.isExpression ? nodeExpressions : nodeMetrics;
|
metrics = props.isExpression ? nodeExpressions : nodeMetrics;
|
||||||
break;
|
break;
|
||||||
|
case "hierarchyServicesConfig":
|
||||||
|
metrics = item.nodeExpressions || [];
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
return metrics || [];
|
return metrics || [];
|
||||||
});
|
});
|
||||||
@ -105,7 +114,11 @@ limitations under the License. -->
|
|||||||
const currentIndex = ref<number>(0);
|
const currentIndex = ref<number>(0);
|
||||||
const getMetricConfig = computed(() => {
|
const getMetricConfig = computed(() => {
|
||||||
let config = [];
|
let config = [];
|
||||||
|
const { hierarchyServicesConfig } = dashboardStore.selectedGrid;
|
||||||
|
let item: any = {};
|
||||||
|
if (hierarchyServicesConfig && props.layer) {
|
||||||
|
item = hierarchyServicesConfig.find((d: any) => d.layer === props.layer) || {};
|
||||||
|
}
|
||||||
switch (props.type) {
|
switch (props.type) {
|
||||||
case "linkServerMetricConfig":
|
case "linkServerMetricConfig":
|
||||||
config = dashboardStore.selectedGrid.linkServerMetricConfig;
|
config = dashboardStore.selectedGrid.linkServerMetricConfig;
|
||||||
@ -116,6 +129,9 @@ limitations under the License. -->
|
|||||||
case "nodeMetricConfig":
|
case "nodeMetricConfig":
|
||||||
config = dashboardStore.selectedGrid.nodeMetricConfig;
|
config = dashboardStore.selectedGrid.nodeMetricConfig;
|
||||||
break;
|
break;
|
||||||
|
case "hierarchyServicesConfig":
|
||||||
|
config = item.expressionsConfig || [];
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
return config || [];
|
return config || [];
|
||||||
});
|
});
|
||||||
|
@ -123,6 +123,7 @@ limitations under the License. -->
|
|||||||
import zoom from "@/views/dashboard/related/components/utils/zoom";
|
import zoom from "@/views/dashboard/related/components/utils/zoom";
|
||||||
import { useQueryTopologyExpressionsProcessor } from "@/hooks/useExpressionsProcessor";
|
import { useQueryTopologyExpressionsProcessor } from "@/hooks/useExpressionsProcessor";
|
||||||
import HierarchySettings from "../config/HierarchySettings.vue";
|
import HierarchySettings from "../config/HierarchySettings.vue";
|
||||||
|
import type { HierarchyServicesConfig } from "@/types/dashboard";
|
||||||
|
|
||||||
/*global Nullable, defineProps */
|
/*global Nullable, defineProps */
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
@ -262,11 +263,13 @@ limitations under the License. -->
|
|||||||
return Number(d[legendMQE.expression]) && d.isReal ? icons.CUBEERROR : icons.CUBE;
|
return Number(d[legendMQE.expression]) && d.isReal ? icons.CUBEERROR : icons.CUBE;
|
||||||
}
|
}
|
||||||
function showNodeTip(event: MouseEvent, data: Node) {
|
function showNodeTip(event: MouseEvent, data: Node) {
|
||||||
const nodeMetrics: string[] = settings.value.nodeExpressions;
|
const config: HierarchyServicesConfig =
|
||||||
const nodeMetricConfig = settings.value.nodeMetricConfig || [];
|
(settings.value.hierarchyServicesConfig || []).find((d: HierarchyServicesConfig) => d.layer === data.layer) || {};
|
||||||
const html = nodeMetrics.map((m, index) => {
|
const exprssions = config.nodeExpressions || [];
|
||||||
|
const nodeMetricConfig = config.expressionsConfig || [];
|
||||||
|
const html = exprssions.map((m, index) => {
|
||||||
const metric =
|
const metric =
|
||||||
topologyStore.hierarchyNodeMetrics[m].values.find(
|
topologyStore.hierarchyNodeMetrics[data.layer || ""][m].values.find(
|
||||||
(val: { id: string; value: unknown }) => val.id === data.id,
|
(val: { id: string; value: unknown }) => val.id === data.id,
|
||||||
) || {};
|
) || {};
|
||||||
const opt: MetricConfigOpt = nodeMetricConfig[index] || {};
|
const opt: MetricConfigOpt = nodeMetricConfig[index] || {};
|
||||||
|
Loading…
Reference in New Issue
Block a user