feat(i18n): add Transloco translation framework with EN/ES and 7 language scaffolds (#2681)
* feat(i18n): add Transloco translation framework and translate all settings tabs (EN/ES) * feat(i18n): translate shared, layout, dashboard, library-creator, and app-root components (EN/ES) and scaffold 7 new languages * feat(i18n): translate bookdrop and metadata components (EN/ES), remove i18n-audit from tracking * fix(i18n): deep-merge English as fallback base for incomplete language translations
This commit is contained in:
+46
-44
@@ -1,47 +1,49 @@
|
||||
<div class="dashboard-scroller-container">
|
||||
<h2 class="dashboard-scroller-title">
|
||||
{{ title }}
|
||||
@if (isMagicShelf) {
|
||||
<i class="pi pi-sparkles magic-shelf-icon"></i>
|
||||
}
|
||||
</h2>
|
||||
|
||||
@if (!books || books.length === 0) {
|
||||
<div class="dashboard-scroller-no-books">
|
||||
<div class="empty-state-icon">
|
||||
<i class="pi pi-book"></i>
|
||||
</div>
|
||||
<p>No books found for this scroller.</p>
|
||||
</div>
|
||||
}
|
||||
|
||||
@if (books) {
|
||||
<div class="dashboard-scroller-infinite"
|
||||
infiniteScroll
|
||||
[infiniteScrollDistance]="2"
|
||||
[infiniteScrollThrottle]="50"
|
||||
#scrollContainer
|
||||
[horizontal]="true">
|
||||
@for (book of books; track book.id) {
|
||||
<div class="dashboard-scroller-card" [ngClass]="{'menu-open': openMenuBookId === book.id, 'square-card': useSquareCovers}">
|
||||
<app-book-card
|
||||
[book]="book"
|
||||
[isCheckboxEnabled]="false"
|
||||
[forceEbookMode]="forceEbookMode"
|
||||
(menuToggled)="handleMenuToggle(book.id, $event)"
|
||||
[overlayPreferenceService]="bookCardOverlayPreferenceService"
|
||||
></app-book-card>
|
||||
</div>
|
||||
<ng-container *transloco="let t; prefix: 'dashboard.scroller'">
|
||||
<div class="dashboard-scroller-container">
|
||||
<h2 class="dashboard-scroller-title">
|
||||
{{ title }}
|
||||
@if (isMagicShelf) {
|
||||
<i class="pi pi-sparkles magic-shelf-icon"></i>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
</h2>
|
||||
|
||||
@if (books === null) {
|
||||
<div class="dashboard-scroller-error">
|
||||
<div class="error-icon">
|
||||
<i class="pi pi-exclamation-triangle"></i>
|
||||
@if (!books || books.length === 0) {
|
||||
<div class="dashboard-scroller-no-books">
|
||||
<div class="empty-state-icon">
|
||||
<i class="pi pi-book"></i>
|
||||
</div>
|
||||
<p>{{ t('noBooksFound') }}</p>
|
||||
</div>
|
||||
<p>Failed to load books! Please try refreshing the page.</p>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
|
||||
@if (books) {
|
||||
<div class="dashboard-scroller-infinite"
|
||||
infiniteScroll
|
||||
[infiniteScrollDistance]="2"
|
||||
[infiniteScrollThrottle]="50"
|
||||
#scrollContainer
|
||||
[horizontal]="true">
|
||||
@for (book of books; track book.id) {
|
||||
<div class="dashboard-scroller-card" [ngClass]="{'menu-open': openMenuBookId === book.id, 'square-card': useSquareCovers}">
|
||||
<app-book-card
|
||||
[book]="book"
|
||||
[isCheckboxEnabled]="false"
|
||||
[forceEbookMode]="forceEbookMode"
|
||||
(menuToggled)="handleMenuToggle(book.id, $event)"
|
||||
[overlayPreferenceService]="bookCardOverlayPreferenceService"
|
||||
></app-book-card>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
|
||||
@if (books === null) {
|
||||
<div class="dashboard-scroller-error">
|
||||
<div class="error-icon">
|
||||
<i class="pi pi-exclamation-triangle"></i>
|
||||
</div>
|
||||
<p>{{ t('loadError') }}</p>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</ng-container>
|
||||
|
||||
+3
-1
@@ -7,6 +7,7 @@ import {ProgressSpinnerModule} from 'primeng/progressspinner';
|
||||
import {Book} from '../../../book/model/book.model';
|
||||
import {ScrollerType} from '../../models/dashboard-config.model';
|
||||
import { BookCardOverlayPreferenceService } from '../../../book/components/book-browser/book-card-overlay-preference.service';
|
||||
import {TranslocoDirective} from '@jsverse/transloco';
|
||||
|
||||
@Component({
|
||||
selector: 'app-dashboard-scroller',
|
||||
@@ -16,7 +17,8 @@ import { BookCardOverlayPreferenceService } from '../../../book/components/book-
|
||||
InfiniteScrollDirective,
|
||||
BookCardComponent,
|
||||
ProgressSpinnerModule,
|
||||
NgClass
|
||||
NgClass,
|
||||
TranslocoDirective
|
||||
],
|
||||
standalone: true
|
||||
})
|
||||
|
||||
+138
-136
@@ -1,154 +1,156 @@
|
||||
<div class="dashboard-settings">
|
||||
<div class="panel-header">
|
||||
<div class="header-icon-wrapper">
|
||||
<i class="pi pi-sliders-h header-icon"></i>
|
||||
<ng-container *transloco="let t; prefix: 'dashboard.settings'">
|
||||
<div class="dashboard-settings">
|
||||
<div class="panel-header">
|
||||
<div class="header-icon-wrapper">
|
||||
<i class="pi pi-sliders-h header-icon"></i>
|
||||
</div>
|
||||
<div class="header-text">
|
||||
<h2 class="panel-title">{{ t('title') }}</h2>
|
||||
<p class="panel-description">{{ t('description') }}</p>
|
||||
</div>
|
||||
<p-button
|
||||
icon="pi pi-times"
|
||||
[text]="true"
|
||||
[rounded]="true"
|
||||
severity="secondary"
|
||||
(onClick)="cancel()"
|
||||
class="close-button"
|
||||
/>
|
||||
</div>
|
||||
<div class="header-text">
|
||||
<h2 class="panel-title">Dashboard Configuration</h2>
|
||||
<p class="panel-description">Add up to 5 scrollers from different book collections and customize their behavior</p>
|
||||
</div>
|
||||
<p-button
|
||||
icon="pi pi-times"
|
||||
[text]="true"
|
||||
[rounded]="true"
|
||||
severity="secondary"
|
||||
(onClick)="cancel()"
|
||||
class="close-button"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div class="scrollers-container">
|
||||
@for (scroller of config.scrollers; track scroller.id; let i = $index) {
|
||||
<div class="scroller-item">
|
||||
<div class="scroller-content">
|
||||
<div class="scroller-controls-left">
|
||||
<p-checkbox [(ngModel)]="scroller.enabled" [binary]="true"></p-checkbox>
|
||||
</div>
|
||||
|
||||
<div class="scroller-fields">
|
||||
<div class="scroller-field" [class.expanded]="scroller.type !== 'magicShelf'">
|
||||
<label>Type</label>
|
||||
<p-select
|
||||
fluid
|
||||
[options]="availableScrollerTypes"
|
||||
[(ngModel)]="scroller.type"
|
||||
(onChange)="onScrollerTypeChange(scroller)"
|
||||
placeholder="Select type"
|
||||
appendTo="body">
|
||||
</p-select>
|
||||
<div class="scrollers-container">
|
||||
@for (scroller of config.scrollers; track scroller.id; let i = $index) {
|
||||
<div class="scroller-item">
|
||||
<div class="scroller-content">
|
||||
<div class="scroller-controls-left">
|
||||
<p-checkbox [(ngModel)]="scroller.enabled" [binary]="true"></p-checkbox>
|
||||
</div>
|
||||
|
||||
@if (scroller.type === 'magicShelf') {
|
||||
<div class="scroller-field">
|
||||
<label>Magic Shelf</label>
|
||||
<div class="scroller-fields">
|
||||
<div class="scroller-field" [class.expanded]="scroller.type !== 'magicShelf'">
|
||||
<label>{{ t('type') }}</label>
|
||||
<p-select
|
||||
fluid
|
||||
[options]="(magicShelves$ | async)!"
|
||||
[(ngModel)]="scroller.magicShelfId"
|
||||
placeholder="Select magic shelf"
|
||||
[options]="availableScrollerTypes"
|
||||
[(ngModel)]="scroller.type"
|
||||
(onChange)="onScrollerTypeChange(scroller)"
|
||||
[placeholder]="t('selectType')"
|
||||
appendTo="body">
|
||||
</p-select>
|
||||
</div>
|
||||
|
||||
<div class="scroller-field">
|
||||
<label>Sort Field</label>
|
||||
<p-select
|
||||
fluid
|
||||
[options]="sortFieldOptions"
|
||||
[(ngModel)]="scroller.sortField"
|
||||
placeholder="Select field"
|
||||
appendTo="body">
|
||||
</p-select>
|
||||
</div>
|
||||
@if (scroller.type === 'magicShelf') {
|
||||
<div class="scroller-field">
|
||||
<label>{{ t('magicShelf') }}</label>
|
||||
<p-select
|
||||
fluid
|
||||
[options]="(magicShelves$ | async)!"
|
||||
[(ngModel)]="scroller.magicShelfId"
|
||||
[placeholder]="t('selectMagicShelf')"
|
||||
appendTo="body">
|
||||
</p-select>
|
||||
</div>
|
||||
|
||||
<div class="scroller-field">
|
||||
<label>Direction</label>
|
||||
<p-select
|
||||
fluid
|
||||
[options]="sortDirectionOptions"
|
||||
[(ngModel)]="scroller.sortDirection"
|
||||
placeholder="Select direction"
|
||||
appendTo="body">
|
||||
</p-select>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
<div class="scroller-field">
|
||||
<label>{{ t('sortField') }}</label>
|
||||
<p-select
|
||||
fluid
|
||||
[options]="sortFieldOptions"
|
||||
[(ngModel)]="scroller.sortField"
|
||||
[placeholder]="t('selectField')"
|
||||
appendTo="body">
|
||||
</p-select>
|
||||
</div>
|
||||
|
||||
<div class="scroller-field max-items-field">
|
||||
<label>Max Items</label>
|
||||
<p-inputNumber
|
||||
fluid
|
||||
[(ngModel)]="scroller.maxItems"
|
||||
[min]="MIN_ITEMS"
|
||||
[max]="MAX_ITEMS"
|
||||
[showButtons]="true">
|
||||
</p-inputNumber>
|
||||
</div>
|
||||
<div class="scroller-field">
|
||||
<label>{{ t('direction') }}</label>
|
||||
<p-select
|
||||
fluid
|
||||
[options]="sortDirectionOptions"
|
||||
[(ngModel)]="scroller.sortDirection"
|
||||
[placeholder]="t('selectDirection')"
|
||||
appendTo="body">
|
||||
</p-select>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
|
||||
<div class="scroller-controls-right">
|
||||
<p-button
|
||||
icon="pi pi-arrow-up"
|
||||
outlined
|
||||
rounded
|
||||
severity="info"
|
||||
size="small"
|
||||
[disabled]="i === 0"
|
||||
(click)="moveUp(i)">
|
||||
</p-button>
|
||||
<p-button
|
||||
icon="pi pi-arrow-down"
|
||||
outlined
|
||||
rounded
|
||||
severity="info"
|
||||
size="small"
|
||||
[disabled]="i === config.scrollers.length - 1"
|
||||
(click)="moveDown(i)">
|
||||
</p-button>
|
||||
<p-button
|
||||
icon="pi pi-trash"
|
||||
outlined
|
||||
rounded
|
||||
size="small"
|
||||
severity="danger"
|
||||
(click)="removeScroller(i)"
|
||||
[disabled]="config.scrollers.length === 1">
|
||||
</p-button>
|
||||
<div class="scroller-field max-items-field">
|
||||
<label>{{ t('maxItems') }}</label>
|
||||
<p-inputNumber
|
||||
fluid
|
||||
[(ngModel)]="scroller.maxItems"
|
||||
[min]="MIN_ITEMS"
|
||||
[max]="MAX_ITEMS"
|
||||
[showButtons]="true">
|
||||
</p-inputNumber>
|
||||
</div>
|
||||
|
||||
<div class="scroller-controls-right">
|
||||
<p-button
|
||||
icon="pi pi-arrow-up"
|
||||
outlined
|
||||
rounded
|
||||
severity="info"
|
||||
size="small"
|
||||
[disabled]="i === 0"
|
||||
(click)="moveUp(i)">
|
||||
</p-button>
|
||||
<p-button
|
||||
icon="pi pi-arrow-down"
|
||||
outlined
|
||||
rounded
|
||||
severity="info"
|
||||
size="small"
|
||||
[disabled]="i === config.scrollers.length - 1"
|
||||
(click)="moveDown(i)">
|
||||
</p-button>
|
||||
<p-button
|
||||
icon="pi pi-trash"
|
||||
outlined
|
||||
rounded
|
||||
size="small"
|
||||
severity="danger"
|
||||
(click)="removeScroller(i)"
|
||||
[disabled]="config.scrollers.length === 1">
|
||||
</p-button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
|
||||
<div class="dialog-footer">
|
||||
<div class="footer-left">
|
||||
<p-button
|
||||
label="Add Scroller"
|
||||
icon="pi pi-plus"
|
||||
severity="primary"
|
||||
(click)="addScroller()"
|
||||
[disabled]="config.scrollers.length >= 5">
|
||||
</p-button>
|
||||
<p-button
|
||||
label="Reset to Default"
|
||||
icon="pi pi-refresh"
|
||||
severity="secondary"
|
||||
text
|
||||
(click)="resetToDefault()">
|
||||
</p-button>
|
||||
</div>
|
||||
<div class="footer-actions">
|
||||
<p-button
|
||||
label="Cancel"
|
||||
[outlined]="true"
|
||||
severity="secondary"
|
||||
(click)="cancel()">
|
||||
</p-button>
|
||||
<p-button
|
||||
label="Save"
|
||||
icon="pi pi-check"
|
||||
severity="success"
|
||||
(click)="save()">
|
||||
</p-button>
|
||||
<div class="dialog-footer">
|
||||
<div class="footer-left">
|
||||
<p-button
|
||||
[label]="t('addScroller')"
|
||||
icon="pi pi-plus"
|
||||
severity="primary"
|
||||
(click)="addScroller()"
|
||||
[disabled]="config.scrollers.length >= 5">
|
||||
</p-button>
|
||||
<p-button
|
||||
[label]="t('resetToDefault')"
|
||||
icon="pi pi-refresh"
|
||||
severity="secondary"
|
||||
text
|
||||
(click)="resetToDefault()">
|
||||
</p-button>
|
||||
</div>
|
||||
<div class="footer-actions">
|
||||
<p-button
|
||||
[label]="'common.cancel' | transloco"
|
||||
[outlined]="true"
|
||||
severity="secondary"
|
||||
(click)="cancel()">
|
||||
</p-button>
|
||||
<p-button
|
||||
[label]="'common.save' | transloco"
|
||||
icon="pi pi-check"
|
||||
severity="success"
|
||||
(click)="save()">
|
||||
</p-button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</ng-container>
|
||||
|
||||
+56
-36
@@ -1,4 +1,5 @@
|
||||
import {Component, inject, OnInit} from '@angular/core';
|
||||
import {Component, DestroyRef, inject, OnInit} from '@angular/core';
|
||||
import {takeUntilDestroyed} from '@angular/core/rxjs-interop';
|
||||
import {CommonModule} from '@angular/common';
|
||||
import {FormsModule} from '@angular/forms';
|
||||
import {DynamicDialogRef} from 'primeng/dynamicdialog';
|
||||
@@ -11,6 +12,7 @@ import {DashboardConfig, ScrollerConfig, ScrollerType} from '../../models/dashbo
|
||||
import {DashboardConfigService} from '../../services/dashboard-config.service';
|
||||
import {MagicShelfService} from '../../../magic-shelf/service/magic-shelf.service';
|
||||
import {map} from 'rxjs/operators';
|
||||
import {TranslocoDirective, TranslocoPipe, TranslocoService} from '@jsverse/transloco';
|
||||
|
||||
export const MAX_SCROLLERS = 5;
|
||||
export const DEFAULT_MAX_ITEMS = 20;
|
||||
@@ -27,7 +29,9 @@ export const MAX_ITEMS = 20;
|
||||
CheckboxModule,
|
||||
InputTextModule,
|
||||
SelectModule,
|
||||
InputNumberModule
|
||||
InputNumberModule,
|
||||
TranslocoDirective,
|
||||
TranslocoPipe
|
||||
],
|
||||
templateUrl: './dashboard-settings.component.html',
|
||||
styleUrls: ['./dashboard-settings.component.scss']
|
||||
@@ -36,16 +40,14 @@ export class DashboardSettingsComponent implements OnInit {
|
||||
private configService = inject(DashboardConfigService);
|
||||
private dialogRef = inject(DynamicDialogRef);
|
||||
private magicShelfService = inject(MagicShelfService);
|
||||
private translocoService = inject(TranslocoService);
|
||||
private destroyRef = inject(DestroyRef);
|
||||
|
||||
config!: DashboardConfig;
|
||||
|
||||
availableScrollerTypes = [
|
||||
{label: 'Continue Reading', value: ScrollerType.LAST_READ},
|
||||
{label: 'Continue Listening', value: ScrollerType.LAST_LISTENED},
|
||||
{label: 'Recently Added', value: ScrollerType.LATEST_ADDED},
|
||||
{label: 'Discover Something New', value: ScrollerType.RANDOM},
|
||||
{label: 'Magic Shelf', value: ScrollerType.MAGIC_SHELF}
|
||||
];
|
||||
availableScrollerTypes: {label: string; value: ScrollerType}[] = [];
|
||||
sortFieldOptions: {label: string; value: string}[] = [];
|
||||
sortDirectionOptions: {label: string; value: string}[] = [];
|
||||
|
||||
magicShelves$ = this.magicShelfService.shelvesState$.pipe(
|
||||
map(state => (state.shelves || []).map(shelf => ({
|
||||
@@ -54,33 +56,16 @@ export class DashboardSettingsComponent implements OnInit {
|
||||
})))
|
||||
);
|
||||
|
||||
sortFieldOptions = [
|
||||
{label: 'Title', value: 'title'},
|
||||
{label: 'Title + Series', value: 'titleSeries'},
|
||||
{label: 'File Name', value: 'fileName'},
|
||||
{label: 'File Path', value: 'filePath'},
|
||||
{label: 'Date Added', value: 'addedOn'},
|
||||
{label: 'Author', value: 'author'},
|
||||
{label: 'Author (Surname)', value: 'authorSurnameVorname'},
|
||||
{label: 'Author + Series', value: 'authorSeries'},
|
||||
{label: 'Personal Rating', value: 'personalRating'},
|
||||
{label: 'Publisher', value: 'publisher'},
|
||||
{label: 'Published Date', value: 'publishedDate'},
|
||||
{label: 'Last Read', value: 'lastReadTime'},
|
||||
{label: 'Pages', value: 'pageCount'}
|
||||
];
|
||||
|
||||
sortDirectionOptions = [
|
||||
{label: 'Ascending', value: 'asc'},
|
||||
{label: 'Descending', value: 'desc'}
|
||||
];
|
||||
|
||||
private magicShelvesMap = new Map<number, string>();
|
||||
|
||||
readonly MIN_ITEMS = MIN_ITEMS;
|
||||
readonly MAX_ITEMS = MAX_ITEMS;
|
||||
|
||||
ngOnInit(): void {
|
||||
this.translocoService.langChanges$
|
||||
.pipe(takeUntilDestroyed(this.destroyRef))
|
||||
.subscribe(() => this.buildTranslatedOptions());
|
||||
|
||||
this.configService.config$.subscribe(config => {
|
||||
this.config = JSON.parse(JSON.stringify(config));
|
||||
});
|
||||
@@ -95,22 +80,57 @@ export class DashboardSettingsComponent implements OnInit {
|
||||
});
|
||||
}
|
||||
|
||||
private buildTranslatedOptions(): void {
|
||||
const t = (key: string) => this.translocoService.translate(`dashboard.settings.${key}`);
|
||||
|
||||
this.availableScrollerTypes = [
|
||||
{label: t('scrollerTypes.lastRead'), value: ScrollerType.LAST_READ},
|
||||
{label: t('scrollerTypes.lastListened'), value: ScrollerType.LAST_LISTENED},
|
||||
{label: t('scrollerTypes.latestAdded'), value: ScrollerType.LATEST_ADDED},
|
||||
{label: t('scrollerTypes.random'), value: ScrollerType.RANDOM},
|
||||
{label: t('scrollerTypes.magicShelf'), value: ScrollerType.MAGIC_SHELF}
|
||||
];
|
||||
|
||||
this.sortFieldOptions = [
|
||||
{label: t('sortFields.title'), value: 'title'},
|
||||
{label: t('sortFields.titleSeries'), value: 'titleSeries'},
|
||||
{label: t('sortFields.fileName'), value: 'fileName'},
|
||||
{label: t('sortFields.filePath'), value: 'filePath'},
|
||||
{label: t('sortFields.addedOn'), value: 'addedOn'},
|
||||
{label: t('sortFields.author'), value: 'author'},
|
||||
{label: t('sortFields.authorSurnameVorname'), value: 'authorSurnameVorname'},
|
||||
{label: t('sortFields.authorSeries'), value: 'authorSeries'},
|
||||
{label: t('sortFields.personalRating'), value: 'personalRating'},
|
||||
{label: t('sortFields.publisher'), value: 'publisher'},
|
||||
{label: t('sortFields.publishedDate'), value: 'publishedDate'},
|
||||
{label: t('sortFields.lastReadTime'), value: 'lastReadTime'},
|
||||
{label: t('sortFields.pageCount'), value: 'pageCount'}
|
||||
];
|
||||
|
||||
this.sortDirectionOptions = [
|
||||
{label: t('sortDirections.asc'), value: 'asc'},
|
||||
{label: t('sortDirections.desc'), value: 'desc'}
|
||||
];
|
||||
}
|
||||
|
||||
getScrollerTitle(scroller: ScrollerConfig): string {
|
||||
const t = (key: string) => this.translocoService.translate(`dashboard.settings.scrollerTypes.${key}`);
|
||||
|
||||
if (scroller.type === ScrollerType.MAGIC_SHELF && scroller.magicShelfId) {
|
||||
return this.magicShelvesMap.get(scroller.magicShelfId) || 'Magic Shelf';
|
||||
return this.magicShelvesMap.get(scroller.magicShelfId) || t('magicShelf');
|
||||
}
|
||||
|
||||
switch (scroller.type) {
|
||||
case ScrollerType.LAST_READ:
|
||||
return 'Continue Reading';
|
||||
return t('lastRead');
|
||||
case ScrollerType.LAST_LISTENED:
|
||||
return 'Continue Listening';
|
||||
return t('lastListened');
|
||||
case ScrollerType.LATEST_ADDED:
|
||||
return 'Recently Added';
|
||||
return t('latestAdded');
|
||||
case ScrollerType.RANDOM:
|
||||
return 'Discover Something New';
|
||||
return t('random');
|
||||
default:
|
||||
return 'Scroller';
|
||||
return t('default');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+67
-65
@@ -1,70 +1,72 @@
|
||||
<div class="dashboard-container">
|
||||
@if ((bookState$ | async)?.loaded === false) {
|
||||
<div class="loading-state">
|
||||
<p-progressSpinner
|
||||
class="spinner center-spinner"
|
||||
[style]="{'width': '60px', 'height': '60px'}"
|
||||
strokeWidth="3"
|
||||
fill="transparent"
|
||||
animationDuration="1.5s">
|
||||
</p-progressSpinner>
|
||||
</div>
|
||||
}
|
||||
@if ((bookState$ | async)?.loaded === true) {
|
||||
<div class="dashboard">
|
||||
<div class="dashboard-inner">
|
||||
@if (isLibrariesEmpty$ | async) {
|
||||
<div class="dashboard-no-library">
|
||||
@if ((userService.userState$ | async)?.user?.permissions; as permissions) {
|
||||
<div>
|
||||
@if (permissions.admin || permissions.canManageLibrary) {
|
||||
<div>
|
||||
<h1 class="no-library-header">
|
||||
Welcome to BookLore!<br>
|
||||
Let's create your first library
|
||||
</h1>
|
||||
<p class="welcome-description">
|
||||
A library is where all your books live. Start building your digital collection today!
|
||||
</p>
|
||||
<p-button
|
||||
label="Create Your Library"
|
||||
icon="pi pi-plus"
|
||||
class="p-button-rounded p-button-outlined"
|
||||
(click)="createNewLibrary()">
|
||||
</p-button>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
} @else {
|
||||
<div class="dashboard-settings-button">
|
||||
<p-button
|
||||
icon="pi pi-cog"
|
||||
severity="info"
|
||||
rounded
|
||||
text
|
||||
[pTooltip]="'Customize Dashboard'"
|
||||
tooltipPosition="left"
|
||||
(click)="openDashboardSettings()">
|
||||
</p-button>
|
||||
</div>
|
||||
<ng-container *transloco="let t; prefix: 'dashboard.main'">
|
||||
<div class="dashboard-container">
|
||||
@if ((bookState$ | async)?.loaded === false) {
|
||||
<div class="loading-state">
|
||||
<p-progressSpinner
|
||||
class="spinner center-spinner"
|
||||
[style]="{'width': '60px', 'height': '60px'}"
|
||||
strokeWidth="3"
|
||||
fill="transparent"
|
||||
animationDuration="1.5s">
|
||||
</p-progressSpinner>
|
||||
</div>
|
||||
}
|
||||
@if ((bookState$ | async)?.loaded === true) {
|
||||
<div class="dashboard">
|
||||
<div class="dashboard-inner">
|
||||
@if (isLibrariesEmpty$ | async) {
|
||||
<div class="dashboard-no-library">
|
||||
@if ((userService.userState$ | async)?.user?.permissions; as permissions) {
|
||||
<div>
|
||||
@if (permissions.admin || permissions.canManageLibrary) {
|
||||
<div>
|
||||
<h1 class="no-library-header">
|
||||
{{ t('welcomeTitle') }}<br>
|
||||
{{ t('welcomeSubtitle') }}
|
||||
</h1>
|
||||
<p class="welcome-description">
|
||||
{{ t('welcomeDescription') }}
|
||||
</p>
|
||||
<p-button
|
||||
[label]="t('createLibrary')"
|
||||
icon="pi pi-plus"
|
||||
class="p-button-rounded p-button-outlined"
|
||||
(click)="createNewLibrary()">
|
||||
</p-button>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
} @else {
|
||||
<div class="dashboard-settings-button">
|
||||
<p-button
|
||||
icon="pi pi-cog"
|
||||
severity="info"
|
||||
rounded
|
||||
text
|
||||
[pTooltip]="t('customizeDashboard')"
|
||||
tooltipPosition="left"
|
||||
(click)="openDashboardSettings()">
|
||||
</p-button>
|
||||
</div>
|
||||
|
||||
@if (dashboardConfig$ | async; as config) {
|
||||
@for (scroller of config.scrollers; track scroller.id) {
|
||||
@if (scroller.enabled) {
|
||||
<app-dashboard-scroller
|
||||
[bookListType]="scroller.type"
|
||||
[title]="scroller.title"
|
||||
[isMagicShelf]="scroller.type === ScrollerType.MAGIC_SHELF"
|
||||
[useSquareCovers]="scroller.type === ScrollerType.LAST_LISTENED"
|
||||
[books]="getBooksForScroller(scroller) | async">
|
||||
</app-dashboard-scroller>
|
||||
@if (dashboardConfig$ | async; as config) {
|
||||
@for (scroller of config.scrollers; track scroller.id) {
|
||||
@if (scroller.enabled) {
|
||||
<app-dashboard-scroller
|
||||
[bookListType]="scroller.type"
|
||||
[title]="scroller.title"
|
||||
[isMagicShelf]="scroller.type === ScrollerType.MAGIC_SHELF"
|
||||
[useSquareCovers]="scroller.type === ScrollerType.LAST_LISTENED"
|
||||
[books]="getBooksForScroller(scroller) | async">
|
||||
</app-dashboard-scroller>
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</ng-container>
|
||||
|
||||
+5
-2
@@ -12,6 +12,7 @@ import {Book, ReadStatus} from '../../../book/model/book.model';
|
||||
import {UserService} from '../../../settings/user-management/user.service';
|
||||
import {ProgressSpinner} from 'primeng/progressspinner';
|
||||
import {TooltipModule} from 'primeng/tooltip';
|
||||
import {TranslocoDirective, TranslocoService} from '@jsverse/transloco';
|
||||
import {DashboardConfigService} from '../../services/dashboard-config.service';
|
||||
import {ScrollerConfig, ScrollerType} from '../../models/dashboard-config.model';
|
||||
import {MagicShelfService} from '../../../magic-shelf/service/magic-shelf.service';
|
||||
@@ -33,7 +34,8 @@ const DEFAULT_MAX_ITEMS = 20;
|
||||
DashboardScrollerComponent,
|
||||
AsyncPipe,
|
||||
ProgressSpinner,
|
||||
TooltipModule
|
||||
TooltipModule,
|
||||
TranslocoDirective
|
||||
],
|
||||
standalone: true
|
||||
})
|
||||
@@ -47,6 +49,7 @@ export class MainDashboardComponent implements OnInit {
|
||||
private ruleEvaluatorService = inject(BookRuleEvaluatorService);
|
||||
private sortService = inject(SortService);
|
||||
private pageTitle = inject(PageTitleService);
|
||||
private readonly t = inject(TranslocoService);
|
||||
|
||||
bookState$ = this.bookService.bookState$;
|
||||
dashboardConfig$ = this.dashboardConfigService.config$;
|
||||
@@ -60,7 +63,7 @@ export class MainDashboardComponent implements OnInit {
|
||||
ScrollerType = ScrollerType;
|
||||
|
||||
ngOnInit(): void {
|
||||
this.pageTitle.setPageTitle('Dashboard');
|
||||
this.pageTitle.setPageTitle(this.t.translate('dashboard.main.pageTitle'));
|
||||
|
||||
this.dashboardConfig$.subscribe(() => {
|
||||
this.scrollerBooksCache.clear();
|
||||
|
||||
Reference in New Issue
Block a user