mirror of
https://github.com/GNS3/gns3-web-ui.git
synced 2024-12-22 06:17:47 +00:00
parent
97d1bc7596
commit
5e65aff228
@ -29,16 +29,16 @@
|
|||||||
</form>
|
</form>
|
||||||
</mat-step>
|
</mat-step>
|
||||||
|
|
||||||
<mat-step label="QEMU binary and memory" [completed]="memoryForm.get('ramMemory').value && selectedBinary">
|
<mat-step label="Platform and memory" [completed]="memoryForm.get('ramMemory').value && selectedPlatform">
|
||||||
<form [formGroup]="memoryForm">
|
<form [formGroup]="memoryForm">
|
||||||
<mat-form-field class="form-field">
|
<mat-form-field class="form-field">
|
||||||
<mat-select
|
<mat-select
|
||||||
placeholder="Qemu binary"
|
placeholder="Platform"
|
||||||
[(ngModel)]="selectedBinary"
|
[(ngModel)]="selectedPlatform"
|
||||||
[ngModelOptions]="{ standalone: true }"
|
[ngModelOptions]="{ standalone: true }"
|
||||||
>
|
>
|
||||||
<mat-option *ngFor="let binary of qemuBinaries" [value]="binary">
|
<mat-option *ngFor="let platform of selectPlatform " [value]="platform">
|
||||||
{{ binary.path }}
|
{{ platform }}
|
||||||
</mat-option>
|
</mat-option>
|
||||||
</mat-select> </mat-form-field
|
</mat-select> </mat-form-field
|
||||||
><br />
|
><br />
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { Component, OnInit } from '@angular/core';
|
import { Component, OnInit } from '@angular/core';
|
||||||
import { FormBuilder, FormControl, FormGroup, Validators } from '@angular/forms';
|
import { FormBuilder, FormControl, FormGroup, Validators } from '@angular/forms';
|
||||||
import { ActivatedRoute, Router } from '@angular/router';
|
import { ActivatedRoute, Router } from '@angular/router';
|
||||||
import { FileItem, FileUploader, ParsedResponseHeaders } from 'ng2-file-upload';
|
import { FileItem, FileUploader, FileUploaderOptions, ParsedResponseHeaders } from 'ng2-file-upload';
|
||||||
import { v4 as uuid } from 'uuid';
|
import { v4 as uuid } from 'uuid';
|
||||||
import { Compute } from '../../../../models/compute';
|
import { Compute } from '../../../../models/compute';
|
||||||
import { QemuBinary } from '../../../../models/qemu/qemu-binary';
|
import { QemuBinary } from '../../../../models/qemu/qemu-binary';
|
||||||
@ -23,6 +23,8 @@ import { ToasterService } from '../../../../services/toaster.service';
|
|||||||
export class AddQemuVmTemplateComponent implements OnInit {
|
export class AddQemuVmTemplateComponent implements OnInit {
|
||||||
server: Server;
|
server: Server;
|
||||||
qemuBinaries: QemuBinary[] = [];
|
qemuBinaries: QemuBinary[] = [];
|
||||||
|
selectPlatform: string[] = [];
|
||||||
|
selectedPlatform: string;
|
||||||
selectedBinary: QemuBinary;
|
selectedBinary: QemuBinary;
|
||||||
ramMemory: number;
|
ramMemory: number;
|
||||||
consoleTypes: string[] = [];
|
consoleTypes: string[] = [];
|
||||||
@ -68,6 +70,7 @@ export class AddQemuVmTemplateComponent implements OnInit {
|
|||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.uploader = new FileUploader({});
|
this.uploader = new FileUploader({});
|
||||||
|
|
||||||
this.uploader.onAfterAddingFile = (file) => {
|
this.uploader.onAfterAddingFile = (file) => {
|
||||||
file.withCredentials = false;
|
file.withCredentials = false;
|
||||||
};
|
};
|
||||||
@ -85,6 +88,7 @@ export class AddQemuVmTemplateComponent implements OnInit {
|
|||||||
});
|
});
|
||||||
this.toasterService.success('Image uploaded');
|
this.toasterService.success('Image uploaded');
|
||||||
};
|
};
|
||||||
|
|
||||||
this.uploader.onProgressItem = (progress: any) => {
|
this.uploader.onProgressItem = (progress: any) => {
|
||||||
this.uploadProgress = progress['progress'];
|
this.uploadProgress = progress['progress'];
|
||||||
};
|
};
|
||||||
@ -97,16 +101,18 @@ export class AddQemuVmTemplateComponent implements OnInit {
|
|||||||
this.qemuTemplate = qemuTemplate;
|
this.qemuTemplate = qemuTemplate;
|
||||||
});
|
});
|
||||||
|
|
||||||
this.qemuService.getBinaries(server).subscribe((qemuBinaries: QemuBinary[]) => {
|
|
||||||
|
this.qemuService.getBinaries(this.server).subscribe((qemuBinaries: QemuBinary[]) => {
|
||||||
this.qemuBinaries = qemuBinaries;
|
this.qemuBinaries = qemuBinaries;
|
||||||
if (this.qemuBinaries[0]) this.selectedBinary = this.qemuBinaries[0];
|
if (this.qemuBinaries[0]) this.selectedBinary = this.qemuBinaries[0];
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!this.server.authToken) {
|
this.qemuService.getImages(this.server).subscribe((qemuImages: QemuImage[]) => {
|
||||||
this.qemuService.getImages(server).subscribe((qemuImages: QemuImage[]) => {
|
this.qemuImages = qemuImages;
|
||||||
this.qemuImages = qemuImages;
|
});
|
||||||
});
|
|
||||||
}
|
this.selectPlatform = this.configurationService.getPlatform();
|
||||||
|
this.selectedPlatform = this.selectPlatform[0];
|
||||||
|
|
||||||
this.consoleTypes = this.configurationService.getConsoleTypes();
|
this.consoleTypes = this.configurationService.getConsoleTypes();
|
||||||
});
|
});
|
||||||
@ -124,6 +130,7 @@ export class AddQemuVmTemplateComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
uploadImageFile(event) {
|
uploadImageFile(event) {
|
||||||
|
|
||||||
this.uploadedFile = true;
|
this.uploadedFile = true;
|
||||||
let name = event.target.files[0].name;
|
let name = event.target.files[0].name;
|
||||||
this.diskForm.controls['fileName'].setValue(name);
|
this.diskForm.controls['fileName'].setValue(name);
|
||||||
@ -132,9 +139,10 @@ export class AddQemuVmTemplateComponent implements OnInit {
|
|||||||
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];
|
||||||
if ((itemToUpload as any).options) (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);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
goBack() {
|
goBack() {
|
||||||
@ -142,9 +150,12 @@ export class AddQemuVmTemplateComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
addTemplate() {
|
addTemplate() {
|
||||||
|
debugger
|
||||||
if (!this.nameForm.invalid && !this.memoryForm.invalid && (this.selectedImage || this.chosenImage)) {
|
if (!this.nameForm.invalid && !this.memoryForm.invalid && (this.selectedImage || this.chosenImage)) {
|
||||||
this.qemuTemplate.ram = +this.memoryForm.get('ramMemory').value;
|
this.qemuTemplate.ram = +this.memoryForm.get('ramMemory').value;
|
||||||
this.qemuTemplate.qemu_path = this.selectedBinary.path;
|
this.qemuTemplate.qemu_path = this.selectedBinary.path;
|
||||||
|
this.qemuTemplate.platform = this.selectedPlatform;
|
||||||
|
|
||||||
if (this.newImageSelected) {
|
if (this.newImageSelected) {
|
||||||
this.qemuTemplate.hda_disk_image = this.diskForm.get('fileName').value;
|
this.qemuTemplate.hda_disk_image = this.diskForm.get('fileName').value;
|
||||||
} else {
|
} else {
|
||||||
|
@ -106,6 +106,11 @@ export class NewTemplateDialogComponent implements OnInit {
|
|||||||
if (compute.capabilities.platform === 'linux') this.isLinuxPlatform = true;
|
if (compute.capabilities.platform === 'linux') this.isLinuxPlatform = true;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this.qemuService.getBinaries(this.server).subscribe((binaries) => {
|
||||||
|
this.qemuBinaries = binaries;
|
||||||
|
});
|
||||||
|
|
||||||
this.qemuService.getImages(this.server).subscribe((qemuImages) => {
|
this.qemuService.getImages(this.server).subscribe((qemuImages) => {
|
||||||
this.qemuImages = qemuImages;
|
this.qemuImages = qemuImages;
|
||||||
});
|
});
|
||||||
@ -178,9 +183,7 @@ export class NewTemplateDialogComponent implements OnInit {
|
|||||||
this.uploaderImage.clearQueue();
|
this.uploaderImage.clearQueue();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
this.qemuService.getBinaries(this.server).subscribe((binaries) => {
|
|
||||||
this.qemuBinaries = binaries;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
updateAppliances() {
|
updateAppliances() {
|
||||||
|
@ -2,6 +2,10 @@ import { Injectable } from '@angular/core';
|
|||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class QemuConfigurationService {
|
export class QemuConfigurationService {
|
||||||
|
getPlatform() {
|
||||||
|
return ['x86_64', 'aarch64', 'alpha', 'arm', 'cris', 'i386', 'lm32', 'm68k', 'microblaze', 'microblazeel', 'mips', 'mips64', 'mips64el', 'mipsel', 'moxie', 'or32', 'ppc', 'ppc64', 'ppcemb', 's390x', 'sh4', 'sh4eb', 'sparc', 'sparc64', 'tricore', 'unicore32', 'xtensa', 'xtensaeb'];
|
||||||
|
}
|
||||||
|
|
||||||
getConsoleTypes() {
|
getConsoleTypes() {
|
||||||
return ['telnet', 'vnc', 'spice', 'spice+agent', 'none'];
|
return ['telnet', 'vnc', 'spice', 'spice+agent', 'none'];
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,7 @@ export class QemuService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getImagePath(server: Server, filename: string): string {
|
getImagePath(server: Server, filename: string): string {
|
||||||
return `${server.protocol}//${server.host}:${server.port}/v3/compute/qemu/images/${filename}`;
|
return `${server.protocol}//${server.host}:${server.port}/v3/images/upload/${filename}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
getBinaries(server: Server): Observable<QemuBinary[]> {
|
getBinaries(server: Server): Observable<QemuBinary[]> {
|
||||||
@ -28,11 +28,11 @@ export class QemuService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getImages(server: Server): Observable<any> {
|
getImages(server: Server): Observable<any> {
|
||||||
return this.httpServer.get<QemuImage[]>(server, '/compute/qemu/images') as Observable<QemuImage[]>;
|
return this.httpServer.get<QemuImage[]>(server, '/images') as Observable<QemuImage[]>;
|
||||||
}
|
}
|
||||||
|
|
||||||
addImage(server: Server, qemuImg: QemuImg): Observable<QemuImg> {
|
addImage(server: Server, qemuImg: QemuImg): Observable<QemuImg> {
|
||||||
return this.httpServer.post<QemuImg>(server, '/compute/qemu/img', qemuImg) as Observable<QemuImg>;
|
return this.httpServer.post<QemuImg>(server, '/images/upload', qemuImg) as Observable<QemuImg>;
|
||||||
}
|
}
|
||||||
|
|
||||||
addTemplate(server: Server, qemuTemplate: QemuTemplate): Observable<QemuTemplate> {
|
addTemplate(server: Server, qemuTemplate: QemuTemplate): Observable<QemuTemplate> {
|
||||||
|
Loading…
Reference in New Issue
Block a user