feat(ui): New sidebar & search UI (#831)

This commit is contained in:
Alex
2026-05-04 09:46:48 +01:00
committed by GitHub
parent c9b2a5734e
commit f3138a88c5
182 changed files with 8318 additions and 4660 deletions
@@ -3,12 +3,9 @@
.main-container {
width: 100%;
padding: 1rem;
height: calc(100dvh - 10.5rem);
height: 100%;
min-height: 0;
overflow-y: auto;
@media (width >= 768px) {
height: calc(100dvh - 11.65rem);
}
}
@include settings.settings-page-header;
@@ -1,5 +1,48 @@
:host {
display: block;
height: 100%;
min-height: 0;
}
.settings-container {
border-radius: 0.75rem;
display: flex;
flex-direction: column;
height: 100%;
min-height: 0;
}
.settings-container > p-tabs,
.settings-container p-tabs.p-tabs {
display: flex;
flex-direction: column;
height: 100%;
min-height: 0;
}
.settings-container p-tablist {
flex: 0 0 auto;
}
.settings-container p-tabpanels {
display: flex;
flex: 1 1 auto;
flex-direction: column;
min-height: 0;
overflow: hidden;
border: 1px solid var(--p-content-border-color);
padding: 0;
background: transparent;
}
.settings-container p-tabpanel.p-tabpanel-active {
display: flex;
flex: 1 1 auto;
flex-direction: column;
min-height: 0;
}
.settings-container p-tabpanel.p-tabpanel-active > * {
display: block;
flex: 1 1 auto;
min-height: 0;
height: 100%;
}
@@ -0,0 +1,32 @@
<ng-container *transloco="let t; prefix: 'settingsView.language'">
<div class="settings-card">
<div class="section-header">
<h3 class="section-title">
<i class="pi pi-language"></i>
{{ t('sectionTitle') }}
</h3>
<p class="section-description">{{ t('sectionDesc') }}</p>
</div>
<div class="section-body">
<div class="setting-item">
<div class="setting-header-standalone">
<span class="setting-label">{{ t('label') }}</span>
</div>
<div class="setting-options">
<div class="select-group">
<p-select
size="small"
[options]="languageOptions"
[ngModel]="activeLang()"
(ngModelChange)="onLanguageChange($event)"
optionLabel="label"
optionValue="value"
appendTo="body">
</p-select>
</div>
</div>
</div>
</div>
</div>
</ng-container>
@@ -0,0 +1,41 @@
@use '../../../../shared/styles/settings-shared' as settings;
.settings-card {
@include settings.settings-card;
}
.section-header {
@include settings.settings-section-header;
}
.section-title {
@include settings.settings-section-title;
}
.section-description {
@include settings.settings-section-description;
}
.section-body {
@include settings.settings-section-body;
}
.setting-item {
@include settings.settings-item;
}
.setting-header-standalone {
@include settings.settings-item-header-standalone;
}
.setting-label {
@include settings.settings-label;
}
.setting-options {
@include settings.settings-options;
}
.select-group {
@include settings.settings-select-group;
}
@@ -0,0 +1,35 @@
import {Component, DestroyRef, inject} from '@angular/core';
import {FormsModule} from '@angular/forms';
import {takeUntilDestroyed, toSignal} from '@angular/core/rxjs-interop';
import {Select} from 'primeng/select';
import {TranslocoDirective, TranslocoService} from '@jsverse/transloco';
import {AVAILABLE_LANGS, LANG_LABELS} from '../../../../core/config/transloco-loader';
import {LANG_STORAGE_KEY} from '../../../../core/config/language-initializer';
@Component({
selector: 'app-language-preferences',
standalone: true,
imports: [FormsModule, Select, TranslocoDirective],
templateUrl: './language-preferences.component.html',
styleUrl: './language-preferences.component.scss',
})
export class LanguagePreferencesComponent {
readonly languageOptions = AVAILABLE_LANGS.map(value => ({
value,
label: LANG_LABELS[value] ?? value,
}));
private readonly t = inject(TranslocoService);
private readonly destroyRef = inject(DestroyRef);
readonly activeLang = toSignal(this.t.langChanges$, {initialValue: this.t.getActiveLang()});
onLanguageChange(lang: string): void {
if (lang === this.activeLang()) return;
this.t.load(lang).pipe(takeUntilDestroyed(this.destroyRef)).subscribe({
next: () => {
this.t.setActiveLang(lang);
localStorage.setItem(LANG_STORAGE_KEY, lang);
},
});
}
}
@@ -19,9 +19,9 @@
<div class="setting-options">
<p-select
size="small"
[options]="sortingOptions"
[(ngModel)]="selectedLibrarySorting"
(ngModelChange)="onLibrarySortingChange()"
[options]="sortingOptions()"
[ngModel]="selectedLibrarySorting()"
(ngModelChange)="onLibrarySortingChange($event)"
appendTo="body"
optionLabel="label"
optionValue="value"
@@ -38,9 +38,9 @@
<div class="setting-options">
<p-select
size="small"
[options]="sortingOptions"
[(ngModel)]="selectedShelfSorting"
(ngModelChange)="onShelfSortingChange()"
[options]="sortingOptions()"
[ngModel]="selectedShelfSorting()"
(ngModelChange)="onShelfSortingChange($event)"
appendTo="body"
optionLabel="label"
optionValue="value"
@@ -57,9 +57,9 @@
<div class="setting-options">
<p-select
size="small"
[options]="sortingOptions"
[(ngModel)]="selectedMagicShelfSorting"
(ngModelChange)="onMagicShelfSortingChange()"
[options]="sortingOptions()"
[ngModel]="selectedMagicShelfSorting()"
(ngModelChange)="onMagicShelfSortingChange($event)"
appendTo="body"
optionLabel="label"
optionValue="value"
@@ -1,85 +1,43 @@
import {signal} from '@angular/core';
import {signal, WritableSignal} from '@angular/core';
import {ComponentFixture, TestBed} from '@angular/core/testing';
import {afterEach, beforeEach, describe, expect, it, vi} from 'vitest';
import {MessageService} from 'primeng/api';
import {getTranslocoModule} from '../../../../core/testing/transloco-testing';
import {User, UserService, UserSettings} from '../../user-management/user.service';
import {LayoutService} from '../../../../shared/layout/layout.service';
import {SortPref} from '../../../../shared/layout/sidebar-sort-preferences';
import {SidebarSortingPreferencesComponent} from './sidebar-sorting-preferences.component';
function createUserSettings(): UserSettings {
return {
perBookSetting: {pdf: 'Global', epub: 'Individual', cbx: 'Global'},
pdfReaderSetting: {pageSpread: 'off', pageZoom: '100%', showSidebar: true},
epubReaderSetting: {theme: 'light', font: 'serif', fontSize: 16, flow: 'paginated', spread: 'auto', lineHeight: 1.5, margin: 1, letterSpacing: 0},
ebookReaderSetting: {lineHeight: 1.5, justify: true, hyphenate: true, maxColumnCount: 1, gap: 1, fontSize: 16, theme: 'light', maxInlineSize: 100, maxBlockSize: 100, fontFamily: 'serif', isDark: false, flow: 'paginated'},
cbxReaderSetting: {pageSpread: 'EVEN', pageViewMode: 'SINGLE_PAGE', fitMode: 'AUTO'},
newPdfReaderSetting: {pageSpread: 'EVEN', pageViewMode: 'SINGLE_PAGE', fitMode: 'AUTO'},
sidebarLibrarySorting: {field: 'name', order: 'asc'},
sidebarShelfSorting: {field: 'id', order: 'desc'},
sidebarMagicShelfSorting: {field: 'name', order: 'desc'},
filterMode: 'and',
metadataCenterViewMode: 'route',
enableSeriesView: true,
entityViewPreferences: {global: {sortKey: 'title', sortDir: 'ASC', view: 'GRID', coverSize: 100, seriesCollapsed: false, overlayBookType: false}, overrides: []},
koReaderEnabled: false,
autoSaveMetadata: true,
} as UserSettings;
}
function createUser(): User {
return {
id: 9,
username: 'tester',
name: 'Tester',
email: 'tester@example.com',
assignedLibraries: [],
permissions: {
admin: false,
canUpload: false,
canDownload: false,
canEmailBook: false,
canDeleteBook: false,
canEditMetadata: false,
canManageLibrary: false,
canManageMetadataConfig: false,
canSyncKoReader: false,
canSyncKobo: false,
canAccessOpds: false,
canAccessBookdrop: false,
canAccessLibraryStats: false,
canAccessUserStats: false,
canAccessTaskManager: false,
canManageEmailConfig: false,
canManageGlobalPreferences: false,
canManageIcons: false,
canManageFonts: false,
demoUser: false,
canBulkAutoFetchMetadata: false,
canBulkCustomFetchMetadata: false,
canBulkEditMetadata: false,
canBulkRegenerateCover: false,
canMoveOrganizeFiles: false,
canBulkLockUnlockMetadata: false,
},
userSettings: createUserSettings(),
};
}
describe('SidebarSortingPreferencesComponent', () => {
let fixture: ComponentFixture<SidebarSortingPreferencesComponent>;
let updateUserSetting: ReturnType<typeof vi.fn>;
let setLibrarySort: ReturnType<typeof vi.fn>;
let messageService: {add: ReturnType<typeof vi.fn>};
let librarySort: WritableSignal<SortPref>;
let shelfSort: WritableSignal<SortPref>;
let magicShelfSort: WritableSignal<SortPref>;
beforeEach(() => {
updateUserSetting = vi.fn();
librarySort = signal<SortPref>({field: 'name', order: 'asc'});
shelfSort = signal<SortPref>({field: 'id', order: 'desc'});
magicShelfSort = signal<SortPref>({field: 'name', order: 'desc'});
setLibrarySort = vi.fn((value: SortPref) => librarySort.set(value));
messageService = {add: vi.fn()};
TestBed.configureTestingModule({
imports: [SidebarSortingPreferencesComponent, getTranslocoModule({translocoConfig: {reRenderOnLangChange: false}})],
providers: [
{provide: UserService, useValue: {currentUser: signal(createUser()), updateUserSetting}},
{
provide: LayoutService,
useValue: {
librarySort,
shelfSort,
magicShelfSort,
setLibrarySort,
setShelfSort: vi.fn((value: SortPref) => shelfSort.set(value)),
setMagicShelfSort: vi.fn((value: SortPref) => magicShelfSort.set(value)),
},
},
{provide: MessageService, useValue: messageService},
],
});
@@ -97,18 +55,18 @@ describe('SidebarSortingPreferencesComponent', () => {
it('hydrates sidebar sorting selections from the current user', () => {
const component = fixture.componentInstance;
expect(component.selectedLibrarySorting).toEqual({field: 'name', order: 'asc'});
expect(component.selectedShelfSorting).toEqual({field: 'id', order: 'desc'});
expect(component.sortingOptions).not.toHaveLength(0);
expect(component.selectedLibrarySorting()).toEqual({field: 'name', order: 'asc'});
expect(component.selectedShelfSorting()).toEqual({field: 'id', order: 'desc'});
expect(component.selectedMagicShelfSorting()).toEqual({field: 'name', order: 'desc'});
expect(component.sortingOptions()).not.toHaveLength(0);
});
it('persists library sorting changes and shows a success toast', () => {
const component = fixture.componentInstance;
component.selectedLibrarySorting = {field: 'id', order: 'asc'};
component.onLibrarySortingChange();
component.onLibrarySortingChange({field: 'id', order: 'asc'});
expect(updateUserSetting).toHaveBeenCalledWith(9, 'sidebarLibrarySorting', {field: 'id', order: 'asc'});
expect(setLibrarySort).toHaveBeenCalledWith({field: 'id', order: 'asc'});
expect(messageService.add).toHaveBeenCalledWith(expect.objectContaining({severity: 'success'}));
});
});
@@ -1,12 +1,11 @@
import {Component, DestroyRef, effect, inject, OnInit} from '@angular/core';
import {takeUntilDestroyed} from '@angular/core/rxjs-interop';
import {Component, computed, inject} from '@angular/core';
import {toSignal} from '@angular/core/rxjs-interop';
import {Select} from 'primeng/select';
import {SidebarLibrarySorting, SidebarMagicShelfSorting, SidebarShelfSorting, User, UserService, UserSettings} from '../../user-management/user.service';
import {MessageService} from 'primeng/api';
import {FormsModule} from '@angular/forms';
import {TranslocoDirective, TranslocoService} from '@jsverse/transloco';
type MutableSettingsBranch = Record<string, unknown>;
import {LayoutService} from '../../../../shared/layout/layout.service';
import {SortPref} from '../../../../shared/layout/sidebar-sort-preferences';
@Component({
selector: 'app-sidebar-sorting-preferences',
@@ -18,73 +17,47 @@ type MutableSettingsBranch = Record<string, unknown>;
templateUrl: './sidebar-sorting-preferences.component.html',
styleUrl: './sidebar-sorting-preferences.component.scss'
})
export class SidebarSortingPreferencesComponent implements OnInit {
export class SidebarSortingPreferencesComponent {
private readonly sortingOptionDefs = [
{value: {field: 'name', order: 'asc'}, translationKey: 'nameAsc'},
{value: {field: 'name', order: 'desc'}, translationKey: 'nameDesc'},
{value: {field: 'id', order: 'asc'}, translationKey: 'creationAsc'},
{value: {field: 'id', order: 'desc'}, translationKey: 'creationDesc'},
];
] satisfies {value: SortPref; translationKey: string}[];
sortingOptions: {label: string; value: {field: string; order: string}; translationKey: string}[] = [];
selectedLibrarySorting: SidebarLibrarySorting = {field: 'id', order: 'asc'};
selectedShelfSorting: SidebarShelfSorting = {field: 'id', order: 'asc'};
selectedMagicShelfSorting: SidebarMagicShelfSorting = {field: 'id', order: 'asc'};
private readonly userService = inject(UserService);
private readonly layoutService = inject(LayoutService);
private readonly messageService = inject(MessageService);
private readonly t = inject(TranslocoService);
private readonly destroyRef = inject(DestroyRef);
private readonly activeLang = toSignal(this.t.langChanges$, {initialValue: this.t.getActiveLang()});
private currentUser: User | null = null;
private hasInitialized = false;
readonly selectedLibrarySorting = this.layoutService.librarySort;
readonly selectedShelfSorting = this.layoutService.shelfSort;
readonly selectedMagicShelfSorting = this.layoutService.magicShelfSort;
private readonly syncUserEffect = effect(() => {
const user = this.userService.currentUser();
if (!user) return;
this.currentUser = user;
if (!this.hasInitialized) {
this.hasInitialized = true;
this.loadPreferences(user.userSettings);
}
});
ngOnInit(): void {
this.buildSortingOptions();
this.t.langChanges$.pipe(takeUntilDestroyed(this.destroyRef)).subscribe(() => this.buildSortingOptions());
}
private buildSortingOptions(): void {
this.sortingOptions = this.sortingOptionDefs.map(opt => ({
readonly sortingOptions = computed(() => {
this.activeLang();
return this.sortingOptionDefs.map(opt => ({
...opt,
label: this.t.translate('settingsView.sidebarSort.' + opt.translationKey)
}));
});
onLibrarySortingChange(value: SortPref) {
this.layoutService.setLibrarySort(value);
this.showSuccessToast();
}
private loadPreferences(settings: UserSettings): void {
this.selectedLibrarySorting = settings.sidebarLibrarySorting;
this.selectedShelfSorting = settings.sidebarShelfSorting;
this.selectedMagicShelfSorting = settings.sidebarMagicShelfSorting;
onShelfSortingChange(value: SortPref) {
this.layoutService.setShelfSort(value);
this.showSuccessToast();
}
private updatePreference(path: string[], value: unknown): void {
if (!this.currentUser) return;
let target = this.currentUser.userSettings as unknown as MutableSettingsBranch;
for (let i = 0; i < path.length - 1; i++) {
const next = target[path[i]];
if (!next || typeof next !== 'object') {
target[path[i]] = {};
}
target = target[path[i]] as MutableSettingsBranch;
}
target[path.at(-1)!] = value;
onMagicShelfSortingChange(value: SortPref) {
this.layoutService.setMagicShelfSort(value);
this.showSuccessToast();
}
const [rootKey] = path;
const updatedValue = this.currentUser.userSettings[rootKey as keyof UserSettings];
this.userService.updateUserSetting(this.currentUser.id, rootKey, updatedValue);
private showSuccessToast(): void {
this.messageService.add({
severity: 'success',
summary: this.t.translate('settingsView.sidebarSort.prefsUpdated'),
@@ -92,16 +65,4 @@ export class SidebarSortingPreferencesComponent implements OnInit {
life: 1500
});
}
onLibrarySortingChange() {
this.updatePreference(['sidebarLibrarySorting'], this.selectedLibrarySorting);
}
onShelfSortingChange() {
this.updatePreference(['sidebarShelfSorting'], this.selectedShelfSorting);
}
onMagicShelfSortingChange() {
this.updatePreference(['sidebarMagicShelfSorting'], this.selectedMagicShelfSorting);
}
}
@@ -0,0 +1,15 @@
<ng-container *transloco="let t; prefix: 'settingsView.theme'">
<div class="settings-card">
<div class="section-header">
<h3 class="section-title">
<i class="pi pi-palette"></i>
{{ t('sectionTitle') }}
</h3>
<p class="section-description">{{ t('sectionDesc') }}</p>
</div>
<div class="section-body">
<app-theme-configurator></app-theme-configurator>
</div>
</div>
</ng-container>
@@ -0,0 +1,21 @@
@use '../../../../shared/styles/settings-shared' as settings;
.settings-card {
@include settings.settings-card;
}
.section-header {
@include settings.settings-section-header;
}
.section-title {
@include settings.settings-section-title;
}
.section-description {
@include settings.settings-section-description;
}
.section-body {
@include settings.settings-section-body;
}
@@ -0,0 +1,12 @@
import {Component} from '@angular/core';
import {TranslocoDirective} from '@jsverse/transloco';
import {ThemeConfiguratorComponent} from '../../../../shared/layout/theme-configurator/theme-configurator.component';
@Component({
selector: 'app-theme-preferences',
standalone: true,
imports: [TranslocoDirective, ThemeConfiguratorComponent],
templateUrl: './theme-preferences.component.html',
styleUrl: './theme-preferences.component.scss',
})
export class ThemePreferencesComponent {}
@@ -10,6 +10,11 @@
</p>
</div>
<app-language-preferences></app-language-preferences>
<div class="section-divider"><hr></div>
<app-theme-preferences></app-theme-preferences>
<div class="section-divider"><hr></div>
<app-view-preferences></app-view-preferences>
<div class="section-divider"><hr></div>
<app-filter-preferences></app-filter-preferences>
@@ -35,10 +40,9 @@
<div class="slider-container">
<p-slider
[(ngModel)]="sidebarWidth"
[min]="175"
[max]="400"
[min]="SIDEBAR_MIN_WIDTH"
[max]="SIDEBAR_MAX_WIDTH"
[step]="1"
(onChange)="onSidebarWidthChange()"
(onSlideEnd)="saveSidebarWidth()">
</p-slider>
</div>
@@ -1,22 +1,30 @@
import {signal} from '@angular/core';
import {TestBed} from '@angular/core/testing';
import {describe, expect, it, vi} from 'vitest';
import {ViewPreferencesParentComponent} from './view-preferences-parent.component';
import {LocalStorageService} from '../../../shared/service/local-storage.service';
import {MessageService} from 'primeng/api';
import {TranslocoService} from '@jsverse/transloco';
import {LayoutService} from '../../../shared/layout/layout.service';
describe('ViewPreferencesParentComponent', () => {
it('loads and saves the sidebar width', () => {
const localStorageGet = vi.fn(() => 312);
const localStorageSet = vi.fn();
function createLayoutService(initialWidth: number) {
const sidebarWidth = signal(initialWidth);
return {
sidebarWidth,
setSidebarWidth: vi.fn((value: number) => sidebarWidth.set(value)),
};
}
it('reads the sidebar width from LayoutService and saves it back with persistence', () => {
const layoutService = createLayoutService(312);
const messageAdd = vi.fn();
const translate = vi.fn(key => key);
TestBed.configureTestingModule({
imports: [ViewPreferencesParentComponent],
providers: [
{provide: LocalStorageService, useValue: {get: localStorageGet, set: localStorageSet}},
{provide: LayoutService, useValue: layoutService},
{provide: MessageService, useValue: {add: messageAdd}},
{provide: TranslocoService, useValue: {translate}},
]
@@ -25,12 +33,11 @@ describe('ViewPreferencesParentComponent', () => {
const fixture = TestBed.createComponent(ViewPreferencesParentComponent);
const component = fixture.componentInstance;
component.ngOnInit();
expect(component.sidebarWidth).toBe(312);
component.saveSidebarWidth();
expect(localStorageSet).toHaveBeenCalledWith('sidebarWidth', 312);
expect(layoutService.setSidebarWidth).toHaveBeenCalledWith(312, true);
expect(messageAdd).toHaveBeenCalledWith({
severity: 'success',
summary: 'settingsView.layout.saved',
@@ -38,13 +45,13 @@ describe('ViewPreferencesParentComponent', () => {
});
});
it('updates the sidebar CSS variable when the width changes', () => {
const localStorageGet = vi.fn(() => 225);
it('updates the layout service width immediately while the slider moves', () => {
const layoutService = createLayoutService(225);
TestBed.configureTestingModule({
imports: [ViewPreferencesParentComponent],
providers: [
{provide: LocalStorageService, useValue: {get: localStorageGet, set: vi.fn()}},
{provide: LayoutService, useValue: layoutService},
{provide: MessageService, useValue: {add: vi.fn()}},
{provide: TranslocoService, useValue: {translate: vi.fn()}},
]
@@ -54,16 +61,18 @@ describe('ViewPreferencesParentComponent', () => {
const component = fixture.componentInstance;
component.sidebarWidth = 287;
component.onSidebarWidthChange();
expect(document.documentElement.style.getPropertyValue('--sidebar-width')).toBe('287px');
expect(layoutService.setSidebarWidth).toHaveBeenCalledWith(287, false);
expect(component.sidebarWidth).toBe(287);
});
it('falls back to the default width when no value is stored', () => {
it('falls back to the layout service default width when nothing custom is loaded', () => {
const layoutService = createLayoutService(225);
TestBed.configureTestingModule({
imports: [ViewPreferencesParentComponent],
providers: [
{provide: LocalStorageService, useValue: {get: vi.fn(() => null), set: vi.fn()}},
{provide: LayoutService, useValue: layoutService},
{provide: MessageService, useValue: {add: vi.fn()}},
{provide: TranslocoService, useValue: {translate: vi.fn()}},
]
@@ -72,8 +81,6 @@ describe('ViewPreferencesParentComponent', () => {
const fixture = TestBed.createComponent(ViewPreferencesParentComponent);
const component = fixture.componentInstance;
component.ngOnInit();
expect(component.sidebarWidth).toBe(225);
});
});
@@ -1,4 +1,4 @@
import {Component, inject, OnInit} from '@angular/core';
import {Component, inject} from '@angular/core';
import {FormsModule} from '@angular/forms';
import {TableModule} from 'primeng/table';
@@ -6,10 +6,12 @@ import {ViewPreferencesComponent} from './view-preferences/view-preferences.comp
import {SidebarSortingPreferencesComponent} from './sidebar-sorting-preferences/sidebar-sorting-preferences.component';
import {MetaCenterViewModeComponent} from './meta-center-view-mode/meta-center-view-mode-component';
import {FilterPreferencesComponent} from './filter-preferences/filter-preferences.component';
import {LanguagePreferencesComponent} from './language-preferences/language-preferences.component';
import {ThemePreferencesComponent} from './theme-preferences/theme-preferences.component';
import {TranslocoDirective, TranslocoService} from '@jsverse/transloco';
import {Slider} from 'primeng/slider';
import {MessageService} from 'primeng/api';
import {LocalStorageService} from '../../../shared/service/local-storage.service';
import {LayoutService, SIDEBAR_MAX_WIDTH, SIDEBAR_MIN_WIDTH} from '../../../shared/layout/layout.service';
@Component({
selector: 'app-view-preferences-parent',
@@ -21,30 +23,32 @@ import {LocalStorageService} from '../../../shared/service/local-storage.service
SidebarSortingPreferencesComponent,
MetaCenterViewModeComponent,
FilterPreferencesComponent,
LanguagePreferencesComponent,
ThemePreferencesComponent,
TranslocoDirective,
Slider,
],
templateUrl: './view-preferences-parent.component.html',
styleUrl: './view-preferences-parent.component.scss'
})
export class ViewPreferencesParentComponent implements OnInit {
export class ViewPreferencesParentComponent {
sidebarWidth = 225;
readonly SIDEBAR_MIN_WIDTH = SIDEBAR_MIN_WIDTH;
readonly SIDEBAR_MAX_WIDTH = SIDEBAR_MAX_WIDTH;
private localStorageService = inject(LocalStorageService);
private layoutService = inject(LayoutService);
private messageService = inject(MessageService);
private t = inject(TranslocoService);
ngOnInit(): void {
this.sidebarWidth = this.localStorageService.get<number>('sidebarWidth') ?? 225;
get sidebarWidth(): number {
return this.layoutService.sidebarWidth();
}
onSidebarWidthChange(): void {
document.documentElement.style.setProperty('--sidebar-width', this.sidebarWidth + 'px');
set sidebarWidth(value: number) {
this.layoutService.setSidebarWidth(value, false);
}
saveSidebarWidth(): void {
this.localStorageService.set('sidebarWidth', this.sidebarWidth);
this.layoutService.setSidebarWidth(this.layoutService.sidebarWidth(), true);
this.messageService.add({
severity: 'success',
summary: this.t.translate('settingsView.layout.saved'),