mirror of
https://github.com/apache/skywalking-booster-ui.git
synced 2025-07-20 14:37:34 +00:00
update legend
This commit is contained in:
parent
924cf01d95
commit
d6b25f3746
@ -394,6 +394,7 @@ export const topologyStore = defineStore({
|
|||||||
queryStr: string;
|
queryStr: string;
|
||||||
conditions: { [key: string]: unknown };
|
conditions: { [key: string]: unknown };
|
||||||
}) {
|
}) {
|
||||||
|
console.log(param);
|
||||||
const res: AxiosResponse = await query(param);
|
const res: AxiosResponse = await query(param);
|
||||||
|
|
||||||
if (res.data.errors) {
|
if (res.data.errors) {
|
||||||
|
@ -168,7 +168,12 @@ async function init() {
|
|||||||
svg.value.call(zoom(d3, graph.value));
|
svg.value.call(zoom(d3, graph.value));
|
||||||
// legend
|
// legend
|
||||||
legend.value = graph.value.append("g").attr("class", "topo-legend");
|
legend.value = graph.value.append("g").attr("class", "topo-legend");
|
||||||
topoLegend(legend.value, height.value, width.value, settings.value.legend);
|
topoLegend(
|
||||||
|
legend.value,
|
||||||
|
height.value,
|
||||||
|
width.value,
|
||||||
|
settings.value.description
|
||||||
|
);
|
||||||
svg.value.on("click", (event: any) => {
|
svg.value.on("click", (event: any) => {
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
@ -215,6 +215,20 @@ limitations under the License. -->
|
|||||||
</span>
|
</span>
|
||||||
<div v-show="index !== legend.metric.length - 1">&&</div>
|
<div v-show="index !== legend.metric.length - 1">&&</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="label">Healthy Description</div>
|
||||||
|
<el-input
|
||||||
|
v-model="description.healthy"
|
||||||
|
placeholder="Please input description"
|
||||||
|
size="small"
|
||||||
|
class="mt-5"
|
||||||
|
/>
|
||||||
|
<div class="label">Unhealthy Description</div>
|
||||||
|
<el-input
|
||||||
|
v-model="description.unhealthy"
|
||||||
|
placeholder="Please input description"
|
||||||
|
size="small"
|
||||||
|
class="mt-5"
|
||||||
|
/>
|
||||||
<el-button
|
<el-button
|
||||||
@click="setLegend"
|
@click="setLegend"
|
||||||
class="legend-btn"
|
class="legend-btn"
|
||||||
@ -289,6 +303,7 @@ const legend = reactive<{
|
|||||||
metric: l ? selectedGrid.legend : [{ name: "", condition: "", value: "" }],
|
metric: l ? selectedGrid.legend : [{ name: "", condition: "", value: "" }],
|
||||||
});
|
});
|
||||||
const configType = ref<string>("");
|
const configType = ref<string>("");
|
||||||
|
const description = reactive<any>(selectedGrid.description || {});
|
||||||
|
|
||||||
getMetricList();
|
getMetricList();
|
||||||
async function getMetricList() {
|
async function getMetricList() {
|
||||||
@ -347,6 +362,10 @@ async function setLegend() {
|
|||||||
updateSettings();
|
updateSettings();
|
||||||
const ids = topologyStore.nodes.map((d: Node) => d.id);
|
const ids = topologyStore.nodes.map((d: Node) => d.id);
|
||||||
const names = dashboardStore.selectedGrid.legend.map((d: any) => d.name);
|
const names = dashboardStore.selectedGrid.legend.map((d: any) => d.name);
|
||||||
|
if (!names.length) {
|
||||||
|
emit("updateNodes");
|
||||||
|
return;
|
||||||
|
}
|
||||||
const param = await useQueryTopologyMetrics(names, ids);
|
const param = await useQueryTopologyMetrics(names, ids);
|
||||||
const res = await topologyStore.getLegendMetrics(param);
|
const res = await topologyStore.getLegendMetrics(param);
|
||||||
|
|
||||||
@ -413,6 +432,7 @@ function updateSettings(metricConfig?: { [key: string]: MetricConfigOpt[] }) {
|
|||||||
nodeMetrics: states.nodeMetrics,
|
nodeMetrics: states.nodeMetrics,
|
||||||
legend: metrics,
|
legend: metrics,
|
||||||
...metricConfig,
|
...metricConfig,
|
||||||
|
description,
|
||||||
};
|
};
|
||||||
dashboardStore.selectWidget(param);
|
dashboardStore.selectWidget(param);
|
||||||
dashboardStore.setConfigs(param);
|
dashboardStore.setConfigs(param);
|
||||||
@ -509,7 +529,7 @@ function setConfigType(type: string) {
|
|||||||
|
|
||||||
.inputs {
|
.inputs {
|
||||||
margin-top: 8px;
|
margin-top: 8px;
|
||||||
width: 370px;
|
width: 355px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.item {
|
.item {
|
||||||
|
@ -20,32 +20,25 @@ export default function topoLegend(
|
|||||||
graph: any,
|
graph: any,
|
||||||
clientHeight: number,
|
clientHeight: number,
|
||||||
clientWidth: number,
|
clientWidth: number,
|
||||||
config: any
|
description: any
|
||||||
) {
|
) {
|
||||||
for (const item of ["CUBE", "CUBEERROR"]) {
|
for (const item of ["CUBE", "CUBEERROR"]) {
|
||||||
graph
|
graph
|
||||||
.append("image")
|
.append("image")
|
||||||
.attr("width", 30)
|
.attr("width", 30)
|
||||||
.attr("height", 30)
|
.attr("height", 30)
|
||||||
.attr("x", clientWidth - (item === "CUBEERROR" ? 340 : 440))
|
.attr("x", clientWidth - (item === "CUBEERROR" ? 200 : 410))
|
||||||
.attr("y", clientHeight + 50)
|
.attr("y", clientHeight + 50)
|
||||||
.attr("xlink:href", () =>
|
.attr("xlink:href", () =>
|
||||||
item === "CUBEERROR" ? icons.CUBEERROR : icons.CUBE
|
item === "CUBEERROR" ? icons.CUBEERROR : icons.CUBE
|
||||||
);
|
);
|
||||||
graph
|
graph
|
||||||
.append("text")
|
.append("text")
|
||||||
.attr("x", clientWidth - (item === "CUBEERROR" ? 310 : 410))
|
.attr("x", clientWidth - (item === "CUBEERROR" ? 170 : 380))
|
||||||
.attr("y", clientHeight + 70)
|
.attr("y", clientHeight + 70)
|
||||||
.text(() => {
|
.text(() => {
|
||||||
const l = config || [];
|
const desc = description || {};
|
||||||
const str = l
|
return item === "CUBEERROR" ? desc.unhealthy || "" : desc.healthy || "";
|
||||||
.map((d: any) => `${d.name} ${d.condition} ${d.value}`)
|
|
||||||
.join(" and ");
|
|
||||||
return item === "CUBEERROR"
|
|
||||||
? config && config.length
|
|
||||||
? `Unhealthy (${str})`
|
|
||||||
: "Unhealthy"
|
|
||||||
: "Healthy";
|
|
||||||
})
|
})
|
||||||
.style("fill", "#efeff1")
|
.style("fill", "#efeff1")
|
||||||
.style("font-size", "11px");
|
.style("font-size", "11px");
|
||||||
|
Loading…
Reference in New Issue
Block a user