From 27014d8382614fa965ecfbb45ba4b82ca9b4d537 Mon Sep 17 00:00:00 2001 From: MatthijsSmets Date: Tue, 16 Jan 2024 11:08:09 +0100 Subject: [PATCH] feat: allow user to select amount of spacing --- .../table-settings-modal.component.html | 10 ++++++ .../table-settings-modal.component.ts | 15 +++++++- src/app/debug/table/table.component.css | 9 ----- src/app/debug/table/table.component.html | 12 +++---- src/app/debug/table/table.component.ts | 35 ++++++++++++++++--- src/app/shared/services/settings.service.ts | 17 +++++++-- 6 files changed, 76 insertions(+), 22 deletions(-) diff --git a/src/app/debug/table/table-settings-modal/table-settings-modal.component.html b/src/app/debug/table/table-settings-modal/table-settings-modal.component.html index cf59fdaa..a50563ca 100644 --- a/src/app/debug/table/table-settings-modal/table-settings-modal.component.html +++ b/src/app/debug/table/table-settings-modal/table-settings-modal.component.html @@ -21,6 +21,16 @@
Debug tree

+
+
Report table
+
+ + +
+
+
+ {{getShortenedTableHeaderNames(header)}} @@ -86,13 +86,13 @@ - - + + - {{row[metadataName]|tableCellShortener}} + {{row[metadataName]|tableCellShortener}} diff --git a/src/app/debug/table/table.component.ts b/src/app/debug/table/table.component.ts index 8dbc3162..6be26c66 100644 --- a/src/app/debug/table/table.component.ts +++ b/src/app/debug/table/table.component.ts @@ -1,20 +1,21 @@ -import { Component, EventEmitter, OnInit, Output, ViewChild } from '@angular/core'; +import { Component, EventEmitter, OnDestroy, OnInit, Output, ViewChild } from '@angular/core'; import { ToastComponent } from '../../shared/components/toast/toast.component'; import { HelperService } from '../../shared/services/helper.service'; import { HttpService } from '../../shared/services/http.service'; import { TableSettingsModalComponent } from './table-settings-modal/table-settings-modal.component'; import { TableSettings } from '../../shared/interfaces/table-settings'; -import { catchError } from 'rxjs'; +import { catchError, Subscription } from 'rxjs'; import { Report } from '../../shared/interfaces/report'; import { CookieService } from 'ngx-cookie-service'; import { ChangeNodeLinkStrategyService } from '../../shared/services/node-link-strategy.service'; +import { SettingsService } from '../../shared/services/settings.service'; @Component({ selector: 'app-table', templateUrl: './table.component.html', styleUrls: ['./table.component.css'], }) -export class TableComponent implements OnInit { +export class TableComponent implements OnInit, OnDestroy { DEFAULT_DISPLAY_AMOUNT: number = 10; metadataCount = 0; viewSettings: any = { @@ -66,18 +67,32 @@ export class TableComponent implements OnInit { selectedRow: number = -1; doneRetrieving: boolean = false; @Output() openReportInSeparateTabEvent = new EventEmitter(); + tableSpacing!: number; + tableSpacingSubscription!: Subscription; constructor( private httpService: HttpService, public helperService: HelperService, private cookieService: CookieService, - private changeNodeLinkStrategyService: ChangeNodeLinkStrategyService + private changeNodeLinkStrategyService: ChangeNodeLinkStrategyService, + private settingsService: SettingsService ) {} ngOnInit(): void { this.cookieService.set('transformationEnabled', 'true'); this.loadData(); this.listenForViewUpdate(); + this.subscribeToSettingsObservables(); + } + + ngOnDestroy(): void { + this.tableSpacingSubscription.unsubscribe(); + } + + subscribeToSettingsObservables(): void { + this.tableSpacingSubscription = this.settingsService.tableSpacingObservable.subscribe((value: number): void => { + this.tableSpacing = value; + }); } retrieveRecords() { @@ -409,4 +424,16 @@ export class TableComponent implements OnInit { } return fullName; } + + getTableSpacing() { + return `${this.tableSpacing * 0.25}em 0 ${this.tableSpacing * 0.25}em 0`; + } + + getFontSize() { + return `${8 + this.tableSpacing * 1.2}pt`; + } + + getCheckBoxSize() { + return `${13 + this.tableSpacing}px`; + } } diff --git a/src/app/shared/services/settings.service.ts b/src/app/shared/services/settings.service.ts index 0249a9f1..7de73863 100644 --- a/src/app/shared/services/settings.service.ts +++ b/src/app/shared/services/settings.service.ts @@ -9,6 +9,11 @@ export class SettingsService { this.loadSettingsFromLocalStorage(); } + private loadSettingsFromLocalStorage(): void { + this.setShowMultipleAtATime(localStorage.getItem(this.showMultipleAtATimeKey) === 'true'); + this.setTableSpacing(Number(localStorage.getItem(this.tableSpacingKey))); + } + //Show multiple files in debug tree private showMultipleAtATimeKey: string = 'showMultipleFilesAtATime'; private showMultipleAtATime: boolean = false; @@ -21,7 +26,15 @@ export class SettingsService { localStorage.setItem(this.showMultipleAtATimeKey, String(this.showMultipleAtATime)); } - private loadSettingsFromLocalStorage(): void { - this.setShowMultipleAtATime(localStorage.getItem(this.showMultipleAtATimeKey) === 'true'); + //Table spacing settings + private tableSpacingKey: string = 'tableSpacing'; + private tableSpacing: number = 0; + private tableSpacingSubject: Subject = new ReplaySubject(1); + public tableSpacingObservable: Observable = this.tableSpacingSubject.asObservable(); + + public setTableSpacing(value: number = 0): void { + this.tableSpacing = value; + this.tableSpacingSubject.next(value); + localStorage.setItem(this.tableSpacingKey, String(value)); } }