Fix for importing appliances

This commit is contained in:
piotrpekala7 2020-06-23 14:36:48 +02:00
parent 206242dba9
commit 92cfb2d94a
5 changed files with 33 additions and 3 deletions

View File

@ -147,6 +147,8 @@
{{image.filename}}
</div>
<div>
<span *ngIf="checkImage(image)"><mat-icon matTooltip="Ready to install">check</mat-icon></span>
<span *ngIf="!checkImage(image)"><mat-icon matTooltip="Missing">close</mat-icon></span>
<input
type="file"
class="non-visible"

View File

@ -63,6 +63,10 @@ export class NewTemplateDialogComponent implements OnInit {
public dataSource: MatTableDataSource<Appliance>;
private qemuImages: Image[] = [];
private iosImages: Image[] = [];
private iouImages: Image[] = [];
@ViewChild(MatPaginator, {static: true}) paginator: MatPaginator;
@ViewChild('stepper', {static: true}) stepper: MatStepper;
@ -80,6 +84,18 @@ export class NewTemplateDialogComponent implements OnInit {
) {}
ngOnInit() {
this.qemuService.getImages(this.server).subscribe((qemuImages) => {
this.qemuImages = qemuImages;
});
this.iosService.getImages(this.server).subscribe((iosImages) => {
this.iosImages = iosImages;
});
this.iouService.getImages(this.server).subscribe((iouImages) => {
this.iouImages = iouImages;
});
this.applianceService.getAppliances(this.server).subscribe((appliances) => {
this.appliances = appliances;
this.appliances.forEach(appliance => {
@ -256,6 +272,18 @@ export class NewTemplateDialogComponent implements OnInit {
fileReader.readAsText(file);
}
checkImage(image: Image): boolean {
if (this.applianceToInstall.qemu) {
if (this.qemuImages.filter(n => n.filename === image.filename).length > 0) return true;
} else if (this.applianceToInstall.dynamips) {
if (this.iosImages.filter(n => n.filename === image.filename).length > 0) return true;
} else if (this.applianceToInstall.iou) {
if (this.iouImages.filter(n => n.filename === image.filename).length > 0) return true;
}
return false;
}
downloadImage(image: Image) {
window.open(image.download_url);
}

View File

@ -9,7 +9,7 @@ import { IosImage } from '../models/images/ios-image';
export class IosService {
constructor(private httpServer: HttpServer) {}
getImages(server: Server): Observable<IosImage[]> {
getImages(server: Server): Observable<any> {
return this.httpServer.get<IosImage[]>(server, '/compute/dynamips/images') as Observable<IosImage[]>;
}

View File

@ -17,7 +17,7 @@ export class IouService {
return this.httpServer.get<IouTemplate>(server, `/templates/${template_id}`) as Observable<IouTemplate>;
}
getImages(server: Server): Observable<IouImage[]> {
getImages(server: Server): Observable<any> {
return this.httpServer.get<IouImage[]>(server, '/compute/iou/images') as Observable<IouImage[]>;
}

View File

@ -27,7 +27,7 @@ export class QemuService {
return this.httpServer.get<QemuBinary[]>(server, '/computes/local/qemu/binaries') as Observable<QemuBinary[]>;
}
getImages(server: Server): Observable<QemuImage[]> {
getImages(server: Server): Observable<any> {
return this.httpServer.get<QemuImage[]>(server, '/compute/qemu/images') as Observable<QemuImage[]>;
}