mirror of
https://github.com/GNS3/gns3-web-ui.git
synced 2025-05-07 19:18:40 +00:00
I resolved / Fixed add new template uploading image issue
This commit is contained in:
parent
4c11b6c012
commit
236a9d11b3
@ -129,25 +129,8 @@
|
|||||||
<mat-step *ngIf="applianceToInstall">
|
<mat-step *ngIf="applianceToInstall">
|
||||||
<ng-template matStepLabel>{{ secondActionTitle }}</ng-template>
|
<ng-template matStepLabel>{{ secondActionTitle }}</ng-template>
|
||||||
|
|
||||||
<mat-card [hidden]="!(!isLinuxPlatform && !applianceToInstall.dynamips)">
|
<mat-card [hidden]="!(!isLinuxPlatform || applianceToInstall.dynamips)">
|
||||||
Please configure GNS3 VM to install selected appliance
|
|
||||||
</mat-card>
|
|
||||||
|
|
||||||
<mat-card [hidden]="!(isLinuxPlatform || applianceToInstall.dynamips)">
|
|
||||||
<div *ngIf="applianceToInstall.qemu">
|
<div *ngIf="applianceToInstall.qemu">
|
||||||
<div>
|
|
||||||
Server type<br />
|
|
||||||
<mat-radio-group class="radio-group">
|
|
||||||
<mat-radio-button
|
|
||||||
[disabled]="!isLinuxPlatform"
|
|
||||||
[checked]="isLocalComputerChosen"
|
|
||||||
class="radio-button"
|
|
||||||
value="1"
|
|
||||||
(click)="setServerType('local')"
|
|
||||||
>Install the appliance locally</mat-radio-button
|
|
||||||
>
|
|
||||||
</mat-radio-group>
|
|
||||||
</div>
|
|
||||||
<div>
|
<div>
|
||||||
Qemu binary<br />
|
Qemu binary<br />
|
||||||
<mat-select
|
<mat-select
|
||||||
@ -321,37 +304,13 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div *ngIf="applianceToInstall.docker">
|
<div *ngIf="applianceToInstall.docker">
|
||||||
<div>
|
|
||||||
Server type<br />
|
|
||||||
<mat-radio-group class="radio-group">
|
|
||||||
<mat-radio-button
|
|
||||||
[disabled]="!isLinuxPlatform"
|
|
||||||
[checked]="isLocalComputerChosen"
|
|
||||||
class="radio-button"
|
|
||||||
value="1"
|
|
||||||
(click)="setServerType('local')"
|
|
||||||
>Install the appliance locally</mat-radio-button
|
|
||||||
>
|
|
||||||
</mat-radio-group>
|
|
||||||
</div>
|
|
||||||
<button mat-raised-button color="primary" (click)="createDockerTemplate()" class="create-button">
|
<button mat-raised-button color="primary" (click)="createDockerTemplate()" class="create-button">
|
||||||
Create docker template
|
Create docker template
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div *ngIf="applianceToInstall.dynamips">
|
<div *ngIf="applianceToInstall.dynamips">
|
||||||
<div>
|
|
||||||
Server type<br />
|
|
||||||
<mat-radio-group class="radio-group">
|
|
||||||
<mat-radio-button
|
|
||||||
[checked]="isLocalComputerChosen"
|
|
||||||
class="radio-button"
|
|
||||||
value="1"
|
|
||||||
(click)="setServerType('local')"
|
|
||||||
>Install the appliance locally</mat-radio-button
|
|
||||||
>
|
|
||||||
</mat-radio-group>
|
|
||||||
</div>
|
|
||||||
<div>
|
<div>
|
||||||
Install required files
|
Install required files
|
||||||
<button
|
<button
|
||||||
@ -389,19 +348,6 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div *ngIf="applianceToInstall.iou">
|
<div *ngIf="applianceToInstall.iou">
|
||||||
<div>
|
|
||||||
Server type<br />
|
|
||||||
<mat-radio-group class="radio-group">
|
|
||||||
<mat-radio-button
|
|
||||||
[disabled]="!isLinuxPlatform"
|
|
||||||
[checked]="isLocalComputerChosen"
|
|
||||||
class="radio-button"
|
|
||||||
value="1"
|
|
||||||
(click)="setServerType('local')"
|
|
||||||
>Install the appliance locally</mat-radio-button
|
|
||||||
>
|
|
||||||
</mat-radio-group>
|
|
||||||
</div>
|
|
||||||
<div>
|
<div>
|
||||||
Install required files
|
Install required files
|
||||||
<button
|
<button
|
||||||
|
@ -42,7 +42,7 @@ import { TemplateNameDialogComponent } from './template-name-dialog/template-nam
|
|||||||
]),
|
]),
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
export class NewTemplateDialogComponent implements OnInit {
|
export class NewTemplateDialogComponent implements OnInit {
|
||||||
@Input() server: Server;
|
@Input() server: Server;
|
||||||
@Input() project: Project;
|
@Input() project: Project;
|
||||||
|
|
||||||
@ -93,7 +93,7 @@ export class NewTemplateDialogComponent implements OnInit {
|
|||||||
private computeService: ComputeService,
|
private computeService: ComputeService,
|
||||||
private changeDetectorRef: ChangeDetectorRef,
|
private changeDetectorRef: ChangeDetectorRef,
|
||||||
private progressService: ProgressService
|
private progressService: ProgressService
|
||||||
) {}
|
) { }
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.applianceService.getAppliances(this.server).subscribe((appliances) => {
|
this.applianceService.getAppliances(this.server).subscribe((appliances) => {
|
||||||
@ -109,7 +109,6 @@ export class NewTemplateDialogComponent implements OnInit {
|
|||||||
this.dataSource.paginator = this.paginator;
|
this.dataSource.paginator = this.paginator;
|
||||||
});
|
});
|
||||||
|
|
||||||
if(!this.server.authToken){
|
|
||||||
this.templateService.list(this.server).subscribe((templates) => {
|
this.templateService.list(this.server).subscribe((templates) => {
|
||||||
this.templates = templates;
|
this.templates = templates;
|
||||||
});
|
});
|
||||||
@ -123,19 +122,19 @@ export class NewTemplateDialogComponent implements OnInit {
|
|||||||
this.qemuService.getBinaries(this.server).subscribe((binaries) => {
|
this.qemuService.getBinaries(this.server).subscribe((binaries) => {
|
||||||
this.qemuBinaries = binaries;
|
this.qemuBinaries = binaries;
|
||||||
});
|
});
|
||||||
|
|
||||||
this.qemuService.getImages(this.server).subscribe((qemuImages) => {
|
this.qemuService.getImages(this.server).subscribe((qemuImages) => {
|
||||||
this.qemuImages = qemuImages;
|
this.qemuImages = qemuImages;
|
||||||
});
|
});
|
||||||
|
|
||||||
this.iosService.getImages(this.server).subscribe((iosImages) => {
|
this.iosService.getImages(this.server).subscribe((iosImages) => {
|
||||||
this.iosImages = iosImages;
|
this.iosImages = iosImages;
|
||||||
});
|
});
|
||||||
|
|
||||||
this.iouService.getImages(this.server).subscribe((iouImages) => {
|
|
||||||
this.iouImages = iouImages;
|
|
||||||
});
|
|
||||||
|
|
||||||
|
this.iouService.getImages(this.server).subscribe((iouImages) => {
|
||||||
|
this.iouImages = iouImages;
|
||||||
|
});
|
||||||
|
|
||||||
this.applianceService.getAppliances(this.server).subscribe((appliances) => {
|
this.applianceService.getAppliances(this.server).subscribe((appliances) => {
|
||||||
this.appliances = appliances;
|
this.appliances = appliances;
|
||||||
this.appliances.forEach((appliance) => {
|
this.appliances.forEach((appliance) => {
|
||||||
@ -195,8 +194,7 @@ export class NewTemplateDialogComponent implements OnInit {
|
|||||||
this.progressService.deactivate();
|
this.progressService.deactivate();
|
||||||
this.uploaderImage.clearQueue();
|
this.uploaderImage.clearQueue();
|
||||||
};
|
};
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
updateAppliances() {
|
updateAppliances() {
|
||||||
@ -215,17 +213,19 @@ export class NewTemplateDialogComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
refreshImages() {
|
refreshImages() {
|
||||||
|
|
||||||
this.qemuService.getImages(this.server).subscribe((qemuImages) => {
|
this.qemuService.getImages(this.server).subscribe((qemuImages) => {
|
||||||
this.qemuImages = qemuImages;
|
this.qemuImages = qemuImages;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this.iosService.getImages(this.server).subscribe((iosImages) => {
|
||||||
|
this.iosImages = iosImages;
|
||||||
|
});
|
||||||
|
|
||||||
this.iosService.getImages(this.server).subscribe((iosImages) => {
|
this.iouService.getImages(this.server).subscribe((iouImages) => {
|
||||||
this.iosImages = iosImages;
|
this.iouImages = iouImages;
|
||||||
});
|
});
|
||||||
|
|
||||||
this.iouService.getImages(this.server).subscribe((iouImages) => {
|
|
||||||
this.iouImages = iouImages;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
getAppliance(url: string) {
|
getAppliance(url: string) {
|
||||||
@ -246,7 +246,7 @@ export class NewTemplateDialogComponent implements OnInit {
|
|||||||
let fileReader: FileReader = new FileReader();
|
let fileReader: FileReader = new FileReader();
|
||||||
let emulator;
|
let emulator;
|
||||||
|
|
||||||
fileReader.onloadend = () => {
|
fileReader.onloadend= () => {
|
||||||
let appliance = JSON.parse(fileReader.result as string);
|
let appliance = JSON.parse(fileReader.result as string);
|
||||||
|
|
||||||
if (appliance.docker) emulator = 'docker';
|
if (appliance.docker) emulator = 'docker';
|
||||||
@ -256,9 +256,9 @@ export class NewTemplateDialogComponent implements OnInit {
|
|||||||
|
|
||||||
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.uploader.queue.forEach((elem) => (elem.url = url));
|
||||||
|
|
||||||
const itemToUpload = this.uploader.queue[0];
|
const itemToUpload = this.uploader.queue[0];
|
||||||
(itemToUpload as any).options.disableMultipart = true;
|
if ((itemToUpload as any).options) (itemToUpload as any).options.disableMultipart = true; ((itemToUpload as any).options.headers = [{ name: 'Authorization', value: 'Bearer ' + this.server.authToken }])
|
||||||
|
|
||||||
this.uploader.uploadItem(itemToUpload);
|
this.uploader.uploadItem(itemToUpload);
|
||||||
};
|
};
|
||||||
@ -388,7 +388,7 @@ export class NewTemplateDialogComponent implements OnInit {
|
|||||||
let fileReader: FileReader = new FileReader();
|
let fileReader: FileReader = new FileReader();
|
||||||
let emulator;
|
let emulator;
|
||||||
|
|
||||||
fileReader.onloadend = () => {
|
fileReader.onloadend = () => {
|
||||||
if (this.applianceToInstall.qemu) emulator = 'qemu';
|
if (this.applianceToInstall.qemu) emulator = 'qemu';
|
||||||
if (this.applianceToInstall.dynamips) emulator = 'dynamips';
|
if (this.applianceToInstall.dynamips) emulator = 'dynamips';
|
||||||
if (this.applianceToInstall.iou) emulator = 'iou';
|
if (this.applianceToInstall.iou) emulator = 'iou';
|
||||||
@ -397,8 +397,8 @@ export class NewTemplateDialogComponent implements OnInit {
|
|||||||
this.uploaderImage.queue.forEach((elem) => (elem.url = url));
|
this.uploaderImage.queue.forEach((elem) => (elem.url = url));
|
||||||
|
|
||||||
const itemToUpload = this.uploaderImage.queue[0];
|
const itemToUpload = this.uploaderImage.queue[0];
|
||||||
(itemToUpload as any).options.disableMultipart = true;
|
if ((itemToUpload as any).options) (itemToUpload as any).options.disableMultipart = true; ((itemToUpload as any).options.headers = [{ name: 'Authorization', value: 'Bearer ' + this.server.authToken }])
|
||||||
|
|
||||||
this.uploaderImage.uploadItem(itemToUpload);
|
this.uploaderImage.uploadItem(itemToUpload);
|
||||||
this.progressService.activate();
|
this.progressService.activate();
|
||||||
};
|
};
|
||||||
|
@ -17,7 +17,7 @@ export class ApplianceService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getUploadPath(server: Server, emulator: string, filename: string) {
|
getUploadPath(server: Server, emulator: string, filename: string) {
|
||||||
return `${server.protocol}//${server.host}:${server.port}/v3/compute/${emulator}/images/${filename}`;
|
return `${server.protocol}//${server.host}:${server.port}/v3/images/upload/${filename}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
updateAppliances(server: Server): Observable<Appliance[]> {
|
updateAppliances(server: Server): Observable<Appliance[]> {
|
||||||
|
@ -10,11 +10,11 @@ export class IosService {
|
|||||||
constructor(private httpServer: HttpServer) {}
|
constructor(private httpServer: HttpServer) {}
|
||||||
|
|
||||||
getImages(server: Server): Observable<any> {
|
getImages(server: Server): Observable<any> {
|
||||||
return this.httpServer.get<IosImage[]>(server, '/compute/dynamips/images') as Observable<IosImage[]>;
|
return this.httpServer.get<IosImage[]>(server, '/images') as Observable<IosImage[]>;
|
||||||
}
|
}
|
||||||
|
|
||||||
getImagePath(server: Server, filename: string): string {
|
getImagePath(server: Server, filename: string): string {
|
||||||
return `${server.protocol}//${server.host}:${server.port}/v3/compute/dynamips/images/${filename}`;
|
return `${server.protocol}//${server.host}:${server.port}/v3/images/upload/${filename}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
getTemplates(server: Server): Observable<IosTemplate[]> {
|
getTemplates(server: Server): Observable<IosTemplate[]> {
|
||||||
|
@ -18,11 +18,11 @@ export class IouService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getImages(server: Server): Observable<any> {
|
getImages(server: Server): Observable<any> {
|
||||||
return this.httpServer.get<IouImage[]>(server, '/compute/iou/images') as Observable<IouImage[]>;
|
return this.httpServer.get<IouImage[]>(server, '/images') as Observable<IouImage[]>;
|
||||||
}
|
}
|
||||||
|
|
||||||
getImagePath(server: Server, filename: string): string {
|
getImagePath(server: Server, filename: string): string {
|
||||||
return `${server.protocol}//${server.host}:${server.port}/v3/compute/iou/images/${filename}`;
|
return `${server.protocol}//${server.host}:${server.port}/v3/images/upload/${filename}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
addTemplate(server: Server, iouTemplate: any): Observable<any> {
|
addTemplate(server: Server, iouTemplate: any): Observable<any> {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user