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)"
|
(change)="addAppliance($event)"
|
||||||
ng2FileSelect
|
ng2FileSelect
|
||||||
[uploader]="uploader"/>
|
[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>
|
</mat-card>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
|
@ -109,8 +109,6 @@ export class NewTemplateDialogComponent implements OnInit {
|
|||||||
this.uploaderImage.onSuccessItem = (item: FileItem, response: string, status: number, headers: ParsedResponseHeaders) => {
|
this.uploaderImage.onSuccessItem = (item: FileItem, response: string, status: number, headers: ParsedResponseHeaders) => {
|
||||||
this.toasterService.success('Image imported succesfully');
|
this.toasterService.success('Image imported succesfully');
|
||||||
};
|
};
|
||||||
|
|
||||||
this.getAppliance('http://127.0.0.1:3080/v2/compute/qemu/images/firefox.gns3a');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
getAppliance(url: string) {
|
getAppliance(url: string) {
|
||||||
@ -118,6 +116,9 @@ export class NewTemplateDialogComponent implements OnInit {
|
|||||||
let appliancePath = str[str.length-1];
|
let appliancePath = str[str.length-1];
|
||||||
this.applianceService.getAppliance(this.server, appliancePath).subscribe((appliance: Appliance) => {
|
this.applianceService.getAppliance(this.server, appliancePath).subscribe((appliance: Appliance) => {
|
||||||
this.applianceToInstall = appliance;
|
this.applianceToInstall = appliance;
|
||||||
|
setTimeout(() => {
|
||||||
|
this.stepper.next();
|
||||||
|
}, 100);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -225,20 +226,15 @@ export class NewTemplateDialogComponent implements OnInit {
|
|||||||
let emulator;
|
let emulator;
|
||||||
|
|
||||||
fileReader.onloadend = () => {
|
fileReader.onloadend = () => {
|
||||||
let appliance = JSON.parse(fileReader.result as string);
|
if (this.applianceToInstall.qemu) emulator = 'qemu';
|
||||||
|
|
||||||
if (appliance.docker) emulator = 'docker';
|
|
||||||
if (appliance.dynamips) emulator = 'dynamips';
|
|
||||||
if (appliance.iou) emulator = 'iou';
|
|
||||||
if (appliance.qemu) emulator = 'qemu';
|
|
||||||
|
|
||||||
const url = this.applianceService.getUploadPath(this.server, emulator, fileName);
|
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;
|
(itemToUpload as any).options.disableMultipart = true;
|
||||||
|
|
||||||
this.uploader.uploadItem(itemToUpload);
|
this.uploaderImage.uploadItem(itemToUpload);
|
||||||
};
|
};
|
||||||
|
|
||||||
fileReader.readAsText(file);
|
fileReader.readAsText(file);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user