mirror of
https://github.com/GNS3/gns3-web-ui.git
synced 2025-06-17 14:28:13 +00:00
Code cleaned up
This commit is contained in:
@ -9,6 +9,7 @@ import { SettingsComponent } from './components/settings/settings.component';
|
|||||||
import { LocalServerComponent } from './components/local-server/local-server.component';
|
import { LocalServerComponent } from './components/local-server/local-server.component';
|
||||||
import { PreferencesComponent } from './components/preferences/preferences.component';
|
import { PreferencesComponent } from './components/preferences/preferences.component';
|
||||||
import { QemuPreferencesComponent } from './components/preferences/qemu/qemu-preferences/qemu-preferences.component';
|
import { QemuPreferencesComponent } from './components/preferences/qemu/qemu-preferences/qemu-preferences.component';
|
||||||
|
import { QemuVirtualMachinesComponent } from './components/preferences/qemu/qemu-virtual-machines/qemu-virtual-machines.component';
|
||||||
|
|
||||||
const routes: Routes = [
|
const routes: Routes = [
|
||||||
{
|
{
|
||||||
@ -21,7 +22,8 @@ const routes: Routes = [
|
|||||||
{ path: 'server/:server_id/projects', component: ProjectsComponent },
|
{ path: 'server/:server_id/projects', component: ProjectsComponent },
|
||||||
{ path: 'settings', component: SettingsComponent },
|
{ path: 'settings', component: SettingsComponent },
|
||||||
{ path: 'server/:server_id/preferences', component: PreferencesComponent },
|
{ path: 'server/:server_id/preferences', component: PreferencesComponent },
|
||||||
{ path: 'server/:server_id/preferences/qemu', component: QemuPreferencesComponent }
|
{ path: 'server/:server_id/preferences/qemu', component: QemuPreferencesComponent },
|
||||||
|
{ path: 'server/:server_id/preferences/qemu/templates', component: QemuVirtualMachinesComponent }
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{ path: 'server/:server_id/project/:project_id', component: ProjectMapComponent }
|
{ path: 'server/:server_id/project/:project_id', component: ProjectMapComponent }
|
||||||
|
@ -91,6 +91,7 @@ import { TextEditorDialogComponent } from './components/project-map/drawings-edi
|
|||||||
import { PreferencesComponent } from './components/preferences/preferences.component';
|
import { PreferencesComponent } from './components/preferences/preferences.component';
|
||||||
import { QemuPreferencesComponent } from './components/preferences/qemu/qemu-preferences/qemu-preferences.component';
|
import { QemuPreferencesComponent } from './components/preferences/qemu/qemu-preferences/qemu-preferences.component';
|
||||||
import { ServerSettingsService } from './services/server-settings.service';
|
import { ServerSettingsService } from './services/server-settings.service';
|
||||||
|
import { QemuVirtualMachinesComponent } from './components/preferences/qemu/qemu-virtual-machines/qemu-virtual-machines.component';
|
||||||
|
|
||||||
if (environment.production) {
|
if (environment.production) {
|
||||||
Raven.config('https://b2b1cfd9b043491eb6b566fd8acee358@sentry.io/842726', {
|
Raven.config('https://b2b1cfd9b043491eb6b566fd8acee358@sentry.io/842726', {
|
||||||
@ -144,7 +145,8 @@ if (environment.production) {
|
|||||||
InterfaceLabelDraggedComponent,
|
InterfaceLabelDraggedComponent,
|
||||||
StyleEditorDialogComponent,
|
StyleEditorDialogComponent,
|
||||||
TextEditorDialogComponent,
|
TextEditorDialogComponent,
|
||||||
QemuPreferencesComponent
|
QemuPreferencesComponent,
|
||||||
|
QemuVirtualMachinesComponent
|
||||||
],
|
],
|
||||||
imports: [
|
imports: [
|
||||||
BrowserModule,
|
BrowserModule,
|
||||||
|
@ -2,19 +2,19 @@
|
|||||||
<div class="default-header">
|
<div class="default-header">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<h1 class="col">QEMU preferences</h1>
|
<h1 class="col">QEMU preferences</h1>
|
||||||
<button class="top-button" mat-raised-button color="primary">QEMU Virtual Machines</button>
|
<button *ngIf="server" class="top-button" routerLink="/server/{{server.id}}/preferences/qemu/templates" mat-raised-button color="primary">QEMU Virtual Machines</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="default-content">
|
<div class="default-content">
|
||||||
<div class="example-container mat-elevation-z8">
|
<div class="example-container mat-elevation-z8">
|
||||||
<mat-nav-list *ngIf="settings">
|
<mat-nav-list *ngIf="settings">
|
||||||
<mat-list-item>
|
<mat-list-item>
|
||||||
<mat-checkbox class="example-margin" [(ngModel)]="settings.Qemu.enable_hardware_acceleration">
|
<mat-checkbox class="example-margin" [(ngModel)]="settings.enable_hardware_acceleration">
|
||||||
Enable Hardware Acceleration (KVM/HAXM)
|
Enable Hardware Acceleration (KVM/HAXM)
|
||||||
</mat-checkbox>
|
</mat-checkbox>
|
||||||
</mat-list-item>
|
</mat-list-item>
|
||||||
<mat-list-item *ngIf="settings.Qemu.enable_hardware_acceleration">
|
<mat-list-item *ngIf="settings.enable_hardware_acceleration">
|
||||||
<mat-checkbox class="example-margin" [(ngModel)]="settings.Qemu.require_hardware_acceleration">
|
<mat-checkbox class="example-margin" [(ngModel)]="settings.require_hardware_acceleration">
|
||||||
Require Hardware Acceleration (KVM/HAXM)
|
Require Hardware Acceleration (KVM/HAXM)
|
||||||
</mat-checkbox>
|
</mat-checkbox>
|
||||||
</mat-list-item>
|
</mat-list-item>
|
||||||
|
@ -7,6 +7,7 @@ import { ServerService } from '../../../../services/server.service';
|
|||||||
import { ServerSettings } from '../../../../models/serverSettings';
|
import { ServerSettings } from '../../../../models/serverSettings';
|
||||||
import { Qemu } from '../../../../models/server-settings-models/qemu';
|
import { Qemu } from '../../../../models/server-settings-models/qemu';
|
||||||
import { ToasterService } from '../../../../services/toaster.service';
|
import { ToasterService } from '../../../../services/toaster.service';
|
||||||
|
import { QemuSettings } from '../../../../models/settings/qemu';
|
||||||
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
@ -16,7 +17,7 @@ import { ToasterService } from '../../../../services/toaster.service';
|
|||||||
})
|
})
|
||||||
export class QemuPreferencesComponent implements OnInit {
|
export class QemuPreferencesComponent implements OnInit {
|
||||||
server: Server;
|
server: Server;
|
||||||
settings: ServerSettings;
|
settings: QemuSettings;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private route: ActivatedRoute,
|
private route: ActivatedRoute,
|
||||||
@ -35,24 +36,33 @@ export class QemuPreferencesComponent implements OnInit {
|
|||||||
)
|
)
|
||||||
.subscribe((server: Server) => {
|
.subscribe((server: Server) => {
|
||||||
this.server = server;
|
this.server = server;
|
||||||
this.serverSettingsService.get(this.server).subscribe((settings: ServerSettings) => {
|
this.serverSettingsService.getSettingsForQemu(this.server).subscribe((settings: QemuSettings) => {
|
||||||
this.settings = settings;
|
this.settings = settings;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
apply(){
|
apply(){
|
||||||
if(!this.settings.Qemu.enable_hardware_acceleration){
|
if(!this.settings.enable_hardware_acceleration){
|
||||||
this.settings.Qemu.require_hardware_acceleration = false;
|
this.settings.require_hardware_acceleration = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.serverSettingsService.update(this.server, this.settings)
|
this.serverSettingsService.updateSettingsForQemu(this.server, this.settings)
|
||||||
.subscribe((serverSettings: ServerSettings) => {
|
.subscribe((qemuSettings: QemuSettings) => {
|
||||||
this.toasterService.success(`Changes applied`);
|
this.toasterService.success(`Changes applied`);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
restoreDefaults(){
|
restoreDefaults(){
|
||||||
|
let defaultSettings : QemuSettings = {
|
||||||
|
enable_hardware_acceleration: true,
|
||||||
|
require_hardware_acceleration: true
|
||||||
|
};
|
||||||
|
|
||||||
|
this.serverSettingsService.updateSettingsForQemu(this.server, defaultSettings)
|
||||||
|
.subscribe((qemuSettings: QemuSettings) => {
|
||||||
|
this.settings = qemuSettings;
|
||||||
|
this.toasterService.success(`Restored to default settings`);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,19 @@
|
|||||||
import { Component } from "@angular/core";
|
import { Component, OnInit } from "@angular/core";
|
||||||
|
import { Server } from '../../../../models/server';
|
||||||
|
import { ActivatedRoute } from '@angular/router';
|
||||||
|
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'app-qemu-virtual-machines',
|
||||||
|
templateUrl: './qemu-virtual-machines.component.html',
|
||||||
|
styleUrls: ['./qemu-virtual-machines.component.scss']
|
||||||
|
})
|
||||||
|
export class QemuVirtualMachinesComponent implements OnInit {
|
||||||
|
server: Server;
|
||||||
|
|
||||||
|
constructor(
|
||||||
|
private route: ActivatedRoute
|
||||||
|
) {}
|
||||||
|
|
||||||
|
ngOnInit() {}
|
||||||
|
}
|
||||||
|
4
src/app/models/settings/qemu.ts
Normal file
4
src/app/models/settings/qemu.ts
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
export class QemuSettings {
|
||||||
|
enable_hardware_acceleration: boolean;
|
||||||
|
require_hardware_acceleration: boolean
|
||||||
|
}
|
@ -2,6 +2,7 @@ import { Injectable } from "@angular/core";
|
|||||||
import { HttpServer } from './http-server.service';
|
import { HttpServer } from './http-server.service';
|
||||||
import { Server } from '../models/server';
|
import { Server } from '../models/server';
|
||||||
import { ServerSettings } from '../models/serverSettings';
|
import { ServerSettings } from '../models/serverSettings';
|
||||||
|
import { QemuSettings } from '../models/settings/qemu';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class ServerSettingsService {
|
export class ServerSettingsService {
|
||||||
@ -16,4 +17,15 @@ export class ServerSettingsService {
|
|||||||
update(server: Server, serverSettings: ServerSettings) {
|
update(server: Server, serverSettings: ServerSettings) {
|
||||||
return this.httpServer.post<ServerSettings>(server, `/settings`, serverSettings);
|
return this.httpServer.post<ServerSettings>(server, `/settings`, serverSettings);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getSettingsForQemu(server: Server) {
|
||||||
|
return this.httpServer.get<QemuSettings>(server, `/settings/qemu`);
|
||||||
|
}
|
||||||
|
|
||||||
|
updateSettingsForQemu(server: Server, qemuSettings: QemuSettings) {
|
||||||
|
return this.httpServer.put<QemuSettings>(server, `/settings/qemu`, {
|
||||||
|
enable_hardware_acceleration: qemuSettings.enable_hardware_acceleration,
|
||||||
|
require_hardware_acceleration: qemuSettings.require_hardware_acceleration
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user