Skip to content

Commit 2f4ad6f

Browse files
author
Tristan LOSADA BENINI
committed
feat(astrapia): add fields if not null
NETANOL-226
1 parent 741f7d1 commit 2f4ad6f

File tree

2 files changed

+16
-11
lines changed

2 files changed

+16
-11
lines changed

Astrapia/components/Graph.vue

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ export default {
8888
8989
//link arrow
9090
this.scene.append("defs").selectAll("marker")
91-
.data(["TCP"])
91+
.data(["Marker"])
9292
.enter().append("marker")
9393
.attr('markerUnits', 'userSpaceOnUse')
9494
.attr("id", function (d) {
@@ -145,24 +145,24 @@ export default {
145145
.data(edges, d => [d.source, d.target])
146146
.join(enter => enter.insert("path", "circle")
147147
.attr("fill", "none")
148-
.attr("stroke-width", d => packetCountScale(d.packetCount))
149-
.attr("stroke", d => colorScale(d.byteCount))
150-
.attr("marker-end", "url(#TCP)"));
148+
.attr("stroke-width", d => d.width ?? packetCountScale(d.packetCount))
149+
.attr("stroke", d => d.hexColor ?? colorScale(d.byteCount))
150+
.attr("marker-end", "url(#Marker)"));
151151
152152
this.linkHitArea = this.linkHitArea
153153
.data(edges, d => [d.source, d.target])
154154
.join(enter => enter.insert("path", "circle"))
155155
.call(link => link.append("title")
156-
.text(d => `Bytes: ${d.byteCount} \nPackets: ${d.packetCount} \nProtocols: ${d.dataProtocol}`));
156+
.text(d => `Bytes: ${d.byteCount} \nPackets: ${d.packetCount} \nProtocol: ${d.dataProtocol}`));
157157
158158
this.node = this.node
159159
.data(nodes, d => d.id)
160160
.join(enter => enter.append("circle")
161161
.attr("r", 8)
162-
.attr("fill", "#537B87")
162+
.attr("fill", d => d.hexColor ?? "#537B87")
163163
.call(this.drag(this.simulation))
164164
.call(node => node.append("title")
165-
.text(d => d.name))
165+
.text(d => `IP: ${d.name} ${d.tags ? `\nTags: ${d.tags}` : ''}`))
166166
);
167167
168168
this.label = this.label
@@ -171,7 +171,7 @@ export default {
171171
.attr("text-anchor", "middle")
172172
.attr("dy", "1.8em")
173173
.attr("font-size", "10px")
174-
.text(d => d.name)
174+
.text(d => d.dnsName ?? d.name)
175175
);
176176
177177
let selectedNode = null;

Astrapia/services/topology.service.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
import ApiService from "~/services/restService";
22

33
export interface GraphNode {
4-
id: string
5-
name: string
4+
id: string,
5+
name: string,
6+
dnsName: string | null,
7+
hexColor: string | null,
8+
tags: [] | null
69
}
710

811
export interface GraphEdge {
@@ -11,7 +14,9 @@ export interface GraphEdge {
1114
target: string,
1215
packetCount: number,
1316
byteCount: number,
14-
dataProtocol: string
17+
dataProtocol: string,
18+
width: number | null,
19+
hexColor: string | null
1520
}
1621

1722
export interface IGraphStatistics {

0 commit comments

Comments
 (0)