mirror of
https://github.com/apache/skywalking-booster-ui.git
synced 2025-07-18 18:45:23 +00:00
add marks for topology calls
This commit is contained in:
parent
87a5553e6d
commit
dd3604b7b1
BIN
src/assets/img/technologies/HTTPDARK.png
Normal file
BIN
src/assets/img/technologies/HTTPDARK.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.6 KiB |
BIN
src/assets/img/technologies/HTTPS.png
Normal file
BIN
src/assets/img/technologies/HTTPS.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 847 B |
@ -94,6 +94,8 @@ export const ProcessTopology = {
|
||||
source
|
||||
detectPoints
|
||||
target
|
||||
sourceComponents
|
||||
targetComponents
|
||||
}
|
||||
}
|
||||
`,
|
||||
|
@ -14,7 +14,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import icons from "@/assets/img/icons";
|
||||
export const linkElement = (graph: any) => {
|
||||
const linkEnter = graph
|
||||
.append("path")
|
||||
@ -23,8 +23,8 @@ export const linkElement = (graph: any) => {
|
||||
.attr("stroke", "#97B0F8")
|
||||
.attr("d", (d: any) => {
|
||||
const controlPos = computeControlPoint(
|
||||
[d.source.x, d.source.y - 5],
|
||||
[d.target.x, d.target.y - 5],
|
||||
[d.source.x, d.source.y],
|
||||
[d.target.x, d.target.y],
|
||||
0.5
|
||||
);
|
||||
if (d.lowerArc) {
|
||||
@ -34,7 +34,7 @@ export const linkElement = (graph: any) => {
|
||||
"M" +
|
||||
d.source.x +
|
||||
" " +
|
||||
(d.source.y - 5) +
|
||||
d.source.y +
|
||||
" " +
|
||||
"Q" +
|
||||
controlPos[0] +
|
||||
@ -43,34 +43,15 @@ export const linkElement = (graph: any) => {
|
||||
" " +
|
||||
d.target.x +
|
||||
" " +
|
||||
(d.target.y - 5)
|
||||
d.target.y
|
||||
);
|
||||
});
|
||||
return linkEnter;
|
||||
};
|
||||
export const anchorElement = (graph: any, funcs: any, tip: any) => {
|
||||
const linkEnter = graph
|
||||
.append("circle")
|
||||
.attr("class", "topo-line-anchor")
|
||||
.attr("r", 5)
|
||||
.attr("fill", "#97B0F8")
|
||||
.attr("transform", (d: any) => {
|
||||
const controlPos = computeControlPoint(
|
||||
[d.source.x, d.source.y - 5],
|
||||
[d.target.x, d.target.y - 5],
|
||||
0.5
|
||||
);
|
||||
if (d.lowerArc) {
|
||||
controlPos[1] = -controlPos[1];
|
||||
}
|
||||
const p = quadraticBezier(
|
||||
0.5,
|
||||
{ x: d.source.x, y: d.source.y - 5 },
|
||||
{ x: controlPos[0], y: controlPos[1] },
|
||||
{ x: d.target.x, y: d.target.y - 5 }
|
||||
);
|
||||
return `translate(${p[0]}, ${p[1]})`;
|
||||
})
|
||||
.append("g")
|
||||
.attr("style", "cursor: move;")
|
||||
.on("mouseover", function (event: unknown, d: unknown) {
|
||||
tip.html(funcs.tipHtml).show(d, this);
|
||||
})
|
||||
@ -80,6 +61,60 @@ export const anchorElement = (graph: any, funcs: any, tip: any) => {
|
||||
.on("click", (event: unknown, d: unknown) => {
|
||||
funcs.handleLinkClick(event, d);
|
||||
});
|
||||
linkEnter
|
||||
.append("text")
|
||||
.attr("fill", "#444")
|
||||
.attr("text-anchor", "middle")
|
||||
.attr("x", (d: any) => {
|
||||
const p = getMidpoint(d);
|
||||
return p[0] + 2;
|
||||
})
|
||||
.attr("y", (d: any) => {
|
||||
const p = getMidpoint(d);
|
||||
return p[1] + 5;
|
||||
})
|
||||
.text((d: any) => {
|
||||
const types = [...d.sourceComponents, ...d.targetComponents];
|
||||
if (types.includes("tcp")) {
|
||||
return "tcp";
|
||||
}
|
||||
if (types.includes("https")) {
|
||||
return "https";
|
||||
}
|
||||
if (types.includes("http")) {
|
||||
return "http";
|
||||
}
|
||||
if (types.includes("tls")) {
|
||||
return "tls";
|
||||
}
|
||||
});
|
||||
linkEnter
|
||||
.append("image")
|
||||
.attr("width", 15)
|
||||
.attr("height", 15)
|
||||
.attr("x", (d: any) => {
|
||||
const p = getMidpoint(d);
|
||||
return p[0] - 6;
|
||||
})
|
||||
.attr("y", (d: any) => {
|
||||
const p = getMidpoint(d);
|
||||
return p[1] - 16;
|
||||
})
|
||||
.attr("xlink:href", (d: any) => {
|
||||
const types = [...d.sourceComponents, ...d.targetComponents];
|
||||
if (types.includes("tcp")) {
|
||||
return icons.HTTPDARK;
|
||||
}
|
||||
if (types.includes("https")) {
|
||||
return icons.HTTPS;
|
||||
}
|
||||
if (types.includes("http")) {
|
||||
return icons.HTTPDARK;
|
||||
}
|
||||
if (types.includes("tls")) {
|
||||
return icons.HTTPS;
|
||||
}
|
||||
});
|
||||
return linkEnter;
|
||||
};
|
||||
export const arrowMarker = (graph: any) => {
|
||||
@ -130,3 +165,20 @@ function quadraticBezier(
|
||||
const y = (1 - t) * (1 - t) * ps.y + 2 * t * (1 - t) * pc.y + t * t * pe.y;
|
||||
return [x, y];
|
||||
}
|
||||
function getMidpoint(d: any) {
|
||||
const controlPos = computeControlPoint(
|
||||
[d.source.x, d.source.y],
|
||||
[d.target.x, d.target.y],
|
||||
0.5
|
||||
);
|
||||
if (d.lowerArc) {
|
||||
controlPos[1] = -controlPos[1];
|
||||
}
|
||||
const p = quadraticBezier(
|
||||
0.5,
|
||||
{ x: d.source.x, y: d.source.y },
|
||||
{ x: controlPos[0], y: controlPos[1] },
|
||||
{ x: d.target.x, y: d.target.y }
|
||||
);
|
||||
return p;
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ export default (d3: any, graph: any, funcs: any, tip: any) => {
|
||||
.append("text")
|
||||
.attr("fill", "#000")
|
||||
.attr("text-anchor", "middle")
|
||||
.attr("x", (d: any) => d.x + 5)
|
||||
.attr("x", (d: any) => d.x)
|
||||
.attr("y", (d: any) => d.y + 28)
|
||||
.text((d: { name: string }) =>
|
||||
d.name.length > 10 ? `${d.name.substring(0, 10)}...` : d.name
|
||||
|
@ -458,10 +458,6 @@ watch(
|
||||
right: 50px;
|
||||
}
|
||||
|
||||
.topo-line-anchor {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.topo-call {
|
||||
stroke-linecap: round;
|
||||
stroke-width: 2px;
|
||||
|
Loading…
Reference in New Issue
Block a user