mirror of
https://github.com/GNS3/gns3-web-ui.git
synced 2025-01-31 00:23:57 +00:00
Introduction of experimental features
This commit is contained in:
parent
c2f8065890
commit
e6c1851b16
@ -224,6 +224,9 @@ export class ProjectMapComponent implements OnInit, OnDestroy {
|
|||||||
this.subscriptions.push(
|
this.subscriptions.push(
|
||||||
this.selectionManager.subscribe(this.mapChild.graphLayout.getSelectionTool().rectangleSelected)
|
this.selectionManager.subscribe(this.mapChild.graphLayout.getSelectionTool().rectangleSelected)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
this.mapChild.graphLayout.getLinksWidget().getInterfaceLabelWidget().setEnabled(this.project.show_interface_labels);
|
||||||
|
this.mapChild.reload();
|
||||||
}
|
}
|
||||||
|
|
||||||
onNodeCreation(appliance: Appliance) {
|
onNodeCreation(appliance: Appliance) {
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
<ng-container matColumnDef="actions">
|
<ng-container matColumnDef="actions">
|
||||||
<mat-header-cell *matHeaderCellDef> Actions </mat-header-cell>
|
<mat-header-cell *matHeaderCellDef> Actions </mat-header-cell>
|
||||||
<mat-cell *matCellDef="let row" style="text-align: right">
|
<mat-cell *matCellDef="let row" style="text-align: right">
|
||||||
<button mat-icon-button (click)="delete(row)">
|
<button mat-icon-button (click)="delete(row)" *ngIf="settings.experimental_features">
|
||||||
<mat-icon aria-label="Delete project">delete</mat-icon>
|
<mat-icon aria-label="Delete project">delete</mat-icon>
|
||||||
</button>
|
</button>
|
||||||
</mat-cell>
|
</mat-cell>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { AfterViewInit, Component, OnInit, ViewChild } from '@angular/core';
|
import { Component, OnInit, ViewChild } from '@angular/core';
|
||||||
import { ActivatedRoute, ParamMap } from '@angular/router';
|
import { ActivatedRoute, ParamMap } from '@angular/router';
|
||||||
import { MatSort, MatSortable } from "@angular/material";
|
import { MatSort, MatSortable } from "@angular/material";
|
||||||
|
|
||||||
@ -9,6 +9,7 @@ import { ServerService } from "../shared/services/server.service";
|
|||||||
import { BehaviorSubject } from "rxjs/BehaviorSubject";
|
import { BehaviorSubject } from "rxjs/BehaviorSubject";
|
||||||
import { DataSource } from "@angular/cdk/collections";
|
import { DataSource } from "@angular/cdk/collections";
|
||||||
import { Observable } from "rxjs/Observable";
|
import { Observable } from "rxjs/Observable";
|
||||||
|
import { SettingsService, Settings } from "../shared/services/settings.service";
|
||||||
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
@ -21,12 +22,15 @@ export class ProjectsComponent implements OnInit {
|
|||||||
projectDatabase = new ProjectDatabase();
|
projectDatabase = new ProjectDatabase();
|
||||||
dataSource: ProjectDataSource;
|
dataSource: ProjectDataSource;
|
||||||
displayedColumns = ['name', 'actions'];
|
displayedColumns = ['name', 'actions'];
|
||||||
|
settings: Settings;
|
||||||
|
|
||||||
@ViewChild(MatSort) sort: MatSort;
|
@ViewChild(MatSort) sort: MatSort;
|
||||||
|
|
||||||
constructor(private route: ActivatedRoute,
|
constructor(private route: ActivatedRoute,
|
||||||
private serverService: ServerService,
|
private serverService: ServerService,
|
||||||
private projectService: ProjectService) {
|
private projectService: ProjectService,
|
||||||
|
private settingsService: SettingsService
|
||||||
|
) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -41,8 +45,8 @@ export class ProjectsComponent implements OnInit {
|
|||||||
|
|
||||||
this.route.paramMap
|
this.route.paramMap
|
||||||
.switchMap((params: ParamMap) => {
|
.switchMap((params: ParamMap) => {
|
||||||
const server_id = parseInt(params.get('server_id'), 10);
|
const server_id = params.get('server_id');
|
||||||
return this.serverService.get(server_id);
|
return this.serverService.getLocalOrRemote(server_id);
|
||||||
})
|
})
|
||||||
.subscribe((server: Server) => {
|
.subscribe((server: Server) => {
|
||||||
this.server = server;
|
this.server = server;
|
||||||
@ -52,6 +56,8 @@ export class ProjectsComponent implements OnInit {
|
|||||||
this.projectDatabase.addProjects(projects);
|
this.projectDatabase.addProjects(projects);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this.settings = this.settingsService.getAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
delete(project: Project) {
|
delete(project: Project) {
|
||||||
|
@ -15,7 +15,13 @@
|
|||||||
</mat-panel-description>
|
</mat-panel-description>
|
||||||
</mat-expansion-panel-header>
|
</mat-expansion-panel-header>
|
||||||
|
|
||||||
<mat-checkbox class="example-margin" [(ngModel)]="settings.crash_reports">Send anonymous crash reports</mat-checkbox>
|
<div>
|
||||||
|
<mat-checkbox class="example-margin" [(ngModel)]="settings.crash_reports">Send anonymous crash reports</mat-checkbox>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<mat-checkbox class="example-margin" [(ngModel)]="settings.experimental_features">Enable experimental features (WARNING: IT CAN BREAK YOU LABS!)</mat-checkbox>
|
||||||
|
</div>
|
||||||
|
|
||||||
</mat-expansion-panel>
|
</mat-expansion-panel>
|
||||||
</mat-accordion>
|
</mat-accordion>
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import { Component, OnInit } from '@angular/core';
|
import { Component, OnInit } from '@angular/core';
|
||||||
import { SettingsService } from "../shared/services/settings.service";
|
import { SettingsService } from "../shared/services/settings.service";
|
||||||
|
import { ToasterService } from "../shared/services/toaster.service";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-settings',
|
selector: 'app-settings',
|
||||||
@ -9,7 +10,10 @@ import { SettingsService } from "../shared/services/settings.service";
|
|||||||
export class SettingsComponent implements OnInit {
|
export class SettingsComponent implements OnInit {
|
||||||
settings = { ...SettingsService.DEFAULTS };
|
settings = { ...SettingsService.DEFAULTS };
|
||||||
|
|
||||||
constructor(private settingsService: SettingsService) { }
|
constructor(
|
||||||
|
private settingsService: SettingsService,
|
||||||
|
private toaster: ToasterService
|
||||||
|
) { }
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.settings = this.settingsService.getAll();
|
this.settings = this.settingsService.getAll();
|
||||||
@ -17,5 +21,6 @@ export class SettingsComponent implements OnInit {
|
|||||||
|
|
||||||
save() {
|
save() {
|
||||||
this.settingsService.setAll(this.settings);
|
this.settingsService.setAll(this.settings);
|
||||||
|
this.toaster.success("Settings have been saved.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,6 +21,13 @@ export class ServerService {
|
|||||||
this.indexedDbService.get().getByKey(this.tablename, id));
|
this.indexedDbService.get().getByKey(this.tablename, id));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public getLocalOrRemote(id: string) {
|
||||||
|
if (id === 'local') {
|
||||||
|
|
||||||
|
}
|
||||||
|
return this.get(parseInt(id, 10));
|
||||||
|
}
|
||||||
|
|
||||||
public create(server: Server) {
|
public create(server: Server) {
|
||||||
return this.onReady(() => {
|
return this.onReady(() => {
|
||||||
const promise = new Promise((resolve, reject) => {
|
const promise = new Promise((resolve, reject) => {
|
||||||
|
@ -65,11 +65,16 @@ describe('SettingsService', () => {
|
|||||||
|
|
||||||
service.set('crash_reports', true);
|
service.set('crash_reports', true);
|
||||||
service.subscribe(settings => {
|
service.subscribe(settings => {
|
||||||
changedSettings = settings
|
changedSettings = settings;
|
||||||
});
|
});
|
||||||
service.set('crash_reports', false);
|
service.set('crash_reports', false);
|
||||||
|
|
||||||
expect(changedSettings.crash_reports).toEqual(false);
|
expect(changedSettings.crash_reports).toEqual(false);
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
it('should get isExperimentalEnabled when turned on', inject([SettingsService], (service: SettingsService) => {
|
||||||
|
service.set('experimental_features', true);
|
||||||
|
|
||||||
|
expect(service.isExperimentalEnabled()).toEqual(true);
|
||||||
|
}));
|
||||||
});
|
});
|
||||||
|
@ -6,13 +6,15 @@ import { BehaviorSubject } from "rxjs/BehaviorSubject";
|
|||||||
|
|
||||||
export interface Settings {
|
export interface Settings {
|
||||||
crash_reports: boolean;
|
crash_reports: boolean;
|
||||||
|
experimental_features: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class SettingsService {
|
export class SettingsService {
|
||||||
static DEFAULTS: Settings = {
|
static DEFAULTS: Settings = {
|
||||||
'crash_reports': true
|
'crash_reports': true,
|
||||||
|
'experimental_features': false
|
||||||
};
|
};
|
||||||
|
|
||||||
private settingsSubject: BehaviorSubject<Settings>;
|
private settingsSubject: BehaviorSubject<Settings>;
|
||||||
@ -54,6 +56,10 @@ export class SettingsService {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
isExperimentalEnabled(): boolean {
|
||||||
|
return this.get('experimental_features');
|
||||||
|
}
|
||||||
|
|
||||||
subscribe(subscriber: ((settings: Settings) => void)) {
|
subscribe(subscriber: ((settings: Settings) => void)) {
|
||||||
return this.settingsSubject.subscribe(subscriber);
|
return this.settingsSubject.subscribe(subscriber);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user