Removing components related to gns3vm

This commit is contained in:
piotrpekala7 2021-06-10 13:17:01 +02:00
parent 48f093360d
commit 2b81d72232
15 changed files with 0 additions and 273 deletions

View File

@ -24,7 +24,6 @@ import { AddIosTemplateComponent } from './components/preferences/dynamips/add-i
import { CopyIosTemplateComponent } from './components/preferences/dynamips/copy-ios-template/copy-ios-template.component';
import { IosTemplateDetailsComponent } from './components/preferences/dynamips/ios-template-details/ios-template-details.component';
import { IosTemplatesComponent } from './components/preferences/dynamips/ios-templates/ios-templates.component';
import { Gns3vmComponent } from './components/preferences/gns3vm/gns3vm.component';
import { AddIouTemplateComponent } from './components/preferences/ios-on-unix/add-iou-template/add-iou-template.component';
import { CopyIouTemplateComponent } from './components/preferences/ios-on-unix/copy-iou-template/copy-iou-template.component';
import { IouTemplateDetailsComponent } from './components/preferences/ios-on-unix/iou-template-details/iou-template-details.component';
@ -87,7 +86,6 @@ const routes: Routes = [
resolve: { server: ServerResolve },
},
{ path: 'server/:server_id/preferences', component: PreferencesComponent, canActivate: [LoginGuard] },
{ path: 'server/:server_id/preferences/gns3vm', component: Gns3vmComponent, canActivate: [LoginGuard] },
// { path: 'server/:server_id/preferences/general', component: GeneralPreferencesComponent },
{ path: 'server/:server_id/preferences/builtin', component: BuiltInPreferencesComponent, canActivate: [LoginGuard] },

View File

@ -74,7 +74,6 @@ import { DynamipsPreferencesComponent } from './components/preferences/dynamips/
import { IosTemplateDetailsComponent } from './components/preferences/dynamips/ios-template-details/ios-template-details.component';
import { IosTemplatesComponent } from './components/preferences/dynamips/ios-templates/ios-templates.component';
import { GeneralPreferencesComponent } from './components/preferences/general/general-preferences.component';
import { Gns3vmComponent } from './components/preferences/gns3vm/gns3vm.component';
import { AddIouTemplateComponent } from './components/preferences/ios-on-unix/add-iou-template/add-iou-template.component';
import { CopyIouTemplateComponent } from './components/preferences/ios-on-unix/copy-iou-template/copy-iou-template.component';
import { IouTemplateDetailsComponent } from './components/preferences/ios-on-unix/iou-template-details/iou-template-details.component';
@ -185,7 +184,6 @@ import { NavigationDialogComponent } from './components/projects/navigation-dial
import { ProjectsComponent } from './components/projects/projects.component';
import { SaveProjectDialogComponent } from './components/projects/save-project-dialog/save-project-dialog.component';
import { AddServerDialogComponent } from './components/servers/add-server-dialog/add-server-dialog.component';
import { ConfigureGns3VMDialogComponent } from './components/servers/configure-gns3vm-dialog/configure-gns3vm-dialog.component';
import { ServerDiscoveryComponent } from './components/servers/server-discovery/server-discovery.component';
import { ServersComponent } from './components/servers/servers.component';
import { ConsoleComponent } from './components/settings/console/console.component';
@ -221,7 +219,6 @@ import { DockerConfigurationService } from './services/docker-configuration.serv
import { DockerService } from './services/docker.service';
import { DrawingService } from './services/drawing.service';
import { ExternalSoftwareDefinitionService } from './services/external-software-definition.service';
import { Gns3vmService } from './services/gns3vm.service';
import { GoogleAnalyticsService } from './services/google-analytics.service';
import { HttpServer, ServerErrorHandler } from './services/http-server.service';
import { InfoService } from './services/info.service';
@ -435,8 +432,6 @@ import { LoggedUserComponent } from './components/users/logged-user/logged-user.
AlignVerticallyActionComponent,
ConfirmationBottomSheetComponent,
ConfigDialogComponent,
Gns3vmComponent,
ConfigureGns3VMDialogComponent,
ImportApplianceComponent,
DirectLinkComponent,
SystemStatusComponent,
@ -544,7 +539,6 @@ import { LoggedUserComponent } from './components/users/logged-user/logged-user.
ComputeService,
PacketCaptureService,
NotificationService,
Gns3vmService,
ThemeService,
GoogleAnalyticsService,
NodeConsoleService,
@ -577,7 +571,6 @@ import { LoggedUserComponent } from './components/users/logged-user/logged-user.
InfoDialogComponent,
ChangeSymbolDialogComponent,
EditProjectDialogComponent,
ConfigureGns3VMDialogComponent,
ConfiguratorDialogVpcsComponent,
ConfiguratorDialogEthernetHubComponent,
ConfiguratorDialogEthernetSwitchComponent,

