Skip to content

Commit a99ec5b

Browse files
pgallinoManuel-Pol
andauthored
Refactor UI/mac ip rightbar info (#256)
Co-authored-by: Manuel <[email protected]>
1 parent 1b2680a commit a99ec5b

File tree

3 files changed

+17
-20
lines changed

3 files changed

+17
-20
lines changed

src/graphics/renderables/device_info.ts

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,27 @@ export class DeviceInfo extends BaseInfo {
4040
);
4141

4242
const layer = this.device.viewgraph.getLayer();
43+
const showIp = this.device.getType() !== DeviceType.Switch;
44+
const showMac = layer === Layer.Link;
4345

44-
if (layer == Layer.Link) {
45-
this.device.interfaces.forEach((iface) =>
46+
if (showIp) {
47+
this.device.interfaces.forEach((iface) => {
4648
this.information.addField(
47-
TOOLTIP_KEYS.MAC_ADDRESS,
49+
TOOLTIP_KEYS.IP_ADDRESS + (iface.name ? ` (${iface.name})` : ""),
50+
iface.ip.toString(),
51+
TOOLTIP_KEYS.IP_ADDRESS,
52+
);
53+
});
54+
}
55+
56+
if (showMac) {
57+
this.device.interfaces.forEach((iface) => {
58+
this.information.addField(
59+
TOOLTIP_KEYS.MAC_ADDRESS + (iface.name ? ` (${iface.name})` : ""),
4860
iface.mac.toString(),
4961
TOOLTIP_KEYS.MAC_ADDRESS,
50-
),
51-
);
62+
);
63+
});
5264
}
5365
}
5466

src/types/view-devices/vHost.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import { GlobalContext } from "../../context";
2020
import { DataHost } from "../data-devices";
2121
import { dropPacket } from "../packet";
2222
import { DeviceInfo } from "../../graphics/renderables/device_info";
23-
import { TOOLTIP_KEYS } from "../../utils/constants/tooltips_constants";
2423
import { TcpSegment } from "../../packets/tcp";
2524
import {
2625
TcpListener,
@@ -84,13 +83,6 @@ export class ViewHost extends ViewNetworkDevice {
8483
const programList = getProgramList(this.viewgraph, this.id);
8584

8685
const info = new DeviceInfo(this);
87-
this.interfaces.forEach((iface) =>
88-
info.addField(
89-
TOOLTIP_KEYS.IP_ADDRESS,
90-
iface.ip.toString(),
91-
TOOLTIP_KEYS.IP_ADDRESS,
92-
),
93-
);
9486

9587
info.addProgramRunner(this, programList);
9688

src/types/view-devices/vRouter.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,6 @@ export class ViewRouter extends ViewNetworkDevice {
5959

6060
showInfo(): void {
6161
const info = new DeviceInfo(this);
62-
this.interfaces.forEach((iface) =>
63-
info.addField(
64-
TOOLTIP_KEYS.IP_ADDRESS,
65-
iface.ip?.octets.join("."),
66-
TOOLTIP_KEYS.IP_ADDRESS,
67-
),
68-
);
6962

7063
info.addProgressBar(
7164
TOOLTIP_KEYS.PACKET_QUEUE_USAGE,

0 commit comments

Comments
 (0)