mirror of
https://github.com/GNS3/gns3-web-ui.git
synced 2025-02-07 03:40:11 +00:00
Custom adapters separated to new component
This commit is contained in:
parent
ebde71eba5
commit
18a80468d0
@ -165,6 +165,7 @@ import { SearchFilter } from './filters/searchFilter.pipe';
|
|||||||
import { RecentlyOpenedProjectService } from './services/recentlyOpenedProject.service';
|
import { RecentlyOpenedProjectService } from './services/recentlyOpenedProject.service';
|
||||||
import { ServerManagementService } from './services/server-management.service';
|
import { ServerManagementService } from './services/server-management.service';
|
||||||
import { DeleteActionComponent } from './components/project-map/context-menu/actions/delete-action/delete-action.component';
|
import { DeleteActionComponent } from './components/project-map/context-menu/actions/delete-action/delete-action.component';
|
||||||
|
import { CustomAdaptersComponent } from './components/preferences/common/custom-adapters/custom-adapters.component';
|
||||||
|
|
||||||
if (environment.production) {
|
if (environment.production) {
|
||||||
Raven.config('https://b2b1cfd9b043491eb6b566fd8acee358@sentry.io/842726', {
|
Raven.config('https://b2b1cfd9b043491eb6b566fd8acee358@sentry.io/842726', {
|
||||||
@ -267,7 +268,8 @@ if (environment.production) {
|
|||||||
CopyDockerTemplateComponent,
|
CopyDockerTemplateComponent,
|
||||||
EmptyTemplatesListComponent,
|
EmptyTemplatesListComponent,
|
||||||
SymbolsMenuComponent,
|
SymbolsMenuComponent,
|
||||||
SearchFilter
|
SearchFilter,
|
||||||
|
CustomAdaptersComponent
|
||||||
],
|
],
|
||||||
imports: [
|
imports: [
|
||||||
BrowserModule,
|
BrowserModule,
|
||||||
|
@ -0,0 +1,40 @@
|
|||||||
|
<div class="content" class="configurator">
|
||||||
|
<div class="default-header">
|
||||||
|
<div class="row">
|
||||||
|
<h1 class="col">Custom adapters configuration</h1>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="default-content">
|
||||||
|
<div class="container mat-elevation-z8">
|
||||||
|
<table class="table" mat-table [dataSource]="adapters">
|
||||||
|
<ng-container matColumnDef="adapter_number">
|
||||||
|
<th mat-header-cell *matHeaderCellDef> Adapter number </th>
|
||||||
|
<td mat-cell *matCellDef="let element"> Adapter {{element.adapter_number}} </td>
|
||||||
|
</ng-container>
|
||||||
|
|
||||||
|
<ng-container matColumnDef="port_name">
|
||||||
|
<th mat-header-cell *matHeaderCellDef> Port name </th>
|
||||||
|
<td mat-cell *matCellDef="let element"> Ethernet {{element.adapter_number}} </td>
|
||||||
|
</ng-container>
|
||||||
|
|
||||||
|
<ng-container matColumnDef="adapter_type">
|
||||||
|
<th mat-header-cell *matHeaderCellDef> Adapter type </th>
|
||||||
|
<td mat-cell *matCellDef="let element; let i = index;">
|
||||||
|
<mat-select placeholder="Type" [(ngModel)]="adapters[i].adapter_type">
|
||||||
|
<mat-option *ngFor="let type of networkTypes" [value]="type[0]">
|
||||||
|
{{type[1]}} ({{type[0]}})
|
||||||
|
</mat-option>
|
||||||
|
</mat-select>
|
||||||
|
</td>
|
||||||
|
</ng-container>
|
||||||
|
|
||||||
|
<tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
|
||||||
|
<tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
<div class="buttons-bar">
|
||||||
|
<button mat-button (click)="cancelConfigureCustomAdapters()">Cancel</button>
|
||||||
|
<button mat-raised-button color="primary" (click)="configureCustomAdapters()">Apply</button><br/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
@ -0,0 +1,26 @@
|
|||||||
|
import { Component, Input, Output, EventEmitter } from '@angular/core';
|
||||||
|
import { CustomAdapter } from '../../../../models/qemu/qemu-custom-adapter';
|
||||||
|
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'app-custom-adapters',
|
||||||
|
templateUrl: './custom-adapters.component.html',
|
||||||
|
styleUrls: ['./custom-adapters.component.scss', '../../preferences.component.scss']
|
||||||
|
})
|
||||||
|
export class CustomAdaptersComponent {
|
||||||
|
@Input() networkTypes = [];
|
||||||
|
@Input() displayedColumns: string[] = [];
|
||||||
|
@Output() closeConfiguratorEmitter = new EventEmitter<boolean>();
|
||||||
|
@Output() saveConfigurationEmitter = new EventEmitter<CustomAdapter[]>();
|
||||||
|
|
||||||
|
public adapters: CustomAdapter[];
|
||||||
|
public numberOfAdapters: number;
|
||||||
|
|
||||||
|
cancelConfigureCustomAdapters(){
|
||||||
|
this.closeConfiguratorEmitter.emit(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
configureCustomAdapters(){
|
||||||
|
this.saveConfigurationEmitter.emit(this.adapters);
|
||||||
|
}
|
||||||
|
}
|
@ -198,7 +198,7 @@
|
|||||||
</mat-option>
|
</mat-option>
|
||||||
</mat-select>
|
</mat-select>
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
<button mat-button class="configButton" (click)="configureCustomAdapters()">Configure custom adapters</button><br/>
|
<button mat-button class="configButton" (click)="setCustomAdaptersConfiguratorState(true)">Configure custom adapters</button><br/>
|
||||||
<mat-checkbox [(ngModel)]="qemuTemplate.legacy_networking">
|
<mat-checkbox [(ngModel)]="qemuTemplate.legacy_networking">
|
||||||
Use the legacy networking mode
|
Use the legacy networking mode
|
||||||
</mat-checkbox>
|
</mat-checkbox>
|
||||||
@ -326,44 +326,17 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="content" class="configurator" *ngIf="isConfiguratorOpened">
|
<app-custom-adapters
|
||||||
<div class="default-header">
|
[hidden]="!(isConfiguratorOpened && qemuTemplate)"
|
||||||
<div class="row">
|
#customAdaptersConfigurator
|
||||||
<h1 class="col">Custom adapters configuration</h1>
|
[networkTypes]="networkTypes"
|
||||||
</div>
|
[displayedColumns]="displayedColumns"
|
||||||
</div>
|
(closeConfiguratorEmitter)="setCustomAdaptersConfiguratorState($event)"
|
||||||
<div class="default-content" *ngIf="qemuTemplate">
|
(saveConfigurationEmitter)="saveCustomAdapters($event)"
|
||||||
<div class="container mat-elevation-z8">
|
></app-custom-adapters>
|
||||||
<table class="table" mat-table [dataSource]="adapters">
|
<app-symbols-menu
|
||||||
<ng-container matColumnDef="adapter_number">
|
*ngIf="isSymbolSelectionOpened && qemuTemplate"
|
||||||
<th mat-header-cell *matHeaderCellDef> Adapter number </th>
|
[server]="server"
|
||||||
<td mat-cell *matCellDef="let element"> Adapter {{element.adapter_number}} </td>
|
[symbol]="qemuTemplate.symbol"
|
||||||
</ng-container>
|
(symbolChangedEmitter)="symbolChanged($event)"
|
||||||
|
></app-symbols-menu>
|
||||||
<ng-container matColumnDef="port_name">
|
|
||||||
<th mat-header-cell *matHeaderCellDef> Port name </th>
|
|
||||||
<td mat-cell *matCellDef="let element"> Ethernet {{element.adapter_number}} </td>
|
|
||||||
</ng-container>
|
|
||||||
|
|
||||||
<ng-container matColumnDef="adapter_type">
|
|
||||||
<th mat-header-cell *matHeaderCellDef> Adapter type </th>
|
|
||||||
<td mat-cell *matCellDef="let element; let i = index;">
|
|
||||||
<mat-select placeholder="Type" [(ngModel)]="adapters[i].adapter_type">
|
|
||||||
<mat-option *ngFor="let type of networkTypes" [value]="type[0]">
|
|
||||||
{{type[1]}} ({{type[0]}})
|
|
||||||
</mat-option>
|
|
||||||
</mat-select>
|
|
||||||
</td>
|
|
||||||
</ng-container>
|
|
||||||
|
|
||||||
<tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
|
|
||||||
<tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
<div class="buttons-bar">
|
|
||||||
<button mat-button (click)="cancelConfigureCustomAdapters()">Cancel</button>
|
|
||||||
<button mat-raised-button color="primary" (click)="configureCustomAdapters()">Apply</button><br/>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<app-symbols-menu *ngIf="isSymbolSelectionOpened && qemuTemplate" [server]="server" [symbol]="qemuTemplate.symbol" (symbolChangedEmitter)="symbolChanged($event)"></app-symbols-menu>
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { Component, OnInit } from "@angular/core";
|
import { Component, OnInit, ViewChildren, ViewChild, QueryList } from "@angular/core";
|
||||||
import { ActivatedRoute, Router } from '@angular/router';
|
import { ActivatedRoute, Router } from '@angular/router';
|
||||||
import { ServerService } from '../../../../services/server.service';
|
import { ServerService } from '../../../../services/server.service';
|
||||||
import { QemuService } from '../../../../services/qemu.service';
|
import { QemuService } from '../../../../services/qemu.service';
|
||||||
@ -9,6 +9,7 @@ import { ToasterService } from '../../../../services/toaster.service';
|
|||||||
import { CustomAdapter } from '../../../../models/qemu/qemu-custom-adapter';
|
import { CustomAdapter } from '../../../../models/qemu/qemu-custom-adapter';
|
||||||
import { QemuConfigurationService } from '../../../../services/qemu-configuration.service';
|
import { QemuConfigurationService } from '../../../../services/qemu-configuration.service';
|
||||||
import { FormGroup, FormControl, Validators, FormBuilder } from '@angular/forms';
|
import { FormGroup, FormControl, Validators, FormBuilder } from '@angular/forms';
|
||||||
|
import { CustomAdaptersComponent } from '../../common/custom-adapters/custom-adapters.component';
|
||||||
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
@ -19,9 +20,7 @@ import { FormGroup, FormControl, Validators, FormBuilder } from '@angular/forms'
|
|||||||
export class QemuVmTemplateDetailsComponent implements OnInit {
|
export class QemuVmTemplateDetailsComponent implements OnInit {
|
||||||
server: Server;
|
server: Server;
|
||||||
qemuTemplate: QemuTemplate;
|
qemuTemplate: QemuTemplate;
|
||||||
|
|
||||||
isSymbolSelectionOpened: boolean = false;
|
isSymbolSelectionOpened: boolean = false;
|
||||||
|
|
||||||
consoleTypes: string[] = [];
|
consoleTypes: string[] = [];
|
||||||
diskInterfaces: string[] = [];
|
diskInterfaces: string[] = [];
|
||||||
networkTypes = [];
|
networkTypes = [];
|
||||||
@ -32,11 +31,12 @@ export class QemuVmTemplateDetailsComponent implements OnInit {
|
|||||||
binaries: QemuBinary[] = [];
|
binaries: QemuBinary[] = [];
|
||||||
activateCpuThrottling: boolean = true;
|
activateCpuThrottling: boolean = true;
|
||||||
isConfiguratorOpened: boolean = false;
|
isConfiguratorOpened: boolean = false;
|
||||||
adapters: CustomAdapter[] = [];
|
|
||||||
displayedColumns: string[] = ['adapter_number', 'port_name', 'adapter_type'];
|
displayedColumns: string[] = ['adapter_number', 'port_name', 'adapter_type'];
|
||||||
|
|
||||||
generalSettingsForm: FormGroup;
|
generalSettingsForm: FormGroup;
|
||||||
|
|
||||||
|
@ViewChild("customAdaptersConfigurator")
|
||||||
|
customAdaptersConfigurator: CustomAdaptersComponent;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private route: ActivatedRoute,
|
private route: ActivatedRoute,
|
||||||
private serverService: ServerService,
|
private serverService: ServerService,
|
||||||
@ -62,9 +62,7 @@ export class QemuVmTemplateDetailsComponent implements OnInit {
|
|||||||
this.getConfiguration();
|
this.getConfiguration();
|
||||||
this.qemuService.getTemplate(this.server, template_id).subscribe((qemuTemplate: QemuTemplate) => {
|
this.qemuService.getTemplate(this.server, template_id).subscribe((qemuTemplate: QemuTemplate) => {
|
||||||
this.qemuTemplate = qemuTemplate;
|
this.qemuTemplate = qemuTemplate;
|
||||||
this.qemuTemplate.custom_adapters.forEach((adapter: CustomAdapter) => {
|
this.fillCustomAdapters();
|
||||||
this.adapters.push(adapter);
|
|
||||||
});
|
|
||||||
|
|
||||||
this.qemuService.getBinaries(server).subscribe((qemuBinaries: QemuBinary[]) => {
|
this.qemuService.getBinaries(server).subscribe((qemuBinaries: QemuBinary[]) => {
|
||||||
this.binaries = qemuBinaries;
|
this.binaries = qemuBinaries;
|
||||||
@ -99,24 +97,36 @@ export class QemuVmTemplateDetailsComponent implements OnInit {
|
|||||||
this.qemuTemplate.bios_image = event.target.files[0].name;
|
this.qemuTemplate.bios_image = event.target.files[0].name;
|
||||||
}
|
}
|
||||||
|
|
||||||
cancelConfigureCustomAdapters(){
|
setCustomAdaptersConfiguratorState(state: boolean) {
|
||||||
this.isConfiguratorOpened = !this.isConfiguratorOpened;
|
this.isConfiguratorOpened = state;
|
||||||
|
|
||||||
|
if (state) {
|
||||||
|
this.fillCustomAdapters();
|
||||||
|
this.customAdaptersConfigurator.numberOfAdapters = this.qemuTemplate.adapters;
|
||||||
|
this.customAdaptersConfigurator.adapters = [];
|
||||||
|
this.qemuTemplate.custom_adapters.forEach((adapter: CustomAdapter) => {
|
||||||
|
this.customAdaptersConfigurator.adapters.push({
|
||||||
|
adapter_number: adapter.adapter_number,
|
||||||
|
adapter_type: adapter.adapter_type
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
configureCustomAdapters(){
|
saveCustomAdapters(adapters: CustomAdapter[]){
|
||||||
this.isConfiguratorOpened = !this.isConfiguratorOpened;
|
this.setCustomAdaptersConfiguratorState(false);
|
||||||
this.saveCustomAdapters();
|
this.qemuTemplate.custom_adapters = adapters;
|
||||||
}
|
}
|
||||||
|
|
||||||
saveCustomAdapters() {
|
fillCustomAdapters() {
|
||||||
let copyOfAdapters = this.adapters;
|
let copyOfAdapters = this.qemuTemplate.custom_adapters ? this.qemuTemplate.custom_adapters : [];
|
||||||
this.adapters = [];
|
this.qemuTemplate.custom_adapters = [];
|
||||||
|
|
||||||
for(let i=0; i<this.qemuTemplate.adapters; i++){
|
for(let i=0; i<this.qemuTemplate.adapters; i++){
|
||||||
if (copyOfAdapters[i]) {
|
if (copyOfAdapters[i]) {
|
||||||
this.adapters.push(copyOfAdapters[i]);
|
this.qemuTemplate.custom_adapters.push(copyOfAdapters[i]);
|
||||||
} else {
|
} else {
|
||||||
this.adapters.push({
|
this.qemuTemplate.custom_adapters.push({
|
||||||
adapter_number: i,
|
adapter_number: i,
|
||||||
adapter_type: 'e1000'
|
adapter_type: 'e1000'
|
||||||
});
|
});
|
||||||
@ -135,8 +145,7 @@ export class QemuVmTemplateDetailsComponent implements OnInit {
|
|||||||
if (!this.activateCpuThrottling){
|
if (!this.activateCpuThrottling){
|
||||||
this.qemuTemplate.cpu_throttling = 0;
|
this.qemuTemplate.cpu_throttling = 0;
|
||||||
}
|
}
|
||||||
this.saveCustomAdapters();
|
this.fillCustomAdapters();
|
||||||
this.qemuTemplate.custom_adapters = this.adapters;
|
|
||||||
|
|
||||||
this.qemuService.saveTemplate(this.server, this.qemuTemplate).subscribe((savedTemplate: QemuTemplate) => {
|
this.qemuService.saveTemplate(this.server, this.qemuTemplate).subscribe((savedTemplate: QemuTemplate) => {
|
||||||
this.toasterService.success("Changes saved");
|
this.toasterService.success("Changes saved");
|
||||||
|
@ -85,7 +85,7 @@
|
|||||||
</mat-select>
|
</mat-select>
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
</form>
|
</form>
|
||||||
<button mat-button class="configButton" (click)="configureCustomAdapters()">Configure custom adapters</button><br/>
|
<button mat-button class="configButton" (click)="setCustomAdaptersConfiguratorState(true)">Configure custom adapters</button><br/>
|
||||||
<mat-checkbox [(ngModel)]="virtualBoxTemplate.use_any_adapter">
|
<mat-checkbox [(ngModel)]="virtualBoxTemplate.use_any_adapter">
|
||||||
Allow GNS3 to use any configured VirtualBox adapter
|
Allow GNS3 to use any configured VirtualBox adapter
|
||||||
</mat-checkbox>
|
</mat-checkbox>
|
||||||
@ -107,44 +107,17 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="content" class="configurator" *ngIf="isConfiguratorOpened">
|
<app-custom-adapters
|
||||||
<div class="default-header">
|
[hidden]="!(isConfiguratorOpened && virtualBoxTemplate)"
|
||||||
<div class="row">
|
#customAdaptersConfigurator
|
||||||
<h1 class="col">Custom adapters configuration</h1>
|
[networkTypes]="networkTypes"
|
||||||
</div>
|
[displayedColumns]="displayedColumns"
|
||||||
</div>
|
(closeConfiguratorEmitter)="setCustomAdaptersConfiguratorState($event)"
|
||||||
<div class="default-content" *ngIf="virtualBoxTemplate">
|
(saveConfigurationEmitter)="saveCustomAdapters($event)"
|
||||||
<div class="container mat-elevation-z8">
|
></app-custom-adapters>
|
||||||
<table class="table" mat-table [dataSource]="adapters">
|
<app-symbols-menu
|
||||||
<ng-container matColumnDef="adapter_number">
|
*ngIf="isSymbolSelectionOpened && virtualBoxTemplate"
|
||||||
<th mat-header-cell *matHeaderCellDef> Adapter number </th>
|
[server]="server"
|
||||||
<td mat-cell *matCellDef="let element"> Adapter {{element.adapter_number}} </td>
|
[symbol]="virtualBoxTemplate.symbol"
|
||||||
</ng-container>
|
(symbolChangedEmitter)="symbolChanged($event)"
|
||||||
|
></app-symbols-menu>
|
||||||
<ng-container matColumnDef="port_name">
|
|
||||||
<th mat-header-cell *matHeaderCellDef> Port name </th>
|
|
||||||
<td mat-cell *matCellDef="let element"> Ethernet {{element.adapter_number}} </td>
|
|
||||||
</ng-container>
|
|
||||||
|
|
||||||
<ng-container matColumnDef="adapter_type">
|
|
||||||
<th mat-header-cell *matHeaderCellDef> Adapter type </th>
|
|
||||||
<td mat-cell *matCellDef="let element; let i = index;">
|
|
||||||
<mat-select placeholder="Type" [(ngModel)]="adapters[i].adapter_type">
|
|
||||||
<mat-option *ngFor="let type of networkTypes" [value]="type">
|
|
||||||
{{type}}
|
|
||||||
</mat-option>
|
|
||||||
</mat-select>
|
|
||||||
</td>
|
|
||||||
</ng-container>
|
|
||||||
|
|
||||||
<tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
|
|
||||||
<tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
<div class="buttons-bar">
|
|
||||||
<button mat-button (click)="cancelConfigureCustomAdapters()">Cancel</button>
|
|
||||||
<button mat-raised-button color="primary" (click)="configureCustomAdapters()">Apply</button><br/>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<app-symbols-menu *ngIf="isSymbolSelectionOpened && virtualBoxTemplate" [server]="server" [symbol]="virtualBoxTemplate.symbol" (symbolChangedEmitter)="symbolChanged($event)"></app-symbols-menu>
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { Component, OnInit } from "@angular/core";
|
import { Component, OnInit, ViewChild } from "@angular/core";
|
||||||
import { ActivatedRoute, Router } from '@angular/router';
|
import { ActivatedRoute, Router } from '@angular/router';
|
||||||
import { ServerService } from '../../../../services/server.service';
|
import { ServerService } from '../../../../services/server.service';
|
||||||
import { Server } from '../../../../models/server';
|
import { Server } from '../../../../models/server';
|
||||||
@ -8,6 +8,7 @@ import { VirtualBoxService } from '../../../../services/virtual-box.service';
|
|||||||
import { VirtualBoxTemplate } from '../../../../models/templates/virtualbox-template';
|
import { VirtualBoxTemplate } from '../../../../models/templates/virtualbox-template';
|
||||||
import { CustomAdapter } from '../../../../models/qemu/qemu-custom-adapter';
|
import { CustomAdapter } from '../../../../models/qemu/qemu-custom-adapter';
|
||||||
import { VirtualBoxConfigurationService } from '../../../../services/virtual-box-configuration.service';
|
import { VirtualBoxConfigurationService } from '../../../../services/virtual-box-configuration.service';
|
||||||
|
import { CustomAdaptersComponent } from '../../common/custom-adapters/custom-adapters.component';
|
||||||
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
@ -18,20 +19,19 @@ import { VirtualBoxConfigurationService } from '../../../../services/virtual-box
|
|||||||
export class VirtualBoxTemplateDetailsComponent implements OnInit {
|
export class VirtualBoxTemplateDetailsComponent implements OnInit {
|
||||||
server: Server;
|
server: Server;
|
||||||
virtualBoxTemplate: VirtualBoxTemplate;
|
virtualBoxTemplate: VirtualBoxTemplate;
|
||||||
|
|
||||||
isSymbolSelectionOpened: boolean = false;
|
isSymbolSelectionOpened: boolean = false;
|
||||||
|
|
||||||
consoleTypes: string[] = [];
|
consoleTypes: string[] = [];
|
||||||
onCloseOptions = [];
|
onCloseOptions = [];
|
||||||
categories = [];
|
categories = [];
|
||||||
networkTypes = [];
|
networkTypes = [];
|
||||||
adapters: CustomAdapter[] = [];
|
|
||||||
displayedColumns: string[] = ['adapter_number', 'port_name', 'adapter_type'];
|
displayedColumns: string[] = ['adapter_number', 'port_name', 'adapter_type'];
|
||||||
isConfiguratorOpened: boolean = false;
|
isConfiguratorOpened: boolean = false;
|
||||||
|
|
||||||
generalSettingsForm: FormGroup;
|
generalSettingsForm: FormGroup;
|
||||||
networkForm: FormGroup
|
networkForm: FormGroup
|
||||||
|
|
||||||
|
@ViewChild("customAdaptersConfigurator")
|
||||||
|
customAdaptersConfigurator: CustomAdaptersComponent;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private route: ActivatedRoute,
|
private route: ActivatedRoute,
|
||||||
private serverService: ServerService,
|
private serverService: ServerService,
|
||||||
@ -64,10 +64,7 @@ export class VirtualBoxTemplateDetailsComponent implements OnInit {
|
|||||||
this.getConfiguration();
|
this.getConfiguration();
|
||||||
this.virtualBoxService.getTemplate(this.server, template_id).subscribe((virtualBoxTemplate: VirtualBoxTemplate) => {
|
this.virtualBoxService.getTemplate(this.server, template_id).subscribe((virtualBoxTemplate: VirtualBoxTemplate) => {
|
||||||
this.virtualBoxTemplate = virtualBoxTemplate;
|
this.virtualBoxTemplate = virtualBoxTemplate;
|
||||||
|
this.fillCustomAdapters();
|
||||||
this.virtualBoxTemplate.custom_adapters.forEach((adapter: CustomAdapter) => {
|
|
||||||
this.adapters.push(adapter);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -79,20 +76,36 @@ export class VirtualBoxTemplateDetailsComponent implements OnInit {
|
|||||||
this.networkTypes = this.virtualBoxConfigurationService.getNetworkTypes();
|
this.networkTypes = this.virtualBoxConfigurationService.getNetworkTypes();
|
||||||
}
|
}
|
||||||
|
|
||||||
configureCustomAdapters(){
|
setCustomAdaptersConfiguratorState(state: boolean) {
|
||||||
this.isConfiguratorOpened = !this.isConfiguratorOpened;
|
this.isConfiguratorOpened = state;
|
||||||
this.saveCustomAdapters();
|
|
||||||
|
if (state) {
|
||||||
|
this.fillCustomAdapters();
|
||||||
|
this.customAdaptersConfigurator.numberOfAdapters = this.virtualBoxTemplate.adapters;
|
||||||
|
this.customAdaptersConfigurator.adapters = [];
|
||||||
|
this.virtualBoxTemplate.custom_adapters.forEach((adapter: CustomAdapter) => {
|
||||||
|
this.customAdaptersConfigurator.adapters.push({
|
||||||
|
adapter_number: adapter.adapter_number,
|
||||||
|
adapter_type: adapter.adapter_type
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
saveCustomAdapters() {
|
saveCustomAdapters(adapters: CustomAdapter[]){
|
||||||
let copyOfAdapters = this.adapters;
|
this.setCustomAdaptersConfiguratorState(false);
|
||||||
this.adapters = [];
|
this.virtualBoxTemplate.custom_adapters = adapters;
|
||||||
|
}
|
||||||
|
|
||||||
|
fillCustomAdapters() {
|
||||||
|
let copyOfAdapters = this.virtualBoxTemplate.custom_adapters ? this.virtualBoxTemplate.custom_adapters : [];
|
||||||
|
this.virtualBoxTemplate.custom_adapters = [];
|
||||||
|
|
||||||
for(let i=0; i<this.virtualBoxTemplate.adapters; i++){
|
for(let i=0; i<this.virtualBoxTemplate.adapters; i++){
|
||||||
if (copyOfAdapters[i]) {
|
if (copyOfAdapters[i]) {
|
||||||
this.adapters.push(copyOfAdapters[i]);
|
this.virtualBoxTemplate.custom_adapters.push(copyOfAdapters[i]);
|
||||||
} else {
|
} else {
|
||||||
this.adapters.push({
|
this.virtualBoxTemplate.custom_adapters.push({
|
||||||
adapter_number: i,
|
adapter_number: i,
|
||||||
adapter_type: 'e1000'
|
adapter_type: 'e1000'
|
||||||
});
|
});
|
||||||
@ -100,21 +113,20 @@ export class VirtualBoxTemplateDetailsComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
cancelConfigureCustomAdapters(){
|
|
||||||
this.isConfiguratorOpened = !this.isConfiguratorOpened;
|
|
||||||
}
|
|
||||||
|
|
||||||
goBack() {
|
goBack() {
|
||||||
this.router.navigate(['/server', this.server.id, 'preferences', 'virtualbox', 'templates']);
|
this.router.navigate(['/server', this.server.id, 'preferences', 'virtualbox', 'templates']);
|
||||||
}
|
}
|
||||||
|
|
||||||
onSave() {
|
onSave() {
|
||||||
this.saveCustomAdapters();
|
if (this.generalSettingsForm.invalid || this.networkForm.invalid) {
|
||||||
this.virtualBoxTemplate.custom_adapters = this.adapters;
|
this.toasterService.error(`Fill all required fields`);
|
||||||
|
} else {
|
||||||
|
this.fillCustomAdapters();
|
||||||
|
|
||||||
this.virtualBoxService.saveTemplate(this.server, this.virtualBoxTemplate).subscribe((virtualBoxTemplate: VirtualBoxTemplate) => {
|
this.virtualBoxService.saveTemplate(this.server, this.virtualBoxTemplate).subscribe((virtualBoxTemplate: VirtualBoxTemplate) => {
|
||||||
this.toasterService.success("Changes saved");
|
this.toasterService.success("Changes saved");
|
||||||
});
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
chooseSymbol() {
|
chooseSymbol() {
|
||||||
|
@ -107,7 +107,7 @@
|
|||||||
</mat-option>
|
</mat-option>
|
||||||
</mat-select>
|
</mat-select>
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
<button mat-button class="configButton" (click)="configureCustomAdapters()">Configure custom adapters</button><br/>
|
<button mat-button class="configButton" (click)="setCustomAdaptersConfiguratorState(true)">Configure custom adapters</button><br/>
|
||||||
<mat-checkbox [(ngModel)]="vmwareTemplate.use_any_adapter">
|
<mat-checkbox [(ngModel)]="vmwareTemplate.use_any_adapter">
|
||||||
Allow GNS3 to override non custom VMware adapter
|
Allow GNS3 to override non custom VMware adapter
|
||||||
</mat-checkbox>
|
</mat-checkbox>
|
||||||
@ -129,44 +129,17 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="content" class="configurator" *ngIf="isConfiguratorOpened">
|
<app-custom-adapters
|
||||||
<div class="default-header">
|
[hidden]="!(isConfiguratorOpened && vmwareTemplate)"
|
||||||
<div class="row">
|
#customAdaptersConfigurator
|
||||||
<h1 class="col">Custom adapters configuration</h1>
|
[networkTypes]="networkTypes"
|
||||||
</div>
|
[displayedColumns]="displayedColumns"
|
||||||
</div>
|
(closeConfiguratorEmitter)="setCustomAdaptersConfiguratorState($event)"
|
||||||
<div class="default-content" *ngIf="vmwareTemplate">
|
(saveConfigurationEmitter)="saveCustomAdapters($event)"
|
||||||
<div class="container mat-elevation-z8">
|
></app-custom-adapters>
|
||||||
<table class="table" mat-table [dataSource]="adapters">
|
<app-symbols-menu
|
||||||
<ng-container matColumnDef="adapter_number">
|
*ngIf="isSymbolSelectionOpened && vmwareTemplate"
|
||||||
<th mat-header-cell *matHeaderCellDef> Adapter number </th>
|
[server]="server"
|
||||||
<td mat-cell *matCellDef="let element"> Adapter {{element.adapter_number}} </td>
|
[symbol]="vmwareTemplate.symbol"
|
||||||
</ng-container>
|
(symbolChangedEmitter)="symbolChanged($event)"
|
||||||
|
></app-symbols-menu>
|
||||||
<ng-container matColumnDef="port_name">
|
|
||||||
<th mat-header-cell *matHeaderCellDef> Port name </th>
|
|
||||||
<td mat-cell *matCellDef="let element"> Ethernet {{element.adapter_number}} </td>
|
|
||||||
</ng-container>
|
|
||||||
|
|
||||||
<ng-container matColumnDef="adapter_type">
|
|
||||||
<th mat-header-cell *matHeaderCellDef> Adapter type </th>
|
|
||||||
<td mat-cell *matCellDef="let element; let i = index;">
|
|
||||||
<mat-select placeholder="Type" [(ngModel)]="adapters[i].adapter_type">
|
|
||||||
<mat-option *ngFor="let type of networkTypes" [value]="type">
|
|
||||||
{{type}}
|
|
||||||
</mat-option>
|
|
||||||
</mat-select>
|
|
||||||
</td>
|
|
||||||
</ng-container>
|
|
||||||
|
|
||||||
<tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
|
|
||||||
<tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
<div class="buttons-bar">
|
|
||||||
<button mat-button (click)="cancelConfigureCustomAdapters()">Cancel</button>
|
|
||||||
<button mat-raised-button color="primary" (click)="configureCustomAdapters()">Apply</button><br/>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<app-symbols-menu *ngIf="isSymbolSelectionOpened && vmwareTemplate" [server]="server" [symbol]="vmwareTemplate.symbol" (symbolChangedEmitter)="symbolChanged($event)"></app-symbols-menu>
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { Component, OnInit } from "@angular/core";
|
import { Component, OnInit, ViewChild } from "@angular/core";
|
||||||
import { ActivatedRoute, Router } from '@angular/router';
|
import { ActivatedRoute, Router } from '@angular/router';
|
||||||
import { ServerService } from '../../../../services/server.service';
|
import { ServerService } from '../../../../services/server.service';
|
||||||
import { Server } from '../../../../models/server';
|
import { Server } from '../../../../models/server';
|
||||||
@ -8,6 +8,7 @@ import { VmwareTemplate } from '../../../../models/templates/vmware-template';
|
|||||||
import { VmwareService } from '../../../../services/vmware.service';
|
import { VmwareService } from '../../../../services/vmware.service';
|
||||||
import { VmwareConfigurationService } from '../../../../services/vmware-configuration.service';
|
import { VmwareConfigurationService } from '../../../../services/vmware-configuration.service';
|
||||||
import { CustomAdapter } from '../../../../models/qemu/qemu-custom-adapter';
|
import { CustomAdapter } from '../../../../models/qemu/qemu-custom-adapter';
|
||||||
|
import { CustomAdaptersComponent } from '../../common/custom-adapters/custom-adapters.component';
|
||||||
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
@ -19,17 +20,17 @@ export class VmwareTemplateDetailsComponent implements OnInit {
|
|||||||
server: Server;
|
server: Server;
|
||||||
vmwareTemplate: VmwareTemplate;
|
vmwareTemplate: VmwareTemplate;
|
||||||
generalSettingsForm: FormGroup;
|
generalSettingsForm: FormGroup;
|
||||||
|
|
||||||
adapters: CustomAdapter[] = [];
|
|
||||||
displayedColumns: string[] = ['adapter_number', 'port_name', 'adapter_type'];
|
displayedColumns: string[] = ['adapter_number', 'port_name', 'adapter_type'];
|
||||||
isConfiguratorOpened: boolean = false;
|
isConfiguratorOpened: boolean = false;
|
||||||
isSymbolSelectionOpened: boolean = false;
|
isSymbolSelectionOpened: boolean = false;
|
||||||
|
|
||||||
consoleTypes: string[] = [];
|
consoleTypes: string[] = [];
|
||||||
categories = [];
|
categories = [];
|
||||||
onCloseOptions = [];
|
onCloseOptions = [];
|
||||||
networkTypes = [];
|
networkTypes = [];
|
||||||
|
|
||||||
|
@ViewChild("customAdaptersConfigurator")
|
||||||
|
customAdaptersConfigurator: CustomAdaptersComponent;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private route: ActivatedRoute,
|
private route: ActivatedRoute,
|
||||||
private serverService: ServerService,
|
private serverService: ServerService,
|
||||||
@ -55,10 +56,7 @@ export class VmwareTemplateDetailsComponent implements OnInit {
|
|||||||
this.getConfiguration();
|
this.getConfiguration();
|
||||||
this.vmwareService.getTemplate(this.server, template_id).subscribe((vmwareTemplate: VmwareTemplate) => {
|
this.vmwareService.getTemplate(this.server, template_id).subscribe((vmwareTemplate: VmwareTemplate) => {
|
||||||
this.vmwareTemplate = vmwareTemplate;
|
this.vmwareTemplate = vmwareTemplate;
|
||||||
|
this.fillCustomAdapters();
|
||||||
this.vmwareTemplate.custom_adapters.forEach((adapter: CustomAdapter) => {
|
|
||||||
this.adapters.push(adapter);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -78,8 +76,7 @@ export class VmwareTemplateDetailsComponent implements OnInit {
|
|||||||
if (this.generalSettingsForm.invalid) {
|
if (this.generalSettingsForm.invalid) {
|
||||||
this.toasterService.error(`Fill all required fields`);
|
this.toasterService.error(`Fill all required fields`);
|
||||||
} else {
|
} else {
|
||||||
this.saveCustomAdapters();
|
this.fillCustomAdapters();
|
||||||
this.vmwareTemplate.custom_adapters = this.adapters;
|
|
||||||
|
|
||||||
this.vmwareService.saveTemplate(this.server, this.vmwareTemplate).subscribe((vmwareTemplate: VmwareTemplate) => {
|
this.vmwareService.saveTemplate(this.server, this.vmwareTemplate).subscribe((vmwareTemplate: VmwareTemplate) => {
|
||||||
this.toasterService.success("Changes saved");
|
this.toasterService.success("Changes saved");
|
||||||
@ -87,24 +84,36 @@ export class VmwareTemplateDetailsComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
cancelConfigureCustomAdapters(){
|
setCustomAdaptersConfiguratorState(state: boolean) {
|
||||||
this.isConfiguratorOpened = !this.isConfiguratorOpened;
|
this.isConfiguratorOpened = state;
|
||||||
|
|
||||||
|
if (state) {
|
||||||
|
this.fillCustomAdapters();
|
||||||
|
this.customAdaptersConfigurator.numberOfAdapters = this.vmwareTemplate.adapters;
|
||||||
|
this.customAdaptersConfigurator.adapters = [];
|
||||||
|
this.vmwareTemplate.custom_adapters.forEach((adapter: CustomAdapter) => {
|
||||||
|
this.customAdaptersConfigurator.adapters.push({
|
||||||
|
adapter_number: adapter.adapter_number,
|
||||||
|
adapter_type: adapter.adapter_type
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
configureCustomAdapters(){
|
saveCustomAdapters(adapters: CustomAdapter[]){
|
||||||
this.isConfiguratorOpened = !this.isConfiguratorOpened;
|
this.setCustomAdaptersConfiguratorState(false);
|
||||||
this.saveCustomAdapters();
|
this.vmwareTemplate.custom_adapters = adapters;
|
||||||
}
|
}
|
||||||
|
|
||||||
saveCustomAdapters() {
|
fillCustomAdapters() {
|
||||||
let copyOfAdapters = this.adapters;
|
let copyOfAdapters = this.vmwareTemplate.custom_adapters ? this.vmwareTemplate.custom_adapters : [];
|
||||||
this.adapters = [];
|
this.vmwareTemplate.custom_adapters = [];
|
||||||
|
|
||||||
for(let i=0; i<this.vmwareTemplate.adapters; i++){
|
for(let i=0; i<this.vmwareTemplate.adapters; i++){
|
||||||
if (copyOfAdapters[i]) {
|
if (copyOfAdapters[i]) {
|
||||||
this.adapters.push(copyOfAdapters[i]);
|
this.vmwareTemplate.custom_adapters.push(copyOfAdapters[i]);
|
||||||
} else {
|
} else {
|
||||||
this.adapters.push({
|
this.vmwareTemplate.custom_adapters.push({
|
||||||
adapter_number: i,
|
adapter_number: i,
|
||||||
adapter_type: 'e1000'
|
adapter_type: 'e1000'
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user