View File

@ -1,66 +0,0 @@
<div class="content">
<div class="default-header">
<div class="row">
<h1 class="col">GNS3 VM preferences</h1>
</div>
</div>
<div class="default-content">
<mat-card class="matCard" *ngIf="gns3vm">
<mat-checkbox [ngModelOptions]="{ standalone: true }" [(ngModel)]="gns3vm.enable">
Enable the GNS3 VM
</mat-checkbox>
<mat-form-field class="select">
<mat-select
(selectionChange)="changeVmEngine($event)"
[ngModelOptions]="{ standalone: true }"
placeholder="Virtualization engine"
[(ngModel)]="gns3vm.engine"
>
<mat-option *ngFor="let engine of vmEngines" [value]="engine.engine_id">
{{ engine.name }}
</mat-option>
</mat-select>
</mat-form-field>
<mat-form-field class="select">
<mat-select [ngModelOptions]="{ standalone: true }" placeholder="VM name" [(ngModel)]="gns3vm.vmname">
<mat-option *ngFor="let vm of vms" [value]="vm.vmname">
{{ vm.vmname }}
</mat-option>
</mat-select>
</mat-form-field>
<mat-checkbox
*ngIf="gns3vm.engine === 'virtualbox' || gns3vm.engine === 'vmware'"
[ngModelOptions]="{ standalone: true }"
[(ngModel)]="gns3vm.headless"
>
Run the VM in headless mode
</mat-checkbox>
<form *ngIf="gns3vm.engine !== 'remote'" [formGroup]="vmForm">
<mat-form-field *ngIf="gns3vm.engine === 'virtualbox' || gns3vm.engine === 'vmware'" class="form-field">
<input matInput type="number" [ngModelOptions]="{ standalone: true }" [(ngModel)]="port" placeholder="Port" />
</mat-form-field>
<mat-form-field class="form-field">
<input matInput formControlName="ram" type="number" placeholder="RAM" />
<span matSuffix>MB</span>
</mat-form-field>
<mat-form-field class="form-field">
<input matInput formControlName="vcpus" type="number" placeholder="vCPUs" />
</mat-form-field>
</form>
<mat-radio-group
*ngIf="gns3vm.engine !== 'remote'"
[(ngModel)]="gns3vm.when_exit"
aria-label="Actions when closing GNS3"
class="radio-selection"
>
<mat-radio-button value="keep" (click)="setCloseAction('keep')">keep the GNS3 VM running</mat-radio-button>
<mat-radio-button value="suspend" (click)="setCloseAction('suspend')">suspend the GNS3 VM</mat-radio-button>
<mat-radio-button value="stop" (click)="setCloseAction('stop')">stop the GNS3 VM</mat-radio-button>
</mat-radio-group>
</mat-card>
<div class="buttons-bar">
<button mat-button class="cancel-button" (click)="goBack()">Cancel</button>
<button mat-raised-button color="primary" (click)="save()">Save</button>
</div>
</div>
</div>

View File

@ -1,12 +0,0 @@
.form-field {
width: 100%;
}
.select {
width: 100%;
}
.radio-selection {
display: flex;
justify-content: space-between;
}

View File

