refactor(frontend): rename booklore-ui to frontend
- Frontend path: - rename the tracked Angular app tree from `booklore-ui/` to `frontend/` - preserve file contents during the move so this commit stays focused on the path change itself - Frontend docs: - update the moved frontend README and contribution guide where they refer to the renamed folder - keep those edits limited to path references introduced by the directory rename
This commit is contained in:
+118
@@ -0,0 +1,118 @@
|
||||
<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">{{ isBulkMode ? t('titleBulk') : t('title') }}</h2>
|
||||
<p class="panel-description">{{ isBulkMode ? t('descriptionBulk') : t('description') }}</p>
|
||||
</div>
|
||||
<p-button
|
||||
icon="pi pi-times"
|
||||
[rounded]="true"
|
||||
[text]="true"
|
||||
severity="secondary"
|
||||
(click)="closeDialog()"
|
||||
class="close-button">
|
||||
</p-button>
|
||||
</div>
|
||||
|
||||
<div class="dialog-content">
|
||||
<!-- Source Book(s) Info -->
|
||||
<div class="source-info">
|
||||
<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 || t('unknownTitle') }}</div>
|
||||
@if (book.metadata?.authors?.length) {
|
||||
<div class="book-authors">{{ book.metadata?.authors?.join(', ') }}</div>
|
||||
}
|
||||
<div class="file-info">
|
||||
<i class="pi pi-file"></i>
|
||||
<span>{{ getSourceFileInfo(book) }}</span>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Target Book Selection -->
|
||||
<div class="target-selection">
|
||||
<h3 class="section-title">{{ t('selectTargetBook') }}</h3>
|
||||
<p-autocomplete
|
||||
[(ngModel)]="targetBook"
|
||||
[suggestions]="filteredBooks"
|
||||
(completeMethod)="filterBooks($event)"
|
||||
(onSelect)="onBookSelect($event)"
|
||||
(onClear)="onBookClear()"
|
||||
optionLabel="metadata.title"
|
||||
[dropdown]="true"
|
||||
[showClear]="true"
|
||||
[placeholder]="t('searchPlaceholder')"
|
||||
fluid
|
||||
[disabled]="isAttaching">
|
||||
<ng-template let-book pTemplate="item">
|
||||
<div class="book-suggestion">
|
||||
<div class="suggestion-title">{{ book.metadata?.title || t('unknownTitle') }}</div>
|
||||
@if (book.metadata?.authors?.length) {
|
||||
<div class="suggestion-authors">{{ book.metadata.authors.join(', ') }}</div>
|
||||
}
|
||||
@if (book.primaryFile) {
|
||||
<div class="suggestion-format">{{ book.primaryFile.extension?.toUpperCase() || book.primaryFile.bookType }}</div>
|
||||
}
|
||||
</div>
|
||||
</ng-template>
|
||||
<ng-template let-book pTemplate="selectedItem">
|
||||
<span>{{ getBookDisplayName(book) }}</span>
|
||||
</ng-template>
|
||||
</p-autocomplete>
|
||||
</div>
|
||||
|
||||
<!-- Options -->
|
||||
<div class="delete-option">
|
||||
<p-checkbox
|
||||
[(ngModel)]="moveFiles"
|
||||
[binary]="true"
|
||||
inputId="moveFiles"
|
||||
[disabled]="isAttaching">
|
||||
</p-checkbox>
|
||||
<label for="moveFiles" class="delete-label">
|
||||
{{ t('moveFilesLabel') }}
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<!-- Warning Message -->
|
||||
<div class="warning-message">
|
||||
<i class="pi pi-info-circle"></i>
|
||||
<div class="warning-text">
|
||||
@if (moveFiles) {
|
||||
<p>{{ isBulkMode ? t('warningMoveBulk') : t('warningMove') }}</p>
|
||||
} @else {
|
||||
<p>{{ isBulkMode ? t('warningNoMoveBulk') : t('warningNoMove') }}</p>
|
||||
}
|
||||
<p>{{ isBulkMode ? t('warningDeleteBulk') : t('warningDelete') }}</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Action Buttons -->
|
||||
<div class="action-buttons">
|
||||
<p-button
|
||||
[label]="'common.cancel' | transloco"
|
||||
[outlined]="true"
|
||||
severity="secondary"
|
||||
(click)="closeDialog()"
|
||||
[disabled]="isAttaching">
|
||||
</p-button>
|
||||
<p-button
|
||||
[label]="isBulkMode ? t('attachFilesBulk') : t('attachFile')"
|
||||
icon="pi pi-link"
|
||||
(click)="attach()"
|
||||
[disabled]="!canAttach()"
|
||||
[loading]="isAttaching">
|
||||
</p-button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</ng-container>
|
||||
+180
@@ -0,0 +1,180 @@
|
||||
@use '../../../../shared/styles/panel-shared' as panel;
|
||||
|
||||
.book-file-attacher-container {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.panel-header {
|
||||
@include panel.panel-header;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.dialog-content {
|
||||
flex: 1;
|
||||
overflow-y: auto;
|
||||
min-height: 0;
|
||||
padding: 1.5rem;
|
||||
background: var(--card-background);
|
||||
border: 1px solid var(--border-color);
|
||||
border-top: none;
|
||||
border-radius: 0 0 10px 10px;
|
||||
box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 1.5rem;
|
||||
}
|
||||
|
||||
.section-title {
|
||||
font-size: 0.875rem;
|
||||
font-weight: 600;
|
||||
color: var(--p-text-muted-color);
|
||||
margin-bottom: 0.75rem;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.05em;
|
||||
}
|
||||
|
||||
.source-info {
|
||||
.source-books-list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.5rem;
|
||||
max-height: 200px;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.book-info-card {
|
||||
background: var(--p-surface-100);
|
||||
border-radius: 8px;
|
||||
padding: 0.75rem 1rem;
|
||||
border: 1px solid var(--border-color);
|
||||
}
|
||||
|
||||
.book-title {
|
||||
font-weight: 600;
|
||||
font-size: 0.9375rem;
|
||||
margin-bottom: 0.125rem;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
.book-authors {
|
||||
color: var(--p-text-muted-color);
|
||||
font-size: 0.875rem;
|
||||
margin-bottom: 0.375rem;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
.file-info {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
color: var(--p-primary-color);
|
||||
font-size: 0.875rem;
|
||||
font-weight: 500;
|
||||
|
||||
i {
|
||||
font-size: 0.875rem;
|
||||
}
|
||||
|
||||
span {
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.target-selection {
|
||||
:host ::ng-deep {
|
||||
.full-width {
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.book-suggestion {
|
||||
padding: 0.25rem 0;
|
||||
|
||||
.suggestion-title {
|
||||
font-weight: 500;
|
||||
margin-bottom: 0.125rem;
|
||||
}
|
||||
|
||||
.suggestion-authors {
|
||||
font-size: 0.875rem;
|
||||
color: var(--p-text-muted-color);
|
||||
}
|
||||
|
||||
.suggestion-format {
|
||||
font-size: 0.75rem;
|
||||
color: var(--p-primary-color);
|
||||
font-weight: 600;
|
||||
margin-top: 0.25rem;
|
||||
}
|
||||
}
|
||||
|
||||
.delete-option {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.75rem;
|
||||
|
||||
.delete-label {
|
||||
font-size: 0.9375rem;
|
||||
cursor: pointer;
|
||||
user-select: none;
|
||||
}
|
||||
}
|
||||
|
||||
.warning-message {
|
||||
display: flex;
|
||||
gap: 0.75rem;
|
||||
padding: 1rem;
|
||||
background: var(--p-yellow-50);
|
||||
border: 1px solid var(--p-yellow-200);
|
||||
border-radius: 8px;
|
||||
color: var(--p-yellow-800);
|
||||
|
||||
i {
|
||||
flex-shrink: 0;
|
||||
font-size: 1.25rem;
|
||||
margin-top: 0.125rem;
|
||||
}
|
||||
|
||||
.warning-text {
|
||||
font-size: 0.875rem;
|
||||
line-height: 1.5;
|
||||
|
||||
p {
|
||||
margin: 0;
|
||||
|
||||
&:not(:last-child) {
|
||||
margin-bottom: 0.5rem;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
:host-context(.p-dark) {
|
||||
.warning-message {
|
||||
background: rgba(234, 179, 8, 0.1);
|
||||
border-color: rgba(234, 179, 8, 0.3);
|
||||
color: var(--p-yellow-400);
|
||||
}
|
||||
|
||||
.source-info .book-info-card {
|
||||
background: var(--p-surface-800);
|
||||
}
|
||||
}
|
||||
|
||||
.action-buttons {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
gap: 0.75rem;
|
||||
margin-top: auto;
|
||||
padding-top: 0.5rem;
|
||||
}
|
||||
+160
@@ -0,0 +1,160 @@
|
||||
import { Component, computed, inject, OnInit, OnDestroy, Signal, signal } from '@angular/core';
|
||||
import { FormsModule } from '@angular/forms';
|
||||
import { DynamicDialogRef, DynamicDialogConfig } from 'primeng/dynamicdialog';
|
||||
import { AutoComplete, AutoCompleteSelectEvent } from 'primeng/autocomplete';
|
||||
import { Button } from 'primeng/button';
|
||||
import { Checkbox } from 'primeng/checkbox';
|
||||
import { Subject, takeUntil } from 'rxjs';
|
||||
import { BookService } from '../../service/book.service';
|
||||
import { BookFileService } from '../../service/book-file.service';
|
||||
import { Book } from '../../model/book.model';
|
||||
import {MessageService, PrimeTemplate} from 'primeng/api';
|
||||
import { TranslocoDirective, TranslocoPipe, TranslocoService } from '@jsverse/transloco';
|
||||
import { AppSettingsService } from '../../../../shared/service/app-settings.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-book-file-attacher',
|
||||
standalone: true,
|
||||
imports: [
|
||||
FormsModule,
|
||||
AutoComplete,
|
||||
Button,
|
||||
Checkbox,
|
||||
TranslocoDirective,
|
||||
TranslocoPipe,
|
||||
PrimeTemplate,
|
||||
],
|
||||
templateUrl: './book-file-attacher.component.html',
|
||||
styleUrls: ['./book-file-attacher.component.scss']
|
||||
})
|
||||
export class BookFileAttacherComponent implements OnInit, OnDestroy {
|
||||
sourceBooks: Book[] = [];
|
||||
targetBook: Book | null = null;
|
||||
moveFiles = false;
|
||||
isAttaching = false;
|
||||
searchQuery = '';
|
||||
filteredBooks: Book[] = [];
|
||||
|
||||
private destroy$ = new Subject<void>();
|
||||
private allBooks: Signal<Book[]> = signal([]);
|
||||
|
||||
private readonly t = inject(TranslocoService);
|
||||
private readonly appSettingsService = inject(AppSettingsService);
|
||||
|
||||
constructor(
|
||||
private dialogRef: DynamicDialogRef,
|
||||
private config: DynamicDialogConfig,
|
||||
private bookService: BookService,
|
||||
private bookFileService: BookFileService,
|
||||
private messageService: MessageService
|
||||
) {}
|
||||
|
||||
ngOnInit(): void {
|
||||
// Support both single book and multiple books
|
||||
if (this.config.data.sourceBook) {
|
||||
this.sourceBooks = [this.config.data.sourceBook];
|
||||
} else if (this.config.data.sourceBooks) {
|
||||
this.sourceBooks = this.config.data.sourceBooks;
|
||||
}
|
||||
|
||||
if (this.sourceBooks.length === 0) {
|
||||
this.closeDialog();
|
||||
return;
|
||||
}
|
||||
|
||||
const settings = this.appSettingsService.appSettings();
|
||||
if (settings) {
|
||||
this.moveFiles = settings.metadataPersistenceSettings?.moveFilesToLibraryPattern ?? false;
|
||||
}
|
||||
|
||||
// Get the library ID from first source book (all should be same library)
|
||||
const libraryId = this.sourceBooks[0].libraryId;
|
||||
const sourceBookIds = new Set(this.sourceBooks.map(b => b.id));
|
||||
|
||||
this.allBooks = computed(() =>
|
||||
this.bookService.books().filter(book =>
|
||||
book.libraryId === libraryId && !sourceBookIds.has(book.id)
|
||||
)
|
||||
);
|
||||
|
||||
this.filteredBooks = this.allBooks().slice(0, 20);
|
||||
}
|
||||
|
||||
ngOnDestroy(): void {
|
||||
this.destroy$.next();
|
||||
this.destroy$.complete();
|
||||
}
|
||||
|
||||
get isBulkMode(): boolean {
|
||||
return this.sourceBooks.length > 1;
|
||||
}
|
||||
|
||||
filterBooks(event: { query: string }): void {
|
||||
const query = event.query.toLowerCase().trim();
|
||||
const books = this.allBooks();
|
||||
if (!query) {
|
||||
this.filteredBooks = books.slice(0, 20);
|
||||
return;
|
||||
}
|
||||
|
||||
this.filteredBooks = books
|
||||
.filter(book => {
|
||||
const title = book.metadata?.title?.toLowerCase() || '';
|
||||
const authors = book.metadata?.authors?.join(' ').toLowerCase() || '';
|
||||
return title.includes(query) || authors.includes(query);
|
||||
})
|
||||
.slice(0, 20);
|
||||
}
|
||||
|
||||
onBookSelect(event: AutoCompleteSelectEvent): void {
|
||||
this.targetBook = event.value as Book;
|
||||
}
|
||||
|
||||
onBookClear(): void {
|
||||
this.targetBook = null;
|
||||
}
|
||||
|
||||
getBookDisplayName(book: Book): string {
|
||||
const title = book.metadata?.title || `Book #${book.id}`;
|
||||
const authors = book.metadata?.authors?.join(', ');
|
||||
return authors ? `${title} - ${authors}` : title;
|
||||
}
|
||||
|
||||
getSourceFileInfo(book: Book): string {
|
||||
const file = book.primaryFile;
|
||||
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 {
|
||||
return !!this.targetBook && !this.isAttaching;
|
||||
}
|
||||
|
||||
attach(): void {
|
||||
if (!this.targetBook) return;
|
||||
|
||||
this.isAttaching = true;
|
||||
|
||||
const sourceBookIds = this.sourceBooks.map(b => b.id);
|
||||
|
||||
this.bookFileService.attachBookFiles(
|
||||
this.targetBook.id,
|
||||
sourceBookIds,
|
||||
this.moveFiles
|
||||
).pipe(
|
||||
takeUntil(this.destroy$)
|
||||
).subscribe({
|
||||
next: () => {
|
||||
this.dialogRef.close({ success: true });
|
||||
},
|
||||
error: () => {
|
||||
this.isAttaching = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
closeDialog(): void {
|
||||
this.dialogRef.close();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user