Implement interactive metadata review for batch updates, with progress tracking and a unified notification system
This commit is contained in:
committed by
Aditya Chandel
parent
6576f3351a
commit
116f0c950e
@@ -2,13 +2,15 @@ import {Component, inject, OnInit} from '@angular/core';
|
||||
import {RxStompService} from './shared/websocket/rx-stomp.service';
|
||||
import {Message} from '@stomp/stompjs';
|
||||
import {BookService} from './book/service/book.service';
|
||||
import {EventService} from './shared/websocket/event.service';
|
||||
import {NotificationEventService} from './shared/websocket/notification-event.service';
|
||||
import {parseLogNotification} from './shared/websocket/model/log-notification.model';
|
||||
import {ConfirmDialog} from 'primeng/confirmdialog';
|
||||
import {Toast} from 'primeng/toast';
|
||||
import {RouterOutlet} from '@angular/router';
|
||||
import {AuthInitializationService} from './auth-initialization-service';
|
||||
import {AppConfigService} from './core/service/app-config.service';
|
||||
import {MetadataBatchProgressNotification} from './core/model/metadata-batch-progress.model';
|
||||
import {MetadataProgressService} from './core/service/metadata-progress-service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-root',
|
||||
@@ -23,7 +25,8 @@ export class AppComponent implements OnInit {
|
||||
private authInit = inject(AuthInitializationService);
|
||||
private bookService = inject(BookService);
|
||||
private rxStompService = inject(RxStompService);
|
||||
private eventService = inject(EventService);
|
||||
private notificationEventService = inject(NotificationEventService);
|
||||
private metadataProgressService = inject(MetadataProgressService);
|
||||
private appConfigService = inject(AppConfigService);
|
||||
|
||||
ngOnInit(): void {
|
||||
@@ -49,14 +52,14 @@ export class AppComponent implements OnInit {
|
||||
this.bookService.handleMultipleBookUpdates(updatedBooks);
|
||||
});
|
||||
|
||||
this.rxStompService.watch('/topic/book-metadata-batch-progress').subscribe((message: Message) => {
|
||||
const progress = JSON.parse(message.body) as MetadataBatchProgressNotification;
|
||||
this.metadataProgressService.handleIncomingProgress(progress);
|
||||
});
|
||||
|
||||
this.rxStompService.watch('/topic/log').subscribe((message: Message) => {
|
||||
const logNotification = parseLogNotification(message.body);
|
||||
this.eventService.handleIncomingLog(logNotification);
|
||||
this.notificationEventService.handleNewNotification(logNotification);
|
||||
});
|
||||
}
|
||||
|
||||
sendMessage() {
|
||||
const message = `Message generated at ${new Date()}`;
|
||||
this.rxStompService.publish({destination: '/app/send', body: message});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ import {SettingsComponent} from './settings/settings.component';
|
||||
import {PdfViewerComponent} from './book/components/pdf-viewer/pdf-viewer.component';
|
||||
import {EpubViewerComponent} from './book/components/epub-viewer/component/epub-viewer.component';
|
||||
import {ChangePasswordComponent} from './core/component/change-password/change-password.component';
|
||||
import {BookMetadataCenterComponent} from './book/metadata/book-metadata-center/book-metadata-center.component';
|
||||
import {BookMetadataCenterComponent} from './metadata/book-metadata-center-component/book-metadata-center.component';
|
||||
import {SetupComponent} from './core/setup/setup.component';
|
||||
import {SetupGuard} from './core/setup/setup.guard';
|
||||
import {SetupRedirectGuard} from './core/setup/setup-redirect.guard';
|
||||
|
||||
@@ -2,12 +2,13 @@ import {inject, Injectable} from '@angular/core';
|
||||
import {DialogService, DynamicDialogRef} from 'primeng/dynamicdialog';
|
||||
import {ShelfAssignerComponent} from '../shelf-assigner/shelf-assigner.component';
|
||||
import {LockUnlockMetadataDialogComponent} from './lock-unlock-metadata-dialog/lock-unlock-metadata-dialog.component';
|
||||
import {MetadataFetchOptionsComponent} from '../../metadata/metadata-options-dialog/metadata-fetch-options/metadata-fetch-options.component';
|
||||
import {MetadataRefreshType} from '../../metadata/model/request/metadata-refresh-type.enum';
|
||||
import {BulkMetadataUpdateComponent} from '../../metadata/bulk-metadata-update-component/bulk-metadata-update-component';
|
||||
import {MultiBookMetadataEditorComponent} from '../../metadata/multi-book-metadata-editor-component/multi-book-metadata-editor-component';
|
||||
import {MetadataFetchOptionsComponent} from '../../../metadata/metadata-options-dialog/metadata-fetch-options/metadata-fetch-options.component';
|
||||
import {MetadataRefreshType} from '../../../metadata/model/request/metadata-refresh-type.enum';
|
||||
import {BulkMetadataUpdateComponent} from '../../../metadata/bulk-metadata-update-component/bulk-metadata-update-component';
|
||||
import {MultiBookMetadataEditorComponent} from '../../../metadata/multi-book-metadata-editor-component/multi-book-metadata-editor-component';
|
||||
import {FileMoverComponent} from '../../../file-mover-component/file-mover-component';
|
||||
import {count} from 'rxjs';
|
||||
import {MultiBookMetadataFetchComponent} from '../../../metadata/multi-book-metadata-fetch-component/multi-book-metadata-fetch-component';
|
||||
|
||||
@Injectable({providedIn: 'root'})
|
||||
export class BookDialogHelperService {
|
||||
@@ -45,7 +46,7 @@ export class BookDialogHelperService {
|
||||
}
|
||||
|
||||
openMetadataRefreshDialog(bookIds: Set<number>): DynamicDialogRef {
|
||||
return this.dialogService.open(MetadataFetchOptionsComponent, {
|
||||
return this.dialogService.open(MultiBookMetadataFetchComponent, {
|
||||
header: 'Metadata Refresh Options',
|
||||
modal: true,
|
||||
closable: true,
|
||||
|
||||
@@ -8,9 +8,9 @@ import {ShelfAssignerComponent} from '../../shelf-assigner/shelf-assigner.compon
|
||||
import {BookService} from '../../../service/book.service';
|
||||
import {CheckboxChangeEvent, CheckboxModule} from 'primeng/checkbox';
|
||||
import {FormsModule} from '@angular/forms';
|
||||
import {MetadataFetchOptionsComponent} from '../../../metadata/metadata-options-dialog/metadata-fetch-options/metadata-fetch-options.component';
|
||||
import {MetadataRefreshType} from '../../../metadata/model/request/metadata-refresh-type.enum';
|
||||
import {MetadataRefreshRequest} from '../../../metadata/model/request/metadata-refresh-request.model';
|
||||
import {MetadataFetchOptionsComponent} from '../../../../metadata/metadata-options-dialog/metadata-fetch-options/metadata-fetch-options.component';
|
||||
import {MetadataRefreshType} from '../../../../metadata/model/request/metadata-refresh-type.enum';
|
||||
import {MetadataRefreshRequest} from '../../../../metadata/model/request/metadata-refresh-request.model';
|
||||
import {UrlHelperService} from '../../../../utilities/service/url-helper.service';
|
||||
import {NgClass} from '@angular/common';
|
||||
import {UserService} from '../../../../settings/user-management/user.service';
|
||||
@@ -20,7 +20,7 @@ import {TieredMenu} from 'primeng/tieredmenu';
|
||||
import {BookSenderComponent} from '../../book-sender/book-sender.component';
|
||||
import {Router} from '@angular/router';
|
||||
import {ProgressBar} from 'primeng/progressbar';
|
||||
import {BookMetadataCenterComponent} from '../../../metadata/book-metadata-center/book-metadata-center.component';
|
||||
import {BookMetadataCenterComponent} from '../../../../metadata/book-metadata-center-component/book-metadata-center.component';
|
||||
import {takeUntil} from 'rxjs/operators';
|
||||
|
||||
@Component({
|
||||
|
||||
@@ -12,7 +12,7 @@ import {MessageService} from 'primeng/api';
|
||||
import {Router} from '@angular/router';
|
||||
import {filter, Subject} from 'rxjs';
|
||||
import {UserService} from '../../../../settings/user-management/user.service';
|
||||
import {BookMetadataCenterComponent} from '../../../metadata/book-metadata-center/book-metadata-center.component';
|
||||
import {BookMetadataCenterComponent} from '../../../../metadata/book-metadata-center-component/book-metadata-center.component';
|
||||
import {DialogService} from 'primeng/dynamicdialog';
|
||||
import {takeUntil} from 'rxjs/operators';
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ import {Component, inject, Input, OnInit} from '@angular/core';
|
||||
import {Book} from '../../model/book.model';
|
||||
import {UrlHelperService} from '../../../utilities/service/url-helper.service';
|
||||
import {Button} from 'primeng/button';
|
||||
import {BookMetadataCenterComponent} from '../../metadata/book-metadata-center/book-metadata-center.component';
|
||||
import {BookMetadataCenterComponent} from '../../../metadata/book-metadata-center-component/book-metadata-center.component';
|
||||
import {BookService} from '../../service/book.service';
|
||||
import {DialogService} from 'primeng/dynamicdialog';
|
||||
import {UserService} from '../../../settings/user-management/user.service';
|
||||
|
||||
@@ -48,13 +48,13 @@
|
||||
<!-- Search results below small screen search input -->
|
||||
@if (books.length > 0 || searchQuery) {
|
||||
<div
|
||||
class="search-dropdown layout-menu w-[350px] sm:w-[600px]"
|
||||
class="search-dropdown layout-menu w-[300px] sm:w-[600px]"
|
||||
[class.show]="(books.length > 0)"
|
||||
>
|
||||
@if (books.length > 0) {
|
||||
@for (book of books; track book) {
|
||||
<div class="search-dropdown-item flex flex-col" (click)="onBookClick(book)">
|
||||
<div class="flex flex-row w-full px-2">
|
||||
<div class="flex flex-row w-full p-2">
|
||||
<img
|
||||
[attr.src]="urlHelper.getCoverUrl(book.id, book.metadata?.coverUpdatedOn)"
|
||||
alt="Book Cover"
|
||||
@@ -62,14 +62,12 @@
|
||||
/>
|
||||
<div class="search-book-details">
|
||||
<div class="flex items-center">
|
||||
<p class="search-book-name text-lg font-medium truncate">
|
||||
<p class="search-book-name text font-medium truncate">
|
||||
{{ book.metadata?.title | slice: 0:70 }}
|
||||
</p>
|
||||
</div>
|
||||
@if (book.metadata?.authors?.length ?? 0 > 0) {
|
||||
<div class="search-book-authors">
|
||||
<p class="italic">by: {{ getAuthorNames(book.metadata?.authors) }}</p>
|
||||
</div>
|
||||
<p class="italic text-gray-300">by: {{ getAuthorNames(book.metadata?.authors) }}</p>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -83,7 +83,6 @@ export class LibraryCreatorComponent implements OnInit {
|
||||
}
|
||||
|
||||
openIconPicker() {
|
||||
console.log('aaa')
|
||||
if (this.iconPicker) {
|
||||
this.iconPicker.open();
|
||||
}
|
||||
|
||||
-96
@@ -1,96 +0,0 @@
|
||||
<div class="flex flex-col space-y-6 p-4">
|
||||
<table class="min-w-full table-auto border-collapse custom-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="px-4 py-2 text-left font-semibold text-gray-300">Book Field</th>
|
||||
<th class="px-4 py-2 text-left font-semibold text-gray-300">4th Priority</th>
|
||||
<th class="px-4 py-2 text-left font-semibold text-gray-300">3rd Priority</th>
|
||||
<th class="px-4 py-2 text-left font-semibold text-gray-300">2nd Priority</th>
|
||||
<th class="px-4 py-2 text-left font-semibold text-gray-300">1st Priority</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
||||
<tr>
|
||||
<td class="px-4 py-2 text-gray-300">All Other Fields</td>
|
||||
<td class="px-4 py-2">
|
||||
<p-select [options]="providers" [(ngModel)]="allP4.value"
|
||||
(onChange)="syncProvider($event, 'p4')"
|
||||
placeholder="Select All" appendTo="body"
|
||||
class="w-full">
|
||||
</p-select>
|
||||
</td>
|
||||
<td class="px-4 py-2">
|
||||
<p-select [options]="providers" [(ngModel)]="allP3.value"
|
||||
(onChange)="syncProvider($event, 'p3')"
|
||||
placeholder="Select All" appendTo="body"
|
||||
class="w-full">
|
||||
</p-select>
|
||||
</td>
|
||||
<td class="px-4 py-2">
|
||||
<p-select [options]="providers" [(ngModel)]="allP2.value"
|
||||
(onChange)="syncProvider($event, 'p2')"
|
||||
placeholder="Select All" appendTo="body"
|
||||
class="w-full">
|
||||
</p-select>
|
||||
</td>
|
||||
<td class="px-4 py-2">
|
||||
<p-select [options]="providers" [(ngModel)]="allP1.value"
|
||||
(onChange)="syncProvider($event, 'p1')"
|
||||
placeholder="Select All" appendTo="body"
|
||||
class="w-full">
|
||||
</p-select>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@for (field of fields; track field) {
|
||||
<tr [hidden]="field === 'cover' && !refreshCovers">
|
||||
<td class="px-4 py-2 text-gray-300">{{ formatLabel(field) }}</td>
|
||||
<td class="px-4 py-2">
|
||||
<p-select [options]="providers" [(ngModel)]="fieldOptions[field].p4"
|
||||
placeholder="Unset" appendTo="body"
|
||||
class="w-full">
|
||||
</p-select>
|
||||
</td>
|
||||
<td class="px-4 py-2">
|
||||
<p-select [options]="providers" [(ngModel)]="fieldOptions[field].p3"
|
||||
placeholder="Unset" appendTo="body"
|
||||
class="w-full">
|
||||
</p-select>
|
||||
</td>
|
||||
<td class="px-4 py-2">
|
||||
<p-select [options]="providers" [(ngModel)]="fieldOptions[field].p2"
|
||||
placeholder="Unset" appendTo="body"
|
||||
class="w-full">
|
||||
</p-select>
|
||||
</td>
|
||||
<td class="px-4 py-2">
|
||||
<p-select [options]="providers" [(ngModel)]="fieldOptions[field].p1"
|
||||
placeholder="Unset" appendTo="body"
|
||||
class="w-full">
|
||||
</p-select>
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<div class="flex flex-row items-center justify-between gap-4 w-full">
|
||||
|
||||
<div class="flex flex-row gap-10">
|
||||
<div class="flex flex-row items-center gap-4">
|
||||
<p>Refresh covers:</p>
|
||||
<p-checkbox [(ngModel)]="refreshCovers" [binary]="true"></p-checkbox>
|
||||
</div>
|
||||
<div class="flex flex-row items-center gap-4">
|
||||
<p>Merge categories:</p>
|
||||
<p-checkbox [(ngModel)]="mergeCategories" [binary]="true"></p-checkbox>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="flex flex-row gap-6">
|
||||
<p-button severity="warn" outlined="true" label="Reset" (onClick)="reset()"></p-button>
|
||||
<p-button [label]="submitButtonLabel" outlined="true" (onClick)="submit()"></p-button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -5,8 +5,8 @@ import {catchError, filter, map, tap} from 'rxjs/operators';
|
||||
import {Book, BookDeletionResponse, BookMetadata, BookRecommendation, BookSetting, BulkMetadataUpdateRequest, MetadataUpdateWrapper, ReadStatus} from '../model/book.model';
|
||||
import {BookState} from '../model/state/book-state.model';
|
||||
import {API_CONFIG} from '../../config/api-config';
|
||||
import {FetchMetadataRequest} from '../metadata/model/request/fetch-metadata-request.model';
|
||||
import {MetadataRefreshRequest} from '../metadata/model/request/metadata-refresh-request.model';
|
||||
import {FetchMetadataRequest} from '../../metadata/model/request/fetch-metadata-request.model';
|
||||
import {MetadataRefreshRequest} from '../../metadata/model/request/metadata-refresh-request.model';
|
||||
import {MessageService} from 'primeng/api';
|
||||
|
||||
@Injectable({
|
||||
|
||||
@@ -6,8 +6,8 @@ import {ShelfService} from './shelf.service';
|
||||
import {Library} from '../model/library.model';
|
||||
import {Shelf} from '../model/shelf.model';
|
||||
import {DialogService} from 'primeng/dynamicdialog';
|
||||
import {MetadataFetchOptionsComponent} from '../metadata/metadata-options-dialog/metadata-fetch-options/metadata-fetch-options.component';
|
||||
import {MetadataRefreshType} from '../metadata/model/request/metadata-refresh-type.enum';
|
||||
import {MetadataFetchOptionsComponent} from '../../metadata/metadata-options-dialog/metadata-fetch-options/metadata-fetch-options.component';
|
||||
import {MetadataRefreshType} from '../../metadata/model/request/metadata-refresh-type.enum';
|
||||
import {LibraryCreatorComponent} from '../components/library-creator/library-creator.component';
|
||||
import {ShelfEditDialogComponent} from '../components/shelf-edit-dialog/shelf-edit-dialog.component';
|
||||
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
import {inject, Injectable} from '@angular/core';
|
||||
import {HttpClient} from '@angular/common/http';
|
||||
import {Observable, map} from 'rxjs';
|
||||
import {BookMetadata} from '../model/book.model';
|
||||
import {API_CONFIG} from '../../config/api-config';
|
||||
import {MetadataBatchProgressNotification} from '../../core/model/metadata-batch-progress.model';
|
||||
|
||||
export enum FetchedMetadataProposalStatus {
|
||||
FETCHED = 'FETCHED',
|
||||
ACCEPTED = 'ACCEPTED',
|
||||
REJECTED = 'REJECTED',
|
||||
}
|
||||
|
||||
export interface FetchedProposalDto {
|
||||
proposalId: number;
|
||||
taskId: string;
|
||||
bookId: number;
|
||||
fetchedAt: string;
|
||||
reviewedAt: string | null;
|
||||
reviewerUserId: string | null;
|
||||
status: FetchedMetadataProposalStatus;
|
||||
metadataJson: BookMetadata;
|
||||
}
|
||||
|
||||
export interface MetadataFetchTask {
|
||||
id: string;
|
||||
status: string;
|
||||
completed: number;
|
||||
totalBooks: number;
|
||||
startedAt: string;
|
||||
completedAt: string | null;
|
||||
initiatedBy: string;
|
||||
errorMessage: string | null;
|
||||
|
||||
proposals: FetchedProposalDto[];
|
||||
}
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class MetadataTaskService {
|
||||
|
||||
private readonly url = `${API_CONFIG.BASE_URL}/api/metadata/tasks`;
|
||||
private http = inject(HttpClient);
|
||||
|
||||
getTaskWithProposals(taskId: string): Observable<MetadataFetchTask> {
|
||||
return this.http.get<{ task: MetadataFetchTask }>(`${this.url}/${taskId}`)
|
||||
.pipe(
|
||||
map(response => response.task)
|
||||
);
|
||||
}
|
||||
|
||||
deleteTask(taskId: string): Observable<void> {
|
||||
return this.http.delete<void>(`${this.url}/${taskId}`);
|
||||
}
|
||||
|
||||
updateProposalStatus(taskId: string, proposalId: number, status: string): Observable<void> {
|
||||
return this.http.post<void>(`${this.url}/${taskId}/proposals/${proposalId}/status`, null, {
|
||||
params: {status}
|
||||
});
|
||||
}
|
||||
|
||||
getActiveTasks(): Observable<MetadataBatchProgressNotification[]> {
|
||||
return this.http.get<MetadataBatchProgressNotification[]>(`${this.url}/active`);
|
||||
}
|
||||
}
|
||||
+3
-4
@@ -1,5 +1,4 @@
|
||||
<div class="flex flex-col min-w-20">
|
||||
<p>{{latestEvent.timestamp}}</p>
|
||||
<p>{{latestEvent.message}}</p>
|
||||
<div class="flex flex-col px-4 py-6 live-border">
|
||||
<p>{{ latestNotification.timestamp }}</p>
|
||||
<p>{{ latestNotification.message }}</p>
|
||||
</div>
|
||||
|
||||
|
||||
+5
-1
@@ -1 +1,5 @@
|
||||
|
||||
.live-border {
|
||||
background: var(--card-background);
|
||||
border: 1px solid var(--primary-color);
|
||||
border-radius: 0.5rem;
|
||||
}
|
||||
|
||||
+7
-8
@@ -1,25 +1,24 @@
|
||||
import {Component, inject, Input} from '@angular/core';
|
||||
import {Component, inject} from '@angular/core';
|
||||
import {LogNotification} from '../../../shared/websocket/model/log-notification.model';
|
||||
import {EventService} from '../../../shared/websocket/event.service';
|
||||
import {NotificationEventService} from '../../../shared/websocket/notification-event.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-live-notification-box',
|
||||
standalone: true,
|
||||
templateUrl: './live-notification-box.component.html',
|
||||
styleUrl: './live-notification-box.component.scss',
|
||||
styleUrls: ['./live-notification-box.component.scss'],
|
||||
host: {
|
||||
class: 'config-panel'
|
||||
},
|
||||
})
|
||||
export class LiveNotificationBoxComponent {
|
||||
latestNotification: LogNotification = {message: 'No recent notifications...'};
|
||||
|
||||
latestEvent: LogNotification = {message: 'No recent notifications...'};
|
||||
|
||||
private eventService = inject(EventService);
|
||||
private notificationService = inject(NotificationEventService);
|
||||
|
||||
constructor() {
|
||||
this.eventService.latestEvent$.subscribe(event => {
|
||||
this.latestEvent = event;
|
||||
this.notificationService.latestNotification$.subscribe(notification => {
|
||||
this.latestNotification = notification;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
+60
@@ -0,0 +1,60 @@
|
||||
<div class="task-border mt-4">
|
||||
@if (Object.keys(activeTasks).length > 0) {
|
||||
@for (task of activeTasks | keyvalue; track task; let idx = $index) {
|
||||
<div class="task-card p-4">
|
||||
|
||||
<div class="flex items-center justify-between mb-2">
|
||||
<p class="text-sm font-semibold text-[var(--primary-color)]">Metadata Fetch Task</p>
|
||||
<p-tag
|
||||
[value]="getStatusLabel(task.value.status)"
|
||||
[severity]="getTagSeverity(task.value.status)"
|
||||
class="text-xs"
|
||||
></p-tag>
|
||||
</div>
|
||||
|
||||
<div class="task-message text-gray-200">
|
||||
{{ task.value.message }}
|
||||
</div>
|
||||
|
||||
<div class="task-progress-info text-sm text-gray-300">
|
||||
Book <strong>{{ task.value.status === 'COMPLETED' || task.value.completed >= task.value.total ? task.value.total : task.value.completed + 1 }}</strong>
|
||||
of {{ task.value.total }}
|
||||
</div>
|
||||
|
||||
<p-progressBar
|
||||
[style]="{ height: '15px' }"
|
||||
[value]="getProgressPercent(task.value)"
|
||||
[showValue]="true">
|
||||
</p-progressBar>
|
||||
|
||||
@if (task.value.status === 'COMPLETED' || task.value.status === 'ERROR') {
|
||||
<div class="action-buttons mt-4 flex justify-end gap-2">
|
||||
<p-button
|
||||
label="Review"
|
||||
severity="info"
|
||||
icon="pi pi-search"
|
||||
size="small"
|
||||
outlined
|
||||
(click)="reviewTask(task.key)">
|
||||
</p-button>
|
||||
|
||||
<p-button
|
||||
label="Discard"
|
||||
icon="pi pi-times"
|
||||
severity="danger"
|
||||
size="small"
|
||||
pTooltip="Deletes the fetched metadata"
|
||||
tooltipPosition="top"
|
||||
outlined
|
||||
(click)="clearTask(task.key)">
|
||||
</p-button>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
|
||||
@if (idx < Object.keys(activeTasks).length - 1) {
|
||||
<p-divider></p-divider>
|
||||
}
|
||||
}
|
||||
}
|
||||
</div>
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
.task-border {
|
||||
background: var(--card-background);
|
||||
border: 1px solid var(--primary-color);
|
||||
border-radius: 0.5rem;
|
||||
}
|
||||
|
||||
.task-header {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
margin-bottom: 0.5rem;
|
||||
}
|
||||
|
||||
.task-message {
|
||||
font-size: 1rem;
|
||||
color: var(--text-color);
|
||||
margin-bottom: 0.5rem;
|
||||
}
|
||||
|
||||
.task-progress-info {
|
||||
font-size: 0.875rem;
|
||||
color: var(--text-secondary-color);
|
||||
margin-bottom: 0.5rem;
|
||||
}
|
||||
|
||||
.review-button {
|
||||
text-align: right;
|
||||
margin-top: 0.75rem;
|
||||
}
|
||||
+140
@@ -0,0 +1,140 @@
|
||||
import {Component, inject, OnDestroy, OnInit} from '@angular/core';
|
||||
import {Subject} from 'rxjs';
|
||||
import {takeUntil} from 'rxjs/operators';
|
||||
import {KeyValuePipe} from '@angular/common';
|
||||
import {ProgressBarModule} from 'primeng/progressbar';
|
||||
import {ButtonModule} from 'primeng/button';
|
||||
import {Divider} from 'primeng/divider';
|
||||
import {Tooltip} from 'primeng/tooltip';
|
||||
import {DialogService} from 'primeng/dynamicdialog';
|
||||
|
||||
import {
|
||||
MetadataBatchProgressNotification,
|
||||
MetadataBatchStatus,
|
||||
MetadataBatchStatusLabels
|
||||
} from '../../model/metadata-batch-progress.model';
|
||||
import {MetadataProgressService} from '../../service/metadata-progress-service';
|
||||
import {MetadataReviewDialogComponent} from '../../../metadata/metadata-review-dialog-component/metadata-review-dialog-component';
|
||||
import {MetadataTaskService} from '../../../book/service/metadata-task';
|
||||
import {Tag} from 'primeng/tag';
|
||||
|
||||
@Component({
|
||||
selector: 'app-metadata-progress-widget',
|
||||
templateUrl: './metadata-progress-widget-component.html',
|
||||
styleUrls: ['./metadata-progress-widget-component.scss'],
|
||||
standalone: true,
|
||||
imports: [KeyValuePipe, ProgressBarModule, ButtonModule, Divider, Tooltip, Tag]
|
||||
})
|
||||
export class MetadataProgressWidgetComponent implements OnInit, OnDestroy {
|
||||
activeTasks: { [taskId: string]: MetadataBatchProgressNotification } = {};
|
||||
|
||||
private destroy$ = new Subject<void>();
|
||||
private dialogService = inject(DialogService);
|
||||
private metadataProgressService = inject(MetadataProgressService);
|
||||
private metadataTaskService = inject(MetadataTaskService);
|
||||
|
||||
private lastUpdateMap = new Map<string, number>();
|
||||
private timeoutHandles = new Map<string, any>();
|
||||
private readonly TASK_STALL_TIMEOUT_MS = 60 * 1000; // 1 minute
|
||||
|
||||
ngOnInit(): void {
|
||||
this.metadataProgressService.activeTasks$
|
||||
.pipe(takeUntil(this.destroy$))
|
||||
.subscribe(tasks => {
|
||||
this.activeTasks = tasks;
|
||||
this.checkForStalledTasks(tasks);
|
||||
});
|
||||
}
|
||||
|
||||
private checkForStalledTasks(tasks: { [taskId: string]: MetadataBatchProgressNotification }): void {
|
||||
const now = Date.now();
|
||||
|
||||
for (const taskId of this.timeoutHandles.keys()) {
|
||||
if (!tasks[taskId]) {
|
||||
clearTimeout(this.timeoutHandles.get(taskId));
|
||||
this.timeoutHandles.delete(taskId);
|
||||
this.lastUpdateMap.delete(taskId);
|
||||
}
|
||||
}
|
||||
|
||||
for (const [taskId, task] of Object.entries(tasks)) {
|
||||
this.lastUpdateMap.set(taskId, now);
|
||||
|
||||
if (this.timeoutHandles.has(taskId)) {
|
||||
clearTimeout(this.timeoutHandles.get(taskId));
|
||||
}
|
||||
|
||||
this.timeoutHandles.set(
|
||||
taskId,
|
||||
setTimeout(() => {
|
||||
this.markTaskStalled(taskId);
|
||||
}, this.TASK_STALL_TIMEOUT_MS)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
private markTaskStalled(taskId: string): void {
|
||||
const task = this.activeTasks[taskId];
|
||||
if (!task) return;
|
||||
if (task.status !== MetadataBatchStatus.COMPLETED && task.status !== 'ERROR') {
|
||||
this.activeTasks[taskId] = {
|
||||
...task,
|
||||
status: MetadataBatchStatus.ERROR,
|
||||
message: 'Task stalled or backend unavailable'
|
||||
};
|
||||
this.activeTasks = {...this.activeTasks};
|
||||
}
|
||||
}
|
||||
|
||||
getProgressPercent(task: MetadataBatchProgressNotification): number {
|
||||
return task.total > 0 ? Math.round((task.completed / task.total) * 100) : 0;
|
||||
}
|
||||
|
||||
clearTask(taskId: string): void {
|
||||
this.metadataTaskService.deleteTask(taskId).subscribe(() => {
|
||||
this.metadataProgressService.clearTask(taskId);
|
||||
clearTimeout(this.timeoutHandles.get(taskId));
|
||||
this.timeoutHandles.delete(taskId);
|
||||
this.lastUpdateMap.delete(taskId);
|
||||
});
|
||||
}
|
||||
|
||||
reviewTask(taskId: string): void {
|
||||
this.dialogService.open(MetadataReviewDialogComponent, {
|
||||
showHeader: false,
|
||||
width: '90vw',
|
||||
height: '90vh',
|
||||
data: {taskId},
|
||||
closable: false,
|
||||
modal: true
|
||||
});
|
||||
}
|
||||
|
||||
ngOnDestroy(): void {
|
||||
this.destroy$.next();
|
||||
this.destroy$.complete();
|
||||
for (const timeout of this.timeoutHandles.values()) {
|
||||
clearTimeout(timeout);
|
||||
}
|
||||
this.timeoutHandles.clear();
|
||||
this.lastUpdateMap.clear();
|
||||
}
|
||||
|
||||
getTagSeverity(status: 'IN_PROGRESS' | 'COMPLETED' | 'ERROR'): 'info' | 'success' | 'danger' {
|
||||
switch (status) {
|
||||
case 'COMPLETED':
|
||||
return 'success';
|
||||
case 'ERROR':
|
||||
return 'danger';
|
||||
case 'IN_PROGRESS':
|
||||
default:
|
||||
return 'info';
|
||||
}
|
||||
}
|
||||
|
||||
getStatusLabel(status: MetadataBatchStatus): string {
|
||||
return MetadataBatchStatusLabels[status] ?? status;
|
||||
}
|
||||
|
||||
protected readonly Object = Object;
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
<div class="metadata-progress-box flex flex-col w-[25rem] max-h-[60vh] overflow-y-auto">
|
||||
<app-live-notification-box/>
|
||||
|
||||
@if (hasMetadataTasks$ | async) {
|
||||
<app-metadata-progress-widget/>
|
||||
}
|
||||
</div>
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
.metadata-progress-box {
|
||||
overflow-y: auto;
|
||||
border-radius: 0.5rem;
|
||||
}
|
||||
|
||||
::ng-deep .p-divider-horizontal {
|
||||
margin: 0 !important;
|
||||
padding: 0 !important;
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
import {Component, inject} from '@angular/core';
|
||||
import {LiveNotificationBoxComponent} from '../live-notification-box/live-notification-box.component';
|
||||
import {MetadataProgressWidgetComponent} from '../metadata-progress-widget-component/metadata-progress-widget-component';
|
||||
import {MetadataProgressService} from '../../service/metadata-progress-service';
|
||||
import {map} from 'rxjs/operators';
|
||||
import {AsyncPipe} from '@angular/common';
|
||||
|
||||
@Component({
|
||||
selector: 'app-unified-notification-popover-component',
|
||||
imports: [
|
||||
LiveNotificationBoxComponent,
|
||||
MetadataProgressWidgetComponent,
|
||||
AsyncPipe
|
||||
],
|
||||
templateUrl: './unified-notification-popover-component.html',
|
||||
standalone: true,
|
||||
styleUrl: './unified-notification-popover-component.scss'
|
||||
})
|
||||
export class UnifiedNotificationBoxComponent {
|
||||
metadataProgressService = inject(MetadataProgressService);
|
||||
|
||||
hasMetadataTasks$ = this.metadataProgressService.activeTasks$.pipe(
|
||||
map(tasks => Object.keys(tasks).length > 0)
|
||||
);
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
import {MetadataRefreshOptions} from '../../book/metadata/model/request/metadata-refresh-options.model';
|
||||
import {MetadataRefreshOptions} from '../../metadata/model/request/metadata-refresh-options.model';
|
||||
|
||||
export interface MetadataMatchWeights {
|
||||
title: number;
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
export enum MetadataBatchStatus {
|
||||
IN_PROGRESS = 'IN_PROGRESS',
|
||||
COMPLETED = 'COMPLETED',
|
||||
ERROR = 'ERROR',
|
||||
}
|
||||
|
||||
export const MetadataBatchStatusLabels: Record<MetadataBatchStatus, string> = {
|
||||
[MetadataBatchStatus.IN_PROGRESS]: 'In Progress',
|
||||
[MetadataBatchStatus.COMPLETED]: 'Completed',
|
||||
[MetadataBatchStatus.ERROR]: 'Error',
|
||||
};
|
||||
|
||||
export interface MetadataBatchProgressNotification {
|
||||
taskId: string;
|
||||
completed: number;
|
||||
total: number;
|
||||
message: string;
|
||||
status: MetadataBatchStatus;
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
import {inject, Injectable, OnDestroy} from '@angular/core';
|
||||
import {BehaviorSubject, Subject, Subscription} from 'rxjs';
|
||||
import {MetadataBatchProgressNotification} from '../model/metadata-batch-progress.model';
|
||||
import {MetadataTaskService} from '../../book/service/metadata-task';
|
||||
import {UserService} from '../../settings/user-management/user.service';
|
||||
import {filter, take} from 'rxjs/operators';
|
||||
|
||||
@Injectable({providedIn: 'root'})
|
||||
export class MetadataProgressService implements OnDestroy {
|
||||
private progressMap = new Map<string, BehaviorSubject<MetadataBatchProgressNotification>>();
|
||||
|
||||
private progressUpdatesSubject = new Subject<MetadataBatchProgressNotification>();
|
||||
progressUpdates$ = this.progressUpdatesSubject.asObservable();
|
||||
|
||||
private activeTasksSubject = new BehaviorSubject<{ [taskId: string]: MetadataBatchProgressNotification }>({});
|
||||
activeTasks$ = this.activeTasksSubject.asObservable();
|
||||
|
||||
private metadataTaskService = inject(MetadataTaskService);
|
||||
private userService = inject(UserService);
|
||||
|
||||
private subscriptions = new Subscription();
|
||||
|
||||
constructor() {
|
||||
const sub = this.userService.userState$
|
||||
.pipe(
|
||||
filter(user => !!user),
|
||||
take(1)
|
||||
)
|
||||
.subscribe(user => {
|
||||
if (!this.hasMetadataPermissions(user)) {
|
||||
return;
|
||||
}
|
||||
const activeTasksSub = this.metadataTaskService.getActiveTasks().subscribe({
|
||||
next: (tasks) => this.initializeActiveTasks(tasks),
|
||||
error: (err) => console.warn('Failed to fetch active metadata tasks:', err)
|
||||
});
|
||||
this.subscriptions.add(activeTasksSub);
|
||||
});
|
||||
|
||||
this.subscriptions.add(sub);
|
||||
}
|
||||
|
||||
handleIncomingProgress(progress: MetadataBatchProgressNotification): void {
|
||||
const {taskId} = progress;
|
||||
|
||||
if (!this.progressMap.has(taskId)) {
|
||||
this.progressMap.set(taskId, new BehaviorSubject(progress));
|
||||
} else {
|
||||
this.progressMap.get(taskId)!.next(progress);
|
||||
}
|
||||
|
||||
this.progressUpdatesSubject.next(progress);
|
||||
this.activeTasksSubject.next(this.getActiveTasks());
|
||||
}
|
||||
|
||||
clearTask(taskId: string): void {
|
||||
this.progressMap.delete(taskId);
|
||||
this.activeTasksSubject.next(this.getActiveTasks());
|
||||
}
|
||||
|
||||
getActiveTasks(): { [taskId: string]: MetadataBatchProgressNotification } {
|
||||
const result: { [taskId: string]: MetadataBatchProgressNotification } = {};
|
||||
this.progressMap.forEach((subject, taskId) => {
|
||||
result[taskId] = subject.getValue();
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
private hasMetadataPermissions(user: any): boolean {
|
||||
return user?.permissions?.admin || user?.permissions?.canEditMetadata;
|
||||
}
|
||||
|
||||
private initializeActiveTasks(tasks: MetadataBatchProgressNotification[]): void {
|
||||
for (const task of tasks) {
|
||||
this.progressMap.set(task.taskId, new BehaviorSubject(task));
|
||||
this.progressUpdatesSubject.next(task);
|
||||
}
|
||||
this.activeTasksSubject.next(this.getActiveTasks());
|
||||
}
|
||||
|
||||
ngOnDestroy(): void {
|
||||
this.subscriptions.unsubscribe();
|
||||
this.progressMap.forEach(subject => subject.complete());
|
||||
this.progressUpdatesSubject.complete();
|
||||
this.activeTasksSubject.complete();
|
||||
}
|
||||
}
|
||||
@@ -18,7 +18,7 @@
|
||||
<form class="flex flex-col gap-4" [formGroup]="setupForm" (ngSubmit)="onSubmit()">
|
||||
|
||||
<div class="flex flex-col gap-2">
|
||||
<label for="username" class="text-xl font-medium">Username</label>
|
||||
<label for="username" class="text-lg font-medium">Username</label>
|
||||
<input
|
||||
pInputText
|
||||
id="username"
|
||||
@@ -36,7 +36,7 @@
|
||||
</div>
|
||||
|
||||
<div class="flex flex-col gap-2">
|
||||
<label for="name" class="text-xl font-medium">Name</label>
|
||||
<label for="name" class="text-lg font-medium">Name</label>
|
||||
<input
|
||||
pInputText
|
||||
id="name"
|
||||
@@ -54,7 +54,7 @@
|
||||
</div>
|
||||
|
||||
<div class="flex flex-col gap-2">
|
||||
<label for="email" class="text-xl font-medium">Email</label>
|
||||
<label for="email" class="text-lg font-medium">Email</label>
|
||||
<input
|
||||
pInputText
|
||||
id="email"
|
||||
@@ -72,7 +72,7 @@
|
||||
</div>
|
||||
|
||||
<div class="flex flex-col gap-2">
|
||||
<label for="password" class="text-xl font-medium">Password</label>
|
||||
<label for="password" class="text-lg font-medium">Password</label>
|
||||
<input
|
||||
pInputText
|
||||
id="password"
|
||||
|
||||
@@ -55,19 +55,30 @@
|
||||
</div>
|
||||
|
||||
<p-divider layout="vertical"/>
|
||||
<li class="relative" (mouseenter)="onHover(true)" (mouseleave)="onHover(false)">
|
||||
<button type="button" class="topbar-item"
|
||||
enterActiveClass="animate-scalein"
|
||||
enterFromClass="hidden"
|
||||
leaveActiveClass="animate-fadeout"
|
||||
leaveToClass="hidden"
|
||||
pStyleClass="@next"
|
||||
[hideOnOutsideClick]="true">
|
||||
<i class="pi pi-wave-pulse" style="font-size: 1.5rem" [class.pulsating]="eventHighlight" [class.highlight]="eventHighlight"></i>
|
||||
|
||||
<li class="relative">
|
||||
<button
|
||||
type="button"
|
||||
class="topbar-item"
|
||||
(click)="notificationPopover.toggle($event)"
|
||||
>
|
||||
<i
|
||||
class="pi"
|
||||
[ngClass]="iconClass"
|
||||
[ngStyle]="{ color: iconColor }"
|
||||
style="font-size: 1.25rem"
|
||||
[class.pulsating]="iconPulsating"
|
||||
aria-label="Unified Notification Icon"
|
||||
></i>
|
||||
</button>
|
||||
@if (isHovered) {
|
||||
<app-live-notification-box class="config-panel notification-box"></app-live-notification-box>
|
||||
|
||||
@if (shouldShowNotificationBadge) {
|
||||
<span class="notification-badge">{{ completedTaskCount }}</span>
|
||||
}
|
||||
|
||||
<p-popover #notificationPopover>
|
||||
<app-unified-notification-popover-component></app-unified-notification-popover-component>
|
||||
</p-popover>
|
||||
</li>
|
||||
|
||||
<p-divider layout="vertical"/>
|
||||
|
||||
@@ -2,22 +2,38 @@
|
||||
color: red !important;
|
||||
}
|
||||
|
||||
@keyframes spin {
|
||||
0% { transform: rotate(0deg); }
|
||||
100% { transform: rotate(360deg); }
|
||||
}
|
||||
|
||||
.spin {
|
||||
animation: spin 1.5s linear infinite;
|
||||
}
|
||||
|
||||
@keyframes pulsate {
|
||||
0% {
|
||||
transform: scale(1);
|
||||
opacity: 1;
|
||||
}
|
||||
50% {
|
||||
transform: scale(1.25);
|
||||
opacity: 0.8;
|
||||
}
|
||||
100% {
|
||||
transform: scale(1);
|
||||
opacity: 1;
|
||||
}
|
||||
0% { transform: scale(1); opacity: 1; }
|
||||
50% { transform: scale(1.25); opacity: 0.8; }
|
||||
100% { transform: scale(1); opacity: 1; }
|
||||
}
|
||||
|
||||
.pulsating {
|
||||
animation: pulsate 1.5s infinite ease-in-out;
|
||||
}
|
||||
|
||||
.notification-badge {
|
||||
position: absolute;
|
||||
top: -0.4rem;
|
||||
right: -0.4rem;
|
||||
background-color: var(--red-500);
|
||||
color: yellowgreen;
|
||||
padding: 0 8px;
|
||||
font-size: 1rem;
|
||||
font-weight: 400;
|
||||
line-height: 1.2;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
pointer-events: none;
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
@@ -1,31 +1,36 @@
|
||||
import {Component, ElementRef, OnDestroy, ViewChild} from '@angular/core';
|
||||
import {MenuItem} from 'primeng/api';
|
||||
import {LayoutService} from '../layout-main/service/app.layout.service';
|
||||
import {Router, RouterLink} from '@angular/router';
|
||||
import {DialogService as PrimeDialogService, DynamicDialogRef} from 'primeng/dynamicdialog';
|
||||
import {LibraryCreatorComponent} from '../../../book/components/library-creator/library-creator.component';
|
||||
import {TooltipModule} from 'primeng/tooltip';
|
||||
import {FormsModule} from '@angular/forms';
|
||||
import {InputTextModule} from 'primeng/inputtext';
|
||||
import {BookSearcherComponent} from '../../../book/components/book-searcher/book-searcher.component';
|
||||
import { AsyncPipe, NgClass } from '@angular/common';
|
||||
import {EventService} from '../../../shared/websocket/event.service';
|
||||
import {Button} from 'primeng/button';
|
||||
import {StyleClass} from 'primeng/styleclass';
|
||||
import {Divider} from 'primeng/divider';
|
||||
import {ThemeConfiguratorComponent} from '../theme-configurator/theme-configurator.component';
|
||||
import {LiveNotificationBoxComponent} from '../../../core/component/live-notification-box/live-notification-box.component';
|
||||
import {BookUploaderComponent} from '../../../utilities/component/book-uploader/book-uploader.component';
|
||||
import {AuthService} from '../../../core/service/auth.service';
|
||||
import {UserService} from '../../../settings/user-management/user.service';
|
||||
import {UserProfileDialogComponent} from '../../../settings/global-preferences/user-profile-dialog/user-profile-dialog.component';
|
||||
import {GithubSupportDialog} from '../../../github-support-dialog/github-support-dialog';
|
||||
import {Popover} from 'primeng/popover';
|
||||
import { Component, ElementRef, OnDestroy, ViewChild } from '@angular/core';
|
||||
import { MenuItem } from 'primeng/api';
|
||||
import { LayoutService } from '../layout-main/service/app.layout.service';
|
||||
import { Router, RouterLink } from '@angular/router';
|
||||
import { DialogService as PrimeDialogService, DynamicDialogRef } from 'primeng/dynamicdialog';
|
||||
import { LibraryCreatorComponent } from '../../../book/components/library-creator/library-creator.component';
|
||||
import { TooltipModule } from 'primeng/tooltip';
|
||||
import { FormsModule } from '@angular/forms';
|
||||
import { InputTextModule } from 'primeng/inputtext';
|
||||
import { BookSearcherComponent } from '../../../book/components/book-searcher/book-searcher.component';
|
||||
import { AsyncPipe, NgClass, NgStyle } from '@angular/common';
|
||||
import { NotificationEventService } from '../../../shared/websocket/notification-event.service';
|
||||
import { Button } from 'primeng/button';
|
||||
import { StyleClass } from 'primeng/styleclass';
|
||||
import { Divider } from 'primeng/divider';
|
||||
import { ThemeConfiguratorComponent } from '../theme-configurator/theme-configurator.component';
|
||||
import { BookUploaderComponent } from '../../../utilities/component/book-uploader/book-uploader.component';
|
||||
import { AuthService } from '../../../core/service/auth.service';
|
||||
import { UserService } from '../../../settings/user-management/user.service';
|
||||
import { UserProfileDialogComponent } from '../../../settings/global-preferences/user-profile-dialog/user-profile-dialog.component';
|
||||
import { GithubSupportDialog } from '../../../github-support-dialog/github-support-dialog';
|
||||
import { Popover } from 'primeng/popover';
|
||||
import { MetadataProgressService } from '../../../core/service/metadata-progress-service';
|
||||
import { takeUntil } from 'rxjs/operators';
|
||||
import { Subject } from 'rxjs';
|
||||
import { MetadataBatchProgressNotification } from '../../../core/model/metadata-batch-progress.model';
|
||||
import { UnifiedNotificationBoxComponent } from '../../../core/component/unified-notification-popover-component/unified-notification-popover-component';
|
||||
|
||||
@Component({
|
||||
selector: 'app-topbar',
|
||||
templateUrl: './app.topbar.component.html',
|
||||
styleUrls: ['./app.topbar.component.scss'],
|
||||
standalone: true,
|
||||
imports: [
|
||||
RouterLink,
|
||||
TooltipModule,
|
||||
@@ -37,37 +42,56 @@ import {Popover} from 'primeng/popover';
|
||||
StyleClass,
|
||||
NgClass,
|
||||
Divider,
|
||||
LiveNotificationBoxComponent,
|
||||
AsyncPipe,
|
||||
Popover
|
||||
Popover,
|
||||
UnifiedNotificationBoxComponent,
|
||||
NgStyle,
|
||||
],
|
||||
})
|
||||
export class AppTopBarComponent implements OnDestroy {
|
||||
items!: MenuItem[];
|
||||
ref: DynamicDialogRef | undefined;
|
||||
|
||||
eventHighlight: boolean = false;
|
||||
showEvents: boolean = false;
|
||||
eventTimeout: any;
|
||||
ref?: DynamicDialogRef;
|
||||
|
||||
@ViewChild('menubutton') menuButton!: ElementRef;
|
||||
@ViewChild('topbarmenubutton') topbarMenuButton!: ElementRef;
|
||||
@ViewChild('topbarmenu') menu!: ElementRef;
|
||||
|
||||
constructor(public layoutService: LayoutService, public dialogService: PrimeDialogService,
|
||||
private eventService: EventService, private router: Router, private authService: AuthService,
|
||||
protected userService: UserService) {
|
||||
this.eventService.eventHighlight$.subscribe(highlight => {
|
||||
this.eventHighlight = highlight;
|
||||
});
|
||||
isMenuVisible = true;
|
||||
progressHighlight = false;
|
||||
completedTaskCount = 0;
|
||||
hasActiveOrCompletedTasks = false;
|
||||
showPulse = false;
|
||||
hasAnyTasks = false;
|
||||
|
||||
private eventTimer: any;
|
||||
private destroy$ = new Subject<void>();
|
||||
|
||||
constructor(
|
||||
public layoutService: LayoutService,
|
||||
public dialogService: PrimeDialogService,
|
||||
private notificationService: NotificationEventService,
|
||||
private router: Router,
|
||||
private authService: AuthService,
|
||||
protected userService: UserService,
|
||||
private metadataProgressService: MetadataProgressService
|
||||
) {
|
||||
this.subscribeToMetadataProgress();
|
||||
this.subscribeToNotifications();
|
||||
|
||||
this.metadataProgressService.activeTasks$
|
||||
.pipe(takeUntil(this.destroy$))
|
||||
.subscribe((tasks) => {
|
||||
this.hasAnyTasks = Object.keys(tasks).length > 0;
|
||||
this.updateCompletedTaskCount(tasks);
|
||||
this.updateTaskVisibility(tasks);
|
||||
});
|
||||
}
|
||||
|
||||
isMenuVisible: boolean = true;
|
||||
isHovered: boolean = false;
|
||||
mobileActionsVisible!: boolean;
|
||||
|
||||
onHover(hovered: boolean): void {
|
||||
this.isHovered = hovered;
|
||||
ngOnDestroy(): void {
|
||||
if (this.ref) this.ref.close();
|
||||
clearTimeout(this.eventTimer);
|
||||
this.destroy$.next();
|
||||
this.destroy$.complete();
|
||||
}
|
||||
|
||||
toggleMenu() {
|
||||
@@ -76,65 +100,96 @@ export class AppTopBarComponent implements OnDestroy {
|
||||
}
|
||||
|
||||
openGithubSupportDialog(): void {
|
||||
this.ref = this.dialogService.open(GithubSupportDialog, {
|
||||
header: 'Support BookLore on GitHub',
|
||||
modal: true,
|
||||
closable: true,
|
||||
style: {
|
||||
position: 'absolute',
|
||||
top: '25%',
|
||||
},
|
||||
});
|
||||
this.openDialog(GithubSupportDialog, 'Support BookLore on GitHub', '25%');
|
||||
}
|
||||
|
||||
openLibraryCreatorDialog(): void {
|
||||
this.ref = this.dialogService.open(LibraryCreatorComponent, {
|
||||
header: 'Create New Library',
|
||||
modal: true,
|
||||
closable: true,
|
||||
style: {
|
||||
position: 'absolute',
|
||||
top: '15%',
|
||||
}
|
||||
});
|
||||
this.openDialog(LibraryCreatorComponent, 'Create New Library', '15%');
|
||||
}
|
||||
|
||||
openFileUploadDialog() {
|
||||
this.ref = this.dialogService.open(BookUploaderComponent, {
|
||||
header: 'Book Uploader',
|
||||
modal: true,
|
||||
closable: true,
|
||||
style: {
|
||||
position: 'absolute',
|
||||
top: '10%',
|
||||
}
|
||||
});
|
||||
openFileUploadDialog(): void {
|
||||
this.openDialog(BookUploaderComponent, 'Book Uploader', '10%');
|
||||
}
|
||||
|
||||
ngOnDestroy(): void {
|
||||
if (this.ref) {
|
||||
this.ref.close();
|
||||
}
|
||||
clearTimeout(this.eventTimeout);
|
||||
openUserProfileDialog(): void {
|
||||
this.openDialog(UserProfileDialogComponent, 'User Profile Information', '10%');
|
||||
}
|
||||
|
||||
navigateToSettings() {
|
||||
this.router.navigate(['/settings']);
|
||||
}
|
||||
|
||||
openUserProfileDialog() {
|
||||
this.ref = this.dialogService.open(UserProfileDialogComponent, {
|
||||
header: 'User Profile Information',
|
||||
modal: true,
|
||||
closable: true,
|
||||
style: {
|
||||
position: 'absolute',
|
||||
top: '10%',
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
logout() {
|
||||
this.authService.logout();
|
||||
}
|
||||
|
||||
private openDialog(component: any, header: string, top: string) {
|
||||
this.ref = this.dialogService.open(component, {
|
||||
header,
|
||||
modal: true,
|
||||
closable: true,
|
||||
style: { position: 'absolute', top },
|
||||
});
|
||||
}
|
||||
|
||||
private subscribeToMetadataProgress() {
|
||||
this.metadataProgressService.progressUpdates$
|
||||
.pipe(takeUntil(this.destroy$))
|
||||
.subscribe((progress) => {
|
||||
this.progressHighlight = progress.status === 'IN_PROGRESS';
|
||||
});
|
||||
}
|
||||
|
||||
private subscribeToNotifications() {
|
||||
this.notificationService.latestNotification$
|
||||
.pipe(takeUntil(this.destroy$))
|
||||
.subscribe(() => {
|
||||
this.triggerPulseEffect();
|
||||
});
|
||||
}
|
||||
|
||||
private triggerPulseEffect() {
|
||||
this.showPulse = true;
|
||||
clearTimeout(this.eventTimer);
|
||||
this.eventTimer = setTimeout(() => {
|
||||
this.showPulse = false;
|
||||
}, 4000);
|
||||
}
|
||||
|
||||
private updateCompletedTaskCount(tasks: { [taskId: string]: MetadataBatchProgressNotification }) {
|
||||
this.completedTaskCount = Object.values(tasks).filter(task => task.status === 'COMPLETED').length;
|
||||
}
|
||||
|
||||
private updateTaskVisibility(tasks: { [taskId: string]: MetadataBatchProgressNotification }) {
|
||||
this.hasActiveOrCompletedTasks =
|
||||
this.progressHighlight || this.completedTaskCount > 0 || Object.keys(tasks).length > 0;
|
||||
}
|
||||
|
||||
get iconClass(): string {
|
||||
if (!this.hasAnyTasks) return 'pi-wave-pulse';
|
||||
if (this.progressHighlight) return 'pi-spinner spin';
|
||||
if (this.showPulse) return 'pi-wave-pulse';
|
||||
if (this.completedTaskCount > 0) return 'pi-bell';
|
||||
return 'pi-wave-pulse';
|
||||
}
|
||||
|
||||
get iconColor(): string {
|
||||
if (this.progressHighlight) return 'yellow';
|
||||
if (this.showPulse) return 'red';
|
||||
if (this.completedTaskCount > 0) return 'red';
|
||||
return 'inherit'; // Default to theme/parent styling
|
||||
}
|
||||
|
||||
get iconPulsating(): boolean {
|
||||
return !this.progressHighlight && this.showPulse;
|
||||
}
|
||||
|
||||
get shouldShowNotificationBadge(): boolean {
|
||||
return (
|
||||
this.completedTaskCount > 0 &&
|
||||
!this.progressHighlight &&
|
||||
!this.showPulse &&
|
||||
this.hasAnyTasks
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
+5
-5
@@ -1,7 +1,7 @@
|
||||
import { Component, inject, OnDestroy, OnInit, Optional } from '@angular/core';
|
||||
import { ActivatedRoute } from '@angular/router';
|
||||
import { UserService } from '../../../settings/user-management/user.service';
|
||||
import { Book, BookRecommendation } from '../../model/book.model';
|
||||
import { UserService } from '../../settings/user-management/user.service';
|
||||
import { Book, BookRecommendation } from '../../book/model/book.model';
|
||||
import { BehaviorSubject, Observable, Subject } from 'rxjs';
|
||||
import {
|
||||
distinctUntilChanged,
|
||||
@@ -13,8 +13,8 @@ import {
|
||||
tap,
|
||||
take,
|
||||
} from 'rxjs/operators';
|
||||
import { BookService } from '../../service/book.service';
|
||||
import { AppSettingsService } from '../../../core/service/app-settings.service';
|
||||
import { BookService } from '../../book/service/book.service';
|
||||
import { AppSettingsService } from '../../core/service/app-settings.service';
|
||||
import {
|
||||
Tab,
|
||||
TabList,
|
||||
@@ -26,7 +26,7 @@ import { MetadataViewerComponent } from './metadata-viewer/metadata-viewer.compo
|
||||
import { MetadataEditorComponent } from './metadata-editor/metadata-editor.component';
|
||||
import { MetadataSearcherComponent } from './metadata-searcher/metadata-searcher.component';
|
||||
import { DynamicDialogConfig, DynamicDialogRef } from 'primeng/dynamicdialog';
|
||||
import { BookMetadataHostService } from '../../../book-metadata-host-service';
|
||||
import { BookMetadataHostService } from '../../book-metadata-host-service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-book-metadata-center',
|
||||
+1
-1
@@ -413,7 +413,7 @@
|
||||
</div>
|
||||
<div class="mt-auto">
|
||||
<p-divider></p-divider>
|
||||
<div class="flex flex-col gap-2 px-2 pt-1 md:pb-4 z-10">
|
||||
<div class="flex flex-col gap-2 px-2 pt-4 md:pb-4 z-10">
|
||||
|
||||
<!-- Desktop Buttons -->
|
||||
<div class="hidden sm:flex justify-between w-full gap-4">
|
||||
+4
-4
@@ -6,17 +6,17 @@ import {FormControl, FormGroup, FormsModule, ReactiveFormsModule} from '@angular
|
||||
import {Observable} from 'rxjs';
|
||||
import {AsyncPipe, NgClass} from '@angular/common';
|
||||
import {MessageService} from 'primeng/api';
|
||||
import {Book, BookMetadata, MetadataClearFlags, MetadataUpdateWrapper} from '../../../model/book.model';
|
||||
import {UrlHelperService} from '../../../../utilities/service/url-helper.service';
|
||||
import {Book, BookMetadata, MetadataClearFlags, MetadataUpdateWrapper} from '../../../book/model/book.model';
|
||||
import {UrlHelperService} from '../../../utilities/service/url-helper.service';
|
||||
import {FileUpload, FileUploadErrorEvent, FileUploadEvent} from 'primeng/fileupload';
|
||||
import {HttpResponse} from '@angular/common/http';
|
||||
import {BookService} from '../../../service/book.service';
|
||||
import {BookService} from '../../../book/service/book.service';
|
||||
import {ProgressSpinner} from 'primeng/progressspinner';
|
||||
import {Tooltip} from 'primeng/tooltip';
|
||||
import {Editor} from 'primeng/editor';
|
||||
import {debounceTime} from 'rxjs/operators';
|
||||
import {Tab, TabList, TabPanel, TabPanels, Tabs} from 'primeng/tabs';
|
||||
import {MetadataRestoreDialogComponent} from '../../../components/book-browser/metadata-restore-dialog-component/metadata-restore-dialog-component';
|
||||
import {MetadataRestoreDialogComponent} from '../../../book/components/book-browser/metadata-restore-dialog-component/metadata-restore-dialog-component';
|
||||
import {DialogService} from 'primeng/dynamicdialog';
|
||||
import {takeUntilDestroyed} from '@angular/core/rxjs-interop';
|
||||
import {MetadataRefreshRequest} from '../../model/request/metadata-refresh-request.model';
|
||||
+33
-29
@@ -4,14 +4,14 @@
|
||||
<div class="flex justify-center items-center" [ngStyle]="{'padding-bottom': '0.75rem', 'padding-left': '7.6rem'}">
|
||||
<p class="ml-3 text-lg">Current Metadata</p>
|
||||
<p-button
|
||||
severity="info"
|
||||
severity="success"
|
||||
icon='pi pi-angle-left'
|
||||
[ngStyle]="{'padding-left': '2rem', 'padding-right': '0.5rem'}"
|
||||
[ngStyle]="{'padding-left': '3rem', 'padding-right': '0.5rem'}"
|
||||
[outlined]="true"
|
||||
pTooltip="Move all missing fields" tooltipPosition="bottom"
|
||||
(onClick)="copyMissing()"></p-button>
|
||||
<p-button
|
||||
severity="info"
|
||||
severity="success"
|
||||
icon='pi pi-angle-double-left'
|
||||
[ngStyle]="{'padding-left': '0.5rem', 'padding-right': '2rem'}"
|
||||
[outlined]="true"
|
||||
@@ -57,7 +57,7 @@
|
||||
@if (book.metadata![field.lockedKey]) {
|
||||
<p-button icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock(field.controlName)" severity="warn"></p-button>
|
||||
}
|
||||
<input pInputText id="{{field.controlName}}" formControlName="{{field.controlName}}" class="input"/>
|
||||
<input pSize="small" fluid pInputText id="{{field.controlName}}" formControlName="{{field.controlName}}" class="input"/>
|
||||
<p-button
|
||||
[icon]="isValueSaved(field.controlName) ? 'pi pi-check' : (hoveredFields[field.controlName] && isValueCopied(field.controlName) ? 'pi pi-times' : 'pi pi-arrow-left')"
|
||||
[outlined]="true"
|
||||
@@ -71,7 +71,7 @@
|
||||
(click)="hoveredFields[field.controlName] && isValueCopied(field.controlName) ? resetField(field.controlName) : copyFetchedToCurrent(field.controlName)"
|
||||
(mouseenter)="onMouseEnter(field.controlName)"
|
||||
(mouseleave)="onMouseLeave(field.controlName)"/>
|
||||
<input pInputText [value]="fetchedMetadata[field.fetchedKey] ?? null" class="input" readonly/>
|
||||
<input pSize="small" pInputText [value]="fetchedMetadata[field.fetchedKey] ?? null" class="input" readonly/>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
@@ -85,7 +85,7 @@
|
||||
@if (book.metadata![field.lockedKey]) {
|
||||
<p-button icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock(field.controlName)" severity="warn"></p-button>
|
||||
}
|
||||
<div class="w-full px-2">
|
||||
<div class="w-full px-4">
|
||||
<p-chips formControlName="{{field.controlName}}" addOnBlur="true"></p-chips>
|
||||
</div>
|
||||
<p-button
|
||||
@@ -102,7 +102,7 @@
|
||||
(mouseenter)="onMouseEnter(field.controlName)"
|
||||
(mouseleave)="onMouseLeave(field.controlName)"/>
|
||||
|
||||
<div class="w-full px-2">
|
||||
<div class="w-full px-4">
|
||||
<p-chips
|
||||
[ngModel]="fetchedMetadata[field.fetchedKey] ?? []"
|
||||
[ngModelOptions]="{ standalone: true }"
|
||||
@@ -122,7 +122,7 @@
|
||||
@if (book.metadata![field.lockedKey]) {
|
||||
<p-button icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock(field.controlName)" severity="warn"></p-button>
|
||||
}
|
||||
<textarea rows="6" pTextarea id="{{field.controlName}}" formControlName="{{field.controlName}}" class="input"></textarea>
|
||||
<textarea rows="3" pTextarea id="{{field.controlName}}" formControlName="{{field.controlName}}" class="input"></textarea>
|
||||
<p-button
|
||||
[icon]="isValueSaved(field.controlName) ? 'pi pi-check' : (hoveredFields[field.controlName] && isValueCopied(field.controlName) ? 'pi pi-times' : 'pi pi-arrow-left')"
|
||||
[outlined]="true"
|
||||
@@ -136,7 +136,7 @@
|
||||
(click)="hoveredFields[field.controlName] && isValueCopied(field.controlName) ? resetField(field.controlName) : copyFetchedToCurrent(field.controlName)"
|
||||
(mouseenter)="onMouseEnter(field.controlName)"
|
||||
(mouseleave)="onMouseLeave(field.controlName)"/>
|
||||
<textarea rows="6" pInputText [value]="fetchedMetadata[field.fetchedKey] ?? null" class="input" readonly></textarea>
|
||||
<textarea rows="3" pInputText [value]="fetchedMetadata[field.fetchedKey] ?? null" class="input" readonly></textarea>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
@@ -150,7 +150,7 @@
|
||||
@if (book.metadata![field.lockedKey]) {
|
||||
<p-button icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock(field.controlName)" severity="warn"></p-button>
|
||||
}
|
||||
<input pInputText id="{{field.controlName}}" formControlName="{{field.controlName}}" class="input"/>
|
||||
<input pInputText pSize="small" id="{{field.controlName}}" formControlName="{{field.controlName}}" class="input"/>
|
||||
<p-button
|
||||
[icon]="isValueSaved(field.controlName) ? 'pi pi-check' : (hoveredFields[field.controlName] && isValueCopied(field.controlName) ? 'pi pi-times' : 'pi pi-arrow-left')"
|
||||
[outlined]="true"
|
||||
@@ -164,21 +164,21 @@
|
||||
(click)="hoveredFields[field.controlName] && isValueCopied(field.controlName) ? resetField(field.controlName) : copyFetchedToCurrent(field.controlName)"
|
||||
(mouseenter)="onMouseEnter(field.controlName)"
|
||||
(mouseleave)="onMouseLeave(field.controlName)"/>
|
||||
<input pInputText [value]="fetchedMetadata[field.fetchedKey] ?? null" class="input" readonly/>
|
||||
<input pInputText pSize="small" [value]="fetchedMetadata[field.fetchedKey] ?? null" class="input" readonly/>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
<div class="flex justify-center items-center" [ngStyle]="{'padding-bottom': '0.75rem', 'padding-left': '7.6rem'}">
|
||||
<p class="ml-3 text-lg">Current Metadata</p>
|
||||
<p-button
|
||||
severity="info"
|
||||
severity="success"
|
||||
icon='pi pi-angle-left'
|
||||
[ngStyle]="{'padding-left': '2rem', 'padding-right': '0.5rem'}"
|
||||
[ngStyle]="{'padding-left': '3rem', 'padding-right': '0.5rem'}"
|
||||
[outlined]="true"
|
||||
pTooltip="Move all missing fields" tooltipPosition="bottom"
|
||||
(onClick)="copyMissing()"></p-button>
|
||||
<p-button
|
||||
severity="info"
|
||||
severity="success"
|
||||
icon='pi pi-angle-double-left'
|
||||
[ngStyle]="{'padding-left': '0.5rem', 'padding-right': '2rem'}"
|
||||
[outlined]="true"
|
||||
@@ -187,22 +187,26 @@
|
||||
<p class="text-lg">Fetched Metadata</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="mt-auto">
|
||||
<p-divider></p-divider>
|
||||
<div class="flex justify-between px-2 pt-1 pb-4">
|
||||
<p-button label="To Metadata List" icon="pi pi-arrow-left" severity="info" (onClick)="goBackClick()"></p-button>
|
||||
<div class="flex gap-x-4 justify-end">
|
||||
<p-button label="Unlock All" icon="pi pi-lock-open" [outlined]="true" severity="success" (onClick)="unlockAll()"></p-button>
|
||||
<p-button label="Lock All" icon="pi pi-lock" [outlined]="true" severity="warn" (onClick)="lockAll()"></p-button>
|
||||
<p-divider layout="vertical"/>
|
||||
<p-button
|
||||
label="Save"
|
||||
[icon]="isSaving ? 'pi pi-spin pi-spinner' : 'pi pi-check'"
|
||||
[loading]="isSaving"
|
||||
[disabled]="isSaving"
|
||||
type="submit"></p-button>
|
||||
|
||||
|
||||
@if (!reviewMode) {
|
||||
<div class="mt-auto">
|
||||
<p-divider></p-divider>
|
||||
<div class="flex justify-between px-2 pt-4">
|
||||
<p-button label="To Metadata List" icon="pi pi-arrow-left" severity="info" (onClick)="goBackClick()"></p-button>
|
||||
<div class="flex gap-x-4 justify-end">
|
||||
<p-button label="Unlock All" icon="pi pi-lock-open" [outlined]="true" severity="success" (onClick)="unlockAll()"></p-button>
|
||||
<p-button label="Lock All" icon="pi pi-lock" [outlined]="true" severity="warn" (onClick)="lockAll()"></p-button>
|
||||
<p-divider layout="vertical"/>
|
||||
<p-button
|
||||
label="Save"
|
||||
[icon]="isSaving ? 'pi pi-spin pi-spinner' : 'pi pi-check'"
|
||||
[loading]="isSaving"
|
||||
[disabled]="isSaving"
|
||||
type="submit"></p-button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
</form>
|
||||
}
|
||||
+7
-3
@@ -1,13 +1,13 @@
|
||||
.form-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
margin-bottom: 0.75rem;
|
||||
margin-bottom: 0.5rem;
|
||||
width: 100%;
|
||||
justify-content: flex-start;
|
||||
}
|
||||
|
||||
.label {
|
||||
width: 6rem;
|
||||
width: 7rem;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
width: 50%;
|
||||
padding: 0.5rem;
|
||||
border-radius: 0.25rem;
|
||||
margin: 0 0.5rem;
|
||||
margin: 0 1rem;
|
||||
}
|
||||
|
||||
.thumbnail {
|
||||
@@ -53,3 +53,7 @@
|
||||
--p-button-outlined-primary-border-color: #E32636;
|
||||
--p-button-outlined-primary-color: #E32636;
|
||||
}
|
||||
|
||||
::ng-deep .p-inputchips {
|
||||
width: 100% !important;
|
||||
}
|
||||
+20
-13
@@ -1,5 +1,5 @@
|
||||
import {Component, DestroyRef, EventEmitter, inject, Input, OnInit, Output} from '@angular/core';
|
||||
import {Book, BookMetadata, MetadataClearFlags, MetadataUpdateWrapper} from '../../../model/book.model';
|
||||
import {Book, BookMetadata, MetadataClearFlags, MetadataUpdateWrapper} from '../../../book/model/book.model';
|
||||
import {MessageService} from 'primeng/api';
|
||||
import {Button} from 'primeng/button';
|
||||
import {FormControl, FormGroup, FormsModule, ReactiveFormsModule} from '@angular/forms';
|
||||
@@ -8,8 +8,8 @@ import {AsyncPipe, NgClass, NgStyle} from '@angular/common';
|
||||
import {Divider} from 'primeng/divider';
|
||||
import {Observable} from 'rxjs';
|
||||
import {Tooltip} from 'primeng/tooltip';
|
||||
import {UrlHelperService} from '../../../../utilities/service/url-helper.service';
|
||||
import {BookService} from '../../../service/book.service';
|
||||
import {UrlHelperService} from '../../../utilities/service/url-helper.service';
|
||||
import {BookService} from '../../../book/service/book.service';
|
||||
import {Textarea} from 'primeng/textarea';
|
||||
import {filter, map} from 'rxjs/operators';
|
||||
import {takeUntilDestroyed} from '@angular/core/rxjs-interop';
|
||||
@@ -58,19 +58,20 @@ export class MetadataPickerComponent implements OnInit {
|
||||
{label: 'Language', controlName: 'language', lockedKey: 'languageLocked', fetchedKey: 'language'},
|
||||
{label: 'ISBN-10', controlName: 'isbn10', lockedKey: 'isbn10Locked', fetchedKey: 'isbn10'},
|
||||
{label: 'ISBN-13', controlName: 'isbn13', lockedKey: 'isbn13Locked', fetchedKey: 'isbn13'},
|
||||
{label: 'Amazon ID (ASIN)', controlName: 'asin', lockedKey: 'asinLocked', fetchedKey: 'asin'},
|
||||
{label: 'Amazon Reviews', controlName: 'amazonReviewCount', lockedKey: 'amazonReviewCountLocked', fetchedKey: 'amazonReviewCount'},
|
||||
{label: 'Amazon Rating', controlName: 'amazonRating', lockedKey: 'amazonRatingLocked', fetchedKey: 'amazonRating'},
|
||||
{label: 'Goodreads ID', controlName: 'goodreadsId', lockedKey: 'goodreadsIdLocked', fetchedKey: 'goodreadsId'},
|
||||
{label: 'Goodreads Reviews', controlName: 'goodreadsReviewCount', lockedKey: 'goodreadsReviewCountLocked', fetchedKey: 'goodreadsReviewCount'},
|
||||
{label: 'Goodreads Rating', controlName: 'goodreadsRating', lockedKey: 'goodreadsRatingLocked', fetchedKey: 'goodreadsRating'},
|
||||
{label: 'Hardcover ID', controlName: 'hardcoverId', lockedKey: 'hardcoverIdLocked', fetchedKey: 'hardcoverId'},
|
||||
{label: 'Hardcover Reviews', controlName: 'hardcoverReviewCount', lockedKey: 'hardcoverReviewCountLocked', fetchedKey: 'hardcoverReviewCount'},
|
||||
{label: 'Hardcover Rating', controlName: 'hardcoverRating', lockedKey: 'hardcoverRatingLocked', fetchedKey: 'hardcoverRating'},
|
||||
{label: 'Google Books ID', controlName: 'googleId', lockedKey: 'googleIdLocked', fetchedKey: 'googleIdRating'},
|
||||
{label: 'ASIN', controlName: 'asin', lockedKey: 'asinLocked', fetchedKey: 'asin'},
|
||||
{label: 'Amz Reviews', controlName: 'amazonReviewCount', lockedKey: 'amazonReviewCountLocked', fetchedKey: 'amazonReviewCount'},
|
||||
{label: 'Amz Rating', controlName: 'amazonRating', lockedKey: 'amazonRatingLocked', fetchedKey: 'amazonRating'},
|
||||
{label: 'GR ID', controlName: 'goodreadsId', lockedKey: 'goodreadsIdLocked', fetchedKey: 'goodreadsId'},
|
||||
{label: 'GR Reviews', controlName: 'goodreadsReviewCount', lockedKey: 'goodreadsReviewCountLocked', fetchedKey: 'goodreadsReviewCount'},
|
||||
{label: 'GR Rating', controlName: 'goodreadsRating', lockedKey: 'goodreadsRatingLocked', fetchedKey: 'goodreadsRating'},
|
||||
{label: 'HC ID', controlName: 'hardcoverId', lockedKey: 'hardcoverIdLocked', fetchedKey: 'hardcoverId'},
|
||||
{label: 'HC Reviews', controlName: 'hardcoverReviewCount', lockedKey: 'hardcoverReviewCountLocked', fetchedKey: 'hardcoverReviewCount'},
|
||||
{label: 'HC Rating', controlName: 'hardcoverRating', lockedKey: 'hardcoverRatingLocked', fetchedKey: 'hardcoverRating'},
|
||||
{label: 'Google ID', controlName: 'googleId', lockedKey: 'googleIdLocked', fetchedKey: 'googleIdRating'},
|
||||
{label: 'Pages', controlName: 'pageCount', lockedKey: 'pageCountLocked', fetchedKey: 'pageCount'}
|
||||
];
|
||||
|
||||
@Input() reviewMode!: boolean;
|
||||
@Input() fetchedMetadata!: BookMetadata;
|
||||
@Input() book$!: Observable<Book | null>;
|
||||
@Output() goBack = new EventEmitter<boolean>();
|
||||
@@ -151,6 +152,12 @@ export class MetadataPickerComponent implements OnInit {
|
||||
map(book => book.metadata),
|
||||
takeUntilDestroyed(this.destroyRef)
|
||||
).subscribe((metadata) => {
|
||||
|
||||
this.metadataForm.reset();
|
||||
this.copiedFields = {};
|
||||
this.savedFields = {};
|
||||
this.hoveredFields = {};
|
||||
|
||||
if (metadata) {
|
||||
this.originalMetadata = metadata;
|
||||
this.originalMetadata.thumbnailUrl = this.urlHelper.getCoverUrl(metadata.bookId, metadata.coverUpdatedOn);
|
||||
+2
-2
@@ -8,7 +8,7 @@
|
||||
</div>
|
||||
} @else {
|
||||
<form class="flex flex-col w-full h-full pt-2 min-w-full md:min-w-[60rem] pr-0 md:pr-2 pl-0 md:pl-2" [formGroup]="form" (ngSubmit)="onSubmit()">
|
||||
<!-- Responsive search inputs -->
|
||||
|
||||
<div class="grid grid-cols-1 md:flex md:flex-row w-full gap-4 md:items-end">
|
||||
|
||||
<div class="flex flex-col gap-1 w-full max-w-full md:w-3/12">
|
||||
@@ -60,7 +60,7 @@
|
||||
@for (metadata of allFetchedMetadata; track metadata) {
|
||||
<div class="book-item flex flex-col w-full">
|
||||
<div class="flex flex-row w-full book-item-content cursor-pointer" (click)="onBookClick(metadata)">
|
||||
<img [src]="metadata.thumbnailUrl || 'assets/images/missing-cover.jpg'" alt="Image" class="img-fixed-dimensions pr-0 md:pr-2 self-center md:self-start"/>
|
||||
<img [src]="metadata.thumbnailUrl || 'assets/images/missing-cover.jpg'" alt="Image" class="img-fixed-dimensions pr-0 md:pr-2 md:py-3 self-center md:self-start"/>
|
||||
<div class="flex flex-col w-full m-2">
|
||||
<div class="flex flex-col md:flex-row gap-2 md:gap-4 justify-between">
|
||||
<p class="font-bold">{{ truncateText(metadata['title']!, 90) }}</p>
|
||||
+16
-37
@@ -1,42 +1,21 @@
|
||||
import {
|
||||
Component,
|
||||
inject,
|
||||
Input,
|
||||
OnDestroy,
|
||||
OnInit
|
||||
} from '@angular/core';
|
||||
import {
|
||||
FormBuilder,
|
||||
FormGroup,
|
||||
ReactiveFormsModule
|
||||
} from '@angular/forms';
|
||||
import { Button } from 'primeng/button';
|
||||
import { InputText } from 'primeng/inputtext';
|
||||
import { Divider } from 'primeng/divider';
|
||||
import { MultiSelect } from 'primeng/multiselect';
|
||||
import { ProgressSpinner } from 'primeng/progressspinner';
|
||||
import {Component, inject, Input, OnDestroy, OnInit} from '@angular/core';
|
||||
import {FormBuilder, FormGroup, ReactiveFormsModule} from '@angular/forms';
|
||||
import {Button} from 'primeng/button';
|
||||
import {InputText} from 'primeng/inputtext';
|
||||
import {Divider} from 'primeng/divider';
|
||||
import {MultiSelect} from 'primeng/multiselect';
|
||||
import {ProgressSpinner} from 'primeng/progressspinner';
|
||||
|
||||
import { FetchMetadataRequest } from '../../model/request/fetch-metadata-request.model';
|
||||
import { MetadataPickerComponent } from '../metadata-picker/metadata-picker.component';
|
||||
import { Book, BookMetadata } from '../../../model/book.model';
|
||||
import { BookService } from '../../../service/book.service';
|
||||
import { AppSettings } from '../../../../core/model/app-settings.model';
|
||||
import { AppSettingsService } from '../../../../core/service/app-settings.service';
|
||||
import {FetchMetadataRequest} from '../../model/request/fetch-metadata-request.model';
|
||||
import {MetadataPickerComponent} from '../metadata-picker/metadata-picker.component';
|
||||
import {Book, BookMetadata} from '../../../book/model/book.model';
|
||||
import {BookService} from '../../../book/service/book.service';
|
||||
import {AppSettings} from '../../../core/model/app-settings.model';
|
||||
import {AppSettingsService} from '../../../core/service/app-settings.service';
|
||||
|
||||
import {
|
||||
combineLatest,
|
||||
Observable,
|
||||
Subject,
|
||||
Subscription,
|
||||
takeUntil,
|
||||
BehaviorSubject
|
||||
} from 'rxjs';
|
||||
import {
|
||||
distinctUntilChanged,
|
||||
filter,
|
||||
switchMap
|
||||
} from 'rxjs/operators';
|
||||
import { ActivatedRoute } from '@angular/router';
|
||||
import {BehaviorSubject, combineLatest, Observable, Subject, Subscription, takeUntil} from 'rxjs';
|
||||
import {distinctUntilChanged, filter, switchMap} from 'rxjs/operators';
|
||||
import {ActivatedRoute} from '@angular/router';
|
||||
import {AsyncPipe} from '@angular/common';
|
||||
|
||||
@Component({
|
||||
+8
-8
@@ -2,20 +2,20 @@ import {Component, DestroyRef, inject, Input, OnChanges, OnInit, Optional, Simpl
|
||||
import {Button} from 'primeng/button';
|
||||
import {AsyncPipe, DecimalPipe, NgClass} from '@angular/common';
|
||||
import {Observable} from 'rxjs';
|
||||
import {BookService} from '../../../service/book.service';
|
||||
import {BookService} from '../../../book/service/book.service';
|
||||
import {Rating, RatingRateEvent} from 'primeng/rating';
|
||||
import {FormsModule} from '@angular/forms';
|
||||
import {Tag} from 'primeng/tag';
|
||||
import {Book, BookMetadata, BookRecommendation, ReadStatus} from '../../../model/book.model';
|
||||
import {Book, BookMetadata, BookRecommendation, ReadStatus} from '../../../book/model/book.model';
|
||||
import {Divider} from 'primeng/divider';
|
||||
import {UrlHelperService} from '../../../../utilities/service/url-helper.service';
|
||||
import {UserService} from '../../../../settings/user-management/user.service';
|
||||
import {UrlHelperService} from '../../../utilities/service/url-helper.service';
|
||||
import {UserService} from '../../../settings/user-management/user.service';
|
||||
import {SplitButton} from 'primeng/splitbutton';
|
||||
import {ConfirmationService, MenuItem, MessageService} from 'primeng/api';
|
||||
import {BookSenderComponent} from '../../../components/book-sender/book-sender.component';
|
||||
import {BookSenderComponent} from '../../../book/components/book-sender/book-sender.component';
|
||||
import {DialogService, DynamicDialogRef} from 'primeng/dynamicdialog';
|
||||
import {EmailService} from '../../../../settings/email/email.service';
|
||||
import {ShelfAssignerComponent} from '../../../components/shelf-assigner/shelf-assigner.component';
|
||||
import {EmailService} from '../../../settings/email/email.service';
|
||||
import {ShelfAssignerComponent} from '../../../book/components/shelf-assigner/shelf-assigner.component';
|
||||
import {Tooltip} from 'primeng/tooltip';
|
||||
import {takeUntilDestroyed} from '@angular/core/rxjs-interop';
|
||||
import {Editor} from 'primeng/editor';
|
||||
@@ -27,7 +27,7 @@ import {Router} from '@angular/router';
|
||||
import {filter, map, take} from 'rxjs/operators';
|
||||
import {Menu} from 'primeng/menu';
|
||||
import {InfiniteScrollDirective} from 'ngx-infinite-scroll';
|
||||
import {BookCardLiteComponent} from '../../../components/book-card-lite/book-card-lite-component';
|
||||
import {BookCardLiteComponent} from '../../../book/components/book-card-lite/book-card-lite-component';
|
||||
|
||||
@Component({
|
||||
selector: 'app-metadata-viewer',
|
||||
+2
-2
@@ -8,8 +8,8 @@ import {Chips} from 'primeng/chips';
|
||||
import {DatePicker} from 'primeng/datepicker';
|
||||
import {DynamicDialogConfig, DynamicDialogRef} from 'primeng/dynamicdialog';
|
||||
import {MessageService} from 'primeng/api';
|
||||
import {BookService} from '../../service/book.service';
|
||||
import {Book, BulkMetadataUpdateRequest} from '../../model/book.model';
|
||||
import {BookService} from '../../book/service/book.service';
|
||||
import {Book, BulkMetadataUpdateRequest} from '../../book/model/book.model';
|
||||
import {Checkbox} from 'primeng/checkbox';
|
||||
import {ProgressSpinner} from 'primeng/progressspinner';
|
||||
|
||||
+102
@@ -0,0 +1,102 @@
|
||||
<div class="flex flex-col space-y-6 p-4">
|
||||
<table class="min-w-full table-auto border-collapse custom-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="px-4 py-1.5 text-left font-semibold text-gray-300">Book Field</th>
|
||||
<th class="px-4 py-1.5 text-left font-semibold text-gray-300">4th Priority</th>
|
||||
<th class="px-4 py-1.5 text-left font-semibold text-gray-300">3rd Priority</th>
|
||||
<th class="px-4 py-1.5 text-left font-semibold text-gray-300">2nd Priority</th>
|
||||
<th class="px-4 py-1.5 text-left font-semibold text-gray-300">1st Priority</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
||||
<tr>
|
||||
<td class="text-sm px-4 py-1.5 text-gray-300">All Other Fields</td>
|
||||
<td class="px-4 py-1.5">
|
||||
<p-select [options]="providers" [(ngModel)]="allP4.value"
|
||||
(onChange)="syncProvider($event, 'p4')"
|
||||
placeholder="Select All" appendTo="body"
|
||||
class="w-full" size="small">
|
||||
</p-select>
|
||||
</td>
|
||||
<td class="px-4 py-1.5">
|
||||
<p-select [options]="providers" [(ngModel)]="allP3.value"
|
||||
(onChange)="syncProvider($event, 'p3')"
|
||||
placeholder="Select All" appendTo="body"
|
||||
class="w-full" size="small">
|
||||
</p-select>
|
||||
</td>
|
||||
<td class="px-4 py-1.5">
|
||||
<p-select [options]="providers" [(ngModel)]="allP2.value"
|
||||
(onChange)="syncProvider($event, 'p2')"
|
||||
placeholder="Select All" appendTo="body"
|
||||
class="w-full" size="small">
|
||||
</p-select>
|
||||
</td>
|
||||
<td class="px-4 py-1.5">
|
||||
<p-select [options]="providers" [(ngModel)]="allP1.value"
|
||||
(onChange)="syncProvider($event, 'p1')"
|
||||
placeholder="Select All" appendTo="body"
|
||||
class="w-full" size="small">
|
||||
</p-select>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@for (field of fields; track field) {
|
||||
<tr [hidden]="field === 'cover' && !refreshCovers">
|
||||
<td class="text-sm px-4 py-1.5 text-gray-300">{{ formatLabel(field) }}</td>
|
||||
<td class="px-4 py-1.5">
|
||||
<p-select [options]="providers" [(ngModel)]="fieldOptions[field].p4"
|
||||
placeholder="Unset" appendTo="body"
|
||||
class="w-full" size="small">
|
||||
</p-select>
|
||||
</td>
|
||||
<td class="px-4 py-1.5">
|
||||
<p-select [options]="providers" [(ngModel)]="fieldOptions[field].p3"
|
||||
placeholder="Unset" appendTo="body"
|
||||
class="w-full" size="small">
|
||||
</p-select>
|
||||
</td>
|
||||
<td class="px-4 py-1.5">
|
||||
<p-select [options]="providers" [(ngModel)]="fieldOptions[field].p2"
|
||||
placeholder="Unset" appendTo="body"
|
||||
class="w-full" size="small">
|
||||
</p-select>
|
||||
</td>
|
||||
<td class="px-4 py-1.5">
|
||||
<p-select [options]="providers" [(ngModel)]="fieldOptions[field].p1"
|
||||
placeholder="Unset" appendTo="body"
|
||||
class="w-full" size="small">
|
||||
</p-select>
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
|
||||
<div class="flex flex-row items-center justify-between gap-4 w-full">
|
||||
|
||||
<div class="flex flex-row gap-10">
|
||||
<div class="flex flex-row items-center gap-4">
|
||||
<p pTooltip="Fetch and update new book cover images" tooltipPosition="top">Update covers:</p>
|
||||
<p-checkbox [(ngModel)]="refreshCovers" [binary]="true"></p-checkbox>
|
||||
</div>
|
||||
<div class="flex flex-row items-center gap-4">
|
||||
<p pTooltip="Combine new genres with existing ones" tooltipPosition="top">Merge genres:</p>
|
||||
<p-checkbox [(ngModel)]="mergeCategories" [binary]="true"></p-checkbox>
|
||||
</div>
|
||||
<div class="flex flex-row items-center gap-4">
|
||||
<p pTooltip="Review and approve metadata changes before saving" tooltipPosition="top">Manual review:</p>
|
||||
<p-checkbox [(ngModel)]="reviewBeforeApply" [binary]="true"></p-checkbox>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="flex flex-row gap-6">
|
||||
<p-button severity="warn" outlined="true" label="Reset Form" (onClick)="reset()"></p-button>
|
||||
<p-button [label]="submitButtonLabel" outlined="true" (onClick)="submit()"></p-button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
+11
-7
@@ -12,11 +12,12 @@ import {
|
||||
FieldProvider,
|
||||
MetadataRefreshOptions
|
||||
} from '../../model/request/metadata-refresh-options.model';
|
||||
import {Tooltip} from 'primeng/tooltip';
|
||||
|
||||
@Component({
|
||||
selector: 'app-metadata-advanced-fetch-options',
|
||||
templateUrl: './metadata-advanced-fetch-options.component.html',
|
||||
imports: [Select, FormsModule, Checkbox, Button],
|
||||
imports: [Select, FormsModule, Checkbox, Button, Tooltip],
|
||||
styleUrl: './metadata-advanced-fetch-options.component.scss',
|
||||
standalone: true
|
||||
})
|
||||
@@ -35,11 +36,12 @@ export class MetadataAdvancedFetchOptionsComponent implements OnChanges {
|
||||
|
||||
refreshCovers: boolean = false;
|
||||
mergeCategories: boolean = false;
|
||||
reviewBeforeApply: boolean = false;
|
||||
|
||||
allP1 = { placeholder: 'Set All', value: null as string | null };
|
||||
allP2 = { placeholder: 'Set All', value: null as string | null };
|
||||
allP3 = { placeholder: 'Set All', value: null as string | null };
|
||||
allP4 = { placeholder: 'Set All', value: null as string | null };
|
||||
allP1 = {placeholder: 'Set All', value: null as string | null};
|
||||
allP2 = {placeholder: 'Set All', value: null as string | null};
|
||||
allP3 = {placeholder: 'Set All', value: null as string | null};
|
||||
allP4 = {placeholder: 'Set All', value: null as string | null};
|
||||
|
||||
fieldOptions: FieldOptions = this.initializeFieldOptions();
|
||||
|
||||
@@ -47,7 +49,7 @@ export class MetadataAdvancedFetchOptionsComponent implements OnChanges {
|
||||
|
||||
private initializeFieldOptions(): FieldOptions {
|
||||
return this.fields.reduce((acc, field) => {
|
||||
acc[field] = { p1: null, p2: null, p3: null, p4: null };
|
||||
acc[field] = {p1: null, p2: null, p3: null, p4: null};
|
||||
return acc;
|
||||
}, {} as FieldOptions);
|
||||
}
|
||||
@@ -56,11 +58,12 @@ export class MetadataAdvancedFetchOptionsComponent implements OnChanges {
|
||||
if (changes['currentMetadataOptions'] && this.currentMetadataOptions) {
|
||||
this.refreshCovers = this.currentMetadataOptions.refreshCovers || false;
|
||||
this.mergeCategories = this.currentMetadataOptions.mergeCategories || false;
|
||||
this.reviewBeforeApply = this.currentMetadataOptions.reviewBeforeApply || false;
|
||||
|
||||
const backendFieldOptions = this.currentMetadataOptions.fieldOptions as FieldOptions || {};
|
||||
for (const field of this.fields) {
|
||||
if (!backendFieldOptions[field]) {
|
||||
backendFieldOptions[field] = { p1: null, p2: null, p3: null, p4: null };
|
||||
backendFieldOptions[field] = {p1: null, p2: null, p3: null, p4: null};
|
||||
} else {
|
||||
backendFieldOptions[field].p4 ??= null;
|
||||
}
|
||||
@@ -93,6 +96,7 @@ export class MetadataAdvancedFetchOptionsComponent implements OnChanges {
|
||||
allP4: this.allP4.value,
|
||||
refreshCovers: this.refreshCovers,
|
||||
mergeCategories: this.mergeCategories,
|
||||
reviewBeforeApply: this.reviewBeforeApply,
|
||||
fieldOptions: this.fieldOptions
|
||||
};
|
||||
this.metadataOptionsSubmitted.emit(metadataRefreshOptions);
|
||||
+2
-2
@@ -4,8 +4,8 @@ import {MetadataAdvancedFetchOptionsComponent} from '../metadata-advanced-fetch-
|
||||
import {MetadataRefreshRequest} from '../../model/request/metadata-refresh-request.model';
|
||||
import {MetadataRefreshType} from '../../model/request/metadata-refresh-type.enum';
|
||||
import {MetadataRefreshOptions} from '../../model/request/metadata-refresh-options.model';
|
||||
import {BookService} from '../../../service/book.service';
|
||||
import {AppSettingsService} from '../../../../core/service/app-settings.service';
|
||||
import {BookService} from '../../../book/service/book.service';
|
||||
import {AppSettingsService} from '../../../core/service/app-settings.service';
|
||||
import {filter, take} from 'rxjs/operators';
|
||||
|
||||
@Component({
|
||||
+100
@@ -0,0 +1,100 @@
|
||||
@if (!loading) {
|
||||
<div class="px-4 pt-4 pb-2 h-full flex flex-col">
|
||||
|
||||
<div class="flex items-center">
|
||||
<h2 class="text-xl font-semibold">Review Metadata Proposal </h2>
|
||||
</div>
|
||||
|
||||
<div class="flex-grow overflow-auto">
|
||||
@if (currentProposal?.metadataJson; as proposed) {
|
||||
<app-metadata-picker
|
||||
[fetchedMetadata]="proposed"
|
||||
[book$]="book$"
|
||||
(goBack)="close()"
|
||||
[reviewMode]="true">
|
||||
</app-metadata-picker>
|
||||
}
|
||||
</div>
|
||||
|
||||
<p-divider/>
|
||||
|
||||
<div class="flex justify-between items-center flex-wrap gap-2 pt-4">
|
||||
|
||||
<div class="flex items-center gap-2 pl-1 group"
|
||||
pTooltip="{{ currentIndex + 1 }} of {{ proposals.length }} processed ({{ ((currentIndex + 1) / proposals.length * 100) | number: '1.0-0' }}%)"
|
||||
tooltipPosition="top">
|
||||
<p-progressBar
|
||||
[value]="((currentIndex + 1) / proposals.length) * 100"
|
||||
styleClass="w-40 h-3 transition-all duration-300 ease-in-out group-hover:shadow-md"
|
||||
showValue="false">
|
||||
</p-progressBar>
|
||||
<span class="text-sm text-gray-300 font-medium tabular-nums whitespace-nowrap">
|
||||
Book {{ currentIndex + 1 }} / {{ proposals.length }}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div class="flex flex-wrap gap-2 justify-end">
|
||||
|
||||
<p-button
|
||||
label="Close"
|
||||
icon="pi pi-times-circle"
|
||||
severity="secondary"
|
||||
[outlined]="true"
|
||||
(click)="close()">
|
||||
</p-button>
|
||||
|
||||
<p-divider layout="vertical"/>
|
||||
|
||||
<p-button
|
||||
label="Lock Metadata"
|
||||
icon="pi pi-lock"
|
||||
severity="warn"
|
||||
[outlined]="true"
|
||||
(click)="lockAllMetadata()">
|
||||
</p-button>
|
||||
|
||||
<p-button
|
||||
label="Unlock Metadata"
|
||||
icon="pi pi-lock-open"
|
||||
severity="success"
|
||||
[outlined]="true"
|
||||
(click)="unlockAllMetadata()">
|
||||
</p-button>
|
||||
|
||||
<p-divider layout="vertical"/>
|
||||
|
||||
<p-button
|
||||
label="Previous"
|
||||
icon="pi pi-angle-left"
|
||||
severity="secondary"
|
||||
[outlined]="true"
|
||||
(click)="previous()"
|
||||
[disabled]="currentIndex === 0">
|
||||
</p-button>
|
||||
|
||||
<p-button
|
||||
[label]="isLast ? 'Reject & Finish' : 'Reject & Next'"
|
||||
[icon]="isLast ? 'pi pi-times-circle' : 'pi pi-angle-right'"
|
||||
iconPos="right"
|
||||
severity="danger"
|
||||
[outlined]="true"
|
||||
(click)="onReject()">
|
||||
</p-button>
|
||||
|
||||
<p-button
|
||||
[label]="isLast ? 'Save & Finish' : 'Save & Next'"
|
||||
[icon]="isLast ? 'pi pi-check-circle' : 'pi pi-angle-right'"
|
||||
iconPos="right"
|
||||
severity="success"
|
||||
[outlined]="true"
|
||||
(click)="onSave(currentProposal!)">
|
||||
</p-button>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
} @else {
|
||||
<div class="p-4 h-full flex items-center justify-center">
|
||||
<p-progressSpinner styleClass="w-8 h-8" strokeWidth="4"></p-progressSpinner>
|
||||
</div>
|
||||
}
|
||||
+181
@@ -0,0 +1,181 @@
|
||||
import {Component, DestroyRef, inject, OnInit, ViewChild} from '@angular/core';
|
||||
import {CommonModule} from '@angular/common';
|
||||
import {DynamicDialogConfig, DynamicDialogRef} from 'primeng/dynamicdialog';
|
||||
import {FetchedProposalDto, MetadataTaskService} from '../../book/service/metadata-task';
|
||||
import {BookService} from '../../book/service/book.service';
|
||||
import {Book} from '../../book/model/book.model';
|
||||
import {BehaviorSubject, Observable} from 'rxjs';
|
||||
import {map} from 'rxjs/operators';
|
||||
import {MetadataPickerComponent} from '../book-metadata-center-component/metadata-picker/metadata-picker.component';
|
||||
import {ProgressSpinner} from 'primeng/progressspinner';
|
||||
import {Button} from 'primeng/button';
|
||||
import {Divider} from 'primeng/divider';
|
||||
import {ProgressBar} from 'primeng/progressbar';
|
||||
import {Tooltip} from 'primeng/tooltip';
|
||||
import {MetadataProgressService} from '../../core/service/metadata-progress-service';
|
||||
import {takeUntilDestroyed} from '@angular/core/rxjs-interop';
|
||||
|
||||
@Component({
|
||||
selector: 'app-metadata-review-dialog-component',
|
||||
standalone: true,
|
||||
templateUrl: './metadata-review-dialog-component.html',
|
||||
styleUrls: ['./metadata-review-dialog-component.scss'],
|
||||
imports: [CommonModule, MetadataPickerComponent, ProgressSpinner, Button, Divider, ProgressBar, Tooltip],
|
||||
})
|
||||
export class MetadataReviewDialogComponent implements OnInit {
|
||||
|
||||
@ViewChild(MetadataPickerComponent)
|
||||
pickerComponent!: MetadataPickerComponent;
|
||||
|
||||
private config = inject(DynamicDialogConfig);
|
||||
private dialogRef = inject(DynamicDialogRef);
|
||||
private metadataTaskService = inject(MetadataTaskService);
|
||||
private bookService = inject(BookService);
|
||||
private progressService = inject(MetadataProgressService);
|
||||
private destroyRef = inject(DestroyRef);
|
||||
|
||||
proposals: FetchedProposalDto[] = [];
|
||||
currentBooks: Record<number, Book> = {};
|
||||
loading = true;
|
||||
currentIndex = 0;
|
||||
private initialized = false;
|
||||
|
||||
private currentIndexSubject = new BehaviorSubject<number>(0);
|
||||
|
||||
book$: Observable<Book | null> = this.currentIndexSubject.pipe(
|
||||
map(idx => {
|
||||
const proposal = this.proposals[idx];
|
||||
if (!proposal) return null;
|
||||
return this.currentBooks[proposal.bookId] ?? null;
|
||||
})
|
||||
);
|
||||
|
||||
ngOnInit() {
|
||||
const taskId = this.config.data?.taskId;
|
||||
if (!taskId) {
|
||||
this.dialogRef.close();
|
||||
return;
|
||||
}
|
||||
|
||||
this.metadataTaskService.getTaskWithProposals(taskId).subscribe({
|
||||
next: (task) => {
|
||||
this.proposals = task.proposals || [];
|
||||
const bookIds = new Set(this.proposals.map(p => p.bookId));
|
||||
|
||||
this.bookService.bookState$
|
||||
.pipe(
|
||||
map(bookState => bookState.books?.filter(book => bookIds.has(book.id)) ?? []),
|
||||
takeUntilDestroyed(this.destroyRef)
|
||||
)
|
||||
.subscribe((matchedBooks) => {
|
||||
|
||||
if (!this.initialized && matchedBooks.length === bookIds.size) {
|
||||
this.currentBooks = matchedBooks.reduce((map, book) => {
|
||||
map[book.id] = book;
|
||||
return map;
|
||||
}, {} as Record<number, Book>);
|
||||
this.loading = false;
|
||||
this.currentIndex = 0;
|
||||
this.currentIndexSubject.next(0);
|
||||
this.initialized = true;
|
||||
} else if (!this.initialized) {
|
||||
this.loading = true;
|
||||
}
|
||||
});
|
||||
},
|
||||
error: () => {
|
||||
this.dialogRef.close();
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
get currentProposal(): FetchedProposalDto | null {
|
||||
return this.proposals[this.currentIndex] ?? null;
|
||||
}
|
||||
|
||||
onReject(): void {
|
||||
const currentProposal = this.currentProposal;
|
||||
if (!currentProposal) return;
|
||||
|
||||
this.metadataTaskService.updateProposalStatus(currentProposal.taskId, currentProposal.proposalId, 'REJECTED').subscribe({
|
||||
next: () => {
|
||||
if (this.isLast) {
|
||||
this.metadataTaskService.deleteTask(currentProposal.taskId).subscribe(() => {
|
||||
this.progressService.clearTask(currentProposal.taskId);
|
||||
this.dialogRef.close();
|
||||
});
|
||||
} else {
|
||||
this.next();
|
||||
}
|
||||
},
|
||||
error: () => {
|
||||
if (this.isLast) {
|
||||
this.dialogRef.close();
|
||||
} else {
|
||||
this.next();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
onSave(updatedFields: Partial<FetchedProposalDto>): void {
|
||||
const currentProposal = this.currentProposal;
|
||||
if (!currentProposal) return;
|
||||
|
||||
this.pickerComponent.onSave();
|
||||
|
||||
this.metadataTaskService.updateProposalStatus(currentProposal.taskId, currentProposal.proposalId, 'ACCEPTED').subscribe({
|
||||
next: () => {
|
||||
if (this.isLast) {
|
||||
this.metadataTaskService.deleteTask(currentProposal.taskId).subscribe(() => {
|
||||
this.progressService.clearTask(currentProposal.taskId);
|
||||
this.dialogRef.close();
|
||||
});
|
||||
} else {
|
||||
this.next();
|
||||
}
|
||||
},
|
||||
error: () => {
|
||||
if (this.isLast) {
|
||||
this.dialogRef.close();
|
||||
} else {
|
||||
this.next();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
next(): void {
|
||||
const nextIndex = this.currentIndex + 1;
|
||||
if (nextIndex >= this.proposals.length) {
|
||||
this.dialogRef.close();
|
||||
} else {
|
||||
this.currentIndex = nextIndex;
|
||||
this.currentIndexSubject.next(nextIndex);
|
||||
}
|
||||
}
|
||||
|
||||
previous(): void {
|
||||
const prevIndex = this.currentIndex - 1;
|
||||
if (prevIndex >= 0) {
|
||||
this.currentIndex = prevIndex;
|
||||
this.currentIndexSubject.next(prevIndex);
|
||||
}
|
||||
}
|
||||
|
||||
lockAllMetadata(): void {
|
||||
this.pickerComponent?.lockAll();
|
||||
}
|
||||
|
||||
unlockAllMetadata(): void {
|
||||
this.pickerComponent?.unlockAll();
|
||||
}
|
||||
|
||||
get isLast(): boolean {
|
||||
return this.currentIndex === this.proposals.length - 1;
|
||||
}
|
||||
|
||||
close(): void {
|
||||
this.dialogRef.close();
|
||||
}
|
||||
}
|
||||
+1
@@ -5,6 +5,7 @@ export interface MetadataRefreshOptions {
|
||||
allP1: string | null;
|
||||
refreshCovers: boolean;
|
||||
mergeCategories: boolean;
|
||||
reviewBeforeApply: boolean;
|
||||
fieldOptions?: FieldOptions;
|
||||
}
|
||||
|
||||
+5
-5
@@ -1,12 +1,12 @@
|
||||
import {Component, inject, OnDestroy, OnInit} from '@angular/core';
|
||||
import {MetadataEditorComponent} from '../book-metadata-center/metadata-editor/metadata-editor.component';
|
||||
import {MetadataSearcherComponent} from '../book-metadata-center/metadata-searcher/metadata-searcher.component';
|
||||
import {MetadataEditorComponent} from '../book-metadata-center-component/metadata-editor/metadata-editor.component';
|
||||
import {MetadataSearcherComponent} from '../book-metadata-center-component/metadata-searcher/metadata-searcher.component';
|
||||
import {Tab, TabList, TabPanel, TabPanels, Tabs} from 'primeng/tabs';
|
||||
import {Book} from '../../model/book.model';
|
||||
import {Book} from '../../book/model/book.model';
|
||||
import {DynamicDialogConfig, DynamicDialogRef} from 'primeng/dynamicdialog';
|
||||
import {BookService} from '../../service/book.service';
|
||||
import {BookService} from '../../book/service/book.service';
|
||||
import {BehaviorSubject, combineLatest, Observable, Subscription} from 'rxjs';
|
||||
import {UserService} from '../../../settings/user-management/user.service';
|
||||
import {UserService} from '../../settings/user-management/user.service';
|
||||
import {distinctUntilChanged, filter, map, shareReplay, switchMap} from 'rxjs/operators';
|
||||
|
||||
@Component({
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
<div class="mx-4 mb-4">
|
||||
<p class="text-sm font-semibold mb-2 text-[var(--primary-color)]">
|
||||
{{ booksToShow.length }} Books Selected
|
||||
</p>
|
||||
<div class="max-h-24 overflow-auto border border-gray-500 rounded p-2 text-sm">
|
||||
<ul class="list-disc pl-5 space-y-1">
|
||||
@for (book of booksToShow; track book.id) {
|
||||
<li>
|
||||
<span class="text-gray-400">#{{ book.id }}</span>: {{ book.metadata?.title || 'Untitled' }}
|
||||
</li>
|
||||
}
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<app-metadata-fetch-options></app-metadata-fetch-options>
|
||||
+51
@@ -0,0 +1,51 @@
|
||||
import {Component, inject, OnDestroy, OnInit} from '@angular/core';
|
||||
import {Subject, takeUntil} from 'rxjs';
|
||||
|
||||
import {MetadataRefreshType} from '../model/request/metadata-refresh-type.enum';
|
||||
import {MetadataRefreshOptions} from '../model/request/metadata-refresh-options.model';
|
||||
|
||||
import {DynamicDialogConfig} from 'primeng/dynamicdialog';
|
||||
import {BookService} from '../../book/service/book.service';
|
||||
import {AppSettingsService} from '../../core/service/app-settings.service';
|
||||
import {MetadataFetchOptionsComponent} from '../metadata-options-dialog/metadata-fetch-options/metadata-fetch-options.component';
|
||||
import {Book} from '../../book/model/book.model';
|
||||
import {FormsModule} from '@angular/forms';
|
||||
|
||||
@Component({
|
||||
selector: 'app-multi-book-metadata-fetch-component',
|
||||
standalone: true,
|
||||
templateUrl: './multi-book-metadata-fetch-component.html',
|
||||
styleUrl: './multi-book-metadata-fetch-component.scss',
|
||||
imports: [MetadataFetchOptionsComponent, FormsModule],
|
||||
})
|
||||
export class MultiBookMetadataFetchComponent implements OnInit, OnDestroy {
|
||||
bookIds!: number[];
|
||||
booksToShow: Book[] = [];
|
||||
metadataRefreshType!: MetadataRefreshType;
|
||||
currentMetadataOptions!: MetadataRefreshOptions;
|
||||
|
||||
private destroy$ = new Subject<void>();
|
||||
|
||||
private dynamicDialogConfig = inject(DynamicDialogConfig);
|
||||
private bookService = inject(BookService);
|
||||
private appSettingsService = inject(AppSettingsService);
|
||||
expanded = false;
|
||||
|
||||
ngOnInit(): void {
|
||||
this.bookIds = this.dynamicDialogConfig.data.bookIds;
|
||||
this.metadataRefreshType = this.dynamicDialogConfig.data.metadataRefreshType;
|
||||
|
||||
this.booksToShow = this.bookService.getBooksByIdsFromState(this.bookIds);
|
||||
|
||||
this.appSettingsService.appSettings$
|
||||
.pipe(takeUntil(this.destroy$))
|
||||
.subscribe(settings => {
|
||||
this.currentMetadataOptions = settings!.metadataRefreshOptions;
|
||||
});
|
||||
}
|
||||
|
||||
ngOnDestroy(): void {
|
||||
this.destroy$.next();
|
||||
this.destroy$.complete();
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -1,10 +1,10 @@
|
||||
import { Component, inject, OnInit } from '@angular/core';
|
||||
import { Divider } from 'primeng/divider';
|
||||
import { MetadataAdvancedFetchOptionsComponent } from '../../book/metadata/metadata-options-dialog/metadata-advanced-fetch-options/metadata-advanced-fetch-options.component';
|
||||
import { MetadataAdvancedFetchOptionsComponent } from '../../metadata/metadata-options-dialog/metadata-advanced-fetch-options/metadata-advanced-fetch-options.component';
|
||||
import { MetadataProviderSettingsComponent } from '../global-preferences/metadata-provider-settings/metadata-provider-settings.component';
|
||||
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
|
||||
import { Tooltip } from 'primeng/tooltip';
|
||||
import { MetadataRefreshOptions } from '../../book/metadata/model/request/metadata-refresh-options.model';
|
||||
import { MetadataRefreshOptions } from '../../metadata/model/request/metadata-refresh-options.model';
|
||||
import { AppSettingsService } from '../../core/service/app-settings.service';
|
||||
import { MessageService } from 'primeng/api';
|
||||
import { Observable } from 'rxjs';
|
||||
|
||||
@@ -1,35 +0,0 @@
|
||||
import {Injectable} from '@angular/core';
|
||||
import {BehaviorSubject} from 'rxjs';
|
||||
import {LogNotification} from './model/log-notification.model';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class EventService {
|
||||
private latestEventSubject = new BehaviorSubject<LogNotification>({message: 'No recent notifications...'});
|
||||
latestEvent$ = this.latestEventSubject.asObservable();
|
||||
|
||||
private eventHighlightSubject = new BehaviorSubject<boolean>(false);
|
||||
eventHighlight$ = this.eventHighlightSubject.asObservable();
|
||||
|
||||
private eventTimeout: any;
|
||||
|
||||
handleIncomingLog(logNotification: LogNotification): void {
|
||||
this.latestEventSubject.next(logNotification);
|
||||
this.eventHighlightSubject.next(true);
|
||||
|
||||
if (this.eventTimeout) {
|
||||
clearTimeout(this.eventTimeout);
|
||||
}
|
||||
|
||||
this.eventTimeout = setTimeout(() => {
|
||||
this.eventHighlightSubject.next(false);
|
||||
}, 7500);
|
||||
|
||||
setTimeout(() => {
|
||||
if (!this.eventHighlightSubject.value) {
|
||||
this.latestEventSubject.next({message: 'No recent notifications...'});
|
||||
}
|
||||
}, 20000);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
import {Injectable} from '@angular/core';
|
||||
import {BehaviorSubject, Observable} from 'rxjs';
|
||||
import {filter} from 'rxjs/operators';
|
||||
import {LogNotification} from './model/log-notification.model';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class NotificationEventService {
|
||||
private latestNotificationSubject = new BehaviorSubject<LogNotification | null>(null);
|
||||
|
||||
latestNotification$: Observable<LogNotification> = this.latestNotificationSubject.asObservable().pipe(
|
||||
filter((event): event is LogNotification => event !== null)
|
||||
);
|
||||
|
||||
private notificationHighlightSubject = new BehaviorSubject<boolean>(false);
|
||||
notificationHighlight$ = this.notificationHighlightSubject.asObservable();
|
||||
|
||||
private highlightTimeout: any;
|
||||
|
||||
handleNewNotification(notification: LogNotification): void {
|
||||
this.latestNotificationSubject.next(notification);
|
||||
this.notificationHighlightSubject.next(true);
|
||||
|
||||
if (this.highlightTimeout) {
|
||||
clearTimeout(this.highlightTimeout);
|
||||
}
|
||||
|
||||
this.highlightTimeout = setTimeout(() => {
|
||||
this.notificationHighlightSubject.next(false);
|
||||
}, 7500);
|
||||
|
||||
setTimeout(() => {
|
||||
if (!this.notificationHighlightSubject.value) {
|
||||
this.latestNotificationSubject.next(null);
|
||||
}
|
||||
}, 20000);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user