feat: add i18n translations for book components, services, and readers (en/es) (#2738)
This commit is contained in:
+30
-28
@@ -1,11 +1,12 @@
|
||||
<ng-container *transloco="let t; prefix: 'book.addPhysicalBook'">
|
||||
<div class="add-physical-book">
|
||||
<div class="panel-header">
|
||||
<div class="header-icon-wrapper">
|
||||
<i class="pi pi-book header-icon"></i>
|
||||
</div>
|
||||
<div class="header-text">
|
||||
<h2 class="panel-title">Add Physical Book</h2>
|
||||
<p class="panel-description">Catalog a physical book without a digital file</p>
|
||||
<h2 class="panel-title">{{ t('title') }}</h2>
|
||||
<p class="panel-description">{{ t('description') }}</p>
|
||||
</div>
|
||||
<p-button
|
||||
icon="pi pi-times"
|
||||
@@ -14,7 +15,7 @@
|
||||
[text]="true"
|
||||
[rounded]="true"
|
||||
class="close-button"
|
||||
pTooltip="Close"
|
||||
[pTooltip]="t('closeTooltip')"
|
||||
tooltipPosition="left"/>
|
||||
</div>
|
||||
|
||||
@@ -22,7 +23,7 @@
|
||||
<div class="form-group highlight-group">
|
||||
<label for="library" class="form-label">
|
||||
<i class="pi pi-folder label-icon"></i>
|
||||
Library
|
||||
{{ t('libraryLabel') }}
|
||||
<span class="required-indicator">*</span>
|
||||
</label>
|
||||
<p-select
|
||||
@@ -31,7 +32,7 @@
|
||||
[(ngModel)]="selectedLibraryId"
|
||||
optionLabel="name"
|
||||
optionValue="id"
|
||||
placeholder="Select a library"
|
||||
[placeholder]="t('libraryPlaceholder')"
|
||||
[style]="{'width': '100%'}"/>
|
||||
</div>
|
||||
|
||||
@@ -41,7 +42,7 @@
|
||||
<div class="form-group highlight-group flex-2">
|
||||
<label for="title" class="form-label">
|
||||
<i class="pi pi-tag label-icon"></i>
|
||||
Title
|
||||
{{ t('titleLabel') }}
|
||||
</label>
|
||||
<div class="input-wrapper">
|
||||
<input
|
||||
@@ -50,7 +51,7 @@
|
||||
pInputText
|
||||
[(ngModel)]="title"
|
||||
class="input-full"
|
||||
placeholder="e.g., The Great Gatsby"
|
||||
[placeholder]="t('titlePlaceholder')"
|
||||
[class.filled]="title.trim()"/>
|
||||
</div>
|
||||
</div>
|
||||
@@ -58,7 +59,7 @@
|
||||
<div class="form-group highlight-group flex-1">
|
||||
<label for="isbn" class="form-label">
|
||||
<i class="pi pi-barcode label-icon"></i>
|
||||
ISBN
|
||||
{{ t('isbnLabel') }}
|
||||
</label>
|
||||
<div class="input-wrapper">
|
||||
<input
|
||||
@@ -67,7 +68,7 @@
|
||||
pInputText
|
||||
[(ngModel)]="isbn"
|
||||
class="input-full"
|
||||
placeholder="e.g., 9780134685991"/>
|
||||
[placeholder]="t('isbnPlaceholder')"/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -77,7 +78,7 @@
|
||||
<div class="form-group highlight-group">
|
||||
<label for="authors" class="form-label">
|
||||
<i class="pi pi-user label-icon"></i>
|
||||
Authors
|
||||
{{ t('authorsLabel') }}
|
||||
</label>
|
||||
<div class="autocomplete-wrapper">
|
||||
<p-autoComplete
|
||||
@@ -89,7 +90,7 @@
|
||||
[suggestions]="filteredAuthors"
|
||||
[forceSelection]="false"
|
||||
[showClear]="false"
|
||||
placeholder="Type author name and press Enter"
|
||||
[placeholder]="t('authorsPlaceholder')"
|
||||
(completeMethod)="filterAuthors($event)"
|
||||
(onKeyUp)="onAutoCompleteKeyUp('authors', $event)"
|
||||
(onSelect)="onAutoCompleteSelect('authors', $event)">
|
||||
@@ -102,14 +103,14 @@
|
||||
<div class="form-group highlight-group">
|
||||
<label for="description" class="form-label">
|
||||
<i class="pi pi-align-left label-icon"></i>
|
||||
Description
|
||||
{{ t('descriptionLabel') }}
|
||||
</label>
|
||||
<textarea
|
||||
id="description"
|
||||
pTextarea
|
||||
[(ngModel)]="description"
|
||||
rows="3"
|
||||
placeholder="Brief description of the book..."
|
||||
[placeholder]="t('descriptionPlaceholder')"
|
||||
class="input-full"></textarea>
|
||||
</div>
|
||||
|
||||
@@ -119,7 +120,7 @@
|
||||
<div class="form-group highlight-group flex-1">
|
||||
<label for="publisher" class="form-label">
|
||||
<i class="pi pi-building label-icon"></i>
|
||||
Publisher
|
||||
{{ t('publisherLabel') }}
|
||||
</label>
|
||||
<input
|
||||
id="publisher"
|
||||
@@ -127,13 +128,13 @@
|
||||
pInputText
|
||||
[(ngModel)]="publisher"
|
||||
class="input-full"
|
||||
placeholder="Publisher name"/>
|
||||
[placeholder]="t('publisherPlaceholder')"/>
|
||||
</div>
|
||||
|
||||
<div class="form-group highlight-group flex-1">
|
||||
<label for="publishedDate" class="form-label">
|
||||
<i class="pi pi-calendar label-icon"></i>
|
||||
Published Date
|
||||
{{ t('publishedDateLabel') }}
|
||||
</label>
|
||||
<input
|
||||
id="publishedDate"
|
||||
@@ -141,7 +142,7 @@
|
||||
pInputText
|
||||
[(ngModel)]="publishedDate"
|
||||
class="input-full"
|
||||
placeholder="e.g., 2020 or 2020-05-15"/>
|
||||
[placeholder]="t('publishedDatePlaceholder')"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -149,7 +150,7 @@
|
||||
<div class="form-group highlight-group flex-1">
|
||||
<label for="language" class="form-label">
|
||||
<i class="pi pi-globe label-icon"></i>
|
||||
Language
|
||||
{{ t('languageLabel') }}
|
||||
</label>
|
||||
<input
|
||||
id="language"
|
||||
@@ -157,19 +158,19 @@
|
||||
pInputText
|
||||
[(ngModel)]="language"
|
||||
class="input-full"
|
||||
placeholder="e.g., English"/>
|
||||
[placeholder]="t('languagePlaceholder')"/>
|
||||
</div>
|
||||
|
||||
<div class="form-group highlight-group flex-1">
|
||||
<label for="pageCount" class="form-label">
|
||||
<i class="pi pi-file label-icon"></i>
|
||||
Page Count
|
||||
{{ t('pageCountLabel') }}
|
||||
</label>
|
||||
<p-inputnumber
|
||||
id="pageCount"
|
||||
[(ngModel)]="pageCount"
|
||||
[useGrouping]="false"
|
||||
placeholder="Number of pages"
|
||||
[placeholder]="t('pageCountPlaceholder')"
|
||||
class="input-full">
|
||||
</p-inputnumber>
|
||||
</div>
|
||||
@@ -180,7 +181,7 @@
|
||||
<div class="form-group highlight-group">
|
||||
<label for="categories" class="form-label">
|
||||
<i class="pi pi-tags label-icon"></i>
|
||||
Categories/Genres
|
||||
{{ t('categoriesLabel') }}
|
||||
</label>
|
||||
<div class="autocomplete-wrapper">
|
||||
<p-autoComplete
|
||||
@@ -192,7 +193,7 @@
|
||||
[suggestions]="filteredCategories"
|
||||
[forceSelection]="false"
|
||||
[showClear]="true"
|
||||
placeholder="Type category and press Enter"
|
||||
[placeholder]="t('categoriesPlaceholder')"
|
||||
(completeMethod)="filterCategories($event)"
|
||||
(onKeyUp)="onAutoCompleteKeyUp('categories', $event)"
|
||||
(onSelect)="onAutoCompleteSelect('categories', $event)">
|
||||
@@ -206,28 +207,28 @@
|
||||
@if (!selectedLibraryId) {
|
||||
<div class="validation-message error">
|
||||
<i class="pi pi-exclamation-circle"></i>
|
||||
<span>Library is required</span>
|
||||
<span>{{ t('validationLibraryRequired') }}</span>
|
||||
</div>
|
||||
} @else if (!title.trim() && !isbn.trim()) {
|
||||
<div class="validation-message error">
|
||||
<i class="pi pi-exclamation-circle"></i>
|
||||
<span>Title or ISBN is required</span>
|
||||
<span>{{ t('validationTitleOrIsbn') }}</span>
|
||||
</div>
|
||||
} @else {
|
||||
<div class="validation-message success">
|
||||
<i class="pi pi-check-circle"></i>
|
||||
<span>Ready to create</span>
|
||||
<span>{{ t('validationReady') }}</span>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
<div class="footer-actions">
|
||||
<p-button
|
||||
label="Cancel"
|
||||
[label]="t('cancelButton')"
|
||||
severity="secondary"
|
||||
[outlined]="true"
|
||||
(onClick)="cancel()"/>
|
||||
<p-button
|
||||
label="Add Physical Book"
|
||||
[label]="t('addButton')"
|
||||
icon="pi pi-plus"
|
||||
severity="success"
|
||||
(onClick)="createBook()"
|
||||
@@ -236,3 +237,4 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</ng-container>
|
||||
|
||||
+3
-1
@@ -14,6 +14,7 @@ import {Library} from '../../model/library.model';
|
||||
import {CreatePhysicalBookRequest} from '../../model/book.model';
|
||||
import {filter, take} from 'rxjs/operators';
|
||||
import {takeUntilDestroyed} from '@angular/core/rxjs-interop';
|
||||
import {TranslocoDirective} from '@jsverse/transloco';
|
||||
|
||||
@Component({
|
||||
selector: 'app-add-physical-book-dialog',
|
||||
@@ -27,7 +28,8 @@ import {takeUntilDestroyed} from '@angular/core/rxjs-interop';
|
||||
Select,
|
||||
Textarea,
|
||||
InputNumber,
|
||||
AutoComplete
|
||||
AutoComplete,
|
||||
TranslocoDirective
|
||||
],
|
||||
styleUrl: './add-physical-book-dialog.component.scss',
|
||||
})
|
||||
|
||||
+12
-12
@@ -1,11 +1,12 @@
|
||||
<ng-container *transloco="let t; prefix: 'book.fileUploader'">
|
||||
<div class="additional-file-uploader-container">
|
||||
<div class="panel-header">
|
||||
<div class="header-icon-wrapper">
|
||||
<i class="pi pi-file-plus header-icon"></i>
|
||||
</div>
|
||||
<div class="header-text">
|
||||
<h2 class="panel-title">Upload Additional File</h2>
|
||||
<p class="panel-description">{{ book.metadata?.title || 'Unknown Title' }}</p>
|
||||
<h2 class="panel-title">{{ t('title') }}</h2>
|
||||
<p class="panel-description">{{ book.metadata?.title || t('unknownTitle') }}</p>
|
||||
</div>
|
||||
<p-button
|
||||
icon="pi pi-times"
|
||||
@@ -24,18 +25,18 @@
|
||||
[(ngModel)]="fileType"
|
||||
optionLabel="label"
|
||||
optionValue="value"
|
||||
placeholder="Select file type"
|
||||
[placeholder]="t('selectFileType')"
|
||||
class="full-width"
|
||||
[disabled]="isUploading"
|
||||
></p-select>
|
||||
|
||||
<!-- Description Field -->
|
||||
<div class="description-field">
|
||||
<label for="description" class="description-label">Description (Optional)</label>
|
||||
<label for="description" class="description-label">{{ t('descriptionLabel') }}</label>
|
||||
<p-textarea
|
||||
[(ngModel)]="description"
|
||||
rows="3"
|
||||
placeholder="Add a description for this file..."
|
||||
[attr.placeholder]="t('descriptionPlaceholder')"
|
||||
class="full-width"
|
||||
[disabled]="isUploading"
|
||||
></p-textarea>
|
||||
@@ -98,7 +99,7 @@
|
||||
<i
|
||||
class="pi pi-spin pi-spinner status-icon"
|
||||
style="color: slateblue"
|
||||
pTooltip="Uploading"
|
||||
[pTooltip]="t('statusUploading')"
|
||||
tooltipPosition="top">
|
||||
</i>
|
||||
}
|
||||
@@ -106,7 +107,7 @@
|
||||
<i
|
||||
class="pi pi-check status-icon"
|
||||
style="color: green"
|
||||
pTooltip="Uploaded"
|
||||
[pTooltip]="t('statusUploaded')"
|
||||
tooltipPosition="top">
|
||||
</i>
|
||||
}
|
||||
@@ -114,7 +115,7 @@
|
||||
<i
|
||||
class="pi pi-exclamation-triangle status-icon"
|
||||
style="color: darkred"
|
||||
pTooltip="{{ uploadFile.errorMessage || 'Upload failed' }}"
|
||||
[pTooltip]="uploadFile.errorMessage || t('statusUploadFailed')"
|
||||
tooltipPosition="top">
|
||||
</i>
|
||||
}
|
||||
@@ -131,12 +132,11 @@
|
||||
<ng-template #empty>
|
||||
<div class="empty-state">
|
||||
<i class="pi pi-cloud-upload empty-icon"></i>
|
||||
<p class="empty-text">Drag and drop a file here to upload.</p>
|
||||
<p class="empty-subtext">
|
||||
Upload an additional file for <strong>{{ book.metadata?.title || 'this book' }}</strong>.
|
||||
</p>
|
||||
<p class="empty-text">{{ t('dragDropText') }}</p>
|
||||
<p class="empty-subtext" [innerHTML]="t('uploadForBook', { title: book.metadata?.title || t('thisBook') })"></p>
|
||||
</div>
|
||||
</ng-template>
|
||||
</p-fileupload>
|
||||
</div>
|
||||
</div>
|
||||
</ng-container>
|
||||
|
||||
+22
-16
@@ -1,4 +1,4 @@
|
||||
import { Component, OnInit, OnDestroy, ChangeDetectorRef } from '@angular/core';
|
||||
import { Component, OnInit, OnDestroy, ChangeDetectorRef, inject } from '@angular/core';
|
||||
|
||||
import { FormsModule } from '@angular/forms';
|
||||
import { DynamicDialogRef, DynamicDialogConfig } from 'primeng/dynamicdialog';
|
||||
@@ -13,6 +13,7 @@ import { AppSettingsService } from '../../../../shared/service/app-settings.serv
|
||||
import { Book, AdditionalFileType } from '../../model/book.model';
|
||||
import { MessageService } from 'primeng/api';
|
||||
import { filter, take } from 'rxjs/operators';
|
||||
import { TranslocoDirective, TranslocoService } from '@jsverse/transloco';
|
||||
|
||||
interface FileTypeOption {
|
||||
label: string;
|
||||
@@ -34,12 +35,15 @@ interface UploadingFile {
|
||||
Button,
|
||||
FileUpload,
|
||||
Badge,
|
||||
Tooltip
|
||||
Tooltip,
|
||||
TranslocoDirective
|
||||
],
|
||||
templateUrl: './additional-file-uploader.component.html',
|
||||
styleUrls: ['./additional-file-uploader.component.scss']
|
||||
})
|
||||
export class AdditionalFileUploaderComponent implements OnInit, OnDestroy {
|
||||
private readonly t = inject(TranslocoService);
|
||||
|
||||
book!: Book;
|
||||
files: UploadingFile[] = [];
|
||||
fileType: AdditionalFileType = AdditionalFileType.ALTERNATIVE_FORMAT;
|
||||
@@ -47,10 +51,7 @@ export class AdditionalFileUploaderComponent implements OnInit, OnDestroy {
|
||||
isUploading = false;
|
||||
maxFileSizeBytes?: number;
|
||||
|
||||
fileTypeOptions: FileTypeOption[] = [
|
||||
{ label: 'Alternative Format', value: AdditionalFileType.ALTERNATIVE_FORMAT },
|
||||
{ label: 'Supplementary File', value: AdditionalFileType.SUPPLEMENTARY }
|
||||
];
|
||||
fileTypeOptions: FileTypeOption[] = [];
|
||||
|
||||
private destroy$ = new Subject<void>();
|
||||
|
||||
@@ -65,6 +66,10 @@ export class AdditionalFileUploaderComponent implements OnInit, OnDestroy {
|
||||
|
||||
ngOnInit(): void {
|
||||
this.book = this.config.data.book;
|
||||
this.fileTypeOptions = [
|
||||
{ label: this.t.translate('book.fileUploader.typeAlternativeFormat'), value: AdditionalFileType.ALTERNATIVE_FORMAT },
|
||||
{ label: this.t.translate('book.fileUploader.typeSupplementary'), value: AdditionalFileType.SUPPLEMENTARY }
|
||||
];
|
||||
this.appSettingsService.appSettings$
|
||||
.pipe(
|
||||
filter(settings => settings != null),
|
||||
@@ -106,7 +111,8 @@ export class AdditionalFileUploaderComponent implements OnInit, OnDestroy {
|
||||
const file = newFiles[0];
|
||||
|
||||
if (this.maxFileSizeBytes && file.size > this.maxFileSizeBytes) {
|
||||
const errorMsg = `File exceeds maximum size of ${this.formatSize(this.maxFileSizeBytes)}`;
|
||||
const maxSize = this.formatSize(this.maxFileSizeBytes);
|
||||
const errorMsg = this.t.translate('book.fileUploader.toast.fileTooLargeError', { maxSize });
|
||||
this.files = [{
|
||||
file,
|
||||
status: 'Failed',
|
||||
@@ -114,8 +120,8 @@ export class AdditionalFileUploaderComponent implements OnInit, OnDestroy {
|
||||
}];
|
||||
this.messageService.add({
|
||||
severity: 'error',
|
||||
summary: 'File Too Large',
|
||||
detail: `${file.name} exceeds the maximum file size of ${this.formatSize(this.maxFileSizeBytes)}`,
|
||||
summary: this.t.translate('book.fileUploader.toast.fileTooLargeSummary'),
|
||||
detail: this.t.translate('book.fileUploader.toast.fileTooLargeDetail', { fileName: file.name, maxSize }),
|
||||
life: 5000
|
||||
});
|
||||
} else {
|
||||
@@ -161,7 +167,7 @@ export class AdditionalFileUploaderComponent implements OnInit, OnDestroy {
|
||||
},
|
||||
error: (err) => {
|
||||
uploadFile.status = 'Failed';
|
||||
uploadFile.errorMessage = err?.error?.message || 'Upload failed due to unknown error.';
|
||||
uploadFile.errorMessage = err?.error?.message || this.t.translate('book.fileUploader.toast.uploadFailedUnknown');
|
||||
console.error('Upload failed for', uploadFile.file.name, err);
|
||||
if (--pending === 0) {
|
||||
this.isUploading = false;
|
||||
@@ -203,18 +209,18 @@ export class AdditionalFileUploaderComponent implements OnInit, OnDestroy {
|
||||
}
|
||||
|
||||
getFileStatusLabel(uploadFile: UploadingFile): string {
|
||||
if (uploadFile.status === 'Failed' && uploadFile.errorMessage?.includes('exceeds maximum size')) {
|
||||
return 'Too Large';
|
||||
if (uploadFile.status === 'Failed' && uploadFile.errorMessage?.includes('maximum size')) {
|
||||
return this.t.translate('book.fileUploader.statusTooLarge');
|
||||
}
|
||||
switch (uploadFile.status) {
|
||||
case 'Pending':
|
||||
return 'Ready';
|
||||
return this.t.translate('book.fileUploader.statusReady');
|
||||
case 'Uploading':
|
||||
return 'Uploading';
|
||||
return this.t.translate('book.fileUploader.statusUploading');
|
||||
case 'Uploaded':
|
||||
return 'Uploaded';
|
||||
return this.t.translate('book.fileUploader.statusUploaded');
|
||||
case 'Failed':
|
||||
return 'Failed';
|
||||
return this.t.translate('book.fileUploader.statusFailed');
|
||||
default:
|
||||
return uploadFile.status;
|
||||
}
|
||||
|
||||
+35
-33
@@ -1,3 +1,4 @@
|
||||
<ng-container *transloco="let t; prefix: 'book.browser'">
|
||||
<div class="book-browser-container">
|
||||
<div class="book-browser-main">
|
||||
|
||||
@@ -12,17 +13,17 @@
|
||||
} @else if (isFilterActive || hasSearchTerm) {
|
||||
{{ computedFilterLabel }}
|
||||
} @else {
|
||||
All Books
|
||||
{{ t('labels.allBooks') }}
|
||||
}
|
||||
} @else if (entityType === EntityType.UNSHELVED) {
|
||||
{{ (isFilterActive || hasSearchTerm) ? 'Unshelved Books (Filtered)' : 'Unshelved Books' }}
|
||||
{{ (isFilterActive || hasSearchTerm) ? t('labels.unshelvedBooksFiltered') : t('labels.unshelvedBooks') }}
|
||||
} @else {
|
||||
{{ entityType }}: {{ (entity$ | async)?.name }}{{ (isFilterActive || hasSearchTerm) ? ' (Filtered)' : '' }}
|
||||
{{ entityType }}: {{ (entity$ | async)?.name }}{{ (isFilterActive || hasSearchTerm) ? ' ' + t('labels.filteredSuffix') : '' }}
|
||||
}
|
||||
</p>
|
||||
@if (seriesCollapseFilter.isSeriesCollapsed && (bookState$ | async)?.books; as books) {
|
||||
<p class="series-collapsed-info">
|
||||
Showing {{ books.length }} {{ books.length === 1 ? 'item' : 'items' }} (series collapsed)
|
||||
{{ t('labels.seriesCollapsedInfo', { count: books.length, itemWord: books.length === 1 ? t('labels.item') : t('labels.items') }) }}
|
||||
</p>
|
||||
}
|
||||
</div>
|
||||
@@ -50,7 +51,7 @@
|
||||
<a class="topbar-items topbar-item" (click)="clearFilter()">
|
||||
<i
|
||||
class="pi pi-filter-slash filter-clear-icon"
|
||||
pTooltip="Clear applied filters"
|
||||
[pTooltip]="t('tooltip.clearFilters')"
|
||||
tooltipPosition="top">
|
||||
</i>
|
||||
</a>
|
||||
@@ -61,7 +62,7 @@
|
||||
<a class="topbar-items topbar-item" (click)="columnPopover.toggle($event)">
|
||||
<i
|
||||
class="pi pi-eye"
|
||||
pTooltip="Visible columns"
|
||||
[pTooltip]="t('tooltip.visibleColumns')"
|
||||
tooltipPosition="top">
|
||||
</i>
|
||||
</a>
|
||||
@@ -73,16 +74,16 @@
|
||||
[(ngModel)]="visibleColumns"
|
||||
(ngModelChange)="onVisibleColumnsChange($event)"
|
||||
display="chip"
|
||||
placeholder="Select Columns"
|
||||
[placeholder]="t('placeholder.selectColumns')"
|
||||
[style]="{ width: '100%' }"
|
||||
[filter]="true"
|
||||
[showClear]="true"
|
||||
></p-multiSelect>
|
||||
</div>
|
||||
<div class="column-popover-footer">
|
||||
<p>Set as default?</p>
|
||||
<p>{{ t('labels.setAsDefault') }}</p>
|
||||
<p-button
|
||||
label="Save"
|
||||
[label]="t('labels.save')"
|
||||
outlined
|
||||
size="small"
|
||||
(click)="columnPreferenceService.saveVisibleColumns(visibleColumns)"></p-button>
|
||||
@@ -94,7 +95,7 @@
|
||||
<a
|
||||
class="topbar-items topbar-item"
|
||||
(click)="seriesCollapseOverlay.toggle($event)"
|
||||
pTooltip="Display settings"
|
||||
[pTooltip]="t('tooltip.displaySettings')"
|
||||
tooltipPosition="top">
|
||||
<i class="pi pi-cog"></i>
|
||||
</a>
|
||||
@@ -108,12 +109,12 @@
|
||||
[ngModel]="seriesCollapseFilter.isSeriesCollapsed"
|
||||
(onChange)="onSeriesCollapseCheckboxChange($event.checked)">
|
||||
</p-checkbox>
|
||||
<label for="collapse-series-checkbox" class="display-settings-label">Collapse series</label>
|
||||
<label for="collapse-series-checkbox" class="display-settings-label">{{ t('labels.collapseSeries') }}</label>
|
||||
</div>
|
||||
</div>
|
||||
@if (isMobile) {
|
||||
<div class="display-settings-section">
|
||||
<label class="display-settings-label">Grid columns</label>
|
||||
<label class="display-settings-label">{{ t('labels.gridColumns') }}</label>
|
||||
<div class="column-options">
|
||||
<button
|
||||
type="button"
|
||||
@@ -134,7 +135,7 @@
|
||||
</div>
|
||||
} @else {
|
||||
<div class="display-settings-section">
|
||||
<label class="display-settings-label">Grid item size</label>
|
||||
<label class="display-settings-label">{{ t('labels.gridItemSize') }}</label>
|
||||
<p-slider
|
||||
[(ngModel)]="coverScalePreferenceService.scaleFactor"
|
||||
[min]="0.5"
|
||||
@@ -156,7 +157,7 @@
|
||||
[ngModel]="bookCardOverlayPreferenceService.showBookTypePill"
|
||||
(onChange)="bookCardOverlayPreferenceService.setShowBookTypePill($event.checked)">
|
||||
</p-checkbox>
|
||||
<label for="show-book-type-pill-checkbox" class="display-settings-label">Book type overlay</label>
|
||||
<label for="show-book-type-pill-checkbox" class="display-settings-label">{{ t('labels.bookTypeOverlay') }}</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -167,7 +168,7 @@
|
||||
<a class="topbar-items topbar-item" (click)="sortPopover.toggle($event)">
|
||||
<i
|
||||
class="pi pi-sort"
|
||||
pTooltip="Select sorting"
|
||||
[pTooltip]="t('tooltip.selectSorting')"
|
||||
tooltipPosition="top">
|
||||
</i>
|
||||
@if (sortCriteriaCount > 1) {
|
||||
@@ -188,7 +189,7 @@
|
||||
<a class="topbar-items topbar-item" (click)="toggleTableGrid()">
|
||||
<i
|
||||
[ngClass]="viewIcon"
|
||||
pTooltip="Toggle between Grid and Table view"
|
||||
[pTooltip]="t('tooltip.toggleView')"
|
||||
tooltipPosition="top">
|
||||
</i>
|
||||
</a>
|
||||
@@ -200,7 +201,7 @@
|
||||
type="button"
|
||||
class="topbar-items topbar-item"
|
||||
(click)="searchDropdown.toggle($event)"
|
||||
pTooltip="Search"
|
||||
[pTooltip]="t('tooltip.search')"
|
||||
tooltipPosition="top"
|
||||
>
|
||||
<i class="pi pi-search"></i>
|
||||
@@ -211,7 +212,7 @@
|
||||
<input
|
||||
type="text"
|
||||
pInputText
|
||||
placeholder="Title, Author, Series, Genre, or ISBN..."
|
||||
[placeholder]="t('placeholder.search')"
|
||||
[(ngModel)]="bookTitle"
|
||||
(ngModelChange)="onSearchTermChange($event)"
|
||||
class="search-input-full"
|
||||
@@ -233,7 +234,7 @@
|
||||
<input
|
||||
type="text"
|
||||
pInputText
|
||||
placeholder="Title, Author, Series, Genre, or ISBN..."
|
||||
[placeholder]="t('placeholder.search')"
|
||||
[(ngModel)]="bookTitle"
|
||||
(ngModelChange)="onSearchTermChange($event)"
|
||||
class="search-input"
|
||||
@@ -253,7 +254,7 @@
|
||||
<a class="topbar-items topbar-item" (click)="toggleSidebar()">
|
||||
<i
|
||||
[ngClass]="showFilter ? 'pi pi-angle-double-right' : 'pi pi-angle-double-left'"
|
||||
pTooltip="Toggle sidebar filters"
|
||||
[pTooltip]="t('tooltip.toggleSidebar')"
|
||||
tooltipPosition="top">
|
||||
</i>
|
||||
</a>
|
||||
@@ -271,14 +272,14 @@
|
||||
@if (bookState?.error) {
|
||||
<div class="no-books-container">
|
||||
<p class="no-books-text">
|
||||
{{ entityType === EntityType.LIBRARY ? "Failed to load library's books!" : "Failed to load shelf's books!" }}
|
||||
{{ entityType === EntityType.LIBRARY ? t('labels.failedLibrary') : t('labels.failedShelf') }}
|
||||
</p>
|
||||
</div>
|
||||
}
|
||||
@if (!bookState?.error && bookState?.loaded && bookState?.books?.length === 0) {
|
||||
<div class="no-books-container">
|
||||
<p class="no-books-text">
|
||||
This collection has no books!
|
||||
{{ t('labels.noBooks') }}
|
||||
</p>
|
||||
</div>
|
||||
}
|
||||
@@ -326,7 +327,7 @@
|
||||
<div class="selected-count-badge">
|
||||
<i class="pi pi-check-circle"></i>
|
||||
<span class="selected-count">{{ selectedCount }}</span>
|
||||
<span class="selected-label">selected</span>
|
||||
<span class="selected-label">{{ t('labels.selected') }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="footer-center">
|
||||
@@ -336,7 +337,7 @@
|
||||
<p-tieredMenu #menu [model]="metadataMenuItems" [popup]="true" appendTo="body" styleClass="footer-menu"/>
|
||||
<p-button
|
||||
(click)="menu.toggle($event)"
|
||||
pTooltip="Metadata actions"
|
||||
[pTooltip]="t('tooltip.metadataActions')"
|
||||
tooltipPosition="top"
|
||||
outlined="true"
|
||||
severity="info"
|
||||
@@ -348,7 +349,7 @@
|
||||
outlined="true"
|
||||
severity="info"
|
||||
(onClick)="openShelfAssigner()"
|
||||
pTooltip="Assign to shelf"
|
||||
[pTooltip]="t('tooltip.assignToShelf')"
|
||||
tooltipPosition="top">
|
||||
</p-button>
|
||||
@if (entityType === EntityType.SHELF) {
|
||||
@@ -357,7 +358,7 @@
|
||||
outlined="true"
|
||||
severity="info"
|
||||
(click)="unshelfBooks()"
|
||||
pTooltip="Remove from this shelf"
|
||||
[pTooltip]="t('tooltip.removeFromShelf')"
|
||||
tooltipPosition="top">
|
||||
</p-button>
|
||||
}
|
||||
@@ -367,7 +368,7 @@
|
||||
icon="pi pi-lock"
|
||||
severity="info"
|
||||
(click)="lockUnlockMetadata()"
|
||||
pTooltip="Lock/Unlock metadata"
|
||||
[pTooltip]="t('tooltip.lockUnlockMetadata')"
|
||||
tooltipPosition="top">
|
||||
</p-button>
|
||||
}
|
||||
@@ -377,7 +378,7 @@
|
||||
icon="pi pi-arrows-h"
|
||||
severity="info"
|
||||
(click)="moveFiles()"
|
||||
pTooltip="Organize Files"
|
||||
[pTooltip]="t('tooltip.organizeFiles')"
|
||||
tooltipPosition="top">
|
||||
</p-button>
|
||||
}
|
||||
@@ -388,7 +389,7 @@
|
||||
severity="info"
|
||||
(click)="attachFilesToBook()"
|
||||
[disabled]="!canAttachFiles()"
|
||||
pTooltip="Attach to Another Book"
|
||||
[pTooltip]="t('tooltip.attachToBook')"
|
||||
tooltipPosition="top">
|
||||
</p-button>
|
||||
}
|
||||
@@ -396,7 +397,7 @@
|
||||
<div class="more-actions-wrapper">
|
||||
<p-button
|
||||
(click)="menu.toggle($event)"
|
||||
pTooltip="More actions"
|
||||
[pTooltip]="t('tooltip.moreActions')"
|
||||
tooltipPosition="top"
|
||||
outlined="true"
|
||||
severity="info"
|
||||
@@ -414,7 +415,7 @@
|
||||
icon="pi pi-check-square"
|
||||
severity="success"
|
||||
(click)="selectAllBooks()"
|
||||
pTooltip="Select all books"
|
||||
[pTooltip]="t('tooltip.selectAll')"
|
||||
tooltipPosition="top">
|
||||
</p-button>
|
||||
<p-button
|
||||
@@ -422,7 +423,7 @@
|
||||
icon="pi pi-times"
|
||||
severity="warn"
|
||||
(click)="deselectAllBooks()"
|
||||
pTooltip="Deselect all books"
|
||||
[pTooltip]="t('tooltip.deselectAll')"
|
||||
tooltipPosition="top">
|
||||
</p-button>
|
||||
</div>
|
||||
@@ -433,7 +434,7 @@
|
||||
icon="pi pi-trash"
|
||||
severity="danger"
|
||||
(click)="confirmDeleteBooks()"
|
||||
pTooltip="Delete selected books"
|
||||
[pTooltip]="t('tooltip.deleteSelected')"
|
||||
tooltipPosition="top">
|
||||
</p-button>
|
||||
}
|
||||
@@ -465,3 +466,4 @@
|
||||
}
|
||||
|
||||
</div>
|
||||
</ng-container>
|
||||
|
||||
+43
-41
@@ -57,6 +57,7 @@ import {BookBrowserScrollService} from './book-browser-scroll.service';
|
||||
import {AppSettingsService} from '../../../../shared/service/app-settings.service';
|
||||
import {MultiSortPopoverComponent} from './sorting/multi-sort-popover/multi-sort-popover.component';
|
||||
import {SortService} from '../../service/sort.service';
|
||||
import {TranslocoDirective, TranslocoService} from '@jsverse/transloco';
|
||||
|
||||
export enum EntityType {
|
||||
LIBRARY = 'Library',
|
||||
@@ -74,7 +75,7 @@ export enum EntityType {
|
||||
imports: [
|
||||
Button, VirtualScrollerModule, BookCardComponent, AsyncPipe, ProgressSpinner, Menu, InputText, FormsModule,
|
||||
BookTableComponent, BookFilterComponent, Tooltip, NgClass, NgStyle, Popover,
|
||||
Checkbox, Slider, Divider, MultiSelect, TieredMenu, BadgeModule, MultiSortPopoverComponent
|
||||
Checkbox, Slider, Divider, MultiSelect, TieredMenu, BadgeModule, MultiSortPopoverComponent, TranslocoDirective
|
||||
],
|
||||
providers: [SeriesCollapseFilter],
|
||||
animations: [
|
||||
@@ -119,6 +120,7 @@ export class BookBrowserComponent implements OnInit, AfterViewInit, OnDestroy {
|
||||
private filterOrchestrationService = inject(BookFilterOrchestrationService);
|
||||
private localStorageService = inject(LocalStorageService);
|
||||
private scrollService = inject(BookBrowserScrollService);
|
||||
private readonly t = inject(TranslocoService);
|
||||
|
||||
bookState$: Observable<BookState> | undefined;
|
||||
entity$: Observable<Library | Shelf | MagicShelf | null> | undefined;
|
||||
@@ -236,7 +238,7 @@ export class BookBrowserComponent implements OnInit, AfterViewInit, OnDestroy {
|
||||
const filters = this.selectedFilter.value;
|
||||
|
||||
if (!filters || Object.keys(filters).length === 0) {
|
||||
return 'All Books';
|
||||
return this.t.translate('book.browser.labels.allBooks');
|
||||
}
|
||||
|
||||
const filterEntries = Object.entries(filters);
|
||||
@@ -258,7 +260,7 @@ export class BookBrowserComponent implements OnInit, AfterViewInit, OnDestroy {
|
||||
.join(', ');
|
||||
|
||||
return filterSummary.length > 50
|
||||
? `${filterEntries.length} Active Filters`
|
||||
? this.t.translate('book.browser.labels.activeFilters', {count: filterEntries.length})
|
||||
: filterSummary;
|
||||
}
|
||||
|
||||
@@ -332,7 +334,7 @@ export class BookBrowserComponent implements OnInit, AfterViewInit, OnDestroy {
|
||||
this.entityType$ = of(entityType);
|
||||
this.entity$ = of(null);
|
||||
this.seriesCollapseFilter.setContext(null, null);
|
||||
this.pageTitle.setPageTitle(currentPath === 'all-books' ? 'All Books' : 'Unshelved Books');
|
||||
this.pageTitle.setPageTitle(currentPath === 'all-books' ? this.t.translate('book.browser.labels.allBooks') : this.t.translate('book.browser.labels.unshelvedBooks'));
|
||||
} else {
|
||||
const routeEntityInfo$ = this.entityService.getEntityInfoFromRoute(this.activatedRoute);
|
||||
this.entityType$ = routeEntityInfo$.pipe(map(info => {
|
||||
@@ -415,7 +417,7 @@ export class BookBrowserComponent implements OnInit, AfterViewInit, OnDestroy {
|
||||
});
|
||||
|
||||
|
||||
this.currentFilterLabel = 'All Books';
|
||||
this.currentFilterLabel = this.t.translate('book.browser.labels.allBooks');
|
||||
const filterParams = queryParamMap.get('filter');
|
||||
|
||||
if (filterParams) {
|
||||
@@ -494,7 +496,7 @@ export class BookBrowserComponent implements OnInit, AfterViewInit, OnDestroy {
|
||||
this.rawFilterParamFromUrl = null;
|
||||
|
||||
const hasSidebarFilters = !!filters && Object.keys(filters).length > 0;
|
||||
this.currentFilterLabel = hasSidebarFilters ? this.computedFilterLabel : 'All Books';
|
||||
this.currentFilterLabel = hasSidebarFilters ? this.computedFilterLabel : this.t.translate('book.browser.labels.allBooks');
|
||||
|
||||
this.queryParamsService.updateFilters(filters);
|
||||
}
|
||||
@@ -558,18 +560,18 @@ export class BookBrowserComponent implements OnInit, AfterViewInit, OnDestroy {
|
||||
|
||||
confirmDeleteBooks(): void {
|
||||
this.confirmationService.confirm({
|
||||
message: `Are you sure you want to delete ${this.selectedBooks.size} book(s)?\n\nThis will permanently remove the book files from your filesystem.\n\nThis action cannot be undone.`,
|
||||
header: 'Confirm Deletion',
|
||||
message: this.t.translate('book.browser.confirm.deleteMessage', {count: this.selectedBooks.size}),
|
||||
header: this.t.translate('book.browser.confirm.deleteHeader'),
|
||||
icon: 'pi pi-exclamation-triangle',
|
||||
acceptIcon: 'pi pi-trash',
|
||||
rejectIcon: 'pi pi-times',
|
||||
acceptLabel: 'Delete',
|
||||
rejectLabel: 'Cancel',
|
||||
acceptLabel: this.t.translate('common.delete'),
|
||||
rejectLabel: this.t.translate('common.cancel'),
|
||||
acceptButtonStyleClass: 'p-button-danger',
|
||||
rejectButtonStyleClass: 'p-button-outlined',
|
||||
accept: () => {
|
||||
const count = this.selectedBooks.size;
|
||||
const loader = this.loadingService.show(`Deleting ${count} book(s)...`);
|
||||
const loader = this.loadingService.show(this.t.translate('book.browser.loading.deleting', {count}));
|
||||
|
||||
this.bookService.deleteBooks(this.selectedBooks)
|
||||
.pipe(finalize(() => this.loadingService.hide(loader)))
|
||||
@@ -735,10 +737,10 @@ export class BookBrowserComponent implements OnInit, AfterViewInit, OnDestroy {
|
||||
this.userService.updateUserSetting(user.id, 'entityViewPreferences', prefs);
|
||||
this.messageService.add({
|
||||
severity: 'success',
|
||||
summary: 'Sort Saved',
|
||||
summary: this.t.translate('book.browser.toast.sortSavedSummary'),
|
||||
detail: this.entityType === EntityType.ALL_BOOKS || this.entityType === EntityType.UNSHELVED
|
||||
? 'Default sort configuration saved.'
|
||||
: `Sort configuration saved for this ${this.entityType.toLowerCase()}.`
|
||||
? this.t.translate('book.browser.toast.sortSavedGlobalDetail')
|
||||
: this.t.translate('book.browser.toast.sortSavedEntityDetail', {entityType: this.entityType.toLowerCase()})
|
||||
});
|
||||
}
|
||||
|
||||
@@ -775,17 +777,17 @@ export class BookBrowserComponent implements OnInit, AfterViewInit, OnDestroy {
|
||||
unshelfBooks(): void {
|
||||
if (!this.entity) return;
|
||||
const count = this.selectedBooks.size;
|
||||
const loader = this.loadingService.show(`Unshelving ${count} book(s)...`);
|
||||
const loader = this.loadingService.show(this.t.translate('book.browser.loading.unshelving', {count}));
|
||||
|
||||
this.bookService.updateBookShelves(this.selectedBooks, new Set(), new Set([this.entity.id!]))
|
||||
.pipe(finalize(() => this.loadingService.hide(loader)))
|
||||
.subscribe({
|
||||
next: () => {
|
||||
this.messageService.add({severity: 'info', summary: 'Success', detail: 'Books shelves updated'});
|
||||
this.messageService.add({severity: 'info', summary: this.t.translate('common.success'), detail: this.t.translate('book.browser.toast.unshelveSuccessDetail')});
|
||||
this.bookSelectionService.deselectAll();
|
||||
},
|
||||
error: () => {
|
||||
this.messageService.add({severity: 'error', summary: 'Error', detail: 'Failed to update books shelves'});
|
||||
this.messageService.add({severity: 'error', summary: this.t.translate('common.error'), detail: this.t.translate('book.browser.toast.unshelveFailedDetail')});
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -829,17 +831,17 @@ export class BookBrowserComponent implements OnInit, AfterViewInit, OnDestroy {
|
||||
if (!this.selectedBooks || this.selectedBooks.size === 0) return;
|
||||
const count = this.selectedBooks.size;
|
||||
this.confirmationService.confirm({
|
||||
message: `Are you sure you want to regenerate covers for ${count} book(s)?`,
|
||||
header: 'Confirm Cover Regeneration',
|
||||
message: this.t.translate('book.browser.confirm.regenCoverMessage', {count}),
|
||||
header: this.t.translate('book.browser.confirm.regenCoverHeader'),
|
||||
icon: 'pi pi-image',
|
||||
acceptLabel: 'Yes',
|
||||
rejectLabel: 'No',
|
||||
acceptLabel: this.t.translate('common.yes'),
|
||||
rejectLabel: this.t.translate('common.no'),
|
||||
acceptButtonProps: {
|
||||
label: 'Yes',
|
||||
label: this.t.translate('common.yes'),
|
||||
severity: 'success'
|
||||
},
|
||||
rejectButtonProps: {
|
||||
label: 'No',
|
||||
label: this.t.translate('common.no'),
|
||||
severity: 'secondary'
|
||||
},
|
||||
accept: () => {
|
||||
@@ -847,16 +849,16 @@ export class BookBrowserComponent implements OnInit, AfterViewInit, OnDestroy {
|
||||
next: () => {
|
||||
this.messageService.add({
|
||||
severity: 'success',
|
||||
summary: 'Cover Regeneration Started',
|
||||
detail: `Regenerating covers for ${count} book(s). Refresh the page when complete.`,
|
||||
summary: this.t.translate('book.browser.toast.regenCoverStartedSummary'),
|
||||
detail: this.t.translate('book.browser.toast.regenCoverStartedDetail', {count}),
|
||||
life: 3000
|
||||
});
|
||||
},
|
||||
error: () => {
|
||||
this.messageService.add({
|
||||
severity: 'error',
|
||||
summary: 'Failed',
|
||||
detail: 'Could not start cover regeneration.',
|
||||
summary: this.t.translate('book.browser.toast.failedSummary'),
|
||||
detail: this.t.translate('book.browser.toast.regenCoverFailedDetail'),
|
||||
life: 3000
|
||||
});
|
||||
}
|
||||
@@ -869,17 +871,17 @@ export class BookBrowserComponent implements OnInit, AfterViewInit, OnDestroy {
|
||||
if (!this.selectedBooks || this.selectedBooks.size === 0) return;
|
||||
const count = this.selectedBooks.size;
|
||||
this.confirmationService.confirm({
|
||||
message: `Are you sure you want to generate custom covers for ${count} book(s)?`,
|
||||
header: 'Confirm Custom Cover Generation',
|
||||
message: this.t.translate('book.browser.confirm.customCoverMessage', {count}),
|
||||
header: this.t.translate('book.browser.confirm.customCoverHeader'),
|
||||
icon: 'pi pi-palette',
|
||||
acceptLabel: 'Yes',
|
||||
rejectLabel: 'No',
|
||||
acceptLabel: this.t.translate('common.yes'),
|
||||
rejectLabel: this.t.translate('common.no'),
|
||||
acceptButtonProps: {
|
||||
label: 'Yes',
|
||||
label: this.t.translate('common.yes'),
|
||||
severity: 'success'
|
||||
},
|
||||
rejectButtonProps: {
|
||||
label: 'No',
|
||||
label: this.t.translate('common.no'),
|
||||
severity: 'secondary'
|
||||
},
|
||||
accept: () => {
|
||||
@@ -887,16 +889,16 @@ export class BookBrowserComponent implements OnInit, AfterViewInit, OnDestroy {
|
||||
next: () => {
|
||||
this.messageService.add({
|
||||
severity: 'success',
|
||||
summary: 'Custom Cover Generation Started',
|
||||
detail: `Generating custom covers for ${count} book(s).`,
|
||||
summary: this.t.translate('book.browser.toast.customCoverStartedSummary'),
|
||||
detail: this.t.translate('book.browser.toast.customCoverStartedDetail', {count}),
|
||||
life: 3000
|
||||
});
|
||||
},
|
||||
error: () => {
|
||||
this.messageService.add({
|
||||
severity: 'error',
|
||||
summary: 'Failed',
|
||||
detail: 'Could not start custom cover generation.',
|
||||
summary: this.t.translate('book.browser.toast.failedSummary'),
|
||||
detail: this.t.translate('book.browser.toast.customCoverFailedDetail'),
|
||||
life: 3000
|
||||
});
|
||||
}
|
||||
@@ -920,8 +922,8 @@ export class BookBrowserComponent implements OnInit, AfterViewInit, OnDestroy {
|
||||
if (sourceBooks.length === 0) {
|
||||
this.messageService.add({
|
||||
severity: 'warn',
|
||||
summary: 'No Eligible Books',
|
||||
detail: 'Selected books must be single-file books (no alternative formats).'
|
||||
summary: this.t.translate('book.browser.toast.noEligibleBooksSummary'),
|
||||
detail: this.t.translate('book.browser.toast.noEligibleBooksDetail')
|
||||
});
|
||||
return;
|
||||
}
|
||||
@@ -931,8 +933,8 @@ export class BookBrowserComponent implements OnInit, AfterViewInit, OnDestroy {
|
||||
if (libraryIds.size > 1) {
|
||||
this.messageService.add({
|
||||
severity: 'warn',
|
||||
summary: 'Multiple Libraries',
|
||||
detail: 'All selected books must be from the same library.'
|
||||
summary: this.t.translate('book.browser.toast.multipleLibrariesSummary'),
|
||||
detail: this.t.translate('book.browser.toast.multipleLibrariesDetail')
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
+1
-1
@@ -8,7 +8,7 @@
|
||||
class="book-cover"
|
||||
[class.loaded]="isImageLoaded"
|
||||
[class.square-cover]="_isAudiobook"
|
||||
[alt]="'Cover of ' + displayTitle"
|
||||
[alt]="('book.card.alt.cover' | transloco: { title: displayTitle })"
|
||||
loading="lazy"
|
||||
decoding="async"
|
||||
(load)="onImageLoad()"/>
|
||||
|
||||
+69
-67
@@ -26,12 +26,13 @@ import {TaskHelperService} from '../../../../settings/task-management/task-helpe
|
||||
import {BookNavigationService} from '../../../service/book-navigation.service';
|
||||
import {BookCardOverlayPreferenceService} from '../book-card-overlay-preference.service';
|
||||
import {AppSettingsService} from '../../../../../shared/service/app-settings.service';
|
||||
import {TranslocoPipe, TranslocoService} from '@jsverse/transloco';
|
||||
|
||||
@Component({
|
||||
selector: 'app-book-card',
|
||||
templateUrl: './book-card.component.html',
|
||||
styleUrls: ['./book-card.component.scss'],
|
||||
imports: [Button, MenuModule, CheckboxModule, FormsModule, NgClass, TieredMenu, ProgressBar, TooltipModule, RouterLink],
|
||||
imports: [Button, MenuModule, CheckboxModule, FormsModule, NgClass, TieredMenu, ProgressBar, TooltipModule, RouterLink, TranslocoPipe],
|
||||
standalone: true,
|
||||
changeDetection: ChangeDetectionStrategy.OnPush
|
||||
})
|
||||
@@ -70,6 +71,7 @@ export class BookCardComponent implements OnInit, OnChanges, OnDestroy {
|
||||
private bookNavigationService = inject(BookNavigationService);
|
||||
private cdr = inject(ChangeDetectorRef);
|
||||
private appSettingsService = inject(AppSettingsService);
|
||||
private readonly t = inject(TranslocoService);
|
||||
|
||||
protected _progressPercentage: number | null = null;
|
||||
protected _koProgressPercentage: number | null = null;
|
||||
@@ -140,7 +142,7 @@ export class BookCardComponent implements OnInit, OnChanges, OnDestroy {
|
||||
if (changes['seriesViewEnabled'] || changes['isSeriesCollapsed']) {
|
||||
this._isSeriesViewActive = this.seriesViewEnabled && !!this.book.seriesCount && this.book.seriesCount >= 1;
|
||||
this._displayTitle = (this.isSeriesCollapsed && this.book.metadata?.seriesName) ? this.book.metadata?.seriesName : this.book.metadata?.title;
|
||||
this._titleTooltip = 'Title: ' + this._displayTitle;
|
||||
this._titleTooltip = this.t.translate('book.card.alt.titleTooltip', { title: this._displayTitle });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -169,8 +171,8 @@ export class BookCardComponent implements OnInit, OnChanges, OnDestroy {
|
||||
this._readStatusTooltip = this.readStatusHelper.getReadStatusTooltip(this.book.readStatus);
|
||||
this._shouldShowStatusIcon = this.readStatusHelper.shouldShowStatusIcon(this.book.readStatus);
|
||||
|
||||
this._seriesCountTooltip = 'Series collapsed: ' + this.book.seriesCount + ' books';
|
||||
this._titleTooltip = 'Title: ' + this._displayTitle;
|
||||
this._seriesCountTooltip = this.t.translate('book.card.alt.seriesCollapsed', { count: this.book.seriesCount });
|
||||
this._titleTooltip = this.t.translate('book.card.alt.titleTooltip', { title: this._displayTitle });
|
||||
}
|
||||
|
||||
get hasProgress(): boolean {
|
||||
@@ -273,12 +275,12 @@ export class BookCardComponent implements OnInit, OnChanges, OnDestroy {
|
||||
private initMenu() {
|
||||
this.items = [
|
||||
{
|
||||
label: 'Assign Shelf',
|
||||
label: this.t.translate('book.card.menu.assignShelf'),
|
||||
icon: 'pi pi-folder',
|
||||
command: () => this.openShelfDialog()
|
||||
},
|
||||
{
|
||||
label: 'View Details',
|
||||
label: this.t.translate('book.card.menu.viewDetails'),
|
||||
icon: 'pi pi-info-circle',
|
||||
command: () => {
|
||||
setTimeout(() => {
|
||||
@@ -301,13 +303,13 @@ export class BookCardComponent implements OnInit, OnChanges, OnDestroy {
|
||||
if (hasAdditionalFiles) {
|
||||
const downloadItems = this.getDownloadMenuItems();
|
||||
items.push({
|
||||
label: 'Download',
|
||||
label: this.t.translate('book.card.menu.download'),
|
||||
icon: 'pi pi-download',
|
||||
items: downloadItems
|
||||
});
|
||||
} else if (this.additionalFilesLoaded) {
|
||||
items.push({
|
||||
label: 'Download',
|
||||
label: this.t.translate('book.card.menu.download'),
|
||||
icon: 'pi pi-download',
|
||||
command: () => {
|
||||
this.bookService.downloadFile(this.book);
|
||||
@@ -315,9 +317,9 @@ export class BookCardComponent implements OnInit, OnChanges, OnDestroy {
|
||||
});
|
||||
} else {
|
||||
items.push({
|
||||
label: 'Download',
|
||||
label: this.t.translate('book.card.menu.download'),
|
||||
icon: this.isSubMenuLoading ? 'pi pi-spin pi-spinner' : 'pi pi-download',
|
||||
items: [{label: 'Loading...', disabled: true}]
|
||||
items: [{label: this.t.translate('book.card.menu.loading'), disabled: true}]
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -329,23 +331,23 @@ export class BookCardComponent implements OnInit, OnChanges, OnDestroy {
|
||||
if (hasAdditionalFiles) {
|
||||
const deleteItems = this.getDeleteMenuItems();
|
||||
items.push({
|
||||
label: 'Delete',
|
||||
label: this.t.translate('book.card.menu.delete'),
|
||||
icon: 'pi pi-trash',
|
||||
items: deleteItems
|
||||
});
|
||||
} else if (this.additionalFilesLoaded) {
|
||||
items.push({
|
||||
label: 'Delete',
|
||||
label: this.t.translate('book.card.menu.delete'),
|
||||
icon: 'pi pi-trash',
|
||||
command: () => {
|
||||
this.confirmationService.confirm({
|
||||
message: `Are you sure you want to delete "${this.book.metadata?.title}"?\n\nThis will permanently remove the book file from your filesystem.\n\nThis action cannot be undone.`,
|
||||
header: 'Confirm Deletion',
|
||||
message: this.t.translate('book.card.confirm.deleteBookMessage', {title: this.book.metadata?.title}),
|
||||
header: this.t.translate('book.card.confirm.deleteBookHeader'),
|
||||
icon: 'pi pi-exclamation-triangle',
|
||||
acceptIcon: 'pi pi-trash',
|
||||
rejectIcon: 'pi pi-times',
|
||||
acceptLabel: 'Delete',
|
||||
rejectLabel: 'Cancel',
|
||||
acceptLabel: this.t.translate('common.delete'),
|
||||
rejectLabel: this.t.translate('common.cancel'),
|
||||
acceptButtonStyleClass: 'p-button-danger',
|
||||
rejectButtonStyleClass: 'p-button-outlined',
|
||||
accept: () => {
|
||||
@@ -356,9 +358,9 @@ export class BookCardComponent implements OnInit, OnChanges, OnDestroy {
|
||||
});
|
||||
} else {
|
||||
items.push({
|
||||
label: 'Delete',
|
||||
label: this.t.translate('book.card.menu.delete'),
|
||||
icon: this.isSubMenuLoading ? 'pi pi-spin pi-spinner' : 'pi pi-trash',
|
||||
items: [{label: 'Loading...', disabled: true}]
|
||||
items: [{label: this.t.translate('book.card.menu.loading'), disabled: true}]
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -366,25 +368,25 @@ export class BookCardComponent implements OnInit, OnChanges, OnDestroy {
|
||||
if (this.user?.permissions.canEmailBook) {
|
||||
items.push(
|
||||
{
|
||||
label: 'Email Book',
|
||||
label: this.t.translate('book.card.menu.emailBook'),
|
||||
icon: 'pi pi-envelope',
|
||||
items: [{
|
||||
label: 'Quick Send',
|
||||
label: this.t.translate('book.card.menu.quickSend'),
|
||||
icon: 'pi pi-envelope',
|
||||
command: () => {
|
||||
this.emailService.emailBookQuick(this.book.id).subscribe({
|
||||
next: () => {
|
||||
this.messageService.add({
|
||||
severity: 'info',
|
||||
summary: 'Success',
|
||||
detail: 'The book sending has been scheduled.',
|
||||
summary: this.t.translate('common.success'),
|
||||
detail: this.t.translate('book.card.toast.quickSendSuccessDetail'),
|
||||
});
|
||||
},
|
||||
error: (err) => {
|
||||
const errorMessage = err?.error?.message || 'An error occurred while sending the book.';
|
||||
const errorMessage = err?.error?.message || this.t.translate('book.card.toast.quickSendErrorDetail');
|
||||
this.messageService.add({
|
||||
severity: 'error',
|
||||
summary: 'Error',
|
||||
summary: this.t.translate('common.error'),
|
||||
detail: errorMessage,
|
||||
});
|
||||
},
|
||||
@@ -392,7 +394,7 @@ export class BookCardComponent implements OnInit, OnChanges, OnDestroy {
|
||||
}
|
||||
},
|
||||
{
|
||||
label: 'Custom Send',
|
||||
label: this.t.translate('book.card.menu.customSend'),
|
||||
icon: 'pi pi-envelope',
|
||||
command: () => {
|
||||
this.bookDialogHelperService.openCustomSendDialog(this.book);
|
||||
@@ -404,11 +406,11 @@ export class BookCardComponent implements OnInit, OnChanges, OnDestroy {
|
||||
|
||||
if (this.user?.permissions.canEditMetadata) {
|
||||
items.push({
|
||||
label: 'Metadata',
|
||||
label: this.t.translate('book.card.menu.metadata'),
|
||||
icon: 'pi pi-database',
|
||||
items: [
|
||||
{
|
||||
label: 'Search Metadata',
|
||||
label: this.t.translate('book.card.menu.searchMetadata'),
|
||||
icon: 'pi pi-sparkles',
|
||||
command: () => {
|
||||
setTimeout(() => {
|
||||
@@ -419,7 +421,7 @@ export class BookCardComponent implements OnInit, OnChanges, OnDestroy {
|
||||
},
|
||||
},
|
||||
{
|
||||
label: 'Auto Fetch',
|
||||
label: this.t.translate('book.card.menu.autoFetch'),
|
||||
icon: 'pi pi-bolt',
|
||||
command: () => {
|
||||
this.taskHelperService.refreshMetadataTask({
|
||||
@@ -429,44 +431,44 @@ export class BookCardComponent implements OnInit, OnChanges, OnDestroy {
|
||||
}
|
||||
},
|
||||
{
|
||||
label: 'Custom Fetch',
|
||||
label: this.t.translate('book.card.menu.customFetch'),
|
||||
icon: 'pi pi-sync',
|
||||
command: () => {
|
||||
this.bookDialogHelperService.openMetadataRefreshDialog(new Set([this.book!.id]))
|
||||
},
|
||||
},
|
||||
{
|
||||
label: 'Regenerate Cover (File)',
|
||||
label: this.t.translate('book.card.menu.regenerateCover'),
|
||||
icon: 'pi pi-image',
|
||||
command: () => {
|
||||
this.bookService.regenerateCover(this.book.id).subscribe({
|
||||
next: () => this.messageService.add({
|
||||
severity: 'success',
|
||||
summary: 'Success',
|
||||
detail: 'Cover regeneration started'
|
||||
summary: this.t.translate('common.success'),
|
||||
detail: this.t.translate('book.card.toast.coverRegenSuccessDetail')
|
||||
}),
|
||||
error: (err) => this.messageService.add({
|
||||
severity: 'error',
|
||||
summary: 'Error',
|
||||
detail: err?.error?.message || 'Failed to regenerate cover'
|
||||
summary: this.t.translate('common.error'),
|
||||
detail: err?.error?.message || this.t.translate('book.card.toast.coverRegenFailedDetail')
|
||||
})
|
||||
});
|
||||
}
|
||||
},
|
||||
{
|
||||
label: 'Generate Custom Cover',
|
||||
label: this.t.translate('book.card.menu.generateCustomCover'),
|
||||
icon: 'pi pi-palette',
|
||||
command: () => {
|
||||
this.bookService.generateCustomCover(this.book.id).subscribe({
|
||||
next: () => this.messageService.add({
|
||||
severity: 'success',
|
||||
summary: 'Success',
|
||||
detail: 'Cover generated successfully'
|
||||
summary: this.t.translate('common.success'),
|
||||
detail: this.t.translate('book.card.toast.customCoverSuccessDetail')
|
||||
}),
|
||||
error: (err) => this.messageService.add({
|
||||
severity: 'error',
|
||||
summary: 'Error',
|
||||
detail: err?.error?.message || 'Failed to generate cover'
|
||||
summary: this.t.translate('common.error'),
|
||||
detail: err?.error?.message || this.t.translate('book.card.toast.customCoverFailedDetail')
|
||||
})
|
||||
});
|
||||
}
|
||||
@@ -484,7 +486,7 @@ export class BookCardComponent implements OnInit, OnChanges, OnDestroy {
|
||||
|
||||
if (this.user?.permissions.canMoveOrganizeFiles && this.diskType === 'LOCAL') {
|
||||
moreActions.push({
|
||||
label: 'Organize File',
|
||||
label: this.t.translate('book.card.menu.organizeFile'),
|
||||
icon: 'pi pi-arrows-h',
|
||||
command: () => {
|
||||
this.bookDialogHelperService.openFileMoverDialog(new Set([this.book.id]));
|
||||
@@ -494,7 +496,7 @@ export class BookCardComponent implements OnInit, OnChanges, OnDestroy {
|
||||
|
||||
moreActions.push(
|
||||
{
|
||||
label: 'Read Status',
|
||||
label: this.t.translate('book.card.menu.readStatus'),
|
||||
icon: 'pi pi-book',
|
||||
items: Object.entries(readStatusLabels).map(([status, label]) => ({
|
||||
label,
|
||||
@@ -503,16 +505,16 @@ export class BookCardComponent implements OnInit, OnChanges, OnDestroy {
|
||||
next: () => {
|
||||
this.messageService.add({
|
||||
severity: 'success',
|
||||
summary: 'Read Status Updated',
|
||||
detail: `Marked as "${label}"`,
|
||||
summary: this.t.translate('book.card.toast.readStatusUpdatedSummary'),
|
||||
detail: this.t.translate('book.card.toast.readStatusUpdatedDetail', {label}),
|
||||
life: 2000
|
||||
});
|
||||
},
|
||||
error: () => {
|
||||
this.messageService.add({
|
||||
severity: 'error',
|
||||
summary: 'Update Failed',
|
||||
detail: 'Could not update read status.',
|
||||
summary: this.t.translate('book.card.toast.readStatusFailedSummary'),
|
||||
detail: this.t.translate('book.card.toast.readStatusFailedDetail'),
|
||||
life: 3000
|
||||
});
|
||||
}
|
||||
@@ -521,23 +523,23 @@ export class BookCardComponent implements OnInit, OnChanges, OnDestroy {
|
||||
}))
|
||||
},
|
||||
{
|
||||
label: 'Reset Booklore Progress',
|
||||
label: this.t.translate('book.card.menu.resetBookloreProgress'),
|
||||
icon: 'pi pi-undo',
|
||||
command: () => {
|
||||
this.bookService.resetProgress(this.book.id, ResetProgressTypes.BOOKLORE).subscribe({
|
||||
next: () => {
|
||||
this.messageService.add({
|
||||
severity: 'success',
|
||||
summary: 'Progress Reset',
|
||||
detail: 'Booklore reading progress has been reset.',
|
||||
summary: this.t.translate('book.card.toast.progressResetSummary'),
|
||||
detail: this.t.translate('book.card.toast.progressResetBookloreDetail'),
|
||||
life: 1500
|
||||
});
|
||||
},
|
||||
error: () => {
|
||||
this.messageService.add({
|
||||
severity: 'error',
|
||||
summary: 'Failed',
|
||||
detail: 'Could not reset Booklore progress.',
|
||||
summary: this.t.translate('book.card.toast.progressResetFailedSummary'),
|
||||
detail: this.t.translate('book.card.toast.progressResetBookloreFailedDetail'),
|
||||
life: 1500
|
||||
});
|
||||
}
|
||||
@@ -545,23 +547,23 @@ export class BookCardComponent implements OnInit, OnChanges, OnDestroy {
|
||||
},
|
||||
},
|
||||
{
|
||||
label: 'Reset KOReader Progress',
|
||||
label: this.t.translate('book.card.menu.resetKOReaderProgress'),
|
||||
icon: 'pi pi-undo',
|
||||
command: () => {
|
||||
this.bookService.resetProgress(this.book.id, ResetProgressTypes.KOREADER).subscribe({
|
||||
next: () => {
|
||||
this.messageService.add({
|
||||
severity: 'success',
|
||||
summary: 'Progress Reset',
|
||||
detail: 'KOReader reading progress has been reset.',
|
||||
summary: this.t.translate('book.card.toast.progressResetSummary'),
|
||||
detail: this.t.translate('book.card.toast.progressResetKOReaderDetail'),
|
||||
life: 1500
|
||||
});
|
||||
},
|
||||
error: () => {
|
||||
this.messageService.add({
|
||||
severity: 'error',
|
||||
summary: 'Failed',
|
||||
detail: 'Could not reset KOReader progress.',
|
||||
summary: this.t.translate('book.card.toast.progressResetFailedSummary'),
|
||||
detail: this.t.translate('book.card.toast.progressResetKOReaderFailedDetail'),
|
||||
life: 1500
|
||||
});
|
||||
}
|
||||
@@ -571,7 +573,7 @@ export class BookCardComponent implements OnInit, OnChanges, OnDestroy {
|
||||
);
|
||||
|
||||
items.push({
|
||||
label: 'More Actions',
|
||||
label: this.t.translate('book.card.menu.moreActions'),
|
||||
icon: 'pi pi-ellipsis-h',
|
||||
items: moreActions
|
||||
});
|
||||
@@ -657,17 +659,17 @@ export class BookCardComponent implements OnInit, OnChanges, OnDestroy {
|
||||
const items: MenuItem[] = [];
|
||||
|
||||
items.push({
|
||||
label: 'Book',
|
||||
label: this.t.translate('book.card.menu.book'),
|
||||
icon: 'pi pi-book',
|
||||
command: () => {
|
||||
this.confirmationService.confirm({
|
||||
message: `Are you sure you want to delete "${this.book.metadata?.title}"?\n\nThis will permanently remove the book file from your filesystem.\n\nThis action cannot be undone.`,
|
||||
header: 'Confirm Deletion',
|
||||
message: this.t.translate('book.card.confirm.deleteBookMessage', {title: this.book.metadata?.title}),
|
||||
header: this.t.translate('book.card.confirm.deleteBookHeader'),
|
||||
icon: 'pi pi-exclamation-triangle',
|
||||
acceptIcon: 'pi pi-trash',
|
||||
rejectIcon: 'pi pi-times',
|
||||
acceptLabel: 'Delete',
|
||||
rejectLabel: 'Cancel',
|
||||
acceptLabel: this.t.translate('common.delete'),
|
||||
rejectLabel: this.t.translate('common.cancel'),
|
||||
acceptButtonStyleClass: 'p-button-danger',
|
||||
rejectButtonStyleClass: 'p-button-outlined',
|
||||
accept: () => {
|
||||
@@ -722,8 +724,8 @@ export class BookCardComponent implements OnInit, OnChanges, OnDestroy {
|
||||
|
||||
private deleteAdditionalFile(bookId: number, fileId: number, fileName: string): void {
|
||||
this.confirmationService.confirm({
|
||||
message: `Are you sure you want to delete the additional file "${fileName}"?`,
|
||||
header: 'Confirm File Deletion',
|
||||
message: this.t.translate('book.card.confirm.deleteFileMessage', {fileName}),
|
||||
header: this.t.translate('book.card.confirm.deleteFileHeader'),
|
||||
icon: 'pi pi-exclamation-triangle',
|
||||
acceptIcon: 'pi pi-trash',
|
||||
rejectIcon: 'pi pi-times',
|
||||
@@ -733,15 +735,15 @@ export class BookCardComponent implements OnInit, OnChanges, OnDestroy {
|
||||
next: () => {
|
||||
this.messageService.add({
|
||||
severity: 'success',
|
||||
summary: 'Success',
|
||||
detail: `Additional file "${fileName}" deleted successfully`
|
||||
summary: this.t.translate('common.success'),
|
||||
detail: this.t.translate('book.card.toast.deleteFileSuccessDetail', {fileName})
|
||||
});
|
||||
},
|
||||
error: (error) => {
|
||||
this.messageService.add({
|
||||
severity: 'error',
|
||||
summary: 'Error',
|
||||
detail: `Failed to delete additional file: ${error.message || 'Unknown error'}`
|
||||
summary: this.t.translate('common.error'),
|
||||
detail: this.t.translate('book.card.toast.deleteFileErrorDetail', {error: error.message || 'Unknown error'})
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
+5
-3
@@ -1,7 +1,8 @@
|
||||
<ng-container *transloco="let t; prefix: 'book.filter'">
|
||||
<div class="book-filter-container">
|
||||
|
||||
<div class="filter-header">
|
||||
<span class="filter-title">Filters</span>
|
||||
<span class="filter-title">{{ t('title') }}</span>
|
||||
<p-selectButton
|
||||
[options]="filterModeOptions"
|
||||
[(ngModel)]="selectedFilterMode"
|
||||
@@ -50,7 +51,7 @@
|
||||
</cdk-virtual-scroll-viewport>
|
||||
@if (truncatedFilters[filterType]) {
|
||||
<div class="truncation-notice">
|
||||
Showing first 100 items
|
||||
{{ t('showingFirst100') }}
|
||||
</div>
|
||||
}
|
||||
}
|
||||
@@ -62,7 +63,8 @@
|
||||
</p-accordion>
|
||||
|
||||
<div class="footer-notice">
|
||||
Note: Top 100 items are displayed per filter category
|
||||
{{ t('footerNote') }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</ng-container>
|
||||
|
||||
+3
-1
@@ -14,6 +14,7 @@ import {MagicShelf} from '../../../../magic-shelf/service/magic-shelf.service';
|
||||
import {Filter, FILTER_LABELS, FilterType} from './book-filter.config';
|
||||
import {BookFilterService} from './book-filter.service';
|
||||
import {filter} from 'rxjs/operators';
|
||||
import {TranslocoDirective} from '@jsverse/transloco';
|
||||
|
||||
type FilterModeOption = { label: string; value: BookFilterMode };
|
||||
|
||||
@@ -26,7 +27,8 @@ type FilterModeOption = { label: string; value: BookFilterMode };
|
||||
imports: [
|
||||
Accordion, AccordionPanel, AccordionHeader, AccordionContent,
|
||||
CdkVirtualScrollViewport, CdkFixedSizeVirtualScroll, CdkVirtualForOf,
|
||||
NgClass, Badge, AsyncPipe, TitleCasePipe, FormsModule, SelectButton
|
||||
NgClass, Badge, AsyncPipe, TitleCasePipe, FormsModule, SelectButton,
|
||||
TranslocoDirective
|
||||
]
|
||||
})
|
||||
export class BookFilterComponent implements OnInit, OnDestroy {
|
||||
|
||||
+6
-4
@@ -1,3 +1,4 @@
|
||||
<ng-container *transloco="let t; prefix: 'book.table'">
|
||||
<p-table
|
||||
[value]="books"
|
||||
[columns]="visibleColumns"
|
||||
@@ -42,7 +43,7 @@
|
||||
[icon]="isMetadataFullyLocked(metadata) ? 'pi pi-lock' : 'pi pi-lock-open'"
|
||||
[severity]="isMetadataFullyLocked(metadata) ? 'danger' : 'success'"
|
||||
[text]="true"
|
||||
[title]="isMetadataFullyLocked(metadata) ? 'Locked' : 'Unlocked'"
|
||||
[title]="isMetadataFullyLocked(metadata) ? t('locked') : t('unlocked')"
|
||||
size="small"
|
||||
[style]="{ width: '1.5rem', height: '1.5rem', padding: '0', fontSize: '0.75rem' }"
|
||||
(click)="toggleMetadataLock(metadata)">
|
||||
@@ -52,7 +53,7 @@
|
||||
<a [routerLink]="urlHelper.getBookUrl(book)">
|
||||
<img
|
||||
[attr.src]="urlHelper.getThumbnailUrl(metadata.bookId, metadata.coverUpdatedOn)"
|
||||
alt="Book Cover"
|
||||
[alt]="t('bookCoverAlt')"
|
||||
class="cover-thumbnail"
|
||||
tooltipPosition="left"
|
||||
[pTooltip]="tooltipContent"
|
||||
@@ -63,7 +64,7 @@
|
||||
<div class="tooltip-cover-container">
|
||||
<img
|
||||
[attr.src]="urlHelper.getThumbnailUrl(metadata.bookId, metadata.coverUpdatedOn)"
|
||||
alt="Book Cover"
|
||||
[alt]="t('bookCoverAlt')"
|
||||
class="tooltip-cover-image"
|
||||
/>
|
||||
<em class="tooltip-cover-title">{{ metadata.title }}</em>
|
||||
@@ -77,7 +78,7 @@
|
||||
@if (shouldShowStatusIcon(book.readStatus)) {
|
||||
<div class="read-status-indicator"
|
||||
[ngClass]="getReadStatusClass(book.readStatus)"
|
||||
[pTooltip]="'Status: ' + getReadStatusTooltip(book.readStatus)"
|
||||
[pTooltip]="t('statusPrefix') + getReadStatusTooltip(book.readStatus)"
|
||||
tooltipPosition="top">
|
||||
<i [class]="getReadStatusIcon(book.readStatus)"></i>
|
||||
</div>
|
||||
@@ -116,3 +117,4 @@
|
||||
}
|
||||
</ng-template>
|
||||
</p-table>
|
||||
</ng-container>
|
||||
|
||||
+8
-5
@@ -15,6 +15,7 @@ import {filter, Subject} from 'rxjs';
|
||||
import {UserService} from '../../../../settings/user-management/user.service';
|
||||
import {take, takeUntil} from 'rxjs/operators';
|
||||
import {ReadStatusHelper} from '../../../helpers/read-status.helper';
|
||||
import {TranslocoDirective, TranslocoService} from '@jsverse/transloco';
|
||||
|
||||
@Component({
|
||||
selector: 'app-book-table',
|
||||
@@ -27,7 +28,8 @@ import {ReadStatusHelper} from '../../../helpers/read-status.helper';
|
||||
Button,
|
||||
TooltipModule,
|
||||
NgClass,
|
||||
RouterLink
|
||||
RouterLink,
|
||||
TranslocoDirective
|
||||
],
|
||||
styleUrls: ['./book-table.component.scss'],
|
||||
providers: [DatePipe]
|
||||
@@ -48,6 +50,7 @@ export class BookTableComponent implements OnInit, OnDestroy, OnChanges {
|
||||
private userService = inject(UserService);
|
||||
private datePipe = inject(DatePipe);
|
||||
private readStatusHelper = inject(ReadStatusHelper);
|
||||
private readonly t = inject(TranslocoService);
|
||||
|
||||
private metadataCenterViewMode: 'route' | 'dialog' = 'route';
|
||||
private destroy$ = new Subject<void>();
|
||||
@@ -327,15 +330,15 @@ export class BookTableComponent implements OnInit, OnDestroy, OnChanges {
|
||||
next: () => {
|
||||
this.messageService.add({
|
||||
severity: 'success',
|
||||
summary: `Metadata ${lockAction === 'LOCK' ? 'Locked' : 'Unlocked'}`,
|
||||
detail: `Book metadata has been ${lockAction === 'LOCK' ? 'locked' : 'unlocked'} successfully.`,
|
||||
summary: lockAction === 'LOCK' ? this.t.translate('book.table.toast.metadataLockedSummary') : this.t.translate('book.table.toast.metadataUnlockedSummary'),
|
||||
detail: lockAction === 'LOCK' ? this.t.translate('book.table.toast.metadataLockedDetail') : this.t.translate('book.table.toast.metadataUnlockedDetail'),
|
||||
});
|
||||
},
|
||||
error: () => {
|
||||
this.messageService.add({
|
||||
severity: 'error',
|
||||
summary: `Failed to ${lockAction === 'LOCK' ? 'Lock' : 'Unlock'}`,
|
||||
detail: `An error occurred while ${lockAction === 'LOCK' ? 'locking' : 'unlocking'} the metadata.`,
|
||||
summary: lockAction === 'LOCK' ? this.t.translate('book.table.toast.lockFailedSummary') : this.t.translate('book.table.toast.unlockFailedSummary'),
|
||||
detail: lockAction === 'LOCK' ? this.t.translate('book.table.toast.lockFailedDetail') : this.t.translate('book.table.toast.unlockFailedDetail'),
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
+6
-4
@@ -2,6 +2,7 @@ import {inject, Injectable} from '@angular/core';
|
||||
import {Subject} from 'rxjs';
|
||||
import {debounceTime} from 'rxjs/operators';
|
||||
import {MessageService} from 'primeng/api';
|
||||
import {TranslocoService} from '@jsverse/transloco';
|
||||
import {LocalStorageService} from '../../../../shared/service/local-storage.service';
|
||||
import {Book} from '../../model/book.model';
|
||||
|
||||
@@ -17,6 +18,7 @@ export class CoverScalePreferenceService {
|
||||
private readonly STORAGE_KEY = 'coverScalePreference';
|
||||
|
||||
private readonly messageService = inject(MessageService);
|
||||
private readonly t = inject(TranslocoService);
|
||||
private readonly localStorageService = inject(LocalStorageService);
|
||||
|
||||
private readonly scaleChangeSubject = new Subject<number>();
|
||||
@@ -64,15 +66,15 @@ export class CoverScalePreferenceService {
|
||||
this.localStorageService.set(this.STORAGE_KEY, scale);
|
||||
this.messageService.add({
|
||||
severity: 'success',
|
||||
summary: 'Cover Size Saved',
|
||||
detail: `Cover size set to ${scale.toFixed(2)}x.`,
|
||||
summary: this.t.translate('book.coverPref.toast.savedSummary'),
|
||||
detail: this.t.translate('book.coverPref.toast.savedDetail', {scale: scale.toFixed(2)}),
|
||||
life: 1500
|
||||
});
|
||||
} catch (e) {
|
||||
this.messageService.add({
|
||||
severity: 'error',
|
||||
summary: 'Save Failed',
|
||||
detail: 'Could not save cover size preference locally.',
|
||||
summary: this.t.translate('book.coverPref.toast.saveFailedSummary'),
|
||||
detail: this.t.translate('book.coverPref.toast.saveFailedDetail'),
|
||||
life: 3000
|
||||
});
|
||||
}
|
||||
|
||||
+4
-2
@@ -1,6 +1,7 @@
|
||||
import {inject, Injectable} from '@angular/core';
|
||||
import {BehaviorSubject} from 'rxjs';
|
||||
import {MessageService} from 'primeng/api';
|
||||
import {TranslocoService} from '@jsverse/transloco';
|
||||
import {LocalStorageService} from '../../../../../shared/service/local-storage.service';
|
||||
|
||||
@Injectable({
|
||||
@@ -10,6 +11,7 @@ export class SidebarFilterTogglePrefService {
|
||||
|
||||
private readonly STORAGE_KEY = 'showSidebarFilter';
|
||||
private readonly messageService = inject(MessageService);
|
||||
private readonly t = inject(TranslocoService);
|
||||
private readonly localStorageService = inject(LocalStorageService);
|
||||
|
||||
private readonly showFilterSubject = new BehaviorSubject<boolean>(true);
|
||||
@@ -43,8 +45,8 @@ export class SidebarFilterTogglePrefService {
|
||||
} catch (e) {
|
||||
this.messageService.add({
|
||||
severity: 'error',
|
||||
summary: 'Save Failed',
|
||||
detail: 'Could not save sidebar filter preference locally.',
|
||||
summary: this.t.translate('book.filterPref.toast.saveFailedSummary'),
|
||||
detail: this.t.translate('book.filterPref.toast.saveFailedDetail'),
|
||||
life: 3000
|
||||
});
|
||||
}
|
||||
|
||||
+8
-6
@@ -1,11 +1,12 @@
|
||||
<ng-container *transloco="let t; prefix: 'book.lockUnlockDialog'">
|
||||
<div class="lock-unlock-container">
|
||||
<div class="panel-header">
|
||||
<div class="header-icon-wrapper">
|
||||
<i class="pi pi-lock header-icon"></i>
|
||||
</div>
|
||||
<div class="header-text">
|
||||
<h2 class="panel-title">Lock or Unlock Metadata</h2>
|
||||
<p class="panel-description">{{ bookIds.size }} book{{ bookIds.size > 1 ? 's' : '' }} selected</p>
|
||||
<h2 class="panel-title">{{ t('title') }}</h2>
|
||||
<p class="panel-description">{{ t('selectedCount', { count: bookIds.size }) }}</p>
|
||||
</div>
|
||||
<p-button
|
||||
icon="pi pi-times"
|
||||
@@ -36,13 +37,14 @@
|
||||
|
||||
<div class="dialog-footer">
|
||||
<div class="footer-actions">
|
||||
<p-button icon="pi pi-refresh" label="Reset" outlined="true" severity="warn" (onClick)="resetFieldLocks()"></p-button>
|
||||
<p-button icon="pi pi-refresh" [label]="t('reset')" outlined="true" severity="warn" (onClick)="resetFieldLocks()"></p-button>
|
||||
</div>
|
||||
<div class="footer-actions">
|
||||
<p-button icon="pi pi-lock" label="Lock All" outlined="true" severity="danger" (onClick)="toggleLockAll('LOCK')"></p-button>
|
||||
<p-button icon="pi pi-lock-open" label="Unlock All" outlined="true" severity="success" (onClick)="toggleLockAll('UNLOCK')"></p-button>
|
||||
<p-button icon="pi pi-lock" [label]="t('lockAll')" outlined="true" severity="danger" (onClick)="toggleLockAll('LOCK')"></p-button>
|
||||
<p-button icon="pi pi-lock-open" [label]="t('unlockAll')" outlined="true" severity="success" (onClick)="toggleLockAll('UNLOCK')"></p-button>
|
||||
<p-divider layout="vertical"></p-divider>
|
||||
<p-button [label]="isSaving ? 'Saving...' : 'Save'" [outlined]="true" icon="pi pi-check" severity="info" (onClick)="applyFieldLocks()" [disabled]="bookIds.size === 0 || isSaving"></p-button>
|
||||
<p-button [label]="isSaving ? t('saving') : t('save')" [outlined]="true" icon="pi pi-check" severity="info" (onClick)="applyFieldLocks()" [disabled]="bookIds.size === 0 || isSaving"></p-button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</ng-container>
|
||||
|
||||
+11
-8
@@ -8,6 +8,7 @@ import {BookService} from '../../../service/book.service';
|
||||
import {Divider} from 'primeng/divider';
|
||||
import {LoadingService} from '../../../../../core/services/loading.service';
|
||||
import {finalize} from 'rxjs';
|
||||
import {TranslocoDirective, TranslocoService} from '@jsverse/transloco';
|
||||
|
||||
@Component({
|
||||
selector: 'app-lock-unlock-metadata-dialog',
|
||||
@@ -15,7 +16,8 @@ import {finalize} from 'rxjs';
|
||||
imports: [
|
||||
Button,
|
||||
FormsModule,
|
||||
Divider
|
||||
Divider,
|
||||
TranslocoDirective
|
||||
],
|
||||
templateUrl: './lock-unlock-metadata-dialog.component.html',
|
||||
styleUrl: './lock-unlock-metadata-dialog.component.scss'
|
||||
@@ -26,6 +28,7 @@ export class LockUnlockMetadataDialogComponent implements OnInit {
|
||||
dialogRef = inject(DynamicDialogRef);
|
||||
private messageService = inject(MessageService);
|
||||
private loadingService = inject(LoadingService);
|
||||
private readonly t = inject(TranslocoService);
|
||||
fieldLocks: Record<string, boolean | undefined> = {};
|
||||
|
||||
bookIds: Set<number> = this.dynamicDialogConfig.data.bookIds;
|
||||
@@ -89,8 +92,8 @@ export class LockUnlockMetadataDialogComponent implements OnInit {
|
||||
|
||||
getLockLabel(field: string): string {
|
||||
const state = this.fieldLocks[field];
|
||||
if (state === undefined) return 'Unselected';
|
||||
return state ? 'Locked' : 'Unlocked';
|
||||
if (state === undefined) return this.t.translate('book.lockUnlockDialog.unselected');
|
||||
return state ? this.t.translate('book.lockUnlockDialog.locked') : this.t.translate('book.lockUnlockDialog.unlocked');
|
||||
}
|
||||
|
||||
getLockIcon(field: string): string {
|
||||
@@ -124,7 +127,7 @@ export class LockUnlockMetadataDialogComponent implements OnInit {
|
||||
}
|
||||
|
||||
this.isSaving = true;
|
||||
const loader = this.loadingService.show('Updating field locks...');
|
||||
const loader = this.loadingService.show(this.t.translate('book.lockUnlockDialog.toast.updatingFieldLocks'));
|
||||
|
||||
this.bookService.toggleFieldLocks(this.bookIds, fieldActions)
|
||||
.pipe(finalize(() => {
|
||||
@@ -135,16 +138,16 @@ export class LockUnlockMetadataDialogComponent implements OnInit {
|
||||
next: () => {
|
||||
this.messageService.add({
|
||||
severity: 'success',
|
||||
summary: 'Field Locks Updated',
|
||||
detail: 'Selected metadata fields have been updated successfully.'
|
||||
summary: this.t.translate('book.lockUnlockDialog.toast.updatedSummary'),
|
||||
detail: this.t.translate('book.lockUnlockDialog.toast.updatedDetail')
|
||||
});
|
||||
this.dialogRef.close('fields-updated');
|
||||
},
|
||||
error: () => {
|
||||
this.messageService.add({
|
||||
severity: 'error',
|
||||
summary: 'Failed to Update Field Locks',
|
||||
detail: 'An error occurred while updating field lock statuses.'
|
||||
summary: this.t.translate('book.lockUnlockDialog.toast.failedSummary'),
|
||||
detail: this.t.translate('book.lockUnlockDialog.toast.failedDetail')
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
+6
-4
@@ -1,6 +1,7 @@
|
||||
<ng-container *transloco="let t; prefix: 'book.sorting'">
|
||||
<div class="multi-sort-container">
|
||||
<div class="multi-sort-header">
|
||||
<span class="header-title">Sort Order</span>
|
||||
<span class="header-title">{{ t('sortOrder') }}</span>
|
||||
</div>
|
||||
|
||||
<div
|
||||
@@ -28,7 +29,7 @@
|
||||
type="button"
|
||||
class="remove-btn"
|
||||
(click)="onRemove(i)"
|
||||
pTooltip="Remove"
|
||||
[pTooltip]="t('removeTooltip')"
|
||||
tooltipPosition="top"
|
||||
[disabled]="sortCriteria.length === 1">
|
||||
<i class="pi pi-times"></i>
|
||||
@@ -45,7 +46,7 @@
|
||||
[(ngModel)]="selectedField"
|
||||
optionLabel="label"
|
||||
optionValue="field"
|
||||
placeholder="Add sort field..."
|
||||
[placeholder]="t('addSortFieldPlaceholder')"
|
||||
[style]="{ width: '100%' }"
|
||||
size="small"
|
||||
appendTo="body"
|
||||
@@ -58,7 +59,7 @@
|
||||
<div class="save-sort-section">
|
||||
<p-button
|
||||
icon="pi pi-save"
|
||||
label="Save as Default"
|
||||
[label]="t('saveAsDefault')"
|
||||
size="small"
|
||||
[outlined]="true"
|
||||
[style]="{ width: '100%' }"
|
||||
@@ -67,3 +68,4 @@
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</ng-container>
|
||||
|
||||
+8
-3
@@ -1,10 +1,11 @@
|
||||
import {Component, EventEmitter, Input, Output} from '@angular/core';
|
||||
import {Component, EventEmitter, inject, Input, Output} from '@angular/core';
|
||||
import {SortDirection, SortOption} from '../../../../model/sort.model';
|
||||
import {CdkDrag, CdkDragDrop, CdkDragHandle, CdkDropList, moveItemInArray} from '@angular/cdk/drag-drop';
|
||||
import {Select} from 'primeng/select';
|
||||
import {FormsModule} from '@angular/forms';
|
||||
import {Tooltip} from 'primeng/tooltip';
|
||||
import {Button} from 'primeng/button';
|
||||
import {TranslocoDirective, TranslocoService} from '@jsverse/transloco';
|
||||
|
||||
@Component({
|
||||
selector: 'app-multi-sort-popover',
|
||||
@@ -16,12 +17,14 @@ import {Button} from 'primeng/button';
|
||||
Select,
|
||||
FormsModule,
|
||||
Tooltip,
|
||||
Button
|
||||
Button,
|
||||
TranslocoDirective
|
||||
],
|
||||
templateUrl: './multi-sort-popover.component.html',
|
||||
styleUrl: './multi-sort-popover.component.scss'
|
||||
})
|
||||
export class MultiSortPopoverComponent {
|
||||
private readonly t = inject(TranslocoService);
|
||||
@Input() sortCriteria: SortOption[] = [];
|
||||
@Input() availableSortOptions: SortOption[] = [];
|
||||
@Input() showSaveButton = false;
|
||||
@@ -79,7 +82,9 @@ export class MultiSortPopoverComponent {
|
||||
}
|
||||
|
||||
getDirectionTooltip(direction: SortDirection): string {
|
||||
return direction === SortDirection.ASCENDING ? 'Ascending - click to change' : 'Descending - click to change';
|
||||
return direction === SortDirection.ASCENDING
|
||||
? this.t.translate('book.sorting.ascendingTooltip')
|
||||
: this.t.translate('book.sorting.descendingTooltip');
|
||||
}
|
||||
|
||||
protected readonly SortDirection = SortDirection;
|
||||
|
||||
+24
-40
@@ -1,6 +1,7 @@
|
||||
import {inject, Injectable} from '@angular/core';
|
||||
import {BehaviorSubject} from 'rxjs';
|
||||
import {MessageService} from 'primeng/api';
|
||||
import {TranslocoService} from '@jsverse/transloco';
|
||||
import {TableColumnPreference, UserService} from '../../../settings/user-management/user.service';
|
||||
|
||||
@Injectable({
|
||||
@@ -9,37 +10,21 @@ import {TableColumnPreference, UserService} from '../../../settings/user-managem
|
||||
export class TableColumnPreferenceService {
|
||||
private readonly userService = inject(UserService);
|
||||
private readonly messageService = inject(MessageService);
|
||||
private readonly t = inject(TranslocoService);
|
||||
|
||||
private readonly preferencesSubject = new BehaviorSubject<TableColumnPreference[]>([]);
|
||||
readonly preferences$ = this.preferencesSubject.asObservable();
|
||||
|
||||
private readonly allAvailableColumns = [
|
||||
{field: 'readStatus', header: 'Read'},
|
||||
{field: 'title', header: 'Title'},
|
||||
{field: 'authors', header: 'Authors'},
|
||||
{field: 'publisher', header: 'Publisher'},
|
||||
{field: 'seriesName', header: 'Series'},
|
||||
{field: 'seriesNumber', header: 'Series #'},
|
||||
{field: 'categories', header: 'Genres'},
|
||||
{field: 'publishedDate', header: 'Published'},
|
||||
{field: 'lastReadTime', header: 'Last Read'},
|
||||
{field: 'addedOn', header: 'Added'},
|
||||
{field: 'fileName', header: 'File Name'},
|
||||
{field: 'fileSizeKb', header: 'File Size'},
|
||||
{field: 'language', header: 'Language'},
|
||||
{field: 'isbn', header: 'ISBN'},
|
||||
{field: 'pageCount', header: 'Pages'},
|
||||
{field: 'amazonRating', header: 'Amazon'},
|
||||
{field: 'amazonReviewCount', header: 'AZ #'},
|
||||
{field: 'goodreadsRating', header: 'Goodreads'},
|
||||
{field: 'goodreadsReviewCount', header: 'GR #'},
|
||||
{field: 'hardcoverRating', header: 'Hardcover'},
|
||||
{field: 'hardcoverReviewCount', header: 'HC #'},
|
||||
{field: 'ranobedbRating', header: 'Ranobedb'},
|
||||
private readonly allAvailableFields = [
|
||||
'readStatus', 'title', 'authors', 'publisher', 'seriesName', 'seriesNumber',
|
||||
'categories', 'publishedDate', 'lastReadTime', 'addedOn', 'fileName', 'fileSizeKb',
|
||||
'language', 'isbn', 'pageCount', 'amazonRating', 'amazonReviewCount',
|
||||
'goodreadsRating', 'goodreadsReviewCount', 'hardcoverRating', 'hardcoverReviewCount',
|
||||
'ranobedbRating',
|
||||
];
|
||||
|
||||
private readonly fallbackPreferences: TableColumnPreference[] = this.allAvailableColumns.map((col, index) => ({
|
||||
field: col.field,
|
||||
private readonly fallbackPreferences: TableColumnPreference[] = this.allAvailableFields.map((field, index) => ({
|
||||
field,
|
||||
visible: true,
|
||||
order: index
|
||||
}));
|
||||
@@ -50,7 +35,10 @@ export class TableColumnPreferenceService {
|
||||
}
|
||||
|
||||
get allColumns(): { field: string; header: string }[] {
|
||||
return this.allAvailableColumns;
|
||||
return this.allAvailableFields.map(field => ({
|
||||
field,
|
||||
header: this.t.translate(`book.columnPref.columns.${field}`)
|
||||
}));
|
||||
}
|
||||
|
||||
get visibleColumns(): { field: string; header: string }[] {
|
||||
@@ -59,7 +47,7 @@ export class TableColumnPreferenceService {
|
||||
.sort((a, b) => a.order - b.order)
|
||||
.map(pref => ({
|
||||
field: pref.field,
|
||||
header: this.getColumnHeader(pref.field)
|
||||
header: this.t.translate(`book.columnPref.columns.${pref.field}`)
|
||||
}));
|
||||
}
|
||||
|
||||
@@ -70,11 +58,11 @@ export class TableColumnPreferenceService {
|
||||
saveVisibleColumns(selectedColumns: { field: string }[]): void {
|
||||
const selectedFieldSet = new Set(selectedColumns.map(c => c.field));
|
||||
|
||||
const updatedPreferences: TableColumnPreference[] = this.allAvailableColumns.map((col, index) => {
|
||||
const selectionIndex = selectedColumns.findIndex(c => c.field === col.field);
|
||||
const updatedPreferences: TableColumnPreference[] = this.allAvailableFields.map((field, index) => {
|
||||
const selectionIndex = selectedColumns.findIndex(c => c.field === field);
|
||||
return {
|
||||
field: col.field,
|
||||
visible: selectedFieldSet.has(col.field),
|
||||
field,
|
||||
visible: selectedFieldSet.has(field),
|
||||
order: selectionIndex >= 0 ? selectionIndex : index
|
||||
};
|
||||
});
|
||||
@@ -88,23 +76,19 @@ export class TableColumnPreferenceService {
|
||||
|
||||
this.messageService.add({
|
||||
severity: 'success',
|
||||
summary: 'Preferences Saved',
|
||||
detail: 'Your column layout has been saved.',
|
||||
summary: this.t.translate('book.columnPref.toast.savedSummary'),
|
||||
detail: this.t.translate('book.columnPref.toast.savedDetail'),
|
||||
life: 1500
|
||||
});
|
||||
}
|
||||
|
||||
private getColumnHeader(field: string): string {
|
||||
return this.allAvailableColumns.find(col => col.field === field)?.header ?? field;
|
||||
}
|
||||
|
||||
private mergeWithAllColumns(savedPrefs: TableColumnPreference[]): TableColumnPreference[] {
|
||||
const savedPrefMap = new Map(savedPrefs.map(p => [p.field, p]));
|
||||
|
||||
return this.allAvailableColumns.map((col, index) => {
|
||||
const saved = savedPrefMap.get(col.field);
|
||||
return this.allAvailableFields.map((field, index) => {
|
||||
const saved = savedPrefMap.get(field);
|
||||
return {
|
||||
field: col.field,
|
||||
field,
|
||||
visible: saved?.visible ?? true,
|
||||
order: saved?.order ?? index
|
||||
};
|
||||
|
||||
+15
-13
@@ -1,11 +1,12 @@
|
||||
<ng-container *transloco="let t; prefix: 'book.fileAttacher'">
|
||||
<div class="book-file-attacher-container">
|
||||
<div class="panel-header">
|
||||
<div class="header-icon-wrapper">
|
||||
<i class="pi pi-link header-icon"></i>
|
||||
</div>
|
||||
<div class="header-text">
|
||||
<h2 class="panel-title">Attach {{ isBulkMode ? 'Files' : 'File' }} to Another Book</h2>
|
||||
<p class="panel-description">Move {{ isBulkMode ? 'these books\' files' : 'this book\'s file' }} to another book as alternative format{{ isBulkMode ? 's' : '' }}</p>
|
||||
<h2 class="panel-title">{{ isBulkMode ? t('titleBulk') : t('title') }}</h2>
|
||||
<p class="panel-description">{{ isBulkMode ? t('descriptionBulk') : t('description') }}</p>
|
||||
</div>
|
||||
<p-button
|
||||
icon="pi pi-times"
|
||||
@@ -20,11 +21,11 @@
|
||||
<div class="dialog-content">
|
||||
<!-- Source Book(s) Info -->
|
||||
<div class="source-info">
|
||||
<h3 class="section-title">Source Book{{ isBulkMode ? 's' : '' }} ({{ sourceBooks.length }})</h3>
|
||||
<h3 class="section-title">{{ isBulkMode ? t('sourceBooksLabel', { count: sourceBooks.length }) : t('sourceBookLabel', { count: sourceBooks.length }) }}</h3>
|
||||
<div class="source-books-list">
|
||||
@for (book of sourceBooks; track book.id) {
|
||||
<div class="book-info-card">
|
||||
<div class="book-title">{{ book.metadata?.title || 'Unknown Title' }}</div>
|
||||
<div class="book-title">{{ book.metadata?.title || t('unknownTitle') }}</div>
|
||||
@if (book.metadata?.authors?.length) {
|
||||
<div class="book-authors">{{ book.metadata?.authors?.join(', ') }}</div>
|
||||
}
|
||||
@@ -39,7 +40,7 @@
|
||||
|
||||
<!-- Target Book Selection -->
|
||||
<div class="target-selection">
|
||||
<h3 class="section-title">Select Target Book</h3>
|
||||
<h3 class="section-title">{{ t('selectTargetBook') }}</h3>
|
||||
<p-autocomplete
|
||||
[(ngModel)]="targetBook"
|
||||
[suggestions]="filteredBooks"
|
||||
@@ -49,12 +50,12 @@
|
||||
optionLabel="metadata.title"
|
||||
[dropdown]="true"
|
||||
[showClear]="true"
|
||||
placeholder="Search for a book in the same library..."
|
||||
[placeholder]="t('searchPlaceholder')"
|
||||
class="full-width"
|
||||
[disabled]="isAttaching">
|
||||
<ng-template let-book pTemplate="item">
|
||||
<div class="book-suggestion">
|
||||
<div class="suggestion-title">{{ book.metadata?.title || 'Unknown Title' }}</div>
|
||||
<div class="suggestion-title">{{ book.metadata?.title || t('unknownTitle') }}</div>
|
||||
@if (book.metadata?.authors?.length) {
|
||||
<div class="suggestion-authors">{{ book.metadata.authors.join(', ') }}</div>
|
||||
}
|
||||
@@ -78,7 +79,7 @@
|
||||
[disabled]="isAttaching">
|
||||
</p-checkbox>
|
||||
<label for="deleteSourceBooks" class="delete-label">
|
||||
Delete source book{{ isBulkMode ? 's' : '' }} after attachment
|
||||
{{ isBulkMode ? t('deleteSourceBulk') : t('deleteSource') }}
|
||||
</label>
|
||||
</div>
|
||||
|
||||
@@ -86,11 +87,11 @@
|
||||
<div class="warning-message">
|
||||
<i class="pi pi-info-circle"></i>
|
||||
<div class="warning-text">
|
||||
<p>This will move {{ isBulkMode ? 'the files from the selected books' : 'the file from the source book' }} to the target book as alternative format{{ isBulkMode ? 's' : '' }}.</p>
|
||||
<p>{{ isBulkMode ? t('warningMoveBulk') : t('warningMove') }}</p>
|
||||
@if (deleteSourceBooks) {
|
||||
<p>The source book{{ isBulkMode ? ' records' : ' record' }} will be deleted (file{{ isBulkMode ? 's' : '' }} will be preserved in target book).</p>
|
||||
<p>{{ isBulkMode ? t('warningDeleteBulk') : t('warningDelete') }}</p>
|
||||
} @else {
|
||||
<p>The source book{{ isBulkMode ? ' records' : ' record' }} will remain but will have no readable files.</p>
|
||||
<p>{{ isBulkMode ? t('warningKeepBulk') : t('warningKeep') }}</p>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
@@ -98,14 +99,14 @@
|
||||
<!-- Action Buttons -->
|
||||
<div class="action-buttons">
|
||||
<p-button
|
||||
label="Cancel"
|
||||
[label]="'common.cancel' | transloco"
|
||||
[outlined]="true"
|
||||
severity="secondary"
|
||||
(click)="closeDialog()"
|
||||
[disabled]="isAttaching">
|
||||
</p-button>
|
||||
<p-button
|
||||
label="Attach {{ isBulkMode ? 'Files' : 'File' }}"
|
||||
[label]="isBulkMode ? t('attachFilesBulk') : t('attachFile')"
|
||||
icon="pi pi-link"
|
||||
(click)="attach()"
|
||||
[disabled]="!canAttach()"
|
||||
@@ -114,3 +115,4 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</ng-container>
|
||||
|
||||
+10
-5
@@ -1,4 +1,4 @@
|
||||
import { Component, OnInit, OnDestroy } from '@angular/core';
|
||||
import { Component, inject, OnInit, OnDestroy } from '@angular/core';
|
||||
import { FormsModule } from '@angular/forms';
|
||||
import { DynamicDialogRef, DynamicDialogConfig } from 'primeng/dynamicdialog';
|
||||
import { AutoComplete, AutoCompleteSelectEvent } from 'primeng/autocomplete';
|
||||
@@ -9,6 +9,7 @@ import { filter, take } from 'rxjs/operators';
|
||||
import { BookService } from '../../service/book.service';
|
||||
import { Book } from '../../model/book.model';
|
||||
import { MessageService } from 'primeng/api';
|
||||
import { TranslocoDirective, TranslocoPipe, TranslocoService } from '@jsverse/transloco';
|
||||
|
||||
@Component({
|
||||
selector: 'app-book-file-attacher',
|
||||
@@ -17,7 +18,9 @@ import { MessageService } from 'primeng/api';
|
||||
FormsModule,
|
||||
AutoComplete,
|
||||
Button,
|
||||
Checkbox
|
||||
Checkbox,
|
||||
TranslocoDirective,
|
||||
TranslocoPipe,
|
||||
],
|
||||
templateUrl: './book-file-attacher.component.html',
|
||||
styleUrls: ['./book-file-attacher.component.scss']
|
||||
@@ -33,6 +36,8 @@ export class BookFileAttacherComponent implements OnInit, OnDestroy {
|
||||
private destroy$ = new Subject<void>();
|
||||
private allBooks: Book[] = [];
|
||||
|
||||
private readonly t = inject(TranslocoService);
|
||||
|
||||
constructor(
|
||||
private dialogRef: DynamicDialogRef,
|
||||
private config: DynamicDialogConfig,
|
||||
@@ -110,9 +115,9 @@ export class BookFileAttacherComponent implements OnInit, OnDestroy {
|
||||
|
||||
getSourceFileInfo(book: Book): string {
|
||||
const file = book.primaryFile;
|
||||
if (!file) return 'Unknown file';
|
||||
const format = file.extension?.toUpperCase() || file.bookType || 'Unknown';
|
||||
return `${format} - ${file.fileName || 'Unknown filename'}`;
|
||||
if (!file) return this.t.translate('book.fileAttacher.unknownFile');
|
||||
const format = file.extension?.toUpperCase() || file.bookType || this.t.translate('book.fileAttacher.unknownFormat');
|
||||
return `${format} - ${file.fileName || this.t.translate('book.fileAttacher.unknownFilename')}`;
|
||||
}
|
||||
|
||||
canAttach(): boolean {
|
||||
|
||||
@@ -10,6 +10,7 @@ import {ConfirmDialog} from 'primeng/confirmdialog';
|
||||
import {ProgressSpinner} from 'primeng/progressspinner';
|
||||
import {Tooltip} from 'primeng/tooltip';
|
||||
import {ConfirmationService, MessageService} from 'primeng/api';
|
||||
import {TranslocoService} from '@jsverse/transloco';
|
||||
import {BookNote, BookNoteService, CreateBookNoteRequest} from '../../../../shared/service/book-note.service';
|
||||
|
||||
@Component({
|
||||
@@ -36,6 +37,7 @@ export class BookNotesComponent implements OnInit, OnChanges {
|
||||
private confirmationService = inject(ConfirmationService);
|
||||
private messageService = inject(MessageService);
|
||||
private destroyRef = inject(DestroyRef);
|
||||
private readonly t = inject(TranslocoService);
|
||||
|
||||
notes: BookNote[] = [];
|
||||
loading = false;
|
||||
@@ -85,8 +87,8 @@ export class BookNotesComponent implements OnInit, OnChanges {
|
||||
this.loading = false;
|
||||
this.messageService.add({
|
||||
severity: 'error',
|
||||
summary: 'Error',
|
||||
detail: 'Failed to load notes for this book.'
|
||||
summary: this.t.translate('common.error'),
|
||||
detail: this.t.translate('book.notes.toast.loadFailedDetail')
|
||||
});
|
||||
}
|
||||
});
|
||||
@@ -116,8 +118,8 @@ export class BookNotesComponent implements OnInit, OnChanges {
|
||||
if (!this.newNote.title.trim() || !this.newNote.content.trim()) {
|
||||
this.messageService.add({
|
||||
severity: 'warn',
|
||||
summary: 'Validation Error',
|
||||
detail: 'Both title and content are required.'
|
||||
summary: this.t.translate('book.notes.toast.validationSummary'),
|
||||
detail: this.t.translate('book.notes.toast.validationDetail')
|
||||
});
|
||||
return;
|
||||
}
|
||||
@@ -130,16 +132,16 @@ export class BookNotesComponent implements OnInit, OnChanges {
|
||||
this.showCreateDialog = false;
|
||||
this.messageService.add({
|
||||
severity: 'success',
|
||||
summary: 'Success',
|
||||
detail: 'Note created successfully.'
|
||||
summary: this.t.translate('common.success'),
|
||||
detail: this.t.translate('book.notes.toast.createSuccessDetail')
|
||||
});
|
||||
},
|
||||
error: (error) => {
|
||||
console.error('Failed to create note:', error);
|
||||
this.messageService.add({
|
||||
severity: 'error',
|
||||
summary: 'Error',
|
||||
detail: 'Failed to create note.'
|
||||
summary: this.t.translate('common.error'),
|
||||
detail: this.t.translate('book.notes.toast.createFailedDetail')
|
||||
});
|
||||
}
|
||||
});
|
||||
@@ -149,8 +151,8 @@ export class BookNotesComponent implements OnInit, OnChanges {
|
||||
if (!this.editNote.title?.trim() || !this.editNote.content?.trim()) {
|
||||
this.messageService.add({
|
||||
severity: 'warn',
|
||||
summary: 'Validation Error',
|
||||
detail: 'Both title and content are required.'
|
||||
summary: this.t.translate('book.notes.toast.validationSummary'),
|
||||
detail: this.t.translate('book.notes.toast.validationDetail')
|
||||
});
|
||||
return;
|
||||
}
|
||||
@@ -170,16 +172,16 @@ export class BookNotesComponent implements OnInit, OnChanges {
|
||||
this.selectedNote = null;
|
||||
this.messageService.add({
|
||||
severity: 'success',
|
||||
summary: 'Success',
|
||||
detail: 'Note updated successfully.'
|
||||
summary: this.t.translate('common.success'),
|
||||
detail: this.t.translate('book.notes.toast.updateSuccessDetail')
|
||||
});
|
||||
},
|
||||
error: (error) => {
|
||||
console.error('Failed to update note:', error);
|
||||
this.messageService.add({
|
||||
severity: 'error',
|
||||
summary: 'Error',
|
||||
detail: 'Failed to update note.'
|
||||
summary: this.t.translate('common.error'),
|
||||
detail: this.t.translate('book.notes.toast.updateFailedDetail')
|
||||
});
|
||||
}
|
||||
});
|
||||
@@ -188,8 +190,8 @@ export class BookNotesComponent implements OnInit, OnChanges {
|
||||
deleteNote(note: BookNote): void {
|
||||
this.confirmationService.confirm({
|
||||
key: 'deleteNote',
|
||||
message: `Are you sure you want to delete the note "${note.title}"?`,
|
||||
header: 'Confirm Deletion',
|
||||
message: this.t.translate('book.notes.confirm.deleteMessage', {title: note.title}),
|
||||
header: this.t.translate('book.notes.confirm.deleteHeader'),
|
||||
icon: 'pi pi-exclamation-triangle',
|
||||
acceptIcon: 'pi pi-trash',
|
||||
rejectIcon: 'pi pi-times',
|
||||
@@ -207,16 +209,16 @@ export class BookNotesComponent implements OnInit, OnChanges {
|
||||
this.notes = this.notes.filter(n => n.id !== noteId);
|
||||
this.messageService.add({
|
||||
severity: 'success',
|
||||
summary: 'Success',
|
||||
detail: 'Note deleted successfully.'
|
||||
summary: this.t.translate('common.success'),
|
||||
detail: this.t.translate('book.notes.toast.deleteSuccessDetail')
|
||||
});
|
||||
},
|
||||
error: (error) => {
|
||||
console.error('Failed to delete note:', error);
|
||||
this.messageService.add({
|
||||
severity: 'error',
|
||||
summary: 'Error',
|
||||
detail: 'Failed to delete note.'
|
||||
summary: this.t.translate('common.error'),
|
||||
detail: this.t.translate('book.notes.toast.deleteFailedDetail')
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
+19
-17
@@ -1,9 +1,10 @@
|
||||
<ng-container *transloco="let t; prefix: 'book.reviews'">
|
||||
<div class="book-reviews-container">
|
||||
<div class="reviews-content">
|
||||
@if (loading) {
|
||||
<div class="loading-state">
|
||||
<p-progressSpinner/>
|
||||
<span class="loading-text">Getting latest reviews...</span>
|
||||
<span class="loading-text">{{ t('labels.loadingReviews') }}</span>
|
||||
</div>
|
||||
} @else if (reviews?.length === 0) {
|
||||
<div class="empty-state">
|
||||
@@ -15,20 +16,20 @@
|
||||
icon="pi pi-download"
|
||||
severity="primary"
|
||||
(click)="fetchNewReviews()"
|
||||
pTooltip="Fetch Reviews"
|
||||
[pTooltip]="t('tooltip.fetchReviews')"
|
||||
tooltipPosition="top"
|
||||
class="action-btn floating-btn">
|
||||
</p-button>
|
||||
}
|
||||
</div>
|
||||
<p class="empty-state-title">No reviews available for this book</p>
|
||||
<p class="empty-state-title">{{ t('empty.noReviews') }}</p>
|
||||
@if (!reviewDownloadEnabled) {
|
||||
<p class="empty-state-subtitle empty-state-subtitle--warning">
|
||||
Book review downloads are currently disabled. Enable this in Metadata Settings to fetch reviews.
|
||||
{{ t('empty.downloadsDisabled') }}
|
||||
</p>
|
||||
} @else if (hasPermission && !reviewsLocked) {
|
||||
<p class="empty-state-subtitle">
|
||||
Click "Fetch Reviews" to download reviews from configured providers
|
||||
{{ t('empty.fetchPrompt') }}
|
||||
</p>
|
||||
}
|
||||
<div class="empty-state-decoration"></div>
|
||||
@@ -40,7 +41,7 @@
|
||||
<div [class]="'review-card' + (!review.title ? ' no-title' : '') + (review.spoiler && !isSpoilerRevealed(review.id!) ? ' has-spoiler' : '')">
|
||||
@if (review.spoiler && !isSpoilerRevealed(review.id!)) {
|
||||
<p-button
|
||||
label="Show Spoiler"
|
||||
[label]="t('labels.showSpoiler')"
|
||||
icon="pi pi-eye"
|
||||
severity="warn"
|
||||
size="small"
|
||||
@@ -52,7 +53,7 @@
|
||||
<div class="review-header-inner">
|
||||
<div class="reviewer-info-group">
|
||||
<div class="reviewer-name-row">
|
||||
<span class="reviewer-name">{{ review.reviewerName || 'Anonymous' }}</span>
|
||||
<span class="reviewer-name">{{ review.reviewerName || t('labels.anonymous') }}</span>
|
||||
@if (review.metadataProvider) {
|
||||
<p-tag
|
||||
[rounded]="true"
|
||||
@@ -63,7 +64,7 @@
|
||||
<p-tag [rounded]="true" [value]="review.country" severity="info"/>
|
||||
}
|
||||
@if (review.spoiler) {
|
||||
<p-tag [rounded]="true" value="Spoiler" severity="warn" icon="pi pi-exclamation-triangle"/>
|
||||
<p-tag [rounded]="true" [value]="t('labels.spoiler')" severity="warn" icon="pi pi-exclamation-triangle"/>
|
||||
}
|
||||
</div>
|
||||
<div class="review-meta">
|
||||
@@ -89,7 +90,7 @@
|
||||
@if (reviewsLocked) {
|
||||
<div class="lock-icon-container">
|
||||
<i class="pi pi-lock lock-icon"
|
||||
pTooltip="Reviews are locked"
|
||||
[pTooltip]="t('tooltip.reviewsLocked')"
|
||||
tooltipPosition="top"></i>
|
||||
</div>
|
||||
} @else {
|
||||
@@ -99,7 +100,7 @@
|
||||
severity="danger"
|
||||
text
|
||||
(onClick)="deleteReview(review)"
|
||||
pTooltip="Delete Review"
|
||||
[pTooltip]="t('tooltip.deleteReview')"
|
||||
tooltipPosition="top"
|
||||
class="action-btn-hover"/>
|
||||
}
|
||||
@@ -126,14 +127,14 @@
|
||||
@if (review.body) {
|
||||
<div class="review-body review-body--blurred">{{ review.body }}</div>
|
||||
} @else {
|
||||
<div class="review-empty-text review-empty-text--blurred">No review content available</div>
|
||||
<div class="review-empty-text review-empty-text--blurred">{{ t('empty.noContent') }}</div>
|
||||
}
|
||||
</div>
|
||||
} @else {
|
||||
@if (review.body) {
|
||||
<div class="review-body">{{ review.body }}</div>
|
||||
} @else {
|
||||
<div class="review-empty-text">No review content available</div>
|
||||
<div class="review-empty-text">{{ t('empty.noContent') }}</div>
|
||||
}
|
||||
}
|
||||
<div class="review-fade-overlay"></div>
|
||||
@@ -157,7 +158,7 @@
|
||||
[severity]="reviewsLocked ? 'danger' : 'success'"
|
||||
[disabled]="!reviewDownloadEnabled || loading"
|
||||
(click)="toggleReviewsLock()"
|
||||
[pTooltip]="loading ? 'Please wait while reviews are being fetched' : (!reviewDownloadEnabled ? 'Enable review downloads in settings to use this feature' : (reviewsLocked ? 'Unlock Reviews' : 'Lock Reviews'))"
|
||||
[pTooltip]="loading ? t('tooltip.pleaseWait') : (!reviewDownloadEnabled ? t('tooltip.enableDownloads') : (reviewsLocked ? t('tooltip.unlockReviews') : t('tooltip.lockReviews')))"
|
||||
tooltipPosition="left"
|
||||
class="action-btn"/>
|
||||
|
||||
@@ -169,7 +170,7 @@
|
||||
[loading]="loading"
|
||||
[disabled]="reviewsLocked || !reviewDownloadEnabled || loading"
|
||||
(click)="fetchNewReviews()"
|
||||
[pTooltip]="loading ? 'Please wait while reviews are being fetched' : (!reviewDownloadEnabled ? 'Enable review downloads in settings to use this feature' : (reviewsLocked ? 'Reviews are locked' : 'Fetch New Reviews'))"
|
||||
[pTooltip]="loading ? t('tooltip.pleaseWait') : (!reviewDownloadEnabled ? t('tooltip.enableDownloads') : (reviewsLocked ? t('tooltip.reviewsLocked') : t('tooltip.fetchNewReviews')))"
|
||||
tooltipPosition="left"
|
||||
class="action-btn"/>
|
||||
}
|
||||
@@ -182,7 +183,7 @@
|
||||
severity="danger"
|
||||
[disabled]="reviewsLocked || loading"
|
||||
(click)="deleteAllReviews()"
|
||||
[pTooltip]="loading ? 'Please wait while reviews are being fetched' : (reviewsLocked ? 'Reviews are locked' : 'Delete All Reviews')"
|
||||
[pTooltip]="loading ? t('tooltip.pleaseWait') : (reviewsLocked ? t('tooltip.reviewsLocked') : t('tooltip.deleteAllReviews'))"
|
||||
tooltipPosition="left"
|
||||
class="action-btn"/>
|
||||
}
|
||||
@@ -195,7 +196,7 @@
|
||||
[severity]="allSpoilersRevealed ? 'warn' : 'info'"
|
||||
[disabled]="loading"
|
||||
(click)="toggleSpoilerVisibility()"
|
||||
[pTooltip]="loading ? 'Please wait while reviews are being fetched' : (allSpoilersRevealed ? 'Hide All Spoilers' : 'Reveal All Spoilers')"
|
||||
[pTooltip]="loading ? t('tooltip.pleaseWait') : (allSpoilersRevealed ? t('tooltip.hideAllSpoilers') : t('tooltip.revealAllSpoilers'))"
|
||||
tooltipPosition="left"
|
||||
class="action-btn"/>
|
||||
|
||||
@@ -206,10 +207,11 @@
|
||||
severity="contrast"
|
||||
[disabled]="loading"
|
||||
(click)="toggleSortOrder()"
|
||||
[pTooltip]="loading ? 'Please wait while reviews are being fetched' : (sortAscending ? 'Sort by Newest First' : 'Sort by Oldest First')"
|
||||
[pTooltip]="loading ? t('tooltip.pleaseWait') : (sortAscending ? t('tooltip.sortNewest') : t('tooltip.sortOldest'))"
|
||||
tooltipPosition="left"
|
||||
class="action-btn"/>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</ng-container>
|
||||
|
||||
+25
-26
@@ -7,6 +7,7 @@ import {Rating} from 'primeng/rating';
|
||||
import {Tag} from 'primeng/tag';
|
||||
import {Button} from 'primeng/button';
|
||||
import {ConfirmationService, MessageService} from 'primeng/api';
|
||||
import {TranslocoDirective, TranslocoService} from '@jsverse/transloco';
|
||||
import {UserService} from '../../../settings/user-management/user.service';
|
||||
import {FormsModule} from '@angular/forms';
|
||||
import {Tooltip} from 'primeng/tooltip';
|
||||
@@ -16,7 +17,7 @@ import {AppSettingsService} from '../../../../shared/service/app-settings.servic
|
||||
@Component({
|
||||
selector: 'app-book-reviews',
|
||||
standalone: true,
|
||||
imports: [ProgressSpinner, Rating, Tag, Button, FormsModule, Tooltip],
|
||||
imports: [ProgressSpinner, Rating, Tag, Button, FormsModule, Tooltip, TranslocoDirective],
|
||||
templateUrl: './book-reviews.component.html',
|
||||
styleUrl: './book-reviews.component.scss'
|
||||
})
|
||||
@@ -32,6 +33,7 @@ export class BookReviewsComponent implements OnInit, OnChanges {
|
||||
private userService = inject(UserService);
|
||||
private appSettingsService = inject(AppSettingsService);
|
||||
private destroyRef = inject(DestroyRef);
|
||||
private readonly t = inject(TranslocoService);
|
||||
|
||||
loading = false;
|
||||
hasPermission = false;
|
||||
@@ -84,8 +86,8 @@ export class BookReviewsComponent implements OnInit, OnChanges {
|
||||
|
||||
this.messageService.add({
|
||||
severity: 'error',
|
||||
summary: 'Failed to Load Reviews',
|
||||
detail: 'Could not load reviews for this book.',
|
||||
summary: this.t.translate('book.reviews.toast.loadFailedSummary'),
|
||||
detail: this.t.translate('book.reviews.toast.loadFailedDetail'),
|
||||
life: 3000
|
||||
});
|
||||
}
|
||||
@@ -107,8 +109,8 @@ export class BookReviewsComponent implements OnInit, OnChanges {
|
||||
this.updateSpoilerState();
|
||||
this.messageService.add({
|
||||
severity: 'success',
|
||||
summary: 'Reviews Updated',
|
||||
detail: 'Latest reviews have been fetched successfully.',
|
||||
summary: this.t.translate('book.reviews.toast.reviewsUpdatedSummary'),
|
||||
detail: this.t.translate('book.reviews.toast.reviewsUpdatedDetail'),
|
||||
life: 3000
|
||||
});
|
||||
},
|
||||
@@ -117,8 +119,8 @@ export class BookReviewsComponent implements OnInit, OnChanges {
|
||||
this.loading = false;
|
||||
this.messageService.add({
|
||||
severity: 'error',
|
||||
summary: 'Fetch Failed',
|
||||
detail: 'Could not fetch new reviews for this book.',
|
||||
summary: this.t.translate('book.reviews.toast.fetchFailedSummary'),
|
||||
detail: this.t.translate('book.reviews.toast.fetchFailedDetail'),
|
||||
life: 3000
|
||||
});
|
||||
}
|
||||
@@ -129,8 +131,8 @@ export class BookReviewsComponent implements OnInit, OnChanges {
|
||||
if (!this.reviews || this.reviews.length === 0 || this.reviewsLocked) return;
|
||||
|
||||
this.confirmationService.confirm({
|
||||
message: `Are you sure you want to delete all ${this.reviews.length} reviews for this book? This action cannot be undone.`,
|
||||
header: 'Confirm Delete All',
|
||||
message: this.t.translate('book.reviews.confirm.deleteAllMessage', {count: this.reviews.length}),
|
||||
header: this.t.translate('book.reviews.confirm.deleteAllHeader'),
|
||||
icon: 'pi pi-exclamation-triangle',
|
||||
acceptIcon: 'pi pi-trash',
|
||||
rejectIcon: 'pi pi-times',
|
||||
@@ -145,8 +147,8 @@ export class BookReviewsComponent implements OnInit, OnChanges {
|
||||
this.allSpoilersRevealed = false;
|
||||
this.messageService.add({
|
||||
severity: 'success',
|
||||
summary: 'All Reviews Deleted',
|
||||
detail: 'All reviews have been successfully deleted.',
|
||||
summary: this.t.translate('book.reviews.toast.allDeletedSummary'),
|
||||
detail: this.t.translate('book.reviews.toast.allDeletedDetail'),
|
||||
life: 3000
|
||||
});
|
||||
},
|
||||
@@ -154,8 +156,8 @@ export class BookReviewsComponent implements OnInit, OnChanges {
|
||||
console.error('Failed to delete all reviews:', error);
|
||||
this.messageService.add({
|
||||
severity: 'error',
|
||||
summary: 'Delete Failed',
|
||||
detail: 'Could not delete all reviews.',
|
||||
summary: this.t.translate('book.reviews.toast.deleteAllFailedSummary'),
|
||||
detail: this.t.translate('book.reviews.toast.deleteAllFailedDetail'),
|
||||
life: 3000
|
||||
});
|
||||
}
|
||||
@@ -200,13 +202,10 @@ export class BookReviewsComponent implements OnInit, OnChanges {
|
||||
.pipe(takeUntilDestroyed(this.destroyRef))
|
||||
.subscribe({
|
||||
next: () => {
|
||||
const action = newLockState ? 'locked' : 'unlocked';
|
||||
this.messageService.add({
|
||||
severity: 'info',
|
||||
summary: `Reviews ${action.charAt(0).toUpperCase() + action.slice(1)}`,
|
||||
detail: newLockState
|
||||
? 'Reviews are now protected from modifications and refreshes.'
|
||||
: 'Reviews can now be modified and refreshed.',
|
||||
summary: this.t.translate(newLockState ? 'book.reviews.toast.lockedSummary' : 'book.reviews.toast.unlockedSummary'),
|
||||
detail: this.t.translate(newLockState ? 'book.reviews.toast.lockedDetail' : 'book.reviews.toast.unlockedDetail'),
|
||||
life: 3000
|
||||
});
|
||||
},
|
||||
@@ -214,8 +213,8 @@ export class BookReviewsComponent implements OnInit, OnChanges {
|
||||
console.error('Failed to toggle lock status:', error);
|
||||
this.messageService.add({
|
||||
severity: 'error',
|
||||
summary: 'Lock Toggle Failed',
|
||||
detail: 'Could not change the lock status for reviews.',
|
||||
summary: this.t.translate('book.reviews.toast.lockFailedSummary'),
|
||||
detail: this.t.translate('book.reviews.toast.lockFailedDetail'),
|
||||
life: 3000
|
||||
});
|
||||
}
|
||||
@@ -255,8 +254,8 @@ export class BookReviewsComponent implements OnInit, OnChanges {
|
||||
if (!review.id || this.reviewsLocked) return;
|
||||
|
||||
this.confirmationService.confirm({
|
||||
message: `Are you sure you want to delete this review by ${review.reviewerName || 'Anonymous'}?`,
|
||||
header: 'Confirm Deletion',
|
||||
message: this.t.translate('book.reviews.confirm.deleteMessage', {reviewer: review.reviewerName || 'Anonymous'}),
|
||||
header: this.t.translate('book.reviews.confirm.deleteHeader'),
|
||||
icon: 'pi pi-exclamation-triangle',
|
||||
acceptIcon: 'pi pi-trash',
|
||||
rejectIcon: 'pi pi-times',
|
||||
@@ -268,8 +267,8 @@ export class BookReviewsComponent implements OnInit, OnChanges {
|
||||
this.updateSpoilerState();
|
||||
this.messageService.add({
|
||||
severity: 'success',
|
||||
summary: 'Review Deleted',
|
||||
detail: 'The review has been successfully deleted.',
|
||||
summary: this.t.translate('book.reviews.toast.deleteSuccessSummary'),
|
||||
detail: this.t.translate('book.reviews.toast.deleteSuccessDetail'),
|
||||
life: 2000
|
||||
});
|
||||
},
|
||||
@@ -277,8 +276,8 @@ export class BookReviewsComponent implements OnInit, OnChanges {
|
||||
console.error('Failed to delete review:', error);
|
||||
this.messageService.add({
|
||||
severity: 'error',
|
||||
summary: 'Delete Failed',
|
||||
detail: 'Could not delete the review.',
|
||||
summary: this.t.translate('book.reviews.toast.deleteFailedSummary'),
|
||||
detail: this.t.translate('book.reviews.toast.deleteFailedDetail'),
|
||||
life: 3000
|
||||
});
|
||||
}
|
||||
|
||||
+7
-5
@@ -1,3 +1,4 @@
|
||||
<ng-container *transloco="let t; prefix: 'book.searcher'">
|
||||
<div class="book-searcher-container">
|
||||
<p-iconfield class="search-iconfield" [class.focused]="isSearchFocused" [class.has-results]="isDropdownOpen">
|
||||
<p-inputicon class="pi pi-search"/>
|
||||
@@ -8,7 +9,7 @@
|
||||
(input)="onSearchInputChange()"
|
||||
(focus)="isSearchFocused = true"
|
||||
(blur)="onSearchBlur()"
|
||||
placeholder="Title, Author, Series, Genre, or ISBN..."
|
||||
[placeholder]="t('placeholder')"
|
||||
class="search-input"
|
||||
/>
|
||||
@if (searchQuery) {
|
||||
@@ -18,7 +19,7 @@
|
||||
[text]="true"
|
||||
[rounded]="true"
|
||||
class="clear-search-btn"
|
||||
aria-label="Clear Search">
|
||||
[attr.aria-label]="t('clearSearch')">
|
||||
</p-button>
|
||||
}
|
||||
</p-iconfield>
|
||||
@@ -34,7 +35,7 @@
|
||||
<div class="search-item-content">
|
||||
<img
|
||||
[attr.src]="urlHelper.getThumbnailUrl(book.id, book.metadata?.coverUpdatedOn)"
|
||||
alt="Book Cover"
|
||||
[alt]="t('bookCoverAlt')"
|
||||
class="search-book-cover"
|
||||
/>
|
||||
<div class="search-book-details">
|
||||
@@ -45,7 +46,7 @@
|
||||
</div>
|
||||
<div class="search-book-meta-line">
|
||||
@if (book.metadata?.authors?.length ?? 0 > 0) {
|
||||
<p class="search-book-authors">by {{ getAuthorNames(book.metadata?.authors) }}</p>
|
||||
<p class="search-book-authors">{{ t('byPrefix') }} {{ getAuthorNames(book.metadata?.authors) }}</p>
|
||||
}
|
||||
@if (getPublishedYear(book.metadata?.publishedDate)) {
|
||||
<span class="metadata-badge year-badge">{{ getPublishedYear(book.metadata?.publishedDate) }}</span>
|
||||
@@ -64,9 +65,10 @@
|
||||
}
|
||||
} @else {
|
||||
<div class="search-dropdown-item no-results">
|
||||
<span>No results found</span>
|
||||
<span>{{ t('noResults') }}</span>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</ng-container>
|
||||
|
||||
+5
-2
@@ -13,6 +13,7 @@ import {Router} from '@angular/router';
|
||||
import {IconField} from 'primeng/iconfield';
|
||||
import {InputIcon} from 'primeng/inputicon';
|
||||
import {HeaderFilter} from '../book-browser/filters/HeaderFilter';
|
||||
import {TranslocoDirective, TranslocoService} from '@jsverse/transloco';
|
||||
|
||||
@Component({
|
||||
selector: 'app-book-searcher',
|
||||
@@ -24,7 +25,8 @@ import {HeaderFilter} from '../book-browser/filters/HeaderFilter';
|
||||
SlicePipe,
|
||||
Divider,
|
||||
IconField,
|
||||
InputIcon
|
||||
InputIcon,
|
||||
TranslocoDirective,
|
||||
],
|
||||
styleUrls: ['./book-searcher.component.scss'],
|
||||
standalone: true
|
||||
@@ -39,6 +41,7 @@ export class BookSearcherComponent implements OnInit, OnDestroy {
|
||||
private bookService = inject(BookService);
|
||||
private router = inject(Router);
|
||||
protected urlHelper = inject(UrlHelperService);
|
||||
private readonly t = inject(TranslocoService);
|
||||
private headerFilter = new HeaderFilter(this.#searchSubject.asObservable());
|
||||
|
||||
ngOnInit(): void {
|
||||
@@ -56,7 +59,7 @@ export class BookSearcherComponent implements OnInit, OnDestroy {
|
||||
}
|
||||
|
||||
getAuthorNames(authors: string[] | undefined): string {
|
||||
return authors?.join(', ') || 'Unknown Author';
|
||||
return authors?.join(', ') || this.t.translate('book.searcher.unknownAuthor');
|
||||
}
|
||||
|
||||
getPublishedYear(publishedDate: string | undefined): string | null {
|
||||
|
||||
+13
-11
@@ -1,11 +1,12 @@
|
||||
<ng-container *transloco="let t; prefix: 'book.sender'">
|
||||
<div class="book-sender-container">
|
||||
<div class="panel-header">
|
||||
<div class="header-icon-wrapper">
|
||||
<i class="pi pi-envelope header-icon"></i>
|
||||
</div>
|
||||
<div class="header-text">
|
||||
<h2 class="panel-title">Send Book</h2>
|
||||
<p class="panel-description">Email this book to a recipient</p>
|
||||
<h2 class="panel-title">{{ t('title') }}</h2>
|
||||
<p class="panel-description">{{ t('description') }}</p>
|
||||
</div>
|
||||
<p-button
|
||||
icon="pi pi-times"
|
||||
@@ -20,11 +21,11 @@
|
||||
<div class="dialog-content">
|
||||
<div class="form-fields">
|
||||
<div class="form-field">
|
||||
<label class="field-label">Email Provider</label>
|
||||
<label class="field-label">{{ t('emailProvider') }}</label>
|
||||
<p-select
|
||||
[options]="emailProviders"
|
||||
optionLabel="label"
|
||||
placeholder="Select Email Provider"
|
||||
[placeholder]="t('selectProvider')"
|
||||
[(ngModel)]="selectedProvider"
|
||||
appendTo="body"
|
||||
class="full-width">
|
||||
@@ -32,11 +33,11 @@
|
||||
</div>
|
||||
|
||||
<div class="form-field">
|
||||
<label class="field-label">Recipient</label>
|
||||
<label class="field-label">{{ t('recipient') }}</label>
|
||||
<p-select
|
||||
[options]="emailRecipients"
|
||||
optionLabel="label"
|
||||
placeholder="Select Book Recipient"
|
||||
[placeholder]="t('selectRecipient')"
|
||||
[(ngModel)]="selectedRecipient"
|
||||
[disabled]="!selectedProvider"
|
||||
appendTo="body"
|
||||
@@ -46,14 +47,14 @@
|
||||
|
||||
@if (emailableFiles.length > 0) {
|
||||
<div class="form-field">
|
||||
<label class="field-label">File Format</label>
|
||||
<label class="field-label">{{ t('fileFormat') }}</label>
|
||||
<div class="format-options">
|
||||
@for (file of emailableFiles; track file.id) {
|
||||
<div class="format-option" [class.selected]="selectedFileId === file.id">
|
||||
<p-radioButton name="fileFormat" [value]="file.id" [(ngModel)]="selectedFileId"/>
|
||||
<div class="format-info">
|
||||
<span class="format-type">{{ file.bookType || 'Unknown' }}</span>
|
||||
@if (file.isPrimary) { <span class="primary-badge">Primary</span> }
|
||||
<span class="format-type">{{ file.bookType || t('unknownFormat') }}</span>
|
||||
@if (file.isPrimary) { <span class="primary-badge">{{ t('primaryBadge') }}</span> }
|
||||
<span class="file-size">{{ formatFileSize(file.fileSizeKb) }}</span>
|
||||
</div>
|
||||
</div>
|
||||
@@ -65,7 +66,7 @@
|
||||
@if (showLargeFileWarning) {
|
||||
<div class="warning-banner">
|
||||
<i class="pi pi-exclamation-triangle"></i>
|
||||
<span>This file exceeds 25MB. Some email providers may reject large attachments.</span>
|
||||
<span>{{ t('largeFileWarning') }}</span>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
@@ -74,9 +75,10 @@
|
||||
<div class="dialog-footer">
|
||||
<p-button
|
||||
icon="pi pi-envelope"
|
||||
label="Send Book"
|
||||
[label]="t('sendBook')"
|
||||
[disabled]="!selectedProvider || !selectedRecipient"
|
||||
(onClick)="sendBook()">
|
||||
</p-button>
|
||||
</div>
|
||||
</div>
|
||||
</ng-container>
|
||||
|
||||
@@ -11,6 +11,7 @@ import {EmailV2ProviderService} from '../../../settings/email-v2/email-v2-provid
|
||||
import {EmailV2RecipientService} from '../../../settings/email-v2/email-v2-recipient/email-v2-recipient.service';
|
||||
import {Book, BookFile} from '../../model/book.model';
|
||||
import {RadioButton} from 'primeng/radiobutton';
|
||||
import {TranslocoDirective, TranslocoService} from '@jsverse/transloco';
|
||||
|
||||
interface EmailableFile {
|
||||
id: number;
|
||||
@@ -27,7 +28,8 @@ const LARGE_FILE_THRESHOLD_KB = 25 * 1024; // 25MB
|
||||
Button,
|
||||
Select,
|
||||
FormsModule,
|
||||
RadioButton
|
||||
RadioButton,
|
||||
TranslocoDirective,
|
||||
],
|
||||
templateUrl: './book-sender.component.html',
|
||||
styleUrls: ['./book-sender.component.scss']
|
||||
@@ -38,6 +40,7 @@ export class BookSenderComponent implements OnInit {
|
||||
private emailRecipientService = inject(EmailV2RecipientService);
|
||||
private emailService = inject(EmailService);
|
||||
private messageService = inject(MessageService);
|
||||
private readonly t = inject(TranslocoService);
|
||||
dynamicDialogRef = inject(DynamicDialogRef);
|
||||
private dynamicDialogConfig = inject(DynamicDialogConfig);
|
||||
|
||||
@@ -143,16 +146,16 @@ export class BookSenderComponent implements OnInit {
|
||||
next: () => {
|
||||
this.messageService.add({
|
||||
severity: 'success',
|
||||
summary: 'Email Scheduled',
|
||||
detail: 'The book has been successfully scheduled for sending.'
|
||||
summary: this.t.translate('book.sender.toast.emailScheduledSummary'),
|
||||
detail: this.t.translate('book.sender.toast.emailScheduledDetail')
|
||||
});
|
||||
this.dynamicDialogRef.close(true);
|
||||
},
|
||||
error: (error) => {
|
||||
this.messageService.add({
|
||||
severity: 'error',
|
||||
summary: 'Sending Failed',
|
||||
detail: 'There was an issue while scheduling the book for sending. Please try again later.'
|
||||
summary: this.t.translate('book.sender.toast.sendingFailedSummary'),
|
||||
detail: this.t.translate('book.sender.toast.sendingFailedDetail')
|
||||
});
|
||||
console.error('Error sending book:', error);
|
||||
}
|
||||
@@ -161,22 +164,22 @@ export class BookSenderComponent implements OnInit {
|
||||
if (!this.selectedProvider) {
|
||||
this.messageService.add({
|
||||
severity: 'error',
|
||||
summary: 'Email Provider Missing',
|
||||
detail: 'Please select an email provider to proceed.'
|
||||
summary: this.t.translate('book.sender.toast.providerMissingSummary'),
|
||||
detail: this.t.translate('book.sender.toast.providerMissingDetail')
|
||||
});
|
||||
}
|
||||
if (!this.selectedRecipient) {
|
||||
this.messageService.add({
|
||||
severity: 'error',
|
||||
summary: 'Recipient Missing',
|
||||
detail: 'Please select a recipient to send the book.'
|
||||
summary: this.t.translate('book.sender.toast.recipientMissingSummary'),
|
||||
detail: this.t.translate('book.sender.toast.recipientMissingDetail')
|
||||
});
|
||||
}
|
||||
if (!this.book?.id) {
|
||||
this.messageService.add({
|
||||
severity: 'error',
|
||||
summary: 'Book Not Selected',
|
||||
detail: 'Please select a book to send.'
|
||||
summary: this.t.translate('book.sender.toast.bookNotSelectedSummary'),
|
||||
detail: this.t.translate('book.sender.toast.bookNotSelectedDetail')
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
+21
-19
@@ -1,10 +1,11 @@
|
||||
<ng-container *transloco="let t; prefix: 'book.seriesPage'">
|
||||
@if (filteredBooks$ | async; as books) {
|
||||
<div class="series-wrapper">
|
||||
<p-tabs [value]="tab" lazy="true" scrollable>
|
||||
<p-tablist>
|
||||
<p-tab value="view">
|
||||
<i [class]="'pi pi-crown'"></i>
|
||||
Series Details
|
||||
{{ t('seriesDetailsTab') }}
|
||||
</p-tab>
|
||||
</p-tablist>
|
||||
<p-tabpanels class="tabpanels-responsive">
|
||||
@@ -49,7 +50,7 @@
|
||||
<div class="metadata-section-padding">
|
||||
<div class="metadata-grid">
|
||||
<p>
|
||||
<span class="metadata-label">Publisher: </span>
|
||||
<span class="metadata-label">{{ t('publisher') }} </span>
|
||||
@if (firstBook.metadata?.publisher; as publisher) {
|
||||
<span class="publisher-link" (click)="goToPublisher(publisher)">
|
||||
{{publisher}}
|
||||
@@ -58,10 +59,10 @@
|
||||
<span>-</span>
|
||||
}
|
||||
</p>
|
||||
<p><strong>Years:</strong> {{ (yearsRange$ | async) || '-' }}</p>
|
||||
<p><strong>Number of books:</strong> {{ books.length || 0}}</p>
|
||||
<p><strong>Language:</strong> {{ firstBook.metadata?.language || "-"}}</p>
|
||||
<p><strong>Read Status: </strong>
|
||||
<p><strong>{{ t('years') }}</strong> {{ (yearsRange$ | async) || '-' }}</p>
|
||||
<p><strong>{{ t('numberOfBooks') }}</strong> {{ books.length || 0}}</p>
|
||||
<p><strong>{{ t('language') }}</strong> {{ firstBook.metadata?.language || "-"}}</p>
|
||||
<p><strong>{{ t('readStatus') }}</strong>
|
||||
@let s = seriesReadStatus$ | async;
|
||||
<span class="status-badge"
|
||||
[ngClass]="getStatusSeverityClass(s || 'UNREAD')">
|
||||
@@ -79,11 +80,11 @@
|
||||
<div [ngClass]="{ 'line-clamp-5': !isExpanded, 'line-clamp-none': isExpanded }"
|
||||
class="description-container">
|
||||
<div class="readonly-editor"
|
||||
[innerHTML]="(firstDescription$ | async) || 'No description available.'"></div>
|
||||
[innerHTML]="(firstDescription$ | async) || t('noDescription')"></div>
|
||||
</div>
|
||||
@let desc = firstDescription$ | async;
|
||||
@if ((desc?.length ?? 0) > 500) {
|
||||
<p-button [label]="isExpanded ? 'Show less' : 'Show more'"
|
||||
<p-button [label]="isExpanded ? t('showLess') : t('showMore')"
|
||||
[icon]="isExpanded ? 'pi pi-chevron-up' : 'pi pi-chevron-down'" iconPos="right" size="small" text
|
||||
(click)="toggleExpand()">
|
||||
</p-button>
|
||||
@@ -108,7 +109,7 @@
|
||||
</div>
|
||||
}
|
||||
@if (books.length === 0) {
|
||||
<div class="empty-state">No books found for this series.</div>
|
||||
<div class="empty-state">{{ t('noBooksFound') }}</div>
|
||||
}
|
||||
</div>
|
||||
|
||||
@@ -129,7 +130,7 @@
|
||||
<div class="selected-count-badge">
|
||||
<i class="pi pi-check-circle badge-icon"></i>
|
||||
<span class="badge-count" style="color: var(--primary-color)">{{ selectedBooks.size }}</span>
|
||||
<span class="badge-label">selected</span>
|
||||
<span class="badge-label">{{ t('selected') }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="footer-center">
|
||||
@@ -138,7 +139,7 @@
|
||||
<p-tieredMenu #menu [model]="metadataMenuItems" [popup]="true" appendTo="body"/>
|
||||
<p-button
|
||||
(click)="menu.toggle($event)"
|
||||
pTooltip="Metadata actions"
|
||||
[pTooltip]="t('tooltip.metadataActions')"
|
||||
tooltipPosition="top"
|
||||
outlined="true"
|
||||
severity="info"
|
||||
@@ -150,7 +151,7 @@
|
||||
outlined="true"
|
||||
severity="info"
|
||||
(onClick)="openShelfAssigner()"
|
||||
pTooltip="Assign to shelf"
|
||||
[pTooltip]="t('tooltip.assignToShelf')"
|
||||
tooltipPosition="top">
|
||||
</p-button>
|
||||
@if (userState.user!.permissions.canBulkLockUnlockMetadata) {
|
||||
@@ -159,7 +160,7 @@
|
||||
icon="pi pi-lock"
|
||||
severity="info"
|
||||
(click)="lockUnlockMetadata()"
|
||||
pTooltip="Lock/Unlock metadata"
|
||||
[pTooltip]="t('tooltip.lockUnlockMetadata')"
|
||||
tooltipPosition="top">
|
||||
</p-button>
|
||||
}
|
||||
@@ -169,7 +170,7 @@
|
||||
icon="pi pi-arrows-h"
|
||||
severity="info"
|
||||
(click)="moveFiles()"
|
||||
pTooltip="Organize Files"
|
||||
[pTooltip]="t('tooltip.organizeFiles')"
|
||||
tooltipPosition="top">
|
||||
</p-button>
|
||||
}
|
||||
@@ -177,7 +178,7 @@
|
||||
<div class="more-actions-wrapper">
|
||||
<p-button
|
||||
(click)="menu.toggle($event)"
|
||||
pTooltip="More actions"
|
||||
[pTooltip]="t('tooltip.moreActions')"
|
||||
tooltipPosition="top"
|
||||
outlined="true"
|
||||
severity="info"
|
||||
@@ -194,7 +195,7 @@
|
||||
icon="pi pi-check-square"
|
||||
severity="success"
|
||||
(click)="selectAllBooks()"
|
||||
pTooltip="Select all books"
|
||||
[pTooltip]="t('tooltip.selectAll')"
|
||||
tooltipPosition="top">
|
||||
</p-button>
|
||||
<p-button
|
||||
@@ -202,7 +203,7 @@
|
||||
icon="pi pi-times"
|
||||
severity="warn"
|
||||
(click)="deselectAllBooks()"
|
||||
pTooltip="Deselect all books"
|
||||
[pTooltip]="t('tooltip.deselectAll')"
|
||||
tooltipPosition="top">
|
||||
</p-button>
|
||||
</div>
|
||||
@@ -213,7 +214,7 @@
|
||||
icon="pi pi-trash"
|
||||
severity="danger"
|
||||
(click)="confirmDeleteBooks()"
|
||||
pTooltip="Delete selected books"
|
||||
[pTooltip]="t('tooltip.deleteSelected')"
|
||||
tooltipPosition="top">
|
||||
</p-button>
|
||||
}
|
||||
@@ -230,7 +231,8 @@
|
||||
<p-progressSpinner strokeWidth="4" fill="transparent" animationDuration=".8s">
|
||||
</p-progressSpinner>
|
||||
<p style="color: var(--primary-color);">
|
||||
Loading series details...
|
||||
{{ t('loadingSeriesDetails') }}
|
||||
</p>
|
||||
</div>
|
||||
}
|
||||
</ng-container>
|
||||
|
||||
@@ -22,6 +22,7 @@ import {TaskHelperService} from "../../../settings/task-management/task-helper.s
|
||||
import {MetadataRefreshType} from "../../../metadata/model/request/metadata-refresh-type.enum";
|
||||
import {TieredMenu} from "primeng/tieredmenu";
|
||||
import {AppSettingsService} from "../../../../shared/service/app-settings.service";
|
||||
import {TranslocoDirective, TranslocoService} from '@jsverse/transloco';
|
||||
import {Tooltip} from "primeng/tooltip";
|
||||
import {Divider} from "primeng/divider";
|
||||
import {animate, style, transition, trigger} from "@angular/animations";
|
||||
@@ -50,7 +51,8 @@ import {BookCardOverlayPreferenceService} from '../book-browser/book-card-overla
|
||||
VirtualScrollerModule,
|
||||
TieredMenu,
|
||||
Tooltip,
|
||||
Divider
|
||||
Divider,
|
||||
TranslocoDirective
|
||||
],
|
||||
animations: [
|
||||
trigger('slideInOut', [
|
||||
@@ -82,6 +84,7 @@ export class SeriesPageComponent implements OnDestroy {
|
||||
private messageService = inject(MessageService);
|
||||
protected bookCardOverlayPreferenceService = inject(BookCardOverlayPreferenceService);
|
||||
protected appSettingsService = inject(AppSettingsService);
|
||||
private readonly t = inject(TranslocoService);
|
||||
|
||||
tab: string = "view";
|
||||
isExpanded = false;
|
||||
@@ -271,23 +274,23 @@ export class SeriesPageComponent implements OnDestroy {
|
||||
const v = (value ?? '').toString().toUpperCase();
|
||||
switch (v) {
|
||||
case ReadStatus.UNREAD:
|
||||
return 'UNREAD';
|
||||
return this.t.translate('book.seriesPage.status.unread');
|
||||
case ReadStatus.READING:
|
||||
return 'READING';
|
||||
return this.t.translate('book.seriesPage.status.reading');
|
||||
case ReadStatus.RE_READING:
|
||||
return 'RE-READING';
|
||||
return this.t.translate('book.seriesPage.status.reReading');
|
||||
case ReadStatus.READ:
|
||||
return 'READ';
|
||||
return this.t.translate('book.seriesPage.status.read');
|
||||
case ReadStatus.PARTIALLY_READ:
|
||||
return 'PARTIALLY READ';
|
||||
return this.t.translate('book.seriesPage.status.partiallyRead');
|
||||
case ReadStatus.PAUSED:
|
||||
return 'PAUSED';
|
||||
return this.t.translate('book.seriesPage.status.paused');
|
||||
case ReadStatus.ABANDONED:
|
||||
return 'ABANDONED';
|
||||
return this.t.translate('book.seriesPage.status.abandoned');
|
||||
case ReadStatus.WONT_READ:
|
||||
return "WON'T READ";
|
||||
return this.t.translate('book.seriesPage.status.wontRead');
|
||||
default:
|
||||
return 'UNSET';
|
||||
return this.t.translate('book.seriesPage.status.unset');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -374,18 +377,18 @@ export class SeriesPageComponent implements OnDestroy {
|
||||
|
||||
confirmDeleteBooks(): void {
|
||||
this.confirmationService.confirm({
|
||||
message: `Are you sure you want to delete ${this.selectedBooks.size} book(s)?\n\nThis will permanently remove the book files from your filesystem.\n\nThis action cannot be undone.`,
|
||||
header: 'Confirm Deletion',
|
||||
message: this.t.translate('book.browser.confirm.deleteMessage', {count: this.selectedBooks.size}),
|
||||
header: this.t.translate('book.browser.confirm.deleteHeader'),
|
||||
icon: 'pi pi-exclamation-triangle',
|
||||
acceptIcon: 'pi pi-trash',
|
||||
rejectIcon: 'pi pi-times',
|
||||
acceptLabel: 'Delete',
|
||||
rejectLabel: 'Cancel',
|
||||
acceptLabel: this.t.translate('common.delete'),
|
||||
rejectLabel: this.t.translate('common.cancel'),
|
||||
acceptButtonStyleClass: 'p-button-danger',
|
||||
rejectButtonStyleClass: 'p-button-outlined',
|
||||
accept: () => {
|
||||
const count = this.selectedBooks.size;
|
||||
const loader = this.loadingService.show(`Deleting ${count} book(s)...`);
|
||||
const loader = this.loadingService.show(this.t.translate('book.browser.loading.deleting', {count}));
|
||||
|
||||
this.bookService.deleteBooks(this.selectedBooks)
|
||||
.pipe(finalize(() => this.loadingService.hide(loader)))
|
||||
@@ -437,17 +440,17 @@ export class SeriesPageComponent implements OnDestroy {
|
||||
if (!this.selectedBooks || this.selectedBooks.size === 0) return;
|
||||
const count = this.selectedBooks.size;
|
||||
this.confirmationService.confirm({
|
||||
message: `Are you sure you want to regenerate covers for ${count} book(s)?`,
|
||||
header: 'Confirm Cover Regeneration',
|
||||
message: this.t.translate('book.browser.confirm.regenCoverMessage', {count}),
|
||||
header: this.t.translate('book.browser.confirm.regenCoverHeader'),
|
||||
icon: 'pi pi-image',
|
||||
acceptLabel: 'Yes',
|
||||
rejectLabel: 'No',
|
||||
acceptButtonProps: {
|
||||
label: 'Yes',
|
||||
label: this.t.translate('common.yes'),
|
||||
severity: 'success'
|
||||
},
|
||||
rejectButtonProps: {
|
||||
label: 'No',
|
||||
label: this.t.translate('common.no'),
|
||||
severity: 'secondary'
|
||||
},
|
||||
accept: () => {
|
||||
@@ -455,16 +458,16 @@ export class SeriesPageComponent implements OnDestroy {
|
||||
next: () => {
|
||||
this.messageService.add({
|
||||
severity: 'success',
|
||||
summary: 'Cover Regeneration Started',
|
||||
detail: `Regenerating covers for ${count} book(s). Refresh the page when complete.`,
|
||||
summary: this.t.translate('book.browser.toast.regenCoverStartedSummary'),
|
||||
detail: this.t.translate('book.browser.toast.regenCoverStartedDetail', {count}),
|
||||
life: 3000
|
||||
});
|
||||
},
|
||||
error: () => {
|
||||
this.messageService.add({
|
||||
severity: 'error',
|
||||
summary: 'Failed',
|
||||
detail: 'Could not start cover regeneration.',
|
||||
summary: this.t.translate('book.browser.toast.failedSummary'),
|
||||
detail: this.t.translate('book.browser.toast.regenCoverFailedDetail'),
|
||||
life: 3000
|
||||
});
|
||||
}
|
||||
@@ -477,17 +480,17 @@ export class SeriesPageComponent implements OnDestroy {
|
||||
if (!this.selectedBooks || this.selectedBooks.size === 0) return;
|
||||
const count = this.selectedBooks.size;
|
||||
this.confirmationService.confirm({
|
||||
message: `Are you sure you want to generate custom covers for ${count} book(s)?`,
|
||||
header: 'Confirm Custom Cover Generation',
|
||||
message: this.t.translate('book.browser.confirm.customCoverMessage', {count}),
|
||||
header: this.t.translate('book.browser.confirm.customCoverHeader'),
|
||||
icon: 'pi pi-palette',
|
||||
acceptLabel: 'Yes',
|
||||
rejectLabel: 'No',
|
||||
acceptButtonProps: {
|
||||
label: 'Yes',
|
||||
label: this.t.translate('common.yes'),
|
||||
severity: 'success'
|
||||
},
|
||||
rejectButtonProps: {
|
||||
label: 'No',
|
||||
label: this.t.translate('common.no'),
|
||||
severity: 'secondary'
|
||||
},
|
||||
accept: () => {
|
||||
@@ -495,16 +498,16 @@ export class SeriesPageComponent implements OnDestroy {
|
||||
next: () => {
|
||||
this.messageService.add({
|
||||
severity: 'success',
|
||||
summary: 'Custom Cover Generation Started',
|
||||
detail: `Generating custom covers for ${count} book(s).`,
|
||||
summary: this.t.translate('book.browser.toast.customCoverStartedSummary'),
|
||||
detail: this.t.translate('book.browser.toast.customCoverStartedDetail', {count}),
|
||||
life: 3000
|
||||
});
|
||||
},
|
||||
error: () => {
|
||||
this.messageService.add({
|
||||
severity: 'error',
|
||||
summary: 'Failed',
|
||||
detail: 'Could not start custom cover generation.',
|
||||
summary: this.t.translate('book.browser.toast.failedSummary'),
|
||||
detail: this.t.translate('book.browser.toast.customCoverFailedDetail'),
|
||||
life: 3000
|
||||
});
|
||||
}
|
||||
|
||||
+11
-12
@@ -1,15 +1,16 @@
|
||||
<ng-container *transloco="let t; prefix: 'book.shelfAssigner'">
|
||||
<div class="shelf-assigner">
|
||||
<div class="panel-header">
|
||||
<div class="header-icon-wrapper">
|
||||
<i class="pi pi-bookmark header-icon"></i>
|
||||
</div>
|
||||
<div class="header-text">
|
||||
<h2 class="panel-title">Assign Books to Shelves</h2>
|
||||
<h2 class="panel-title">{{ t('title') }}</h2>
|
||||
<p class="panel-description">
|
||||
@if (isMultiBooks) {
|
||||
Select shelves for {{ bookIds.size }} {{ bookIds.size === 1 ? 'book' : 'books' }}
|
||||
{{ t('descriptionMulti', { count: bookIds.size }) }}
|
||||
} @else {
|
||||
Organize "{{ book.metadata?.title }}" into your shelves
|
||||
{{ t('descriptionSingle', { title: book.metadata?.title }) }}
|
||||
}
|
||||
</p>
|
||||
</div>
|
||||
@@ -29,7 +30,7 @@
|
||||
<div class="list-header">
|
||||
<span class="shelf-count">
|
||||
<i class="pi pi-bookmark"></i>
|
||||
{{ (shelfState$ | async)!.shelves!.length }} {{ (shelfState$ | async)!.shelves!.length === 1 ? 'shelf' : 'shelves' }} available
|
||||
{{ t('shelvesAvailable', { count: (shelfState$ | async)!.shelves!.length }) }}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
@@ -68,18 +69,15 @@
|
||||
<div class="empty-icon-wrapper">
|
||||
<i class="pi pi-bookmark empty-icon"></i>
|
||||
</div>
|
||||
<h3 class="empty-title">No Shelves Available</h3>
|
||||
<p class="empty-description">
|
||||
Create your first shelf to start organizing your books.<br/>
|
||||
Click the button below to get started.
|
||||
</p>
|
||||
<h3 class="empty-title">{{ t('emptyTitle') }}</h3>
|
||||
<p class="empty-description" [innerHTML]="t('emptyDescription')"></p>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
|
||||
<div class="dialog-footer">
|
||||
<p-button
|
||||
label="Create Shelf"
|
||||
[label]="t('createShelf')"
|
||||
icon="pi pi-plus"
|
||||
[outlined]="true"
|
||||
severity="info"
|
||||
@@ -87,13 +85,13 @@
|
||||
/>
|
||||
<div class="footer-actions">
|
||||
<p-button
|
||||
label="Cancel"
|
||||
[label]="t('cancelButton')"
|
||||
severity="secondary"
|
||||
[outlined]="true"
|
||||
(onClick)="closeDialog()"
|
||||
/>
|
||||
<p-button
|
||||
label="Save Changes"
|
||||
[label]="t('saveChanges')"
|
||||
icon="pi pi-check"
|
||||
severity="success"
|
||||
(onClick)="updateBooksShelves()"
|
||||
@@ -101,3 +99,4 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</ng-container>
|
||||
|
||||
+7
-4
@@ -17,6 +17,7 @@ import {LoadingService} from '../../../../core/services/loading.service';
|
||||
import {UserService} from '../../../settings/user-management/user.service';
|
||||
import {IconDisplayComponent} from '../../../../shared/components/icon-display/icon-display.component';
|
||||
import {IconSelection} from '../../../../shared/service/icon-picker.service';
|
||||
import {TranslocoDirective, TranslocoService} from '@jsverse/transloco';
|
||||
|
||||
@Component({
|
||||
selector: 'app-shelf-assigner',
|
||||
@@ -28,7 +29,8 @@ import {IconSelection} from '../../../../shared/service/icon-picker.service';
|
||||
Checkbox,
|
||||
AsyncPipe,
|
||||
FormsModule,
|
||||
IconDisplayComponent
|
||||
IconDisplayComponent,
|
||||
TranslocoDirective
|
||||
]
|
||||
})
|
||||
export class ShelfAssignerComponent implements OnInit {
|
||||
@@ -41,6 +43,7 @@ export class ShelfAssignerComponent implements OnInit {
|
||||
private bookDialogHelper = inject(BookDialogHelperService);
|
||||
private loadingService = inject(LoadingService);
|
||||
private userService = inject(UserService);
|
||||
private readonly t = inject(TranslocoService);
|
||||
|
||||
shelfState$: Observable<ShelfState> = combineLatest([
|
||||
this.shelfService.shelfState$,
|
||||
@@ -78,17 +81,17 @@ export class ShelfAssignerComponent implements OnInit {
|
||||
}
|
||||
|
||||
private updateBookShelves(bookIds: Set<number>, idsToAssign: Set<number | undefined>, idsToUnassign: Set<number>): void {
|
||||
const loader = this.loadingService.show(`Updating shelves for ${bookIds.size} book(s)...`);
|
||||
const loader = this.loadingService.show(this.t.translate('book.shelfAssigner.loading.updatingShelves', { count: bookIds.size }));
|
||||
|
||||
this.bookService.updateBookShelves(bookIds, idsToAssign, idsToUnassign)
|
||||
.pipe(finalize(() => this.loadingService.hide(loader)))
|
||||
.subscribe({
|
||||
next: () => {
|
||||
this.messageService.add({severity: 'info', summary: 'Success', detail: 'Book shelves updated'});
|
||||
this.messageService.add({severity: 'info', summary: this.t.translate('common.success'), detail: this.t.translate('book.shelfAssigner.toast.updateSuccessDetail')});
|
||||
this.dynamicDialogRef.close({assigned: true});
|
||||
},
|
||||
error: () => {
|
||||
this.messageService.add({severity: 'error', summary: 'Error', detail: 'Failed to update book shelves'});
|
||||
this.messageService.add({severity: 'error', summary: this.t.translate('common.error'), detail: this.t.translate('book.shelfAssigner.toast.updateFailedDetail')});
|
||||
this.dynamicDialogRef.close({assigned: false});
|
||||
}
|
||||
});
|
||||
|
||||
+19
-17
@@ -1,11 +1,12 @@
|
||||
<ng-container *transloco="let t; prefix: 'book.shelfCreator'">
|
||||
<div class="shelf-creator">
|
||||
<div class="panel-header">
|
||||
<div class="header-icon-wrapper">
|
||||
<i class="pi pi-bookmark header-icon"></i>
|
||||
</div>
|
||||
<div class="header-text">
|
||||
<h2 class="panel-title">Create New Shelf</h2>
|
||||
<p class="panel-description">Add a custom shelf to organize your books</p>
|
||||
<h2 class="panel-title">{{ t('title') }}</h2>
|
||||
<p class="panel-description">{{ t('description') }}</p>
|
||||
</div>
|
||||
<p-button
|
||||
icon="pi pi-times"
|
||||
@@ -14,7 +15,7 @@
|
||||
[text]="true"
|
||||
[rounded]="true"
|
||||
class="close-button"
|
||||
pTooltip="Close"
|
||||
[pTooltip]="t('closeTooltip')"
|
||||
tooltipPosition="left"/>
|
||||
</div>
|
||||
|
||||
@@ -22,7 +23,7 @@
|
||||
<div class="form-group highlight-group">
|
||||
<label for="shelfName" class="form-label">
|
||||
<i class="pi pi-tag label-icon"></i>
|
||||
Shelf Name
|
||||
{{ t('shelfNameLabel') }}
|
||||
<span class="required-indicator">*</span>
|
||||
</label>
|
||||
<div class="input-wrapper">
|
||||
@@ -32,9 +33,9 @@
|
||||
pInputText
|
||||
[(ngModel)]="shelfName"
|
||||
class="input-full"
|
||||
placeholder="e.g., Favorites, To Read, Currently Reading"
|
||||
[placeholder]="t('shelfNamePlaceholder')"
|
||||
[class.filled]="shelfName.trim()"
|
||||
|
||||
|
||||
/>
|
||||
@if (shelfName.trim()) {
|
||||
<i class="pi pi-check-circle input-icon success"></i>
|
||||
@@ -47,14 +48,14 @@
|
||||
<div class="form-group highlight-group">
|
||||
<label class="form-label">
|
||||
<i class="pi pi-palette label-icon"></i>
|
||||
Shelf Icon (Optional)
|
||||
{{ t('shelfIconLabel') }}
|
||||
</label>
|
||||
@if (!selectedIcon) {
|
||||
<button class="icon-select-btn" (click)="openIconPicker()" type="button">
|
||||
<i class="pi pi-plus"></i>
|
||||
<div class="btn-content">
|
||||
<span class="btn-title">Choose an Icon</span>
|
||||
<span class="btn-subtitle">Select from available icons</span>
|
||||
<span class="btn-title">{{ t('chooseIcon') }}</span>
|
||||
<span class="btn-subtitle">{{ t('chooseIconSubtitle') }}</span>
|
||||
</div>
|
||||
</button>
|
||||
} @else {
|
||||
@@ -66,7 +67,7 @@
|
||||
/>
|
||||
</div>
|
||||
<div class="icon-info">
|
||||
<span class="icon-label">Selected Icon</span>
|
||||
<span class="icon-label">{{ t('selectedIcon') }}</span>
|
||||
<span class="icon-name">
|
||||
@if (selectedIcon.type === 'PRIME_NG') {
|
||||
{{ selectedIcon.value }}
|
||||
@@ -82,7 +83,7 @@
|
||||
[rounded]="true"
|
||||
size="small"
|
||||
(onClick)="clearSelectedIcon()"
|
||||
pTooltip="Remove icon"
|
||||
[pTooltip]="t('removeIconTooltip')"
|
||||
tooltipPosition="left"
|
||||
/>
|
||||
</div>
|
||||
@@ -95,11 +96,11 @@
|
||||
<div class="form-group highlight-group">
|
||||
<label class="form-label">
|
||||
<i class="pi pi-globe label-icon"></i>
|
||||
Visibility
|
||||
{{ t('visibilityLabel') }}
|
||||
</label>
|
||||
<div class="input-wrapper" style="display: flex; align-items: center; gap: 0.5rem;">
|
||||
<p-checkbox [(ngModel)]="isPublic" [binary]="true" inputId="publicShelf"></p-checkbox>
|
||||
<label for="publicShelf" style="cursor: pointer">Make this shelf public (read-only for others)</label>
|
||||
<label for="publicShelf" style="cursor: pointer">{{ t('makePublicLabel') }}</label>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
@@ -110,24 +111,24 @@
|
||||
@if (!shelfName.trim()) {
|
||||
<div class="validation-message error">
|
||||
<i class="pi pi-exclamation-circle"></i>
|
||||
<span>Shelf name is required</span>
|
||||
<span>{{ t('validationRequired') }}</span>
|
||||
</div>
|
||||
} @else {
|
||||
<div class="validation-message success">
|
||||
<i class="pi pi-check-circle"></i>
|
||||
<span>Ready to create</span>
|
||||
<span>{{ t('validationReady') }}</span>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
<div class="footer-actions">
|
||||
<p-button
|
||||
label="Cancel"
|
||||
[label]="t('cancelButton')"
|
||||
severity="secondary"
|
||||
[outlined]="true"
|
||||
(onClick)="cancel()"
|
||||
/>
|
||||
<p-button
|
||||
label="Create Shelf"
|
||||
[label]="t('createButton')"
|
||||
icon="pi pi-plus"
|
||||
severity="success"
|
||||
(onClick)="createShelf()"
|
||||
@@ -136,3 +137,4 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</ng-container>
|
||||
|
||||
+6
-3
@@ -11,6 +11,7 @@ import {Tooltip} from 'primeng/tooltip';
|
||||
import {IconDisplayComponent} from '../../../../shared/components/icon-display/icon-display.component';
|
||||
import {UserService} from '../../../settings/user-management/user.service';
|
||||
import {CheckboxModule} from 'primeng/checkbox';
|
||||
import {TranslocoDirective, TranslocoService} from '@jsverse/transloco';
|
||||
|
||||
@Component({
|
||||
selector: 'app-shelf-creator',
|
||||
@@ -22,7 +23,8 @@ import {CheckboxModule} from 'primeng/checkbox';
|
||||
InputText,
|
||||
Tooltip,
|
||||
IconDisplayComponent,
|
||||
CheckboxModule
|
||||
CheckboxModule,
|
||||
TranslocoDirective
|
||||
],
|
||||
styleUrl: './shelf-creator.component.scss',
|
||||
})
|
||||
@@ -32,6 +34,7 @@ export class ShelfCreatorComponent {
|
||||
private messageService = inject(MessageService);
|
||||
private iconPickerService = inject(IconPickerService);
|
||||
private userService = inject(UserService);
|
||||
private readonly t = inject(TranslocoService);
|
||||
|
||||
shelfName: string = '';
|
||||
selectedIcon: IconSelection | null = null;
|
||||
@@ -67,11 +70,11 @@ export class ShelfCreatorComponent {
|
||||
|
||||
this.shelfService.createShelf(newShelf as Shelf).subscribe({
|
||||
next: () => {
|
||||
this.messageService.add({severity: 'info', summary: 'Success', detail: `Shelf created: ${this.shelfName}`});
|
||||
this.messageService.add({severity: 'info', summary: this.t.translate('common.success'), detail: this.t.translate('book.shelfCreator.toast.createSuccessDetail', { name: this.shelfName })});
|
||||
this.dynamicDialogRef.close(true);
|
||||
},
|
||||
error: (e) => {
|
||||
this.messageService.add({severity: 'error', summary: 'Error', detail: 'Failed to create shelf'});
|
||||
this.messageService.add({severity: 'error', summary: this.t.translate('common.error'), detail: this.t.translate('book.shelfCreator.toast.createFailedDetail')});
|
||||
console.error('Error creating shelf:', e);
|
||||
}
|
||||
});
|
||||
|
||||
+12
-10
@@ -1,12 +1,13 @@
|
||||
<ng-container *transloco="let t; prefix: 'book.shelfEditDialog'">
|
||||
<div class="shelf-form">
|
||||
<div class="panel-header">
|
||||
<div class="header-icon-wrapper">
|
||||
<i class="pi pi-pencil header-icon"></i>
|
||||
</div>
|
||||
<div class="header-text">
|
||||
<h2 class="panel-title">Edit Shelf</h2>
|
||||
<h2 class="panel-title">{{ t('title') }}</h2>
|
||||
<p class="panel-description">
|
||||
Customize your shelf name and icon
|
||||
{{ t('description') }}
|
||||
</p>
|
||||
</div>
|
||||
<p-button
|
||||
@@ -22,15 +23,15 @@
|
||||
<div class="shelf-container">
|
||||
<div class="shelf-fields">
|
||||
<div class="shelf-row">
|
||||
<label class="label">Shelf Name:</label>
|
||||
<input type="text" pInputText [(ngModel)]="shelfName" placeholder="Enter shelf name..." class="input"/>
|
||||
<label class="label">{{ t('shelfNameLabel') }}</label>
|
||||
<input type="text" pInputText [(ngModel)]="shelfName" [placeholder]="t('shelfNamePlaceholder')" class="input"/>
|
||||
</div>
|
||||
|
||||
<div class="shelf-row">
|
||||
<label class="label">Shelf Icon:</label>
|
||||
<label class="label">{{ t('shelfIconLabel') }}</label>
|
||||
<div class="icon-section">
|
||||
@if (!selectedIcon) {
|
||||
<p-button label="Select Icon" icon="pi pi-search" [outlined]="true" severity="info" (onClick)="openIconPicker()"></p-button>
|
||||
<p-button [label]="t('selectIcon')" icon="pi pi-search" [outlined]="true" severity="info" (onClick)="openIconPicker()"></p-button>
|
||||
}
|
||||
|
||||
@if (selectedIcon) {
|
||||
@@ -50,10 +51,10 @@
|
||||
|
||||
@if (isAdmin) {
|
||||
<div class="shelf-row">
|
||||
<label class="label">Visibility:</label>
|
||||
<label class="label">{{ t('visibilityLabel') }}</label>
|
||||
<div class="visibility-section" style="display: flex; align-items: center; gap: 0.5rem;">
|
||||
<p-checkbox [(ngModel)]="isPublic" [binary]="true" inputId="publicShelf"></p-checkbox>
|
||||
<label for="publicShelf" style="cursor: pointer; user-select: none;">Public Shelf</label>
|
||||
<label for="publicShelf" style="cursor: pointer; user-select: none;">{{ t('publicShelfLabel') }}</label>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
@@ -64,13 +65,13 @@
|
||||
<div></div>
|
||||
<div class="footer-actions">
|
||||
<p-button
|
||||
label="Cancel"
|
||||
[label]="t('cancelButton')"
|
||||
severity="secondary"
|
||||
[outlined]="true"
|
||||
(onClick)="closeDialog()"
|
||||
/>
|
||||
<p-button
|
||||
label="Save Changes"
|
||||
[label]="t('saveChanges')"
|
||||
icon="pi pi-check"
|
||||
severity="success"
|
||||
(onClick)="save()"
|
||||
@@ -78,3 +79,4 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</ng-container>
|
||||
|
||||
+6
-3
@@ -11,6 +11,7 @@ import {IconPickerService, IconSelection} from '../../../../shared/service/icon-
|
||||
import {IconDisplayComponent} from '../../../../shared/components/icon-display/icon-display.component';
|
||||
import {CheckboxModule} from 'primeng/checkbox';
|
||||
import {UserService} from '../../../settings/user-management/user.service';
|
||||
import {TranslocoDirective, TranslocoService} from '@jsverse/transloco';
|
||||
|
||||
@Component({
|
||||
selector: 'app-shelf-edit-dialog',
|
||||
@@ -20,7 +21,8 @@ import {UserService} from '../../../settings/user-management/user.service';
|
||||
ReactiveFormsModule,
|
||||
FormsModule,
|
||||
IconDisplayComponent,
|
||||
CheckboxModule
|
||||
CheckboxModule,
|
||||
TranslocoDirective
|
||||
],
|
||||
templateUrl: './shelf-edit-dialog.component.html',
|
||||
standalone: true,
|
||||
@@ -34,6 +36,7 @@ export class ShelfEditDialogComponent implements OnInit {
|
||||
private messageService = inject(MessageService);
|
||||
private iconPickerService = inject(IconPickerService);
|
||||
private userService = inject(UserService);
|
||||
private readonly t = inject(TranslocoService);
|
||||
|
||||
shelfName: string = '';
|
||||
selectedIcon: IconSelection | null = null;
|
||||
@@ -82,11 +85,11 @@ export class ShelfEditDialogComponent implements OnInit {
|
||||
|
||||
this.shelfService.updateShelf(shelf, this.shelf?.id).subscribe({
|
||||
next: () => {
|
||||
this.messageService.add({severity: 'success', summary: 'Shelf Updated', detail: 'The shelf was updated successfully.'});
|
||||
this.messageService.add({severity: 'success', summary: this.t.translate('book.shelfEditDialog.toast.updateSuccessSummary'), detail: this.t.translate('book.shelfEditDialog.toast.updateSuccessDetail')});
|
||||
this.dynamicDialogRef.close();
|
||||
},
|
||||
error: (e) => {
|
||||
this.messageService.add({severity: 'error', summary: 'Update Failed', detail: 'An error occurred while updating the shelf. Please try again.'});
|
||||
this.messageService.add({severity: 'error', summary: this.t.translate('book.shelfEditDialog.toast.updateFailedSummary'), detail: this.t.translate('book.shelfEditDialog.toast.updateFailedDetail')});
|
||||
console.error(e);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -9,6 +9,7 @@ import {LoadingService} from '../../../core/services/loading.service';
|
||||
import {User} from '../../settings/user-management/user.service';
|
||||
import {APIException} from '../../../shared/models/api-exception.model';
|
||||
import {HttpErrorResponse} from '@angular/common/http';
|
||||
import {TranslocoService} from '@jsverse/transloco';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
@@ -19,6 +20,7 @@ export class BookMenuService {
|
||||
messageService = inject(MessageService);
|
||||
bookService = inject(BookService);
|
||||
loadingService = inject(LoadingService);
|
||||
private readonly t = inject(TranslocoService);
|
||||
|
||||
getMetadataMenuItems(
|
||||
autoFetchMetadata: () => void,
|
||||
@@ -34,7 +36,7 @@ export class BookMenuService {
|
||||
|
||||
if (permissions?.canBulkAutoFetchMetadata) {
|
||||
items.push({
|
||||
label: 'Auto Fetch Metadata',
|
||||
label: this.t.translate('book.menuService.menu.autoFetchMetadata'),
|
||||
icon: 'pi pi-bolt',
|
||||
command: autoFetchMetadata
|
||||
});
|
||||
@@ -42,7 +44,7 @@ export class BookMenuService {
|
||||
|
||||
if (permissions?.canBulkCustomFetchMetadata) {
|
||||
items.push({
|
||||
label: 'Custom Fetch Metadata',
|
||||
label: this.t.translate('book.menuService.menu.customFetchMetadata'),
|
||||
icon: 'pi pi-sync',
|
||||
command: fetchMetadata
|
||||
});
|
||||
@@ -50,12 +52,12 @@ export class BookMenuService {
|
||||
|
||||
if (permissions?.canBulkEditMetadata) {
|
||||
items.push({
|
||||
label: 'Bulk Metadata Editor',
|
||||
label: this.t.translate('book.menuService.menu.bulkMetadataEditor'),
|
||||
icon: 'pi pi-table',
|
||||
command: bulkEditMetadata
|
||||
});
|
||||
items.push({
|
||||
label: 'Multi-Book Metadata Editor',
|
||||
label: this.t.translate('book.menuService.menu.multiBookMetadataEditor'),
|
||||
icon: 'pi pi-clone',
|
||||
command: multiBookEditMetadata
|
||||
});
|
||||
@@ -63,12 +65,12 @@ export class BookMenuService {
|
||||
|
||||
if (permissions?.canBulkRegenerateCover) {
|
||||
items.push({
|
||||
label: 'Regenerate Covers',
|
||||
label: this.t.translate('book.menuService.menu.regenerateCovers'),
|
||||
icon: 'pi pi-image',
|
||||
command: regenerateCovers
|
||||
});
|
||||
items.push({
|
||||
label: 'Generate Custom Covers',
|
||||
label: this.t.translate('book.menuService.menu.generateCustomCovers'),
|
||||
icon: 'pi pi-palette',
|
||||
command: generateCustomCovers
|
||||
});
|
||||
@@ -84,27 +86,27 @@ export class BookMenuService {
|
||||
|
||||
if (permissions?.canBulkResetBookReadStatus) {
|
||||
items.push({
|
||||
label: 'Update Read Status',
|
||||
label: this.t.translate('book.menuService.menu.updateReadStatus'),
|
||||
icon: 'pi pi-book',
|
||||
items: Object.entries(readStatusLabels).map(([status, label]) => ({
|
||||
label,
|
||||
command: () => {
|
||||
this.confirmationService.confirm({
|
||||
message: `Are you sure you want to mark ${count} book(s) as "${label}"?`,
|
||||
header: 'Confirm Read Status Update',
|
||||
message: this.t.translate('book.menuService.confirm.readStatusMessage', {count, label}),
|
||||
header: this.t.translate('book.menuService.confirm.readStatusHeader'),
|
||||
icon: 'pi pi-exclamation-triangle',
|
||||
acceptLabel: 'Yes',
|
||||
rejectLabel: 'No',
|
||||
acceptLabel: this.t.translate('common.yes'),
|
||||
rejectLabel: this.t.translate('common.no'),
|
||||
acceptButtonProps: {
|
||||
label: 'Yes',
|
||||
label: this.t.translate('common.yes'),
|
||||
severity: 'success'
|
||||
},
|
||||
rejectButtonProps: {
|
||||
label: 'No',
|
||||
label: this.t.translate('common.no'),
|
||||
severity: 'secondary'
|
||||
},
|
||||
accept: () => {
|
||||
const loader = this.loadingService.show(`Updating read status for ${count} book(s)...`);
|
||||
const loader = this.loadingService.show(this.t.translate('book.menuService.loading.updatingReadStatus', {count}));
|
||||
|
||||
this.bookService.updateBookReadStatus(Array.from(selectedBooks), status as ReadStatus)
|
||||
.pipe(finalize(() => this.loadingService.hide(loader)))
|
||||
@@ -112,8 +114,8 @@ export class BookMenuService {
|
||||
next: () => {
|
||||
this.messageService.add({
|
||||
severity: 'success',
|
||||
summary: 'Read Status Updated',
|
||||
detail: `Marked as "${label}"`,
|
||||
summary: this.t.translate('book.menuService.toast.readStatusUpdatedSummary'),
|
||||
detail: this.t.translate('book.menuService.toast.readStatusUpdatedDetail', {label}),
|
||||
life: 2000
|
||||
});
|
||||
},
|
||||
@@ -121,8 +123,8 @@ export class BookMenuService {
|
||||
const apiError = err.error as APIException;
|
||||
this.messageService.add({
|
||||
severity: 'error',
|
||||
summary: 'Update Failed',
|
||||
detail: apiError?.message || 'Could not update read status.',
|
||||
summary: this.t.translate('book.menuService.toast.updateFailedSummary'),
|
||||
detail: apiError?.message || this.t.translate('book.menuService.toast.readStatusFailedDetail'),
|
||||
life: 3000
|
||||
});
|
||||
}
|
||||
@@ -136,20 +138,20 @@ export class BookMenuService {
|
||||
|
||||
if (permissions?.canBulkEditMetadata) {
|
||||
items.push({
|
||||
label: 'Set Age Rating',
|
||||
label: this.t.translate('book.menuService.menu.setAgeRating'),
|
||||
icon: 'pi pi-user',
|
||||
items: [
|
||||
...AGE_RATING_OPTIONS.map(option => ({
|
||||
label: option.label,
|
||||
command: () => {
|
||||
this.confirmationService.confirm({
|
||||
message: `Are you sure you want to set the age rating to "${option.label}" for ${count} book(s)?`,
|
||||
header: 'Confirm Age Rating Update',
|
||||
message: this.t.translate('book.menuService.confirm.ageRatingMessage', {label: option.label, count}),
|
||||
header: this.t.translate('book.menuService.confirm.ageRatingHeader'),
|
||||
icon: 'pi pi-exclamation-triangle',
|
||||
acceptLabel: 'Yes',
|
||||
rejectLabel: 'No',
|
||||
acceptLabel: this.t.translate('common.yes'),
|
||||
rejectLabel: this.t.translate('common.no'),
|
||||
accept: () => {
|
||||
const loader = this.loadingService.show(`Setting age rating for ${count} book(s)...`);
|
||||
const loader = this.loadingService.show(this.t.translate('book.menuService.loading.settingAgeRating', {count}));
|
||||
this.bookService.updateBooksMetadata({
|
||||
bookIds: Array.from(selectedBooks),
|
||||
ageRating: option.id
|
||||
@@ -158,8 +160,8 @@ export class BookMenuService {
|
||||
next: () => {
|
||||
this.messageService.add({
|
||||
severity: 'success',
|
||||
summary: 'Age Rating Updated',
|
||||
detail: `Set to "${option.label}"`,
|
||||
summary: this.t.translate('book.menuService.toast.ageRatingUpdatedSummary'),
|
||||
detail: this.t.translate('book.menuService.toast.ageRatingUpdatedDetail', {label: option.label}),
|
||||
life: 2000
|
||||
});
|
||||
},
|
||||
@@ -167,8 +169,8 @@ export class BookMenuService {
|
||||
const apiError = err.error as APIException;
|
||||
this.messageService.add({
|
||||
severity: 'error',
|
||||
summary: 'Update Failed',
|
||||
detail: apiError?.message || 'Could not update age rating.',
|
||||
summary: this.t.translate('book.menuService.toast.updateFailedSummary'),
|
||||
detail: apiError?.message || this.t.translate('book.menuService.toast.ageRatingFailedDetail'),
|
||||
life: 3000
|
||||
});
|
||||
}
|
||||
@@ -181,17 +183,17 @@ export class BookMenuService {
|
||||
separator: true
|
||||
},
|
||||
{
|
||||
label: 'Clear Age Rating',
|
||||
label: this.t.translate('book.menuService.menu.clearAgeRating'),
|
||||
icon: 'pi pi-times',
|
||||
command: () => {
|
||||
this.confirmationService.confirm({
|
||||
message: `Are you sure you want to clear the age rating for ${count} book(s)?`,
|
||||
header: 'Confirm Clear Age Rating',
|
||||
message: this.t.translate('book.menuService.confirm.clearAgeRatingMessage', {count}),
|
||||
header: this.t.translate('book.menuService.confirm.clearAgeRatingHeader'),
|
||||
icon: 'pi pi-exclamation-triangle',
|
||||
acceptLabel: 'Yes',
|
||||
rejectLabel: 'No',
|
||||
acceptLabel: this.t.translate('common.yes'),
|
||||
rejectLabel: this.t.translate('common.no'),
|
||||
accept: () => {
|
||||
const loader = this.loadingService.show(`Clearing age rating for ${count} book(s)...`);
|
||||
const loader = this.loadingService.show(this.t.translate('book.menuService.loading.clearingAgeRating', {count}));
|
||||
this.bookService.updateBooksMetadata({
|
||||
bookIds: Array.from(selectedBooks),
|
||||
clearAgeRating: true
|
||||
@@ -200,8 +202,8 @@ export class BookMenuService {
|
||||
next: () => {
|
||||
this.messageService.add({
|
||||
severity: 'success',
|
||||
summary: 'Age Rating Cleared',
|
||||
detail: 'Age rating has been cleared.',
|
||||
summary: this.t.translate('book.menuService.toast.ageRatingClearedSummary'),
|
||||
detail: this.t.translate('book.menuService.toast.ageRatingClearedDetail'),
|
||||
life: 2000
|
||||
});
|
||||
},
|
||||
@@ -209,8 +211,8 @@ export class BookMenuService {
|
||||
const apiError = err.error as APIException;
|
||||
this.messageService.add({
|
||||
severity: 'error',
|
||||
summary: 'Update Failed',
|
||||
detail: apiError?.message || 'Could not clear age rating.',
|
||||
summary: this.t.translate('book.menuService.toast.updateFailedSummary'),
|
||||
detail: apiError?.message || this.t.translate('book.menuService.toast.clearAgeRatingFailedDetail'),
|
||||
life: 3000
|
||||
});
|
||||
}
|
||||
@@ -223,20 +225,20 @@ export class BookMenuService {
|
||||
});
|
||||
|
||||
items.push({
|
||||
label: 'Set Content Rating',
|
||||
label: this.t.translate('book.menuService.menu.setContentRating'),
|
||||
icon: 'pi pi-shield',
|
||||
items: [
|
||||
...Object.entries(CONTENT_RATING_LABELS).map(([value, label]) => ({
|
||||
label: label,
|
||||
command: () => {
|
||||
this.confirmationService.confirm({
|
||||
message: `Are you sure you want to set the content rating to "${label}" for ${count} book(s)?`,
|
||||
header: 'Confirm Content Rating Update',
|
||||
message: this.t.translate('book.menuService.confirm.contentRatingMessage', {label, count}),
|
||||
header: this.t.translate('book.menuService.confirm.contentRatingHeader'),
|
||||
icon: 'pi pi-exclamation-triangle',
|
||||
acceptLabel: 'Yes',
|
||||
rejectLabel: 'No',
|
||||
acceptLabel: this.t.translate('common.yes'),
|
||||
rejectLabel: this.t.translate('common.no'),
|
||||
accept: () => {
|
||||
const loader = this.loadingService.show(`Setting content rating for ${count} book(s)...`);
|
||||
const loader = this.loadingService.show(this.t.translate('book.menuService.loading.settingContentRating', {count}));
|
||||
this.bookService.updateBooksMetadata({
|
||||
bookIds: Array.from(selectedBooks),
|
||||
contentRating: value
|
||||
@@ -245,8 +247,8 @@ export class BookMenuService {
|
||||
next: () => {
|
||||
this.messageService.add({
|
||||
severity: 'success',
|
||||
summary: 'Content Rating Updated',
|
||||
detail: `Set to "${label}"`,
|
||||
summary: this.t.translate('book.menuService.toast.contentRatingUpdatedSummary'),
|
||||
detail: this.t.translate('book.menuService.toast.contentRatingUpdatedDetail', {label}),
|
||||
life: 2000
|
||||
});
|
||||
},
|
||||
@@ -254,8 +256,8 @@ export class BookMenuService {
|
||||
const apiError = err.error as APIException;
|
||||
this.messageService.add({
|
||||
severity: 'error',
|
||||
summary: 'Update Failed',
|
||||
detail: apiError?.message || 'Could not update content rating.',
|
||||
summary: this.t.translate('book.menuService.toast.updateFailedSummary'),
|
||||
detail: apiError?.message || this.t.translate('book.menuService.toast.contentRatingFailedDetail'),
|
||||
life: 3000
|
||||
});
|
||||
}
|
||||
@@ -268,17 +270,17 @@ export class BookMenuService {
|
||||
separator: true
|
||||
},
|
||||
{
|
||||
label: 'Clear Content Rating',
|
||||
label: this.t.translate('book.menuService.menu.clearContentRating'),
|
||||
icon: 'pi pi-times',
|
||||
command: () => {
|
||||
this.confirmationService.confirm({
|
||||
message: `Are you sure you want to clear the content rating for ${count} book(s)?`,
|
||||
header: 'Confirm Clear Content Rating',
|
||||
message: this.t.translate('book.menuService.confirm.clearContentRatingMessage', {count}),
|
||||
header: this.t.translate('book.menuService.confirm.clearContentRatingHeader'),
|
||||
icon: 'pi pi-exclamation-triangle',
|
||||
acceptLabel: 'Yes',
|
||||
rejectLabel: 'No',
|
||||
acceptLabel: this.t.translate('common.yes'),
|
||||
rejectLabel: this.t.translate('common.no'),
|
||||
accept: () => {
|
||||
const loader = this.loadingService.show(`Clearing content rating for ${count} book(s)...`);
|
||||
const loader = this.loadingService.show(this.t.translate('book.menuService.loading.clearingContentRating', {count}));
|
||||
this.bookService.updateBooksMetadata({
|
||||
bookIds: Array.from(selectedBooks),
|
||||
clearContentRating: true
|
||||
@@ -287,8 +289,8 @@ export class BookMenuService {
|
||||
next: () => {
|
||||
this.messageService.add({
|
||||
severity: 'success',
|
||||
summary: 'Content Rating Cleared',
|
||||
detail: 'Content rating has been cleared.',
|
||||
summary: this.t.translate('book.menuService.toast.contentRatingClearedSummary'),
|
||||
detail: this.t.translate('book.menuService.toast.contentRatingClearedDetail'),
|
||||
life: 2000
|
||||
});
|
||||
},
|
||||
@@ -296,8 +298,8 @@ export class BookMenuService {
|
||||
const apiError = err.error as APIException;
|
||||
this.messageService.add({
|
||||
severity: 'error',
|
||||
summary: 'Update Failed',
|
||||
detail: apiError?.message || 'Could not clear content rating.',
|
||||
summary: this.t.translate('book.menuService.toast.updateFailedSummary'),
|
||||
detail: apiError?.message || this.t.translate('book.menuService.toast.clearContentRatingFailedDetail'),
|
||||
life: 3000
|
||||
});
|
||||
}
|
||||
@@ -313,17 +315,17 @@ export class BookMenuService {
|
||||
// Shelf Actions
|
||||
if (permissions?.canManageLibrary || permissions?.admin) { // Assuming these permissions cover shelf management for books
|
||||
items.push({
|
||||
label: 'Remove from all shelves',
|
||||
label: this.t.translate('book.menuService.menu.removeFromAllShelves'),
|
||||
icon: 'pi pi-bookmark-fill', // Or bookmark-slash
|
||||
command: () => {
|
||||
this.confirmationService.confirm({
|
||||
message: `Are you sure you want to remove ${count} book(s) from ALL their shelves?`,
|
||||
header: 'Confirm Unshelve',
|
||||
message: this.t.translate('book.menuService.confirm.unshelveMessage', {count}),
|
||||
header: this.t.translate('book.menuService.confirm.unshelveHeader'),
|
||||
icon: 'pi pi-exclamation-triangle',
|
||||
acceptLabel: 'Yes',
|
||||
rejectLabel: 'No',
|
||||
acceptLabel: this.t.translate('common.yes'),
|
||||
rejectLabel: this.t.translate('common.no'),
|
||||
accept: () => {
|
||||
const loader = this.loadingService.show(`Removing ${count} book(s) from shelves...`);
|
||||
const loader = this.loadingService.show(this.t.translate('book.menuService.loading.removingFromShelves', {count}));
|
||||
const books = this.bookService.getBooksByIdsFromState(Array.from(selectedBooks));
|
||||
const allShelfIds = new Set<number>();
|
||||
books.forEach(b => b.shelves?.forEach(s => {
|
||||
@@ -332,7 +334,7 @@ export class BookMenuService {
|
||||
|
||||
if (allShelfIds.size === 0) {
|
||||
this.loadingService.hide(loader);
|
||||
this.messageService.add({ severity: 'info', summary: 'Info', detail: 'Selected books are not on any shelves.' });
|
||||
this.messageService.add({ severity: 'info', summary: 'Info', detail: this.t.translate('book.menuService.toast.noBooksOnShelvesDetail') });
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -340,10 +342,10 @@ export class BookMenuService {
|
||||
.pipe(finalize(() => this.loadingService.hide(loader)))
|
||||
.subscribe({
|
||||
next: () => {
|
||||
this.messageService.add({severity: 'success', summary: 'Success', detail: 'Books removed from all shelves'});
|
||||
this.messageService.add({severity: 'success', summary: this.t.translate('common.success'), detail: this.t.translate('book.menuService.toast.unshelveSuccessDetail')});
|
||||
},
|
||||
error: () => {
|
||||
this.messageService.add({severity: 'error', summary: 'Error', detail: 'Failed to update books shelves'});
|
||||
this.messageService.add({severity: 'error', summary: this.t.translate('common.error'), detail: this.t.translate('book.menuService.toast.unshelveFailedDetail')});
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -354,17 +356,17 @@ export class BookMenuService {
|
||||
|
||||
if (permissions?.canBulkResetBookloreReadProgress) {
|
||||
items.push({
|
||||
label: 'Reset Booklore Progress',
|
||||
label: this.t.translate('book.menuService.menu.resetBookloreProgress'),
|
||||
icon: 'pi pi-undo',
|
||||
command: () => {
|
||||
this.confirmationService.confirm({
|
||||
message: `Are you sure you want to reset Booklore reading progress for ${count} book(s)?`,
|
||||
header: 'Confirm Reset',
|
||||
message: this.t.translate('book.menuService.confirm.resetBookloreMessage', {count}),
|
||||
header: this.t.translate('book.menuService.confirm.resetHeader'),
|
||||
icon: 'pi pi-exclamation-triangle',
|
||||
acceptLabel: 'Yes',
|
||||
rejectLabel: 'No',
|
||||
acceptLabel: this.t.translate('common.yes'),
|
||||
rejectLabel: this.t.translate('common.no'),
|
||||
accept: () => {
|
||||
const loader = this.loadingService.show(`Resetting Booklore progress for ${count} book(s)...`);
|
||||
const loader = this.loadingService.show(this.t.translate('book.menuService.loading.resettingBookloreProgress', {count}));
|
||||
|
||||
this.bookService.resetProgress(Array.from(selectedBooks), ResetProgressTypes.BOOKLORE)
|
||||
.pipe(finalize(() => this.loadingService.hide(loader)))
|
||||
@@ -372,8 +374,8 @@ export class BookMenuService {
|
||||
next: () => {
|
||||
this.messageService.add({
|
||||
severity: 'success',
|
||||
summary: 'Progress Reset',
|
||||
detail: 'Booklore reading progress has been reset.',
|
||||
summary: this.t.translate('book.menuService.toast.progressResetSummary'),
|
||||
detail: this.t.translate('book.menuService.toast.bookloreProgressResetDetail'),
|
||||
life: 1500
|
||||
});
|
||||
},
|
||||
@@ -381,8 +383,8 @@ export class BookMenuService {
|
||||
const apiError = err.error as APIException;
|
||||
this.messageService.add({
|
||||
severity: 'error',
|
||||
summary: 'Failed',
|
||||
detail: apiError?.message || 'Could not reset progress.',
|
||||
summary: this.t.translate('book.menuService.toast.failedSummary'),
|
||||
detail: apiError?.message || this.t.translate('book.menuService.toast.progressResetFailedDetail'),
|
||||
life: 3000
|
||||
});
|
||||
}
|
||||
@@ -395,17 +397,17 @@ export class BookMenuService {
|
||||
|
||||
if (permissions?.canBulkResetKoReaderReadProgress) {
|
||||
items.push({
|
||||
label: 'Reset KOReader Progress',
|
||||
label: this.t.translate('book.menuService.menu.resetKOReaderProgress'),
|
||||
icon: 'pi pi-undo',
|
||||
command: () => {
|
||||
this.confirmationService.confirm({
|
||||
message: `Are you sure you want to reset KOReader reading progress for ${count} book(s)?`,
|
||||
header: 'Confirm Reset',
|
||||
message: this.t.translate('book.menuService.confirm.resetKOReaderMessage', {count}),
|
||||
header: this.t.translate('book.menuService.confirm.resetHeader'),
|
||||
icon: 'pi pi-exclamation-triangle',
|
||||
acceptLabel: 'Yes',
|
||||
rejectLabel: 'No',
|
||||
acceptLabel: this.t.translate('common.yes'),
|
||||
rejectLabel: this.t.translate('common.no'),
|
||||
accept: () => {
|
||||
const loader = this.loadingService.show(`Resetting KOReader progress for ${count} book(s)...`);
|
||||
const loader = this.loadingService.show(this.t.translate('book.menuService.loading.resettingKOReaderProgress', {count}));
|
||||
|
||||
this.bookService.resetProgress(Array.from(selectedBooks), ResetProgressTypes.KOREADER)
|
||||
.pipe(finalize(() => this.loadingService.hide(loader)))
|
||||
@@ -413,8 +415,8 @@ export class BookMenuService {
|
||||
next: () => {
|
||||
this.messageService.add({
|
||||
severity: 'success',
|
||||
summary: 'Progress Reset',
|
||||
detail: 'KOReader reading progress has been reset.',
|
||||
summary: this.t.translate('book.menuService.toast.progressResetSummary'),
|
||||
detail: this.t.translate('book.menuService.toast.koreaderProgressResetDetail'),
|
||||
life: 1500
|
||||
});
|
||||
},
|
||||
@@ -422,8 +424,8 @@ export class BookMenuService {
|
||||
const apiError = err.error as APIException;
|
||||
this.messageService.add({
|
||||
severity: 'error',
|
||||
summary: 'Failed',
|
||||
detail: apiError?.message || 'Could not reset progress.',
|
||||
summary: this.t.translate('book.menuService.toast.failedSummary'),
|
||||
detail: apiError?.message || this.t.translate('book.menuService.toast.progressResetFailedDetail'),
|
||||
life: 3000
|
||||
});
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ import {Router} from '@angular/router';
|
||||
import {BookStateService} from './book-state.service';
|
||||
import {BookSocketService} from './book-socket.service';
|
||||
import {BookPatchService} from './book-patch.service';
|
||||
import {TranslocoService} from '@jsverse/transloco';
|
||||
|
||||
export interface BookStatusUpdateResponse {
|
||||
bookId: number;
|
||||
@@ -41,6 +42,7 @@ export class BookService {
|
||||
private bookStateService = inject(BookStateService);
|
||||
private bookSocketService = inject(BookSocketService);
|
||||
private bookPatchService = inject(BookPatchService);
|
||||
private readonly t = inject(TranslocoService);
|
||||
|
||||
private loading$: Observable<Book[]> | null = null;
|
||||
|
||||
@@ -210,22 +212,22 @@ export class BookService {
|
||||
if (response.failedFileDeletions?.length > 0) {
|
||||
this.messageService.add({
|
||||
severity: 'warn',
|
||||
summary: 'Some files could not be deleted',
|
||||
detail: `Books: ${response.failedFileDeletions.join(', ')}`,
|
||||
summary: this.t.translate('book.bookService.toast.someFilesNotDeletedSummary'),
|
||||
detail: this.t.translate('book.bookService.toast.someFilesNotDeletedDetail', {fileNames: response.failedFileDeletions.join(', ')}),
|
||||
});
|
||||
} else {
|
||||
this.messageService.add({
|
||||
severity: 'success',
|
||||
summary: 'Books Deleted',
|
||||
detail: `${idList.length} book(s) deleted successfully.`,
|
||||
summary: this.t.translate('book.bookService.toast.booksDeletedSummary'),
|
||||
detail: this.t.translate('book.bookService.toast.booksDeletedDetail', {count: idList.length}),
|
||||
});
|
||||
}
|
||||
}),
|
||||
catchError(error => {
|
||||
this.messageService.add({
|
||||
severity: 'error',
|
||||
summary: 'Delete Failed',
|
||||
detail: error?.error?.message || error?.message || 'An error occurred while deleting books.',
|
||||
summary: this.t.translate('book.bookService.toast.deleteFailedSummary'),
|
||||
detail: error?.error?.message || error?.message || this.t.translate('book.bookService.toast.deleteFailedDetail'),
|
||||
});
|
||||
return throwError(() => error);
|
||||
})
|
||||
@@ -253,15 +255,15 @@ export class BookService {
|
||||
});
|
||||
this.messageService.add({
|
||||
severity: 'success',
|
||||
summary: 'Physical Book Created',
|
||||
detail: `"${newBook.metadata?.title || 'Book'}" has been added to your library.`
|
||||
summary: this.t.translate('book.bookService.toast.physicalBookCreatedSummary'),
|
||||
detail: this.t.translate('book.bookService.toast.physicalBookCreatedDetail', {title: newBook.metadata?.title || 'Book'})
|
||||
});
|
||||
}),
|
||||
catchError(error => {
|
||||
this.messageService.add({
|
||||
severity: 'error',
|
||||
summary: 'Creation Failed',
|
||||
detail: error?.error?.message || error?.message || 'An error occurred while creating the physical book.'
|
||||
summary: this.t.translate('book.bookService.toast.creationFailedSummary'),
|
||||
detail: error?.error?.message || error?.message || this.t.translate('book.bookService.toast.creationFailedDetail')
|
||||
});
|
||||
return throwError(() => error);
|
||||
})
|
||||
@@ -384,15 +386,15 @@ export class BookService {
|
||||
|
||||
this.messageService.add({
|
||||
severity: 'success',
|
||||
summary: 'File Deleted',
|
||||
detail: 'Additional file deleted successfully.'
|
||||
summary: this.t.translate('book.bookService.toast.fileDeletedSummary'),
|
||||
detail: this.t.translate('book.bookService.toast.additionalFileDeletedDetail')
|
||||
});
|
||||
}),
|
||||
catchError(error => {
|
||||
this.messageService.add({
|
||||
severity: 'error',
|
||||
summary: 'Delete Failed',
|
||||
detail: error?.error?.message || error?.message || 'An error occurred while deleting the file.'
|
||||
summary: this.t.translate('book.bookService.toast.fileDeleteFailedSummary'),
|
||||
detail: error?.error?.message || error?.message || this.t.translate('book.bookService.toast.fileDeleteFailedDetail')
|
||||
});
|
||||
return throwError(() => error);
|
||||
})
|
||||
@@ -441,15 +443,15 @@ export class BookService {
|
||||
|
||||
this.messageService.add({
|
||||
severity: 'success',
|
||||
summary: 'File Deleted',
|
||||
detail: 'Book file deleted successfully.'
|
||||
summary: this.t.translate('book.bookService.toast.fileDeletedSummary'),
|
||||
detail: this.t.translate('book.bookService.toast.bookFileDeletedDetail')
|
||||
});
|
||||
}),
|
||||
catchError(error => {
|
||||
this.messageService.add({
|
||||
severity: 'error',
|
||||
summary: 'Delete Failed',
|
||||
detail: error?.error?.message || error?.message || 'An error occurred while deleting the file.'
|
||||
summary: this.t.translate('book.bookService.toast.fileDeleteFailedSummary'),
|
||||
detail: error?.error?.message || error?.message || this.t.translate('book.bookService.toast.fileDeleteFailedDetail')
|
||||
});
|
||||
return throwError(() => error);
|
||||
})
|
||||
@@ -507,15 +509,15 @@ export class BookService {
|
||||
|
||||
this.messageService.add({
|
||||
severity: 'success',
|
||||
summary: 'File Uploaded',
|
||||
detail: 'Additional file uploaded successfully.'
|
||||
summary: this.t.translate('book.bookService.toast.fileUploadedSummary'),
|
||||
detail: this.t.translate('book.bookService.toast.fileUploadedDetail')
|
||||
});
|
||||
}),
|
||||
catchError(error => {
|
||||
this.messageService.add({
|
||||
severity: 'error',
|
||||
summary: 'Upload Failed',
|
||||
detail: error?.error?.message || error?.message || 'An error occurred while uploading the file.'
|
||||
summary: this.t.translate('book.bookService.toast.uploadFailedSummary'),
|
||||
detail: error?.error?.message || error?.message || this.t.translate('book.bookService.toast.uploadFailedDetail')
|
||||
});
|
||||
return throwError(() => error);
|
||||
})
|
||||
@@ -644,8 +646,8 @@ export class BookService {
|
||||
catchError(error => {
|
||||
this.messageService.add({
|
||||
severity: 'error',
|
||||
summary: 'Field Lock Update Failed',
|
||||
detail: 'Failed to update metadata field locks. Please try again.',
|
||||
summary: this.t.translate('book.bookService.toast.fieldLockFailedSummary'),
|
||||
detail: this.t.translate('book.bookService.toast.fieldLockFailedDetail'),
|
||||
});
|
||||
throw error;
|
||||
})
|
||||
@@ -789,15 +791,15 @@ export class BookService {
|
||||
const fileCount = sourceBookIds.length;
|
||||
this.messageService.add({
|
||||
severity: 'success',
|
||||
summary: 'Files Attached',
|
||||
detail: `${fileCount} book file${fileCount > 1 ? 's have' : ' has'} been attached successfully.`
|
||||
summary: this.t.translate('book.bookService.toast.filesAttachedSummary'),
|
||||
detail: this.t.translate('book.bookService.toast.filesAttachedDetail', {count: fileCount})
|
||||
});
|
||||
}),
|
||||
catchError(error => {
|
||||
this.messageService.add({
|
||||
severity: 'error',
|
||||
summary: 'Attachment Failed',
|
||||
detail: error?.error?.message || error?.message || 'An error occurred while attaching the files.'
|
||||
summary: this.t.translate('book.bookService.toast.attachmentFailedSummary'),
|
||||
detail: error?.error?.message || error?.message || this.t.translate('book.bookService.toast.attachmentFailedDetail')
|
||||
});
|
||||
return throwError(() => error);
|
||||
})
|
||||
|
||||
@@ -13,6 +13,7 @@ import {LoadingService} from '../../../core/services/loading.service';
|
||||
import {finalize} from 'rxjs';
|
||||
import {DialogLauncherService} from '../../../shared/services/dialog-launcher.service';
|
||||
import {BookDialogHelperService} from '../components/book-browser/book-dialog-helper.service';
|
||||
import {TranslocoService} from '@jsverse/transloco';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
@@ -30,14 +31,15 @@ export class LibraryShelfMenuService {
|
||||
private userService = inject(UserService);
|
||||
private loadingService = inject(LoadingService);
|
||||
private bookDialogHelperService = inject(BookDialogHelperService);
|
||||
private readonly t = inject(TranslocoService);
|
||||
|
||||
initializeLibraryMenuItems(entity: Library | Shelf | MagicShelf | null): MenuItem[] {
|
||||
return [
|
||||
{
|
||||
label: 'Options',
|
||||
label: this.t.translate('book.shelfMenuService.library.optionsLabel'),
|
||||
items: [
|
||||
{
|
||||
label: 'Add Physical Book',
|
||||
label: this.t.translate('book.shelfMenuService.library.addPhysicalBook'),
|
||||
icon: 'pi pi-book',
|
||||
command: () => {
|
||||
this.bookDialogHelperService.openAddPhysicalBookDialog(entity?.id as number);
|
||||
@@ -47,44 +49,44 @@ export class LibraryShelfMenuService {
|
||||
separator: true
|
||||
},
|
||||
{
|
||||
label: 'Edit Library',
|
||||
label: this.t.translate('book.shelfMenuService.library.editLibrary'),
|
||||
icon: 'pi pi-pen-to-square',
|
||||
command: () => {
|
||||
this.dialogLauncherService.openLibraryEditDialog((entity?.id as number));
|
||||
}
|
||||
},
|
||||
{
|
||||
label: 'Re-scan Library',
|
||||
label: this.t.translate('book.shelfMenuService.library.rescanLibrary'),
|
||||
icon: 'pi pi-refresh',
|
||||
command: () => {
|
||||
this.confirmationService.confirm({
|
||||
message: `Are you sure you want to refresh library: ${entity?.name}?`,
|
||||
header: 'Confirmation',
|
||||
message: this.t.translate('book.shelfMenuService.confirm.rescanLibraryMessage', {name: entity?.name}),
|
||||
header: this.t.translate('book.shelfMenuService.confirm.header'),
|
||||
icon: undefined,
|
||||
acceptLabel: 'Rescan',
|
||||
rejectLabel: 'Cancel',
|
||||
acceptLabel: this.t.translate('book.shelfMenuService.confirm.rescanLabel'),
|
||||
rejectLabel: this.t.translate('common.cancel'),
|
||||
acceptIcon: undefined,
|
||||
rejectIcon: undefined,
|
||||
acceptButtonStyleClass: undefined,
|
||||
rejectButtonStyleClass: undefined,
|
||||
rejectButtonProps: {
|
||||
label: 'Cancel',
|
||||
label: this.t.translate('common.cancel'),
|
||||
severity: 'secondary',
|
||||
},
|
||||
acceptButtonProps: {
|
||||
label: 'Rescan',
|
||||
label: this.t.translate('book.shelfMenuService.confirm.rescanLabel'),
|
||||
severity: 'success',
|
||||
},
|
||||
accept: () => {
|
||||
this.libraryService.refreshLibrary(entity?.id!).subscribe({
|
||||
complete: () => {
|
||||
this.messageService.add({severity: 'info', summary: 'Success', detail: 'Library refresh scheduled'});
|
||||
this.messageService.add({severity: 'info', summary: this.t.translate('common.success'), detail: this.t.translate('book.shelfMenuService.toast.libraryRefreshSuccessDetail')});
|
||||
},
|
||||
error: () => {
|
||||
this.messageService.add({
|
||||
severity: 'error',
|
||||
summary: 'Failed',
|
||||
detail: 'Failed to refresh library',
|
||||
summary: this.t.translate('book.shelfMenuService.toast.failedSummary'),
|
||||
detail: this.t.translate('book.shelfMenuService.toast.libraryRefreshFailedDetail'),
|
||||
});
|
||||
}
|
||||
});
|
||||
@@ -93,14 +95,14 @@ export class LibraryShelfMenuService {
|
||||
}
|
||||
},
|
||||
{
|
||||
label: 'Custom Fetch Metadata',
|
||||
label: this.t.translate('book.shelfMenuService.library.customFetchMetadata'),
|
||||
icon: 'pi pi-sync',
|
||||
command: () => {
|
||||
this.dialogLauncherService.openLibraryMetadataFetchDialog((entity?.id as number));
|
||||
}
|
||||
},
|
||||
{
|
||||
label: 'Auto Fetch Metadata',
|
||||
label: this.t.translate('book.shelfMenuService.library.autoFetchMetadata'),
|
||||
icon: 'pi pi-bolt',
|
||||
command: () => {
|
||||
this.taskHelperService.refreshMetadataTask({
|
||||
@@ -113,37 +115,37 @@ export class LibraryShelfMenuService {
|
||||
separator: true
|
||||
},
|
||||
{
|
||||
label: 'Delete Library',
|
||||
label: this.t.translate('book.shelfMenuService.library.deleteLibrary'),
|
||||
icon: 'pi pi-trash',
|
||||
command: () => {
|
||||
this.confirmationService.confirm({
|
||||
message: `Are you sure you want to delete library: ${entity?.name}?`,
|
||||
header: 'Confirmation',
|
||||
acceptLabel: 'Yes',
|
||||
rejectLabel: 'Cancel',
|
||||
message: this.t.translate('book.shelfMenuService.confirm.deleteLibraryMessage', {name: entity?.name}),
|
||||
header: this.t.translate('book.shelfMenuService.confirm.header'),
|
||||
acceptLabel: this.t.translate('common.yes'),
|
||||
rejectLabel: this.t.translate('common.cancel'),
|
||||
rejectButtonProps: {
|
||||
label: 'Cancel',
|
||||
label: this.t.translate('common.cancel'),
|
||||
severity: 'secondary',
|
||||
},
|
||||
acceptButtonProps: {
|
||||
label: 'Yes',
|
||||
label: this.t.translate('common.yes'),
|
||||
severity: 'danger',
|
||||
},
|
||||
accept: () => {
|
||||
const loader = this.loadingService.show(`Deleting library '${entity?.name}'...`);
|
||||
const loader = this.loadingService.show(this.t.translate('book.shelfMenuService.loading.deletingLibrary', {name: entity?.name}));
|
||||
|
||||
this.libraryService.deleteLibrary(entity?.id!)
|
||||
.pipe(finalize(() => this.loadingService.hide(loader)))
|
||||
.subscribe({
|
||||
complete: () => {
|
||||
this.router.navigate(['/']);
|
||||
this.messageService.add({severity: 'info', summary: 'Success', detail: 'Library was deleted'});
|
||||
this.messageService.add({severity: 'info', summary: this.t.translate('common.success'), detail: this.t.translate('book.shelfMenuService.toast.libraryDeletedDetail')});
|
||||
},
|
||||
error: () => {
|
||||
this.messageService.add({
|
||||
severity: 'error',
|
||||
summary: 'Failed',
|
||||
detail: 'Failed to delete library',
|
||||
summary: this.t.translate('book.shelfMenuService.toast.failedSummary'),
|
||||
detail: this.t.translate('book.shelfMenuService.toast.libraryDeleteFailedDetail'),
|
||||
});
|
||||
}
|
||||
});
|
||||
@@ -164,10 +166,10 @@ export class LibraryShelfMenuService {
|
||||
|
||||
return [
|
||||
{
|
||||
label: (isPublicShelf ? 'Public Shelf - ' : '') + (disableOptions ? 'Read only' : 'Options'),
|
||||
label: (isPublicShelf ? this.t.translate('book.shelfMenuService.shelf.publicShelfPrefix') : '') + (disableOptions ? this.t.translate('book.shelfMenuService.shelf.readOnly') : this.t.translate('book.shelfMenuService.shelf.optionsLabel')),
|
||||
items: [
|
||||
{
|
||||
label: 'Edit Shelf',
|
||||
label: this.t.translate('book.shelfMenuService.shelf.editShelf'),
|
||||
icon: 'pi pi-pen-to-square',
|
||||
disabled: disableOptions,
|
||||
command: () => {
|
||||
@@ -178,34 +180,34 @@ export class LibraryShelfMenuService {
|
||||
separator: true
|
||||
},
|
||||
{
|
||||
label: 'Delete Shelf',
|
||||
label: this.t.translate('book.shelfMenuService.shelf.deleteShelf'),
|
||||
icon: 'pi pi-trash',
|
||||
disabled: disableOptions,
|
||||
command: () => {
|
||||
this.confirmationService.confirm({
|
||||
message: `Are you sure you want to delete shelf: ${entity?.name}?`,
|
||||
header: 'Confirmation',
|
||||
acceptLabel: 'Yes',
|
||||
rejectLabel: 'Cancel',
|
||||
message: this.t.translate('book.shelfMenuService.confirm.deleteShelfMessage', {name: entity?.name}),
|
||||
header: this.t.translate('book.shelfMenuService.confirm.header'),
|
||||
acceptLabel: this.t.translate('common.yes'),
|
||||
rejectLabel: this.t.translate('common.cancel'),
|
||||
acceptButtonProps: {
|
||||
label: 'Yes',
|
||||
label: this.t.translate('common.yes'),
|
||||
severity: 'danger'
|
||||
},
|
||||
rejectButtonProps: {
|
||||
label: 'Cancel',
|
||||
label: this.t.translate('common.cancel'),
|
||||
severity: 'secondary'
|
||||
},
|
||||
accept: () => {
|
||||
this.shelfService.deleteShelf(entity?.id!).subscribe({
|
||||
complete: () => {
|
||||
this.router.navigate(['/']);
|
||||
this.messageService.add({severity: 'info', summary: 'Success', detail: 'Shelf was deleted'});
|
||||
this.messageService.add({severity: 'info', summary: this.t.translate('common.success'), detail: this.t.translate('book.shelfMenuService.toast.shelfDeletedDetail')});
|
||||
},
|
||||
error: () => {
|
||||
this.messageService.add({
|
||||
severity: 'error',
|
||||
summary: 'Failed',
|
||||
detail: 'Failed to delete shelf',
|
||||
summary: this.t.translate('book.shelfMenuService.toast.failedSummary'),
|
||||
detail: this.t.translate('book.shelfMenuService.toast.shelfDeleteFailedDetail'),
|
||||
});
|
||||
}
|
||||
});
|
||||
@@ -225,10 +227,10 @@ export class LibraryShelfMenuService {
|
||||
|
||||
return [
|
||||
{
|
||||
label: 'Options',
|
||||
label: this.t.translate('book.shelfMenuService.magicShelf.optionsLabel'),
|
||||
items: [
|
||||
{
|
||||
label: 'Edit Magic Shelf',
|
||||
label: this.t.translate('book.shelfMenuService.magicShelf.editMagicShelf'),
|
||||
icon: 'pi pi-pen-to-square',
|
||||
disabled: disableOptions,
|
||||
command: () => {
|
||||
@@ -239,34 +241,34 @@ export class LibraryShelfMenuService {
|
||||
separator: true
|
||||
},
|
||||
{
|
||||
label: 'Delete Magic Shelf',
|
||||
label: this.t.translate('book.shelfMenuService.magicShelf.deleteMagicShelf'),
|
||||
icon: 'pi pi-trash',
|
||||
disabled: disableOptions,
|
||||
command: () => {
|
||||
this.confirmationService.confirm({
|
||||
message: `Are you sure you want to delete magic shelf: ${entity?.name}?`,
|
||||
header: 'Confirmation',
|
||||
acceptLabel: 'Yes',
|
||||
rejectLabel: 'Cancel',
|
||||
message: this.t.translate('book.shelfMenuService.confirm.deleteMagicShelfMessage', {name: entity?.name}),
|
||||
header: this.t.translate('book.shelfMenuService.confirm.header'),
|
||||
acceptLabel: this.t.translate('common.yes'),
|
||||
rejectLabel: this.t.translate('common.cancel'),
|
||||
acceptButtonProps: {
|
||||
label: 'Yes',
|
||||
label: this.t.translate('common.yes'),
|
||||
severity: 'danger'
|
||||
},
|
||||
rejectButtonProps: {
|
||||
label: 'Cancel',
|
||||
label: this.t.translate('common.cancel'),
|
||||
severity: 'secondary'
|
||||
},
|
||||
accept: () => {
|
||||
this.magicShelfService.deleteShelf(entity?.id!).subscribe({
|
||||
complete: () => {
|
||||
this.router.navigate(['/']);
|
||||
this.messageService.add({severity: 'info', summary: 'Success', detail: 'Magic shelf was deleted'});
|
||||
this.messageService.add({severity: 'info', summary: this.t.translate('common.success'), detail: this.t.translate('book.shelfMenuService.toast.magicShelfDeletedDetail')});
|
||||
},
|
||||
error: () => {
|
||||
this.messageService.add({
|
||||
severity: 'error',
|
||||
summary: 'Failed',
|
||||
detail: 'Failed to delete shelf',
|
||||
summary: this.t.translate('book.shelfMenuService.toast.failedSummary'),
|
||||
detail: this.t.translate('book.shelfMenuService.toast.magicShelfDeleteFailedDetail'),
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user