Merge pull request #440 from GNS3/removing-console-errors

Removing errors & warnings, missing validation added
This commit is contained in:
piotrpekala7 2019-07-03 04:58:22 -07:00 committed by GitHub
commit 4a7a92078a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
18 changed files with 31 additions and 34 deletions

View File

@ -8,7 +8,7 @@
<mat-card class="matCard">
<form [formGroup]="formGroup">
<mat-form-field class="form-field">
<input formControlName="templateName" matInput type="text" [(ngModel)]="templateName" placeholder="Template name">
<input formControlName="templateName" matInput type="text" placeholder="Template name">
</mat-form-field>
</form>
</mat-card>

View File

@ -54,7 +54,7 @@ export class CloudNodesAddTemplateComponent implements OnInit {
});
cloudTemplate.template_id = uuid();
cloudTemplate.name = this.templateName;
cloudTemplate.name = this.formGroup.get('templateName').value;
this.builtInTemplatesService.addTemplate(this.server, cloudTemplate).subscribe((cloudNodeTemplate) => {
this.goBack();

View File

@ -8,10 +8,10 @@
<mat-card class="matCard">
<form [formGroup]="formGroup">
<mat-form-field class="form-field">
<input formControlName="templateName" matInput type="text" [(ngModel)]="templateName" placeholder="Template name">
<input formControlName="templateName" matInput type="text" placeholder="Template name">
</mat-form-field>
<mat-form-field class="form-field">
<input formControlName="numberOfPorts" matInput type="text" [(ngModel)]="numberOfPorts" placeholder="Number of ports">
<input formControlName="numberOfPorts" matInput type="text" placeholder="Number of ports">
</mat-form-field>
</form>
</mat-card>

View File

@ -75,7 +75,6 @@ describe('EthernetHubsAddTemplateComponent', () => {
it('should call add template', () => {
spyOn(mockedBuiltInTemplatesService, 'addTemplate').and.returnValue(of({} as EthernetHubTemplate));
component.templateName = "sample name";
component.numberOfPorts = 2;
component.server = {id: 1} as Server;
component.formGroup.controls['templateName'].setValue('template name');
component.formGroup.controls['numberOfPorts'].setValue('1');
@ -89,7 +88,6 @@ describe('EthernetHubsAddTemplateComponent', () => {
spyOn(mockedBuiltInTemplatesService, 'addTemplate').and.returnValue(of({} as EthernetHubTemplate));
spyOn(mockedToasterService, 'error');
component.templateName = "";
component.numberOfPorts = 2;
component.server = {id: 1} as Server;
component.addTemplate();

View File

@ -17,7 +17,6 @@ import { FormBuilder, FormGroup, FormControl, Validators } from '@angular/forms'
})
export class EthernetHubsAddTemplateComponent implements OnInit {
server: Server;
numberOfPorts: number;
templateName: string = '';
formGroup: FormGroup;
@ -56,9 +55,9 @@ export class EthernetHubsAddTemplateComponent implements OnInit {
});
ethernetHubTemplate.template_id = uuid();
ethernetHubTemplate.name = this.templateName;
ethernetHubTemplate.name = this.formGroup.get('templateName').value;
for(let i=0; i<this.numberOfPorts; i++){
for(let i=0; i<this.formGroup.get('numberOfPorts').value; i++){
ethernetHubTemplate.ports_mapping.push({
name: `Ethernet${i}`,
port_number: i

View File

@ -8,7 +8,10 @@
<mat-card class="matCard">
<form [formGroup]="formGroup">
<mat-form-field class="form-field">
<input formControlName="templateName" matInput type="text" [(ngModel)]="templateName" placeholder="Template name">
<input formControlName="templateName" matInput type="text" placeholder="Template name">
</mat-form-field>
<mat-form-field class="form-field">
<input formControlName="numberOfPorts" matInput type="text" placeholder="Number of ports">
</mat-form-field>
</form>
</mat-card>

View File

@ -75,7 +75,6 @@ describe('EthernetSwitchesAddTemplateComponent', () => {
it('should call add template', () => {
spyOn(mockedBuiltInTemplatesService, 'addTemplate').and.returnValue(of({} as EthernetSwitchTemplate));
component.templateName = "sample name";
component.numberOfPorts = 2;
component.server = {id: 1} as Server;
component.formGroup.controls['templateName'].setValue('template name');
component.formGroup.controls['numberOfPorts'].setValue('1');

View File

@ -17,7 +17,6 @@ import { FormGroup, FormBuilder, FormControl, Validators } from '@angular/forms'
})
export class EthernetSwitchesAddTemplateComponent implements OnInit {
server: Server;
numberOfPorts: number;
templateName: string = '';
formGroup: FormGroup;
@ -56,9 +55,9 @@ export class EthernetSwitchesAddTemplateComponent implements OnInit {
});
ethernetSwitchTemplate.template_id = uuid();
ethernetSwitchTemplate.name = this.templateName;
ethernetSwitchTemplate.name = this.formGroup.get('templateName').value;
for(let i=0; i<this.numberOfPorts; i++){
for(let i=0; i<this.formGroup.get('numberOfPorts').value; i++){
ethernetSwitchTemplate.ports_mapping.push({
ethertype: '',
name: `Ethernet${i}`,

View File

@ -34,7 +34,6 @@
matInput
class="filename"
type="text"
[(ngModel)]="dockerTemplate.image"
formControlName="filename"
placeholder="Image name"/>
</mat-form-field>
@ -48,7 +47,6 @@
matInput
class="templatename"
type="text"
[(ngModel)]="dockerTemplate.name"
formControlName="templateName"
placeholder="Container name"/>
</mat-form-field>
@ -61,7 +59,6 @@
matInput
class="networkadapter"
type="number"
[(ngModel)]="dockerTemplate.adapters"
formControlName="adapters"
placeholder="Adapters"/>
</mat-form-field>

View File

@ -87,6 +87,9 @@ export class AddDockerTemplateComponent implements OnInit {
addTemplate() {
if ((!this.virtualMachineForm.invalid || !this.newImageSelected) && !this.containerNameForm.invalid && !this.networkAdaptersForm.invalid) {
this.dockerTemplate.template_id = uuid();
this.dockerTemplate.image = this.virtualMachineForm.get('filename').value;
this.dockerTemplate.name = this.containerNameForm.get('templateName').value;
this.dockerTemplate.adapters = this.networkAdaptersForm.get('adapters').value;
this.dockerService.addTemplate(this.server, this.dockerTemplate).subscribe((template: DockerTemplate) => {
this.goBack();

View File

@ -12,7 +12,6 @@
<mat-form-field class="form-field">
<input
matInput type="text"
[(ngModel)]="iosTemplate.image"
formControlName="imageName"
placeholder="IOS image"/>
</mat-form-field>
@ -23,7 +22,6 @@
<mat-form-field class="form-field">
<input
matInput type="text"
[(ngModel)]="iosTemplate.name"
formControlName="templateName"
placeholder="Name"/>
</mat-form-field>
@ -31,8 +29,7 @@
<mat-select
placeholder="Platform"
(selectionChange)="onPlatformChosen($event)"
formControlName="platform"
[(ngModel)]="iosTemplate.platform">
formControlName="platform">
<mat-option *ngFor="let platform of platforms" [value]="platform">
{{platform}}
</mat-option>
@ -42,8 +39,7 @@
<mat-select
placeholder="Chassis"
(selectionChange)="onChassisChosen($event)"
formControlName="chassis"
[(ngModel)]="iosTemplate.chassis">
formControlName="chassis">
<mat-option *ngFor="let chassis of chassis[iosTemplate.platform]" [value]="chassis">
{{chassis}}
</mat-option>
@ -61,7 +57,6 @@
<mat-form-field class="form-field">
<input
matInput type="number"
[(ngModel)]="iosTemplate.ram"
formControlName="memory"
value="defaultRam[iosTemplate.platform]"
placeholder="Default RAM"/>

View File

@ -90,6 +90,11 @@ export class AddIosTemplateComponent implements OnInit {
addTemplate() {
if (!this.iosImageForm.invalid && !this.iosNameForm.invalid && !this.iosMemoryForm.invalid) {
this.iosTemplate.template_id = uuid();
this.iosTemplate.image = this.iosImageForm.get("imageName").value;
this.iosTemplate.name = this.iosNameForm.get('templateName').value;
this.iosTemplate.platform = this.iosNameForm.get('platform').value;
this.iosTemplate.chassis = this.iosNameForm.get('chassis').value;
this.iosTemplate.ram = this.iosMemoryForm.get('memory').value;
if (this.isEtherSwitchRouter) {
this.iosTemplate.symbol = ":/symbols/multilayer_switch.svg";

View File

@ -16,7 +16,7 @@
<mat-step label="Name">
<form [formGroup]="templateNameForm">
<mat-form-field class="form-field">
<input matInput placeholder="Name" type="text" [(ngModel)]="iouTemplate.name" formControlName="templateName"/>
<input matInput placeholder="Name" type="text" formControlName="templateName"/>
</mat-form-field>
</form>
</mat-step>
@ -59,7 +59,6 @@
<input
matInput
type="text"
[(ngModel)]="iouTemplate.path"
formControlName="imageName"
placeholder="IOU image"/>
</mat-form-field>

View File

@ -82,6 +82,8 @@ export class AddIouTemplateComponent implements OnInit {
addTemplate() {
if (!this.templateNameForm.invalid && ((this.newImageSelected && !this.imageForm.invalid) || (!this.newImageSelected && this.iouTemplate.path))) {
this.iouTemplate.template_id = uuid();
this.iouTemplate.name = this.templateNameForm.get("templateName").value;
this.iouTemplate.path = this.imageForm.get("imageName").value;
this.iouService.addTemplate(this.server, this.iouTemplate).subscribe((template: IouTemplate) => {
this.goBack();

View File

@ -12,7 +12,6 @@
<mat-form-field class="form-field">
<input
matInput type="text"
[(ngModel)]="qemuTemplate.name"
formControlName="templateName"
placeholder="Please choose a descriptive name for your new QEMU virtual machine"
ngDefaultContro/>
@ -26,9 +25,9 @@
<form [formGroup]="memoryForm">
<mat-form-field class="form-field">
<mat-select
placeholder="Qemu binary"
placeholder="Qemu binary"
[(ngModel)]="selectedBinary"
formControlName="binary" >
[ngModelOptions]="{standalone: true}">
<mat-option *ngFor="let binary of qemuBinaries" [value]="binary">
{{binary.path}}
</mat-option>
@ -38,7 +37,6 @@
<input
matInput type="number"
placeholder="RAM"
[(ngModel)]="ramMemory"
formControlName="ramMemory"
ngDefaultContro/>
</mat-form-field>

View File

@ -51,7 +51,6 @@ export class AddQemuVmTemplateComponent implements OnInit {
});
this.memoryForm = this.formBuilder.group({
binary: new FormControl('', Validators.required),
ramMemory: new FormControl('', Validators.required)
});
@ -95,7 +94,7 @@ export class AddQemuVmTemplateComponent implements OnInit {
addTemplate() {
if (!this.nameForm.invalid && !this.memoryForm.invalid && (this.selectedImage || this.chosenImage)) {
this.qemuTemplate.ram = this.ramMemory;
this.qemuTemplate.ram = this.memoryForm.get("ramMemory").value;
this.qemuTemplate.qemu_path = this.selectedBinary.path;
if (this.newImageSelected) {
this.qemuTemplate.hda_disk_image = this.chosenImage;
@ -103,6 +102,7 @@ export class AddQemuVmTemplateComponent implements OnInit {
this.qemuTemplate.hda_disk_image = this.selectedImage.path;
}
this.qemuTemplate.template_id = uuid();
this.qemuTemplate.name = this.nameForm.get("templateName").value;
this.qemuService.addTemplate(this.server, this.qemuTemplate).subscribe((template: QemuTemplate) => {
this.goBack();

View File

@ -7,7 +7,7 @@
</mat-form-field>
<mat-form-field class="form-field">
<input matInput [ngModelOptions]="{standalone: true}" placeholder="Fill color" type="color" [(ngModel)]="element.stroke">
<input matInput [ngModelOptions]="{standalone: true}" placeholder="Border color" type="color" [(ngModel)]="element.stroke">
</mat-form-field>
<mat-form-field class="form-field">

View File

@ -80,7 +80,7 @@ g.node:hover {
}
.extended {
width: 720px !important;
width: 700px !important;
height: 100%;
overflow: hidden;
}