Default settings for templates

This commit is contained in:
piotrpekala7 2020-04-27 22:38:37 +02:00
parent 18f7f350f7
commit b6d02ca5d4
2 changed files with 12 additions and 2 deletions

View File

@ -21,6 +21,7 @@
<mat-form-field class="form-field">
<mat-select
placeholder="Image"
(selectionChange)="onImageChosen($event)"
formControlName="imageName">
<mat-option *ngFor="let image of iosImages" [value]="image.filename">
{{image.filename}}

View File

@ -77,7 +77,6 @@ export class AddIosTemplateComponent implements OnInit {
file.withCredentials = false;
};
this.uploader.onErrorItem = (item: FileItem, response: string, status: number, headers: ParsedResponseHeaders) => {
console.log(response);
this.toasterService.error('An error occured: ' + response);
};
this.uploader.onSuccessItem = (
@ -180,7 +179,7 @@ export class AddIosTemplateComponent implements OnInit {
}
completeModulesData() {
if(Object.keys(this.networkModules[this.iosTemplate.platform])){
if (Object.keys(this.networkModules[this.iosTemplate.platform])){
for(let i=0; i<Object.keys(this.networkModules[this.iosTemplate.platform]).length; i++){
if(!this.networkModulesForTemplate[i]) this.networkModulesForTemplate[i] = '';
}
@ -195,6 +194,16 @@ export class AddIosTemplateComponent implements OnInit {
this.router.navigate(['/server', this.server.id, 'preferences', 'dynamips', 'templates']);
}
onImageChosen() {
let name: string = this.iosImageForm.get("imageName").value.split('-')[0];
this.iosNameForm.controls['templateName'].setValue(name);
if (this.platforms.includes(name.split('-')[0])) {
this.iosNameForm.controls['platform'].setValue(name);
this.iosMemoryForm.controls['memory'].setValue(this.defaultRam[name]);
}
}
onPlatformChosen() {
this.iosTemplate.chassis = '';
this.networkAdaptersForTemplate = [];