mirror of
https://github.com/GNS3/gns3-web-ui.git
synced 2025-04-18 23:36:53 +00:00
Fix for docker templates
This commit is contained in:
parent
e7dfa6242b
commit
41e7f1c53e
@ -113,49 +113,66 @@
|
||||
<mat-step *ngIf="applianceToInstall">
|
||||
<ng-template matStepLabel>{{secondActionTitle}}</ng-template>
|
||||
|
||||
<mat-card [hidden]="applianceToInstall">
|
||||
Please select appliance to install first
|
||||
</mat-card>
|
||||
|
||||
<mat-card [hidden]="!applianceToInstall">
|
||||
<div>
|
||||
Server type<br/>
|
||||
<mat-radio-group class="radio-group">
|
||||
<mat-radio-button [disabled]="true" class="radio-button" value="1" (click)="setServerType('local')">Install the appliance locally</mat-radio-button>
|
||||
<mat-radio-button class="radio-button" value="2" checked (click)="setServerType('gns3 vm')">Install the appliance on the GNS3 VM</mat-radio-button>
|
||||
</mat-radio-group>
|
||||
<div *ngIf="applianceToInstall.qemu">
|
||||
<div>
|
||||
Server type<br/>
|
||||
<mat-radio-group class="radio-group">
|
||||
<mat-radio-button [disabled]="true" class="radio-button" value="1" (click)="setServerType('local')">Install the appliance locally</mat-radio-button>
|
||||
<mat-radio-button class="radio-button" value="2" checked (click)="setServerType('gns3 vm')">Install the appliance on the GNS3 VM</mat-radio-button>
|
||||
</mat-radio-group>
|
||||
</div>
|
||||
<div>
|
||||
Qemu binary<br/>
|
||||
<mat-select
|
||||
class="selection-group"
|
||||
placeholder="Qemu binary"
|
||||
[(ngModel)]="selectedBinary"
|
||||
[ngModelOptions]="{standalone: true}">
|
||||
<mat-option *ngFor="let binary of qemuBinaries" [value]="binary">
|
||||
{{binary.path}}
|
||||
</mat-option>
|
||||
</mat-select>
|
||||
</div>
|
||||
<div>
|
||||
Install required files
|
||||
<mat-list>
|
||||
<mat-list-item *ngFor="let image of applianceToInstall.images">
|
||||
<div class="list-item">
|
||||
<div>
|
||||
{{image.filename}}
|
||||
</div>
|
||||
<div>
|
||||
<input
|
||||
type="file"
|
||||
class="non-visible"
|
||||
#file2
|
||||
(change)="importImage($event)"
|
||||
ng2FileSelect
|
||||
[uploader]="uploaderImage"/>
|
||||
<button class="button" mat-raised-button (click)="file2.click()">Import</button>
|
||||
<button class="button" mat-raised-button (click)="downloadImage(image)">Download</button>
|
||||
<button class="button" mat-raised-button color="primary" (click)="createQemuTemplate(image)">Create</button>
|
||||
</div>
|
||||
</div>
|
||||
</mat-list-item>
|
||||
</mat-list>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
Qemu binary<br/>
|
||||
<mat-select
|
||||
class="selection-group"
|
||||
placeholder="Qemu binary"
|
||||
[(ngModel)]="selectedBinary"
|
||||
[ngModelOptions]="{standalone: true}">
|
||||
<mat-option *ngFor="let binary of qemuBinaries" [value]="binary">
|
||||
{{binary.path}}
|
||||
</mat-option>
|
||||
</mat-select>
|
||||
</div>
|
||||
<div>
|
||||
Install required files
|
||||
<mat-list>
|
||||
<mat-list-item *ngFor="let image of applianceToInstall.images">
|
||||
<div class="list-item">
|
||||
<div>
|
||||
{{image.filename}}
|
||||
</div>
|
||||
<div>
|
||||
<input
|
||||
type="file"
|
||||
class="non-visible"
|
||||
#file2
|
||||
(change)="importImage($event)"
|
||||
ng2FileSelect
|
||||
[uploader]="uploaderImage"/>
|
||||
<button class="button" mat-raised-button (click)="file2.click()">Import</button>
|
||||
<button class="button" mat-raised-button (click)="downloadImage(image)">Download</button>
|
||||
<button class="button" mat-raised-button color="primary" (click)="create(image)">Create</button>
|
||||
</div>
|
||||
</div>
|
||||
</mat-list-item>
|
||||
</mat-list>
|
||||
|
||||
<div *ngIf="applianceToInstall.docker">
|
||||
<div>
|
||||
Server type<br/>
|
||||
<mat-radio-group class="radio-group">
|
||||
<mat-radio-button [disabled]="true" class="radio-button" value="1" (click)="setServerType('local')">Install the appliance locally</mat-radio-button>
|
||||
<mat-radio-button class="radio-button" value="2" checked (click)="setServerType('gns3 vm')">Install the appliance on the GNS3 VM</mat-radio-button>
|
||||
</mat-radio-group>
|
||||
</div>
|
||||
<button mat-raised-button color="primary" (click)="createDockerTemplate()" class="create-button">Create docker template</button>
|
||||
</div>
|
||||
</mat-card>
|
||||
|
||||
|
@ -13,6 +13,8 @@ import { QemuBinary } from '../../../models/qemu/qemu-binary';
|
||||
import { QemuService } from '../../../services/qemu.service';
|
||||
import { QemuTemplate } from '../../../models/templates/qemu-template';
|
||||
import { v4 as uuid } from 'uuid';
|
||||
import { DockerTemplate } from '../../../models/templates/docker-template';
|
||||
import { DockerService } from '../../../services/docker.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-new-template-dialog',
|
||||
@ -64,6 +66,7 @@ export class NewTemplateDialogComponent implements OnInit {
|
||||
private changeDetector: ChangeDetectorRef,
|
||||
private toasterService: ToasterService,
|
||||
private qemuService: QemuService,
|
||||
private dockerService: DockerService,
|
||||
public dialog: MatDialog
|
||||
) {}
|
||||
|
||||
@ -246,7 +249,27 @@ export class NewTemplateDialogComponent implements OnInit {
|
||||
window.open(image.download_url);
|
||||
}
|
||||
|
||||
create(image: Image) {
|
||||
createDockerTemplate() {
|
||||
let dockerTemplate: DockerTemplate = new DockerTemplate();
|
||||
dockerTemplate.name = this.applianceToInstall.name;
|
||||
dockerTemplate.adapters = this.applianceToInstall.docker.adapters;
|
||||
dockerTemplate.console_type = this.applianceToInstall.docker.console_type;
|
||||
dockerTemplate.builtin = this.applianceToInstall.builtin;
|
||||
dockerTemplate.category = this.applianceToInstall.category;
|
||||
dockerTemplate.default_name_format = this.applianceToInstall.port_name_format;
|
||||
dockerTemplate.symbol = this.applianceToInstall.symbol;
|
||||
dockerTemplate.compute_id = this.isGns3VmChosen ? 'vm' : 'local';
|
||||
dockerTemplate.template_id = uuid();
|
||||
dockerTemplate.image = this.applianceToInstall.docker.image;
|
||||
dockerTemplate.template_type = 'docker';
|
||||
|
||||
this.dockerService.addTemplate(this.server, dockerTemplate).subscribe(() => {
|
||||
this.toasterService.success('Template added');
|
||||
this.dialogRef.close();
|
||||
});
|
||||
}
|
||||
|
||||
createQemuTemplate(image: Image) {
|
||||
let qemuTemplate: QemuTemplate = new QemuTemplate();
|
||||
qemuTemplate.name = this.applianceToInstall.name;
|
||||
qemuTemplate.ram = this.applianceToInstall.qemu.ram;
|
||||
|
Loading…
x
Reference in New Issue
Block a user