mirror of
https://github.com/GNS3/gns3-web-ui.git
synced 2025-04-07 10:36:41 +00:00
Improvements to add new Ethernet switch ports
This commit is contained in:
parent
64cc001512
commit
cd483e047b
@ -1,6 +1,7 @@
|
||||
import { Component, Input, OnInit } from '@angular/core';
|
||||
import { PortsMappingEntity } from '../../../../models/ethernetHub/ports-mapping-enity';
|
||||
import { BuiltInTemplatesConfigurationService } from '../../../../services/built-in-templates-configuration.service';
|
||||
import { ToasterService } from "@services/toaster.service";
|
||||
|
||||
@Component({
|
||||
selector: 'app-ports',
|
||||
@ -12,16 +13,23 @@ export class PortsComponent implements OnInit {
|
||||
newPort: PortsMappingEntity = {
|
||||
name: '',
|
||||
port_number: 0,
|
||||
vlan: 1,
|
||||
type: 'access',
|
||||
ethertype: '0x8100',
|
||||
};
|
||||
|
||||
portTypes: string[] = [];
|
||||
etherTypes: string[] = [];
|
||||
displayedColumns: string[] = ['port_number', 'vlan', 'type', 'ethertype', 'action'];
|
||||
|
||||
constructor(private builtInTemplatesConfigurationService: BuiltInTemplatesConfigurationService) {}
|
||||
constructor(
|
||||
private builtInTemplatesConfigurationService: BuiltInTemplatesConfigurationService,
|
||||
private toasterService: ToasterService,
|
||||
) {}
|
||||
|
||||
ngOnInit() {
|
||||
this.getConfiguration();
|
||||
this.newPort.port_number = this.ethernetPorts.length;
|
||||
}
|
||||
|
||||
getConfiguration() {
|
||||
@ -30,13 +38,18 @@ export class PortsComponent implements OnInit {
|
||||
}
|
||||
|
||||
onAdd() {
|
||||
this.newPort.name = "Ethernet" + this.newPort.port_number;
|
||||
this.ethernetPorts.push(this.newPort);
|
||||
|
||||
this.newPort = {
|
||||
name: '',
|
||||
port_number: 0,
|
||||
};
|
||||
const portExists = this.ethernetPorts.some(p => p.port_number === this.newPort.port_number);
|
||||
if (portExists) {
|
||||
this.toasterService.error(`Port number ${this.newPort.port_number} already exists.`);
|
||||
return;
|
||||
}
|
||||
|
||||
const port: PortsMappingEntity = { ...this.newPort };
|
||||
port.name = "Ethernet" + port.port_number;
|
||||
this.ethernetPorts.push(port);
|
||||
this.ethernetPorts = [].concat(this.ethernetPorts); // this forces the refresh of the table
|
||||
this.newPort.port_number = this.ethernetPorts.length;
|
||||
}
|
||||
|
||||
delete(port: PortsMappingEntity) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user