diff --git a/booklore-ui/src/app/book/components/book-browser/book-browser.component.ts b/booklore-ui/src/app/book/components/book-browser/book-browser.component.ts
index 38e553467..486e692dc 100644
--- a/booklore-ui/src/app/book/components/book-browser/book-browser.component.ts
+++ b/booklore-ui/src/app/book/components/book-browser/book-browser.component.ts
@@ -269,12 +269,14 @@ export class BookBrowserComponent implements OnInit {
unshelfBooks() {
if (this.entity) {
this.bookService.updateBookShelves(this.selectedBooks, new Set(), new Set([this.entity.id])).subscribe(
- () => {
- this.messageService.add({severity: 'info', summary: 'Success', detail: 'Books shelves updated'});
- this.selectedBooks = new Set();
- },
- () => {
- this.messageService.add({severity: 'error', summary: 'Error', detail: 'Failed to update books shelves'});
+ {
+ next: () => {
+ this.messageService.add({severity: 'info', summary: 'Success', detail: 'Books shelves updated'});
+ this.selectedBooks = new Set();
+ },
+ error: () => {
+ this.messageService.add({severity: 'error', summary: 'Error', detail: 'Failed to update books shelves'});
+ }
}
);
}
diff --git a/booklore-ui/src/app/book/components/shelf-assigner/shelf-assigner.component.ts b/booklore-ui/src/app/book/components/shelf-assigner/shelf-assigner.component.ts
index a2ca0e0ec..42d13d5c0 100644
--- a/booklore-ui/src/app/book/components/shelf-assigner/shelf-assigner.component.ts
+++ b/booklore-ui/src/app/book/components/shelf-assigner/shelf-assigner.component.ts
@@ -1,14 +1,14 @@
-import { Component, OnInit, ViewChild } from '@angular/core';
-import { DynamicDialogConfig, DynamicDialogRef } from 'primeng/dynamicdialog';
-import { Book } from '../../model/book.model';
+import {Component, OnInit, ViewChild} from '@angular/core';
+import {DynamicDialogConfig, DynamicDialogRef} from 'primeng/dynamicdialog';
+import {Book} from '../../model/book.model';
import {MessageService, PrimeTemplate} from 'primeng/api';
-import { ShelfService } from '../../service/shelf.service';
-import { Observable } from 'rxjs';
-import { BookService } from '../../service/book.service';
-import { map, tap } from 'rxjs/operators';
-import { Shelf } from '../../model/shelf.model';
-import { IconPickerComponent } from '../../../utilities/component/icon-picker/icon-picker.component';
-import { ShelfState } from '../../model/state/shelf-state.model';
+import {ShelfService} from '../../service/shelf.service';
+import {Observable} from 'rxjs';
+import {BookService} from '../../service/book.service';
+import {map, tap} from 'rxjs/operators';
+import {Shelf} from '../../model/shelf.model';
+import {IconPickerComponent} from '../../../utilities/component/icon-picker/icon-picker.component';
+import {ShelfState} from '../../model/state/shelf-state.model';
import {Button} from 'primeng/button';
import {Divider} from 'primeng/divider';
import {AsyncPipe, NgForOf, NgIf} from '@angular/common';
@@ -79,16 +79,16 @@ export class ShelfAssignerComponent implements OnInit {
name: this.shelfName,
icon: this.selectedIcon ? this.selectedIcon.replace('pi pi-', '') : 'heart'
};
- this.shelfService.createShelf(newShelf as Shelf).subscribe(
- () => {
- this.messageService.add({ severity: 'info', summary: 'Success', detail: `Shelf created: ${this.shelfName}` });
+ this.shelfService.createShelf(newShelf as Shelf).subscribe({
+ next: () => {
+ this.messageService.add({severity: 'info', summary: 'Success', detail: `Shelf created: ${this.shelfName}`});
this.displayShelfDialog = false;
},
- error => {
- this.messageService.add({ severity: 'error', summary: 'Error', detail: 'Failed to create shelf' });
- console.error('Error creating shelf:', error);
+ error: (e) => {
+ this.messageService.add({severity: 'error', summary: 'Error', detail: 'Failed to create shelf'});
+ console.error('Error creating shelf:', e);
}
- );
+ });
}
updateBooksShelves(): void {
@@ -101,11 +101,11 @@ export class ShelfAssignerComponent implements OnInit {
private updateBookShelves(bookIds: Set, idsToAssign: Set, idsToUnassign: Set): void {
this.bookService.updateBookShelves(bookIds, idsToAssign, idsToUnassign).subscribe({
next: () => {
- this.messageService.add({ severity: 'info', summary: 'Success', detail: 'Book shelves updated' });
+ this.messageService.add({severity: 'info', summary: 'Success', detail: 'Book shelves updated'});
this.dynamicDialogRef.close();
},
error: () => {
- this.messageService.add({ severity: 'error', summary: 'Error', detail: 'Failed to update book shelves' });
+ this.messageService.add({severity: 'error', summary: 'Error', detail: 'Failed to update book shelves'});
this.dynamicDialogRef.close();
}
});
diff --git a/booklore-ui/src/app/utilities/component/file-upload/file-upload.component.ts b/booklore-ui/src/app/utilities/component/file-upload/file-upload.component.ts
index d93a570b9..bae8da52b 100644
--- a/booklore-ui/src/app/utilities/component/file-upload/file-upload.component.ts
+++ b/booklore-ui/src/app/utilities/component/file-upload/file-upload.component.ts
@@ -36,7 +36,7 @@ export class FileUploadComponent {
private fileUploadService: FileUploadService,
private toastService: ToastService,
private dynamicDialogRef: DynamicDialogRef) {
- this.libraryState$ = this.libraryService.libraryState$;
+ this.libraryState$ = this.libraryService.libraryState$;
}
triggerFileInput(fileInput: HTMLInputElement): void {
@@ -70,19 +70,18 @@ export class FileUploadComponent {
const libraryId = this.selectedLibrary?.id ? this.selectedLibrary.id.toString() : '';
const path = this.selectedPath || '';
this.isUploading = true;
- this.fileUploadService.uploadFile(file, libraryId, path)
- .subscribe(
- () => {
- console.log('File uploaded successfully');
- this.toastService.showSuccess("File uploaded", file.name);
- this.isUploading = false;
- this.dynamicDialogRef.close();
- },
- (error) => {
- this.isUploading = false;
- this.toastService.showError("Upload failed", error.error.message);
- this.errorMessage = "Upload failed. " + error.error.message + ".";
- }
- );
+ this.fileUploadService.uploadFile(file, libraryId, path).subscribe({
+ next: () => {
+ console.log('File uploaded successfully');
+ this.toastService.showSuccess("File uploaded", file.name);
+ this.isUploading = false;
+ this.dynamicDialogRef.close();
+ },
+ error: (e) => {
+ this.isUploading = false;
+ this.toastService.showError("Upload failed", e.error.message);
+ this.errorMessage = "Upload failed. " + e.error.message + ".";
+ }
+ });
}
}