Option to show interface labels should be saved for opened project

This commit is contained in:
Piotr Pekala 2019-09-06 08:18:26 -07:00
parent 03dbac5aba
commit 00597accac
3 changed files with 18 additions and 5 deletions

View File

@ -8,7 +8,7 @@
[drawings]="drawings"
[width]="project.scene_width"
[height]="project.scene_height"
[show-interface-labels]="project.show_interface_labels"
[show-interface-labels]="isInterfaceLabelVisible"
[readonly]="inReadOnlyMode"
(nodeDragged)="onNodeDragged($event)"
(drawingDragged)="onDrawingDragged($event)"
@ -24,7 +24,7 @@
[drawings]="drawings"
[width]="project.scene_width"
[height]="project.scene_height"
[show-interface-labels]="project.show_interface_labels"
[show-interface-labels]="isInterfaceLabelVisible"
[selection-tool]="tools.selection"
[moving-tool]="tools.moving"
[draw-link-tool]="tools.draw_link"
@ -78,7 +78,7 @@
<mat-menu #viewMenu="matMenu" [overlapTrigger]="false">
<div class="options-item">
<mat-checkbox [ngModel]="project.show_interface_labels" (change)="toggleShowInterfaceLabels($event.checked)">
<mat-checkbox [ngModel]="isInterfaceLabelVisible" (change)="toggleShowInterfaceLabels($event.checked)">
Show interface labels
</mat-checkbox>
<mat-checkbox [ngModel]="isConsoleVisible" (change)="toggleShowConsole($event.checked)">

View File

@ -78,6 +78,7 @@ export class ProjectMapComponent implements OnInit, OnDestroy {
public isProjectMapMenuVisible: boolean = false;
public isConsoleVisible: boolean = false;
public isTopologySummaryVisible: boolean = false;
public isInterfaceLabelVisible: boolean = false;
tools = {
selection: true,
@ -156,6 +157,12 @@ export class ProjectMapComponent implements OnInit, OnDestroy {
}),
mergeMap((project: Project) => {
this.project = project;
if (this.mapSettingsService.interfaceLabels.has(project.project_id)) {
this.isInterfaceLabelVisible = this.mapSettingsService.interfaceLabels.get(project.project_id);
} else {
this.isInterfaceLabelVisible = this.project.show_interface_labels;
}
this.recentlyOpenedProjectService.setServerId(this.server.id.toString());
this.recentlyOpenedProjectService.setProjectId(this.project.project_id);
@ -403,8 +410,9 @@ export class ProjectMapComponent implements OnInit, OnDestroy {
this.toolsService.drawLinkToolActivation(this.tools.draw_link);
}
public toggleShowInterfaceLabels(enabled: boolean) {
this.project.show_interface_labels = enabled;
public toggleShowInterfaceLabels(visible: boolean) {
this.isInterfaceLabelVisible = visible;
this.mapSettingsService.toggleShowInterfaceLabels(this.project.project_id, this.isInterfaceLabelVisible);
}
public toggleShowConsole(visible: boolean) {

View File

@ -6,6 +6,7 @@ export class MapSettingsService {
public isMapLocked = new Subject<boolean>();
public isTopologySummaryVisible: boolean = false;
public isLogConsoleVisible: boolean = false;
public interfaceLabels: Map<string, boolean> = new Map<string, boolean>();
constructor() {}
@ -20,4 +21,8 @@ export class MapSettingsService {
toggleLogConsole(value: boolean) {
this.isLogConsoleVisible = value;
}
toggleShowInterfaceLabels(projectId: string, value: boolean) {
this.interfaceLabels.set(projectId, value);
}
}