mirror of
https://github.com/GNS3/gns3-web-ui.git
synced 2024-12-23 14:52:22 +00:00
Validation added
This commit is contained in:
parent
ecce86aaf7
commit
96e297ff6a
@ -3,6 +3,7 @@ import { Server } from '../../../../../models/server';
|
||||
import { Node } from '../../../../../cartography/models/node';
|
||||
import { MatDialog, MatDialogRef } from '@angular/material';
|
||||
import { ConfiguratorDialogVpcsComponent } from '../../../node-editors/configurator/vpcs/configurator-vpcs.component';
|
||||
import { ConfiguratorDialogEthernetHubComponent } from '../../../node-editors/configurator/ethernet_hub/configurator-ethernet-hub.component';
|
||||
|
||||
|
||||
@Component({
|
||||
@ -24,7 +25,7 @@ export class ConfigActionComponent {
|
||||
if (this.node.node_type === 'vpcs') {
|
||||
this.dialogRef = this.dialog.open(ConfiguratorDialogVpcsComponent, this.conf);
|
||||
} else if (this.node.node_type === 'ethernet_hub') {
|
||||
|
||||
this.dialogRef = this.dialog.open(ConfiguratorDialogEthernetHubComponent, this.conf);
|
||||
} else if (this.node.node_type === 'ethernet_switch') {
|
||||
|
||||
} else if (this.node.node_type === 'cloud') {
|
||||
@ -43,11 +44,11 @@ export class ConfigActionComponent {
|
||||
|
||||
} else if (this.node.node_type === 'nat') {
|
||||
|
||||
} else if (this.node.node_type === 'frame_relay_switch') {
|
||||
} else if (this.node.node_type === 'frame_relay_switch') {
|
||||
|
||||
} else if (this.node.node_type === 'atm_switch') {
|
||||
} else if (this.node.node_type === 'atm_switch') {
|
||||
|
||||
} else if (this.node.node_type === 'traceng') {
|
||||
} else if (this.node.node_type === 'traceng') {
|
||||
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,31 @@
|
||||
<h1 mat-dialog-title>Configurator for node {{node.name}}</h1>
|
||||
|
||||
<div class="modal-form-container">
|
||||
<div class="content">
|
||||
<div class="default-content">
|
||||
<mat-card class="matCard">
|
||||
<form [formGroup]="inputForm">
|
||||
<mat-form-field class="form-field">
|
||||
<input
|
||||
matInput type="text"
|
||||
[(ngModel)]="node.name"
|
||||
formControlName="name"
|
||||
placeholder="Name">
|
||||
</mat-form-field>
|
||||
<mat-form-field class="form-field">
|
||||
<input
|
||||
matInput type="number"
|
||||
[(ngModel)]="numberOfPorts"
|
||||
[ngModelOptions]="{standalone: true}"
|
||||
placeholder="Number of ports">
|
||||
</mat-form-field>
|
||||
</form>
|
||||
</mat-card>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div mat-dialog-actions>
|
||||
<button mat-button (click)="onCancelClick()" color="accent">Cancel</button>
|
||||
<button mat-button (click)="onSaveClick()" tabindex="2" mat-raised-button color="primary">Apply</button>
|
||||
</div>
|
@ -0,0 +1,83 @@
|
||||
import { Component, OnInit, Input } from "@angular/core";
|
||||
import { FormBuilder, FormGroup, Validators, FormControl } from '@angular/forms';
|
||||
import { VpcsConfigurationService } from '../../../../../services/vpcs-configuration.service';
|
||||
import { Node } from '../../../../../cartography/models/node';
|
||||
import { Server } from '../../../../../models/server';
|
||||
import { NodeService } from '../../../../../services/node.service';
|
||||
import { ToasterService } from '../../../../../services/toaster.service';
|
||||
import { MatDialogRef } from '@angular/material';
|
||||
|
||||
|
||||
@Component({
|
||||
selector: 'app-configurator-ethernet-hub',
|
||||
templateUrl: './configurator-ethernet-hub.component.html',
|
||||
styleUrls: ['../configurator.component.scss']
|
||||
})
|
||||
export class ConfiguratorDialogEthernetHubComponent implements OnInit {
|
||||
server: Server;
|
||||
node: Node;
|
||||
numberOfPorts: number;
|
||||
inputForm: FormGroup;
|
||||
consoleTypes: string[] = [];
|
||||
categories = [];
|
||||
|
||||
constructor(
|
||||
public dialogRef: MatDialogRef<ConfiguratorDialogEthernetHubComponent>,
|
||||
public nodeService: NodeService,
|
||||
private toasterService: ToasterService,
|
||||
private formBuilder: FormBuilder,
|
||||
private vpcsConfigurationService: VpcsConfigurationService
|
||||
) {
|
||||
this.inputForm = this.formBuilder.group({
|
||||
name: new FormControl('', Validators.required)
|
||||
});
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
this.nodeService.getNode(this.server, this.node).subscribe((node: Node) => {
|
||||
this.node = node;
|
||||
this.getConfiguration();
|
||||
})
|
||||
}
|
||||
|
||||
getConfiguration() {
|
||||
this.consoleTypes = this.vpcsConfigurationService.getConsoleTypes();
|
||||
this.categories = this.vpcsConfigurationService.getCategories();
|
||||
}
|
||||
|
||||
onSaveClick() {
|
||||
if (this.inputForm.valid) {
|
||||
for(let i=0; i<this.numberOfPorts; i++){
|
||||
this.node.ports.push({
|
||||
adapter_number: 0,
|
||||
link_type: 'ethernet',
|
||||
name: `Ethernet${i}`,
|
||||
port_number: i,
|
||||
short_name: `e${i}`
|
||||
});
|
||||
}
|
||||
|
||||
// {
|
||||
// "adapter_number": 0,
|
||||
// "data_link_types": {
|
||||
// "Ethernet": "DLT_EN10MB"
|
||||
// },
|
||||
// "link_type": "ethernet",
|
||||
// "name": "Ethernet0",
|
||||
// "port_number": 0,
|
||||
// "short_name": "e0"
|
||||
// }
|
||||
|
||||
this.nodeService.updateNode(this.server, this.node).subscribe(() => {
|
||||
this.toasterService.success(`Node ${this.node.name} updated.`);
|
||||
this.onCancelClick();
|
||||
});
|
||||
} else {
|
||||
this.toasterService.error(`Fill all required fields.`)
|
||||
}
|
||||
}
|
||||
|
||||
onCancelClick() {
|
||||
this.dialogRef.close();
|
||||
}
|
||||
}
|
@ -46,10 +46,14 @@ export class ConfiguratorDialogVpcsComponent implements OnInit {
|
||||
}
|
||||
|
||||
onSaveClick() {
|
||||
this.nodeService.updateNode(this.server, this.node).subscribe(() => {
|
||||
this.toasterService.success(`Node ${this.node.name} updated.`);
|
||||
this.onCancelClick();
|
||||
});
|
||||
if (this.inputForm.valid) {
|
||||
this.nodeService.updateNode(this.server, this.node).subscribe(() => {
|
||||
this.toasterService.success(`Node ${this.node.name} updated.`);
|
||||
this.onCancelClick();
|
||||
});
|
||||
} else {
|
||||
this.toasterService.error(`Fill all required fields.`);
|
||||
}
|
||||
}
|
||||
|
||||
onCancelClick() {
|
||||
|
Loading…
Reference in New Issue
Block a user