Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@ export class GlobalContext {
input.accept = ".json";

input.onchange = (event) => {
// NOTE: browser takes care of making sure we get a single file here
const file = (event.target as HTMLInputElement).files[0];
const reader = new FileReader();
reader.readAsText(file);
Expand Down
18 changes: 16 additions & 2 deletions src/types/graphs/viewgraph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,15 @@ export class ViewGraph {
this.ctx = ctx;
this.datagraph = datagraph;
this.viewport = ctx.getViewport();
this.layer = layer;

// NOTE: here we initialize on Link layer to avoid weird issues related
// to devices hiding themselves due to being on an unfinished viewgraph
this.layer = Layer.Link;
this.packetManager = new PacketManager();
this.constructView();

// Change to the specified layer
this.changeLayerAndHideDevices(layer);
}

private constructView() {
Expand Down Expand Up @@ -195,7 +201,11 @@ export class ViewGraph {
return this.layer;
}

changeCurrLayer(newLayer: Layer) {
/**
* Changes the layer of the viewgraph and updates the visibility of devices and edges.
* This skips notifying other components about the change.
*/
private changeLayerAndHideDevices(newLayer: Layer) {
this.layer = newLayer;

for (const [, device] of this.graph.getAllVertices()) {
Expand Down Expand Up @@ -227,6 +237,10 @@ export class ViewGraph {
for (const [, device] of this.graph.getAllVertices()) {
device.updateDevicesAspect();
}
}

changeCurrLayer(newLayer: Layer) {
this.changeLayerAndHideDevices(newLayer);

// warn Packet Manager that the layer has been changed
this.packetManager.layerChanged(newLayer);
Expand Down