Possibility to manage network adapters added

This commit is contained in:
piotrpekala7 2020-04-29 17:27:47 +02:00
parent 57c9caa40f
commit e78ca38f30
4 changed files with 14 additions and 16 deletions

View File

@ -48,12 +48,12 @@
</mat-option>
</mat-select>
</mat-form-field>
<mat-form-field class="form-field" *ngIf="chassis[iosTemplate.platform]">
<mat-form-field class="form-field" *ngIf="chassis[iosNameForm.get('platform').value]">
<mat-select
placeholder="Chassis"
(selectionChange)="onChassisChosen($event)"
formControlName="chassis">
<mat-option *ngFor="let chassis of chassis[iosTemplate.platform]" [value]="chassis">
<mat-option *ngFor="let chassis of chassis[iosNameForm.get('platform').value]" [value]="chassis">
{{chassis}}
</mat-option>
</mat-select>
@ -71,7 +71,7 @@
<input
matInput type="number"
formControlName="memory"
value="defaultRam[iosTemplate.platform]"
value="defaultRam[iosNameForm.get('platform').value]"
placeholder="Default RAM"/>
<span matSuffix>MB</span>
</mat-form-field>
@ -81,27 +81,27 @@
</form>
</mat-step>
<mat-step label="Network adapters">
<div *ngIf="iosTemplate.chassis && chassis[iosTemplate.platform]">
<div *ngIf="chassis[iosNameForm.get('platform').value]">
<div *ngFor="let index of [0,1,2,3,4,5,6,7]">
<mat-select
placeholder="Slot {{index}}"
[(ngModel)]="networkAdaptersForTemplate[index]"
[ngModelOptions]="{standalone: true}"
*ngIf="networkAdapters[iosTemplate.chassis][index]">
<mat-option *ngFor="let option of networkAdapters[iosTemplate.chassis][index]" [value]="option">
*ngIf="networkAdapters[iosNameForm.get('chassis').value] && networkAdapters[iosNameForm.get('chassis').value][index]">
<mat-option *ngFor="let option of networkAdapters[iosNameForm.get('chassis').value][index]" [value]="option">
{{option}}
</mat-option>
</mat-select>
</div>
</div>
<div *ngIf="iosTemplate.platform && !chassis[iosTemplate.platform]">
<div *ngIf="chassis[iosNameForm.get('platform').value]">
<div *ngFor="let index of [0,1,2,3,4,5,6,7]">
<mat-select
placeholder="Slot {{index}}"
[(ngModel)]="networkAdaptersForTemplate[index]"
[ngModelOptions]="{standalone: true}"
*ngIf="networkAdaptersForPlatform[iosTemplate.platform][index]">
<mat-option *ngFor="let option of networkAdaptersForPlatform[iosTemplate.platform][index]" [value]="option">
*ngIf="networkAdaptersForPlatform[iosNameForm.get('platform').value] && networkAdaptersForPlatform[iosNameForm.get('platform').value][index]">
<mat-option *ngFor="let option of networkAdaptersForPlatform[iosNameForm.get('platform').value][index]" [value]="option">
{{option}}
</mat-option>
</mat-select>
@ -115,7 +115,7 @@
placeholder="WIC {{index}}"
[(ngModel)]="networkModulesForTemplate[index]"
[ngModelOptions]="{standalone: true}"
*ngIf="networkModules[iosNameForm.get('platform').value][index]">
*ngIf="networkModules[iosNameForm.get('platform').value] && networkModules[iosNameForm.get('platform').value][index]">
<mat-option *ngFor="let option of networkModules[iosNameForm.get('platform').value][index]" [value]="option">
{{option}}
</mat-option>

View File

@ -129,12 +129,12 @@ export class AddIosTemplateComponent implements OnInit {
}
addTemplate() {
if (!this.iosImageForm.invalid && !this.iosNameForm.invalid && !this.iosMemoryForm.invalid) {
if (!this.iosImageForm.invalid && !this.iosMemoryForm.invalid && this.iosNameForm.get('templateName').value && this.iosNameForm.get('platform').value) {
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;
if (this.chassis[this.iosNameForm.get('platform').value]) this.iosTemplate.chassis = this.iosNameForm.get('chassis').value;
this.iosTemplate.ram = this.iosMemoryForm.get('memory').value;
if (this.isEtherSwitchRouter) {

View File

@ -2,7 +2,7 @@ export class IosTemplate {
auto_delete_disks: boolean;
builtin: boolean;
category: string;
chassis: string;
chassis?: string;
compute_id: string;
console_auto_start: boolean;
console_type: string;
@ -14,7 +14,7 @@ export class IosTemplate {
idlepc: string;
idlesleep: number;
image: string;
iomem: number;
iomem?: number;
mac_addr: string;
mmap: boolean;
name: string;

View File

@ -184,7 +184,6 @@ export class TemplateMocksService {
auto_delete_disks: true,
builtin: false,
category: 'router',
chassis: '',
compute_id: 'local',
console_auto_start: false,
console_type: 'telnet',
@ -196,7 +195,6 @@ export class TemplateMocksService {
idlepc: '',
idlesleep: 30,
image: '',
iomem: 0,
mac_addr: '',
mmap: true,
name: '',