mirror of
https://github.com/GNS3/gns3-web-ui.git
synced 2025-06-18 14:58:15 +00:00
Fix for docker templates
This commit is contained in:
@ -113,49 +113,66 @@
|
|||||||
<mat-step *ngIf="applianceToInstall">
|
<mat-step *ngIf="applianceToInstall">
|
||||||
<ng-template matStepLabel>{{secondActionTitle}}</ng-template>
|
<ng-template matStepLabel>{{secondActionTitle}}</ng-template>
|
||||||
|
|
||||||
|
<mat-card [hidden]="applianceToInstall">
|
||||||
|
Please select appliance to install first
|
||||||
|
</mat-card>
|
||||||
|
|
||||||
<mat-card [hidden]="!applianceToInstall">
|
<mat-card [hidden]="!applianceToInstall">
|
||||||
<div>
|
<div *ngIf="applianceToInstall.qemu">
|
||||||
Server type<br/>
|
<div>
|
||||||
<mat-radio-group class="radio-group">
|
Server type<br/>
|
||||||
<mat-radio-button [disabled]="true" class="radio-button" value="1" (click)="setServerType('local')">Install the appliance locally</mat-radio-button>
|
<mat-radio-group class="radio-group">
|
||||||
<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-button [disabled]="true" class="radio-button" value="1" (click)="setServerType('local')">Install the appliance locally</mat-radio-button>
|
||||||
</mat-radio-group>
|
<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>
|
||||||
<div>
|
|
||||||
Qemu binary<br/>
|
<div *ngIf="applianceToInstall.docker">
|
||||||
<mat-select
|
<div>
|
||||||
class="selection-group"
|
Server type<br/>
|
||||||
placeholder="Qemu binary"
|
<mat-radio-group class="radio-group">
|
||||||
[(ngModel)]="selectedBinary"
|
<mat-radio-button [disabled]="true" class="radio-button" value="1" (click)="setServerType('local')">Install the appliance locally</mat-radio-button>
|
||||||
[ngModelOptions]="{standalone: true}">
|
<mat-radio-button class="radio-button" value="2" checked (click)="setServerType('gns3 vm')">Install the appliance on the GNS3 VM</mat-radio-button>
|
||||||
<mat-option *ngFor="let binary of qemuBinaries" [value]="binary">
|
</mat-radio-group>
|
||||||
{{binary.path}}
|
</div>
|
||||||
</mat-option>
|
<button mat-raised-button color="primary" (click)="createDockerTemplate()" class="create-button">Create docker template</button>
|
||||||
</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>
|
</div>
|
||||||
</mat-card>
|
</mat-card>
|
||||||
|
|
||||||
|
@ -13,6 +13,8 @@ import { QemuBinary } from '../../../models/qemu/qemu-binary';
|
|||||||
import { QemuService } from '../../../services/qemu.service';
|
import { QemuService } from '../../../services/qemu.service';
|
||||||
import { QemuTemplate } from '../../../models/templates/qemu-template';
|
import { QemuTemplate } from '../../../models/templates/qemu-template';
|
||||||
import { v4 as uuid } from 'uuid';
|
import { v4 as uuid } from 'uuid';
|
||||||
|
import { DockerTemplate } from '../../../models/templates/docker-template';
|
||||||
|
import { DockerService } from '../../../services/docker.service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-new-template-dialog',
|
selector: 'app-new-template-dialog',
|
||||||
@ -64,6 +66,7 @@ export class NewTemplateDialogComponent implements OnInit {
|
|||||||
private changeDetector: ChangeDetectorRef,
|
private changeDetector: ChangeDetectorRef,
|
||||||
private toasterService: ToasterService,
|
private toasterService: ToasterService,
|
||||||
private qemuService: QemuService,
|
private qemuService: QemuService,
|
||||||
|
private dockerService: DockerService,
|
||||||
public dialog: MatDialog
|
public dialog: MatDialog
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
@ -246,7 +249,27 @@ export class NewTemplateDialogComponent implements OnInit {
|
|||||||
window.open(image.download_url);
|
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();
|
let qemuTemplate: QemuTemplate = new QemuTemplate();
|
||||||
qemuTemplate.name = this.applianceToInstall.name;
|
qemuTemplate.name = this.applianceToInstall.name;
|
||||||
qemuTemplate.ram = this.applianceToInstall.qemu.ram;
|
qemuTemplate.ram = this.applianceToInstall.qemu.ram;
|
||||||
|
Reference in New Issue
Block a user