mirror of
https://github.com/GNS3/gns3-web-ui.git
synced 2025-05-10 04:22:56 +00:00
Fix for importing images
This commit is contained in:
parent
7a62a7589a
commit
df8f39e951
@ -101,7 +101,7 @@
|
||||
(change)="addAppliance($event)"
|
||||
ng2FileSelect
|
||||
[uploader]="uploader"/>
|
||||
<button mat-raised-button color="primary" (click)="file.click()">Click to import appliance</button>
|
||||
<button mat-raised-button color="primary" (click)="file.click()" class="create-button">Click to import appliance</button>
|
||||
</mat-card>
|
||||
|
||||
<div>
|
||||
|
@ -109,8 +109,6 @@ export class NewTemplateDialogComponent implements OnInit {
|
||||
this.uploaderImage.onSuccessItem = (item: FileItem, response: string, status: number, headers: ParsedResponseHeaders) => {
|
||||
this.toasterService.success('Image imported succesfully');
|
||||
};
|
||||
|
||||
this.getAppliance('http://127.0.0.1:3080/v2/compute/qemu/images/firefox.gns3a');
|
||||
}
|
||||
|
||||
getAppliance(url: string) {
|
||||
@ -118,6 +116,9 @@ export class NewTemplateDialogComponent implements OnInit {
|
||||
let appliancePath = str[str.length-1];
|
||||
this.applianceService.getAppliance(this.server, appliancePath).subscribe((appliance: Appliance) => {
|
||||
this.applianceToInstall = appliance;
|
||||
setTimeout(() => {
|
||||
this.stepper.next();
|
||||
}, 100);
|
||||
});
|
||||
}
|
||||
|
||||
@ -225,20 +226,15 @@ export class NewTemplateDialogComponent implements OnInit {
|
||||
let emulator;
|
||||
|
||||
fileReader.onloadend = () => {
|
||||
let appliance = JSON.parse(fileReader.result as string);
|
||||
|
||||
if (appliance.docker) emulator = 'docker';
|
||||
if (appliance.dynamips) emulator = 'dynamips';
|
||||
if (appliance.iou) emulator = 'iou';
|
||||
if (appliance.qemu) emulator = 'qemu';
|
||||
if (this.applianceToInstall.qemu) emulator = 'qemu';
|
||||
|
||||
const url = this.applianceService.getUploadPath(this.server, emulator, fileName);
|
||||
this.uploader.queue.forEach(elem => (elem.url = url));
|
||||
this.uploaderImage.queue.forEach(elem => (elem.url = url));
|
||||
|
||||
const itemToUpload = this.uploader.queue[0];
|
||||
const itemToUpload = this.uploaderImage.queue[0];
|
||||
(itemToUpload as any).options.disableMultipart = true;
|
||||
|
||||
this.uploader.uploadItem(itemToUpload);
|
||||
this.uploaderImage.uploadItem(itemToUpload);
|
||||
};
|
||||
|
||||
fileReader.readAsText(file);
|
||||
|
Loading…
x
Reference in New Issue
Block a user