mirror of
https://github.com/GNS3/gns3-web-ui.git
synced 2025-04-15 06:06:35 +00:00
Fix for node select interface
This commit is contained in:
parent
5e95cfdea1
commit
02095ca359
@ -1,9 +1,15 @@
|
||||
<div class="context-menu" [style.left]="leftPosition" [style.top]="topPosition" *ngIf="node">
|
||||
<span [matMenuTriggerFor]="selectInterfaceMenu"></span>
|
||||
<mat-menu [style.min-height]="0" #selectInterfaceMenu="matMenu" class="context-menu-items">
|
||||
<button mat-menu-item *ngFor="let port of availablePorts" (click)="chooseInterface(port)">
|
||||
<mat-icon>add_circle_outline</mat-icon>
|
||||
<span>{{ port.name }}</span>
|
||||
<button mat-menu-item *ngFor="let port of ports" (click)="chooseInterface(port)" [disabled]="!port.available">
|
||||
<svg *ngIf="port.available" width="10" height="10">
|
||||
<rect class="status" x="0" y="0" width="10" height="10" fill="green"></rect>
|
||||
</svg>
|
||||
<svg *ngIf="!port.available" width="10" height="10">
|
||||
<rect class="status" x="0" y="0" width="10" height="10" fill="red"></rect>
|
||||
</svg>
|
||||
<!-- <mat-icon>add_circle_outline</mat-icon> -->
|
||||
<span class="port">{{ port.name }}</span>
|
||||
</button>
|
||||
</mat-menu>
|
||||
</div>
|
||||
|
@ -20,7 +20,6 @@ export class NodeSelectInterfaceComponent implements OnInit {
|
||||
protected topPosition;
|
||||
protected leftPosition;
|
||||
public node: Node;
|
||||
public availablePorts: Port[];
|
||||
public ports: Port[];
|
||||
|
||||
constructor(
|
||||
@ -49,16 +48,26 @@ export class NodeSelectInterfaceComponent implements OnInit {
|
||||
let linkNodes: LinkNode[] = [];
|
||||
this.links.forEach((link: Link) => {
|
||||
link.nodes.forEach((linkNode: LinkNode) => {
|
||||
if(linkNode.node_id === this.node.node_id) {
|
||||
if (linkNode.node_id === this.node.node_id) {
|
||||
linkNodes.push(linkNode);
|
||||
}
|
||||
});
|
||||
});
|
||||
this.availablePorts = [];
|
||||
|
||||
this.ports = [];
|
||||
this.node.ports.forEach((port: Port) => {
|
||||
if(linkNodes.filter((linkNode: LinkNode) => linkNode.port_number === port.port_number).length === 0){
|
||||
this.availablePorts.push(port);
|
||||
let linkNodesOnTheSameAdapter = linkNodes.filter((linkNode: LinkNode) => linkNode.adapter_number === port.adapter_number);
|
||||
if (linkNodesOnTheSameAdapter.length === 0) {
|
||||
port.available = true;
|
||||
} else {
|
||||
if (linkNodesOnTheSameAdapter.filter((linkNode: LinkNode) => linkNode.port_number === port.port_number).length === 0) {
|
||||
port.available = true;
|
||||
} else {
|
||||
port.available = false;
|
||||
}
|
||||
}
|
||||
|
||||
this.ports.push(port);
|
||||
});
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user