mirror of
https://github.com/GNS3/gns3-web-ui.git
synced 2025-01-03 11:34:12 +00:00
Update import-appliance.component.ts
This commit is contained in:
parent
e965bc11e2
commit
58069d4962
@ -26,6 +26,7 @@ export class ImportApplianceComponent implements OnInit {
|
|||||||
@Input('project') project: Project;
|
@Input('project') project: Project;
|
||||||
@Input('server') server: Server;
|
@Input('server') server: Server;
|
||||||
uploader: FileUploader;
|
uploader: FileUploader;
|
||||||
|
template;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private toasterService: ToasterService,
|
private toasterService: ToasterService,
|
||||||
@ -51,10 +52,21 @@ export class ImportApplianceComponent implements OnInit {
|
|||||||
status: number,
|
status: number,
|
||||||
headers: ParsedResponseHeaders
|
headers: ParsedResponseHeaders
|
||||||
) => {
|
) => {
|
||||||
|
if (this.template.template_type === 'qemu') {
|
||||||
|
this.qemuService.addTemplate(this.server, this.template).subscribe(() => this.onUploadComplete());
|
||||||
|
} else if (this.template.template_type === 'iou') {
|
||||||
|
this.iouService.addTemplate(this.server, this.template).subscribe(() => this.onUploadComplete());
|
||||||
|
} else if (this.template.template_type === 'dynamips') {
|
||||||
|
this.iosService.addTemplate(this.server, this.template).subscribe(() => this.onUploadComplete());
|
||||||
|
} else if (this.template.template_type === 'docker') {
|
||||||
|
this.dockerService.addTemplate(this.server, this.template).subscribe(() => this.onUploadComplete());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
private onUploadComplete() {
|
||||||
this.toasterService.success('Appliance imported successfully');
|
this.toasterService.success('Appliance imported successfully');
|
||||||
this.uploader.queue = [];
|
this.uploader.queue = [];
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public uploadAppliance(event) {
|
public uploadAppliance(event) {
|
||||||
@ -131,6 +143,7 @@ export class ImportApplianceComponent implements OnInit {
|
|||||||
} else {
|
} else {
|
||||||
template.symbol = `:/symbols/${template.category}_guest.svg`;
|
template.symbol = `:/symbols/${template.category}_guest.svg`;
|
||||||
}
|
}
|
||||||
|
this.template = template;
|
||||||
|
|
||||||
const url = this.getUploadPath(this.server, template.template_type, name);
|
const url = this.getUploadPath(this.server, template.template_type, name);
|
||||||
this.uploader.queue.forEach(elem => (elem.url = url));
|
this.uploader.queue.forEach(elem => (elem.url = url));
|
||||||
@ -140,7 +153,7 @@ export class ImportApplianceComponent implements OnInit {
|
|||||||
fileReader.readAsText(file);
|
fileReader.readAsText(file);
|
||||||
}
|
}
|
||||||
|
|
||||||
getUploadPath(server: Server, emulator: string, filename: string) {
|
private getUploadPath(server: Server, emulator: string, filename: string) {
|
||||||
return `http://${server.host}:${server.port}/v2/${emulator}/images/${filename}`;
|
return `http://${server.host}:${server.port}/v2/${emulator}/images/${filename}`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user