@ -1,89 +0,0 @@
import { Component, OnInit } from '@angular/core';
import { FormBuilder, FormControl, FormGroup, Validators } from '@angular/forms';
import { ActivatedRoute, Router } from '@angular/router';
import { Gns3vm } from '../../../models/gns3vm/gns3vm';
import { Gns3vmEngine } from '../../../models/gns3vm/gns3vmEngine';
import { VM } from '../../../models/gns3vm/vm';
import { Server } from '../../../models/server';
import { Gns3vmService } from '../../../services/gns3vm.service';
import { ServerService } from '../../../services/server.service';
import { ToasterService } from '../../../services/toaster.service';
@Component({
selector: 'app-gns3vm',
templateUrl: './gns3vm.component.html',
styleUrls: ['./gns3vm.component.scss'],
})
export class Gns3vmComponent implements OnInit {
public server: Server;
public gns3vm: Gns3vm;
public vmEngines: Gns3vmEngine[];
public vms: VM[] = [];
public vmForm: FormGroup;
public port: number;
constructor(
private route: ActivatedRoute,
private serverService: ServerService,
private gns3vmService: Gns3vmService,
private router: Router,
private formBuilder: FormBuilder,
private toasterService: ToasterService
) {
this.vmForm = this.formBuilder.group({
ram: new FormControl(null, [Validators.required]),
vcpus: new FormControl(null, [Validators.required]),
});
}
ngOnInit() {
const server_id = this.route.snapshot.paramMap.get('server_id');
this.serverService.get(parseInt(server_id, 10)).then((server: Server) => {
this.server = server;
this.gns3vmService.getGns3vm(this.server).subscribe((vm: Gns3vm) => {
this.gns3vm = vm;
this.vmForm.controls['ram'].setValue(this.gns3vm.ram);
this.vmForm.controls['vcpus'].setValue(this.gns3vm.vcpus);
if (this.gns3vm.port) this.port = this.gns3vm.port;
this.gns3vmService.getGns3vmEngines(this.server).subscribe((vmEngines: Gns3vmEngine[]) => {
this.vmEngines = vmEngines;
});
this.gns3vmService.getVms(this.server, this.gns3vm.engine).subscribe((vms: VM[]) => {
this.vms = vms;
});
});
});
}
goBack() {
this.router.navigate(['/server', this.server.id, 'preferences']);
}
setCloseAction(action: string) {
this.gns3vm.when_exit = action;
}
changeVmEngine(event) {
this.gns3vmService.getVms(this.server, event.value).subscribe(
(vms: VM[]) => {
this.vms = vms;
},
(error) => {}
);
}
save() {
if ((this.vmForm.valid && this.gns3vm.vmname) || (this.gns3vm.engine === 'remote' && this.gns3vm.vmname)) {
this.gns3vm.ram = this.vmForm.get('ram').value;
this.gns3vm.vcpus = this.vmForm.get('vcpus').value;
if (this.port) this.gns3vm.port = this.port;
this.gns3vmService.updateGns3vm(this.server, this.gns3vm).subscribe(() => {
this.toasterService.success('GNS3 VM updated.');
});
this.goBack();
} else {
this.toasterService.error('Fill all required fields with correct values.');
}
}
}

View File

@ -7,7 +7,6 @@
<div class="default-content">
<div class="listcontainer mat-elevation-z8">
<mat-nav-list>
<mat-list-item routerLink="/server/{{ serverId }}/preferences/gns3vm"> GNS3 VM </mat-list-item>
<mat-list-item routerLink="/server/{{ serverId }}/preferences/builtin"> Built-in </mat-list-item>
<mat-list-item routerLink="/server/{{ serverId }}/preferences/dynamips/templates"> Dynamips </mat-list-item>
<mat-list-item routerLink="/server/{{ serverId }}/preferences/iou/templates"> IOS on Unix </mat-list-item>

View File

@ -14,7 +14,6 @@ import { ProjectService } from '../../services/project.service';
import { RecentlyOpenedProjectService } from '../../services/recentlyOpenedProject.service';
import { Settings, SettingsService } from '../../services/settings.service';
import { ToasterService } from '../../services/toaster.service';
import { ConfigureGns3VMDialogComponent } from '../servers/configure-gns3vm-dialog/configure-gns3vm-dialog.component';
import { AddBlankProjectDialogComponent } from './add-blank-project-dialog/add-blank-project-dialog.component';
import { ChooseNameDialogComponent } from './choose-name-dialog/choose-name-dialog.component';
import { ConfirmationBottomSheetComponent } from './confirmation-bottomsheet/confirmation-bottomsheet.component';
@ -64,23 +63,6 @@ export class ProjectsComponent implements OnInit {
this.settings = this.settingsService.getAll();
this.projectService.projectListSubject.subscribe(() => this.refresh());
let gns3vmConfig = localStorage.getItem('gns3vmConfig');
if (this.electronService.isElectronApp && gns3vmConfig !== 'configured') {
const dialogRef = this.dialog.open(ConfigureGns3VMDialogComponent, {
width: '350px',
height: '120px',
autoFocus: false,
disableClose: true,
});
dialogRef.afterClosed().subscribe((answer: boolean) => {
if (answer) {
localStorage.setItem('gns3vmConfig', 'configured');
this.router.navigate(['/server', this.server.id, 'preferences', 'gns3vm']);
}
});
}
}
goToPreferences() {

View File

@ -1,7 +0,0 @@
<span class="message">{{ message }}</span>
<div mat-dialog-actions>
<button mat-button class="cancelButton" (click)="onNoClick()" color="accent">No</button>
<button mat-button class="confirmButton" (click)="onYesClick()" tabindex="2" mat-raised-button color="primary">
Yes
</button>
</div>

View File

@ -1,22 +0,0 @@
import { Component, OnInit } from '@angular/core';
import { MatDialogRef } from '@angular/material/dialog';
@Component({
selector: 'app-configure-gns3-vm-dialog',
templateUrl: 'configure-gns3vm-dialog.component.html',
styleUrls: ['configure-gns3vm-dialog.component.scss'],
})
export class ConfigureGns3VMDialogComponent implements OnInit {
public message: string = 'Do you want to configure GNS3 VM?';
constructor(public dialogRef: MatDialogRef<ConfigureGns3VMDialogComponent>) {}
ngOnInit() {}
onNoClick(): void {
this.dialogRef.close(false);
}
onYesClick(): void {
this.dialogRef.close(true);
}
}

View File

@ -1,10 +0,0 @@
export interface Gns3vm {
enable: boolean;
engine: string;
headless: boolean;
port: number;
ram: number;
vcpus: number;
vmname: string;
when_exit: string;
}

View File

@ -1,8 +0,0 @@
export interface Gns3vmEngine {
description: string;
engine_id: string;
name: string;
support_headless: boolean;
support_ram: boolean;
support_when_exit: boolean;
}

View File

@ -1,3 +0,0 @@
export interface VM {
vmname: string;
}

View File

@ -1,28 +0,0 @@
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';
import { Gns3vm } from '../models/gns3vm/gns3vm';
import { Gns3vmEngine } from '../models/gns3vm/gns3vmEngine';
import { VM } from '../models/gns3vm/vm';
import { Server } from '../models/server';
import { HttpServer } from './http-server.service';
@Injectable()
export class Gns3vmService {
constructor(private httpServer: HttpServer) {}
getGns3vm(server: Server): Observable<Gns3vm> {
return this.httpServer.get<Gns3vm>(server, '/gns3vm') as Observable<Gns3vm>;
}
updateGns3vm(server: Server, gns3vm: Gns3vm): Observable<Gns3vm> {
return this.httpServer.put<Gns3vm>(server, `/gns3vm`, gns3vm) as Observable<Gns3vm>;
}
getGns3vmEngines(server: Server): Observable<Gns3vmEngine[]> {
return this.httpServer.get<Gns3vmEngine[]>(server, '/gns3vm/engines') as Observable<Gns3vmEngine[]>;
}
getVms(server: Server, engine: string): Observable<VM[]> {
return this.httpServer.get<VM[]>(server, `/gns3vm/engines/${engine}/vms`);
}
}