Merge pull request #988 from booklore-app/develop

Merge develop into master for release
This commit is contained in:
Aditya Chandel
2025-08-25 15:30:07 -06:00
committed by GitHub
35 changed files with 1034 additions and 347 deletions
+3
View File
@@ -8,6 +8,9 @@ categories:
- title: '✨ Enhancements'
labels:
- 'enhancement'
- title: '🎨 UI Tweaks'
labels:
- 'ui-tweaks'
- title: '🐛 Bug Fixes'
labels:
- 'bug'
@@ -6,14 +6,12 @@ import com.adityachandel.booklore.model.dto.kobo.KoboAuthentication;
import com.adityachandel.booklore.model.dto.kobo.KoboReadingStateWrapper;
import com.adityachandel.booklore.model.dto.kobo.KoboResources;
import com.adityachandel.booklore.model.dto.kobo.KoboTestResponse;
import com.adityachandel.booklore.service.BookService;
import com.adityachandel.booklore.service.KoboEntitlementService;
import com.adityachandel.booklore.service.KoboReadingStateService;
import com.adityachandel.booklore.service.ShelfService;
import com.adityachandel.booklore.service.*;
import com.adityachandel.booklore.service.kobo.*;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonNode;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.RandomStringUtils;
@@ -23,6 +21,9 @@ import org.springframework.http.ResponseEntity;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.web.bind.annotation.*;
import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Files;
import java.util.List;
import java.util.Set;
@@ -42,6 +43,7 @@ public class KoboController {
private final KoboLibrarySyncService koboLibrarySyncService;
private final KoboThumbnailService koboThumbnailService;
private final ShelfService shelfService;
private final BookDownloadService bookDownloadService;
@ModelAttribute
public void captureToken(@PathVariable("token") String token) {
@@ -129,11 +131,11 @@ public class KoboController {
}
@GetMapping("/v1/books/{bookId}/download")
public ResponseEntity<?> downloadBook(@PathVariable String bookId) {
public void downloadBook(@PathVariable String bookId, HttpServletResponse response) throws IOException {
if (StringUtils.isNumeric(bookId)) {
return bookService.downloadBook(Long.parseLong(bookId));
bookDownloadService.downloadKoboBook(Long.parseLong(bookId), response);
} else {
return koboServerProxy.proxyCurrentRequest(null, false);
koboServerProxy.proxyCurrentRequest(null, false);
}
}
@@ -95,7 +95,7 @@ public class GlobalExceptionHandler {
@ExceptionHandler(Exception.class)
public ResponseEntity<ErrorResponse> handleGenericException(Exception ex) {
ErrorResponse errorResponse = new ErrorResponse(HttpStatus.INTERNAL_SERVER_ERROR.value(), "An unexpected error occurred.");
ErrorResponse errorResponse = new ErrorResponse(HttpStatus.INTERNAL_SERVER_ERROR.value(), ex.getMessage());
log.error(ex.getMessage(), ex);
return new ResponseEntity<>(errorResponse, HttpStatus.INTERNAL_SERVER_ERROR);
}
@@ -4,8 +4,9 @@ import lombok.Getter;
@Getter
public enum AppSettingKey {
QUICK_BOOK_MATCH("quick_book_match", true, false),
OIDC_PROVIDER_DETAILS("oidc_provider_details", true, true),
QUICK_BOOK_MATCH("quick_book_match", true, false),
OIDC_AUTO_PROVISION_DETAILS("oidc_auto_provision_details", true, false),
SIDEBAR_LIBRARY_SORTING("sidebar_library_sorting", true, false),
SIDEBAR_SHELF_SORTING("sidebar_shelf_sorting", true, false),
@@ -13,6 +14,7 @@ public enum AppSettingKey {
METADATA_MATCH_WEIGHTS("metadata_match_weights", true, false),
METADATA_PERSISTENCE_SETTINGS("metadata_persistence_settings", true, false),
METADATA_PUBLIC_REVIEWS_SETTINGS("metadata_public_reviews_settings", true, false),
KOBO_SETTINGS("kobo_settings", true, false),
AUTO_BOOK_SEARCH("auto_book_search", false, false),
COVER_IMAGE_RESOLUTION("cover_image_resolution", false, false),
@@ -30,4 +30,5 @@ public class AppSettings {
private MetadataMatchWeights metadataMatchWeights;
private MetadataPersistenceSettings metadataPersistenceSettings;
private MetadataPublicReviewsSettings metadataPublicReviewsSettings;
private KoboSettings koboSettings;
}
@@ -0,0 +1,11 @@
package com.adityachandel.booklore.model.dto.settings;
import lombok.Builder;
import lombok.Data;
@Builder
@Data
public class KoboSettings {
private boolean convertToKepub;
private int conversionLimitInMb;
}
@@ -0,0 +1,6 @@
package com.adityachandel.booklore.model.enums;
public enum KoboBookFormat {
EPUB3,
KEPUB,
}
@@ -0,0 +1,117 @@
package com.adityachandel.booklore.service;
import com.adityachandel.booklore.exception.ApiError;
import com.adityachandel.booklore.model.dto.settings.KoboSettings;
import com.adityachandel.booklore.model.entity.BookEntity;
import com.adityachandel.booklore.model.enums.BookFileType;
import com.adityachandel.booklore.repository.BookRepository;
import com.adityachandel.booklore.service.appsettings.AppSettingService;
import com.adityachandel.booklore.service.kobo.KepubConversionService;
import com.adityachandel.booklore.util.FileUtils;
import jakarta.servlet.http.HttpServletResponse;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.core.io.Resource;
import org.springframework.core.io.UrlResource;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
import org.springframework.util.FileSystemUtils;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
@Slf4j
@AllArgsConstructor
@Service
public class BookDownloadService {
private final BookRepository bookRepository;
private final KepubConversionService kepubConversionService;
private final AppSettingService appSettingService;
public ResponseEntity<Resource> downloadBook(Long bookId) {
try {
BookEntity bookEntity = bookRepository.findById(bookId)
.orElseThrow(() -> ApiError.BOOK_NOT_FOUND.createException(bookId));
Path file = Paths.get(FileUtils.getBookFullPath(bookEntity)).toAbsolutePath().normalize();
Resource resource = new UrlResource(file.toUri());
return ResponseEntity.ok()
.contentType(MediaType.APPLICATION_OCTET_STREAM)
.header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=\"" + file.getFileName() + "\"")
.body(resource);
} catch (Exception e) {
log.error("Failed to download book {}: {}", bookId, e.getMessage(), e);
throw ApiError.FAILED_TO_DOWNLOAD_FILE.createException(bookId);
}
}
public void downloadKoboBook(Long bookId, HttpServletResponse response) {
BookEntity bookEntity = bookRepository.findById(bookId).orElseThrow(() -> ApiError.BOOK_NOT_FOUND.createException(bookId));
if (bookEntity.getBookType() != BookFileType.EPUB) {
throw ApiError.GENERIC_BAD_REQUEST.createException("The requested book is not an EPUB file.");
}
KoboSettings koboSettings = appSettingService.getAppSettings().getKoboSettings();
if (koboSettings == null) {
throw ApiError.GENERIC_BAD_REQUEST.createException("Kobo settings not found.");
}
boolean asKepub = koboSettings.isConvertToKepub() && bookEntity.getFileSizeKb() <= (long) koboSettings.getConversionLimitInMb() * 1024;
Path tempDir = null;
try {
File inputFile = new File(FileUtils.getBookFullPath(bookEntity));
File fileToSend = inputFile;
if (asKepub) {
tempDir = Files.createTempDirectory("kepub-output");
fileToSend = kepubConversionService.convertEpubToKepub(inputFile, tempDir.toFile());
}
setResponseHeaders(response, fileToSend);
streamFileToResponse(fileToSend, response);
log.info("Successfully streamed {} ({} bytes) to client", fileToSend.getName(), fileToSend.length());
} catch (Exception e) {
log.error("Failed to download kobo book {}: {}", bookId, e.getMessage(), e);
throw ApiError.FAILED_TO_DOWNLOAD_FILE.createException(bookId);
} finally {
cleanupTempDirectory(tempDir);
}
}
private void setResponseHeaders(HttpServletResponse response, File file) {
response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE);
response.setContentLengthLong(file.length());
response.setHeader(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=\"" + file.getName() + "\"");
}
private void streamFileToResponse(File file, HttpServletResponse response) throws IOException {
try (InputStream in = Files.newInputStream(file.toPath())) {
in.transferTo(response.getOutputStream());
response.getOutputStream().flush();
}
}
private void cleanupTempDirectory(Path tempDir) {
if (tempDir != null) {
try {
FileSystemUtils.deleteRecursively(tempDir);
log.debug("Deleted temporary directory {}", tempDir);
} catch (Exception e) {
log.warn("Failed to delete temporary directory {}: {}", tempDir, e.getMessage());
}
}
}
}
@@ -59,6 +59,7 @@ public class BookService {
private final AuthenticationService authenticationService;
private final BookQueryService bookQueryService;
private final UserProgressService userProgressService;
private final BookDownloadService bookDownloadService;
private void setBookProgress(Book book, UserBookProgressEntity progress) {
@@ -312,12 +313,12 @@ public class BookService {
userBookProgress.setCbxProgress(request.getCbxProgress().getPage());
userBookProgress.setCbxProgressPercent(request.getCbxProgress().getPercentage());
}
// Update dateFinished if provided
if (request.getDateFinished() != null) {
userBookProgress.setDateFinished(request.getDateFinished());
}
userBookProgressRepository.save(userBookProgress);
}
@@ -453,18 +454,7 @@ public class BookService {
}
public ResponseEntity<Resource> downloadBook(Long bookId) {
try {
BookEntity bookEntity = bookRepository.findById(bookId).orElseThrow(() -> ApiError.BOOK_NOT_FOUND.createException(bookId));
Path file = Paths.get(FileUtils.getBookFullPath(bookEntity)).toAbsolutePath().normalize();
Resource resource = new UrlResource(file.toUri());
return ResponseEntity.ok()
.contentType(MediaType.APPLICATION_OCTET_STREAM)
.header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=\"" + file.getFileName() + "\"")
.body(resource);
} catch (Exception e) {
throw ApiError.FAILED_TO_DOWNLOAD_FILE.createException(bookId);
}
return bookDownloadService.downloadBook(bookId);
}
public ResponseEntity<ByteArrayResource> getBookContent(long bookId) throws IOException {
@@ -1,12 +1,15 @@
package com.adityachandel.booklore.service;
import com.adityachandel.booklore.model.dto.kobo.*;
import com.adityachandel.booklore.model.dto.settings.KoboSettings;
import com.adityachandel.booklore.model.entity.AuthorEntity;
import com.adityachandel.booklore.model.entity.BookEntity;
import com.adityachandel.booklore.model.entity.BookMetadataEntity;
import com.adityachandel.booklore.model.entity.CategoryEntity;
import com.adityachandel.booklore.model.enums.BookFileType;
import com.adityachandel.booklore.model.enums.KoboBookFormat;
import com.adityachandel.booklore.model.enums.KoboReadStatus;
import com.adityachandel.booklore.service.appsettings.AppSettingService;
import com.adityachandel.booklore.util.kobo.KoboUrlBuilder;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;
@@ -25,6 +28,7 @@ public class KoboEntitlementService {
private final KoboUrlBuilder koboUrlBuilder;
private final BookQueryService bookQueryService;
private final AppSettingService appSettingService;
public List<NewEntitlement> generateNewEntitlements(Set<Long> bookIds, String token, boolean removed) {
List<BookEntity> books = bookQueryService.findAllWithMetadataByIds(bookIds);
@@ -146,6 +150,12 @@ public class KoboEntitlementService {
String downloadUrl = koboUrlBuilder.downloadUrl(token, book.getId());
KoboBookFormat bookFormat = KoboBookFormat.EPUB3;
KoboSettings koboSettings = appSettingService.getAppSettings().getKoboSettings();
if (koboSettings != null && koboSettings.isConvertToKepub()) {
bookFormat = KoboBookFormat.KEPUB;
}
return KoboBookMetadata.builder()
.crossRevisionId(String.valueOf(book.getId()))
.revisionId(String.valueOf(book.getId()))
@@ -170,7 +180,7 @@ public class KoboEntitlementService {
.downloadUrls(List.of(
KoboBookMetadata.DownloadUrl.builder()
.url(downloadUrl)
.format("EPUB3")
.format(bookFormat.toString())
.size(book.getFileSizeKb() * 1024)
.build()
))
@@ -89,6 +89,7 @@ public class AppSettingService {
builder.metadataMatchWeights(settingPersistenceHelper.getJsonSetting(settingsMap, AppSettingKey.METADATA_MATCH_WEIGHTS, MetadataMatchWeights.class, settingPersistenceHelper.getDefaultMetadataMatchWeights(), true));
builder.metadataPersistenceSettings(settingPersistenceHelper.getJsonSetting(settingsMap, AppSettingKey.METADATA_PERSISTENCE_SETTINGS, MetadataPersistenceSettings.class, settingPersistenceHelper.getDefaultMetadataPersistenceSettings(), true));
builder.metadataPublicReviewsSettings(settingPersistenceHelper.getJsonSetting(settingsMap, AppSettingKey.METADATA_PUBLIC_REVIEWS_SETTINGS, MetadataPublicReviewsSettings.class, settingPersistenceHelper.getDefaultMetadataPublicReviewsSettings(), true));
builder.koboSettings(settingPersistenceHelper.getJsonSetting(settingsMap, AppSettingKey.KOBO_SETTINGS, KoboSettings.class, settingPersistenceHelper.getDefaultKoboSettings(), true));
builder.coverResolution(settingPersistenceHelper.getOrCreateSetting(AppSettingKey.COVER_IMAGE_RESOLUTION, "250x350"));
builder.autoBookSearch(Boolean.parseBoolean(settingPersistenceHelper.getOrCreateSetting(AppSettingKey.AUTO_BOOK_SEARCH, "true")));
@@ -200,4 +200,11 @@ public class SettingPersistenceHelper {
))
.build();
}
public KoboSettings getDefaultKoboSettings() {
return KoboSettings.builder()
.convertToKepub(false)
.conversionLimitInMb(100)
.build();
}
}
@@ -0,0 +1,113 @@
package com.adityachandel.booklore.service.kobo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.StandardCopyOption;
import java.util.stream.Collectors;
@Slf4j
@Service
public class KepubConversionService {
private static final String KEPUBIFY_BINARY_MACOS_ARM64 = "/bin/kepubify-darwin-arm64";
private static final String KEPUBIFY_BINARY_LINUX_X64 = "/bin/kepubify-linux-64bit";
public File convertEpubToKepub(File epubFile, File tempDir) throws IOException, InterruptedException {
validateInputs(epubFile);
Path kepubifyBinary = setupKepubifyBinary(tempDir);
File outputFile = executeKepubifyConversion(epubFile, tempDir, kepubifyBinary);
log.info("Successfully converted {} to {} (size: {} bytes)", epubFile.getName(), outputFile.getName(), outputFile.length());
return outputFile;
}
private void validateInputs(File epubFile) {
if (epubFile == null || !epubFile.isFile() || !epubFile.getName().endsWith(".epub")) {
throw new IllegalArgumentException("Invalid EPUB file: " + epubFile);
}
}
private Path setupKepubifyBinary(File tempDir) throws IOException {
Path tempKepubify = tempDir.toPath().resolve("kepubify");
String resourcePath = getKepubifyResourcePath();
try (InputStream in = getClass().getResourceAsStream(resourcePath)) {
if (in == null) {
throw new IOException("Resource not found: " + resourcePath);
}
Files.copy(in, tempKepubify, StandardCopyOption.REPLACE_EXISTING);
}
tempKepubify.toFile().setExecutable(true);
return tempKepubify;
}
private String getKepubifyResourcePath() {
String osName = System.getProperty("os.name").toLowerCase();
String osArch = System.getProperty("os.arch").toLowerCase();
log.debug("Detected OS: {} ({})", osName, osArch);
if (osName.contains("mac") || osName.contains("darwin")) {
return KEPUBIFY_BINARY_MACOS_ARM64;
} else if (osName.contains("linux")) {
return KEPUBIFY_BINARY_LINUX_X64;
} else {
throw new IllegalStateException("Unsupported operating system: " + osName);
}
}
private File executeKepubifyConversion(File epubFile, File tempDir, Path kepubifyBinary) throws IOException, InterruptedException {
ProcessBuilder pb = new ProcessBuilder(kepubifyBinary.toAbsolutePath().toString(), "-o", tempDir.getAbsolutePath(), epubFile.getAbsolutePath());
pb.directory(tempDir);
log.info("Starting kepubify conversion for {} -> output dir: {}", epubFile.getAbsolutePath(), tempDir.getAbsolutePath());
Process process = pb.start();
String output = readProcessOutput(process.getInputStream());
String error = readProcessOutput(process.getErrorStream());
int exitCode = process.waitFor();
logProcessResults(exitCode, output, error);
if (exitCode != 0) {
throw new IOException(String.format("Kepubify conversion failed with exit code: %d. Error: %s", exitCode, error));
}
return findOutputFile(tempDir);
}
private String readProcessOutput(InputStream inputStream) {
return new BufferedReader(new InputStreamReader(inputStream))
.lines()
.collect(Collectors.joining("\n"));
}
private void logProcessResults(int exitCode, String output, String error) {
log.debug("Kepubify process exited with code {}", exitCode);
if (!output.isEmpty()) {
log.debug("Kepubify stdout: {}", output);
}
if (!error.isEmpty()) {
log.error("Kepubify stderr: {}", error);
}
}
private File findOutputFile(File tempDir) throws IOException {
File[] kepubFiles = tempDir.listFiles((dir, name) -> name.endsWith(".kepub.epub"));
if (kepubFiles == null || kepubFiles.length == 0) {
throw new IOException("Kepubify conversion completed but no .kepub.epub file was created in: " + tempDir.getAbsolutePath());
}
return kepubFiles[0];
}
}
@@ -3,6 +3,7 @@ package com.adityachandel.booklore.util.kobo;
import com.adityachandel.booklore.util.RequestUtils;
import jakarta.servlet.http.HttpServletRequest;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.support.ServletUriComponentsBuilder;
import org.springframework.web.util.UriComponentsBuilder;
@@ -11,6 +12,9 @@ import org.springframework.web.util.UriComponentsBuilder;
@Slf4j
public class KoboUrlBuilder {
@Value("${server.port}")
private int serverPort;
public UriComponentsBuilder baseBuilder() {
HttpServletRequest request = RequestUtils.getCurrentRequest();
@@ -18,10 +22,9 @@ public class KoboUrlBuilder {
.fromCurrentContextPath()
.replacePath("")
.replaceQuery(null)
.port(-1); // drop default port
.port(-1);
String host = builder.build().getHost();
String scheme = builder.build().getScheme();
if (host == null) host = "";
@@ -34,6 +37,7 @@ public class KoboUrlBuilder {
}
log.info("Applied X-Forwarded-Port: {}", port);
} catch (NumberFormatException e) {
builder.port(serverPort);
log.warn("Invalid X-Forwarded-Port header: {}", xfPort);
}
@@ -3,6 +3,7 @@ package com.adityachandel.booklore;
import com.adityachandel.booklore.config.security.AuthenticationService;
import com.adityachandel.booklore.mapper.BookMapper;
import com.adityachandel.booklore.repository.*;
import com.adityachandel.booklore.service.BookDownloadService;
import com.adityachandel.booklore.service.BookQueryService;
import com.adityachandel.booklore.service.BookService;
import com.adityachandel.booklore.service.UserProgressService;
@@ -46,6 +47,7 @@ class BookServiceDeleteTests {
AuthenticationService authenticationService = Mockito.mock(AuthenticationService.class);
BookQueryService bookQueryService = Mockito.mock(BookQueryService.class);
UserProgressService userProgressService = Mockito.mock(UserProgressService.class);
BookDownloadService bookDownloadService = Mockito.mock(BookDownloadService.class);
bookService = new BookService(
bookRepository,
@@ -60,7 +62,8 @@ class BookServiceDeleteTests {
userBookProgressRepository,
authenticationService,
bookQueryService,
userProgressService
userProgressService,
bookDownloadService
);
}
@@ -44,7 +44,8 @@
<i
class="pi pi-filter-slash"
pTooltip="Clear applied filters"
tooltipPosition="top">
tooltipPosition="top"
style="color: orange;">
</i>
</a>
}
@@ -83,7 +84,6 @@
</p-popover>
</div>
}
<div>
<a
class="topbar-items topbar-item"
@@ -117,6 +117,15 @@
{{ coverScalePreferenceService.scaleFactor.toFixed(2) }}x
</div>
</div>
<!--<div class="flex flex-col gap-2">
<label class="font-medium text-sm">Show Sidebar Filters:</label>
<div class="flex gap-4 justify-start">
<p-toggle-switch
[(ngModel)]="sidebarFilterTogglePrefService.selectedShowFilter"
(onChange)="sidebarFilterTogglePrefService.selectedShowFilter = $event.checked">
</p-toggle-switch>
</div>
</div>-->
<div class="flex flex-col gap-2">
<label class="font-medium text-sm">Sidebar Filter Sort:</label>
<div class="flex gap-4 justify-start">
@@ -173,12 +182,12 @@
<i class="pi pi-search"></i>
</button>
<p-popover #searchDropdown [dismissable]="true" appendTo="body" [style]="{ width: '18rem' }">
<p-popover #searchDropdown [dismissable]="true" appendTo="body" [style]="{ width: '24rem' }">
<div class="relative w-full">
<input
type="text"
pInputText
placeholder="Title, Series or Author..."
placeholder="Title, Author, Series, Genre, or ISBN..."
[(ngModel)]="bookTitle"
(ngModelChange)="onSearchTermChange($event)"
class="w-full"
@@ -200,7 +209,7 @@
<input
type="text"
pInputText
placeholder="Title, Series or Author..."
placeholder="Title, Author, Series, Genre, or ISBN..."
[(ngModel)]="bookTitle"
(ngModelChange)="onSearchTermChange($event)"
class="search-input"
@@ -217,15 +226,13 @@
}
</div>
<p-button
class="pr-2"
icon="pi pi-chevron-right"
[outlined]="true"
[rounded]="true"
(click)="toggleFilterSidebar()"
pTooltip="Toggle filter sidebar"
tooltipPosition="top"
/>
<a class="topbar-items topbar-item" (click)="toggleSidebar()">
<i
[ngClass]="showFilter ? 'pi pi-angle-double-right' : 'pi pi-angle-double-left'"
pTooltip="Toggle sidebar filters"
tooltipPosition="top">
</i>
</a>
</div>
</div>
@@ -396,19 +403,23 @@
}
</div>
@if (this.showFilter) {
<div
class="mobile-filter-mask"
(click)="this.showFilter = false">
</div>
<app-book-filter
[showFilter]="showFilter"
class="filter-overlay-container z-50 flex-shrink-0"
[ngClass]="{ 'active': showFilter, 'ml-4': showFilter }"
[entity$]="entity$"
[entityType$]="entityType$"
[resetFilter$]="resetFilterSubject"
(filterSelected)="onFilterSelected($event)"
(filterModeChanged)="onFilterModeChanged($event)">
</app-book-filter>
}
<app-book-filter
[showFilter]="showFilter"
class="filter-overlay-container z-50 flex-shrink-0"
[ngClass]="{ 'active': showFilter, 'ml-4': showFilter }"
[entity$]="entity$"
[entityType$]="entityType$"
[resetFilter$]="resetFilterSubject">
</app-book-filter>
</div>
@@ -96,11 +96,12 @@
}
.search-input {
width: 100%;
min-width: 22rem;
padding-left: 30px;
height: 2.5rem;
line-height: 2.5rem;
font-size: 1rem;
box-sizing: border-box;
}
.mobile-filter-mask {
@@ -1,4 +1,4 @@
import {AfterViewInit, ChangeDetectorRef, Component, inject, OnInit, ViewChild} from '@angular/core';
import {Component, inject, OnInit, ViewChild} from '@angular/core';
import {ActivatedRoute, Router} from '@angular/router';
import {ConfirmationService, MenuItem, MessageService, PrimeTemplate} from 'primeng/api';
import {LibraryService} from '../../service/library.service';
@@ -46,6 +46,7 @@ import {BookMenuService} from '../../service/book-menu.service';
import {MagicShelf, MagicShelfService} from '../../../magic-shelf.service';
import {BookRuleEvaluatorService} from '../../../book-rule-evaluator.service';
import {GroupRule} from '../../../magic-shelf-component/magic-shelf-component';
import {SidebarFilterTogglePrefService} from './filters/sidebar-filter-toggle-pref-service';
export enum EntityType {
LIBRARY = 'Library',
@@ -87,18 +88,19 @@ const SORT_DIRECTION = {
providers: [SeriesCollapseFilter],
animations: [
trigger('slideInOut', [
state('void', style({ transform: 'translateY(100%)' })),
state('*', style({ transform: 'translateY(0)' })),
transition(':enter', [ animate('0.1s ease-in') ]),
transition(':leave', [ animate('0.1s ease-out') ])
state('void', style({transform: 'translateY(100%)'})),
state('*', style({transform: 'translateY(0)'})),
transition(':enter', [animate('0.1s ease-in')]),
transition(':leave', [animate('0.1s ease-out')])
])
]
})
export class BookBrowserComponent implements OnInit, AfterViewInit {
export class BookBrowserComponent implements OnInit {
protected userService = inject(UserService);
protected coverScalePreferenceService = inject(CoverScalePreferenceService);
protected filterSortPreferenceService = inject(FilterSortPreferenceService);
protected columnPreferenceService = inject(TableColumnPreferenceService);
protected sidebarFilterTogglePrefService = inject(SidebarFilterTogglePrefService);
private activatedRoute = inject(ActivatedRoute);
private messageService = inject(MessageService);
private libraryService = inject(LibraryService);
@@ -108,7 +110,6 @@ export class BookBrowserComponent implements OnInit, AfterViewInit {
private bookMenuService = inject(BookMenuService);
private sortService = inject(SortService);
private router = inject(Router);
private changeDetectorRef = inject(ChangeDetectorRef);
private libraryShelfMenuService = inject(LibraryShelfMenuService);
protected seriesCollapseFilter = inject(SeriesCollapseFilter);
protected confirmationService = inject(ConfirmationService);
@@ -148,14 +149,30 @@ export class BookBrowserComponent implements OnInit, AfterViewInit {
private headerFilter = new HeaderFilter(this.searchTerm$);
protected bookSorter = new BookSorter(selectedSort => this.applySortOption(selectedSort));
@ViewChild(BookTableComponent) bookTableComponent!: BookTableComponent;
@ViewChild(BookFilterComponent) bookFilterComponent!: BookFilterComponent;
@ViewChild(BookTableComponent)
bookTableComponent!: BookTableComponent;
@ViewChild(BookFilterComponent, { static: false })
bookFilterComponent!: BookFilterComponent;
get currentCardSize() { return this.coverScalePreferenceService.currentCardSize; }
get gridColumnMinWidth(): string { return this.coverScalePreferenceService.gridColumnMinWidth; }
get viewIcon(): string { return this.currentViewMode === VIEW_MODES.GRID ? 'pi pi-objects-column' : 'pi pi-table'; }
get hasSidebarFilters(): boolean { return !!this.selectedFilter.value && Object.keys(this.selectedFilter.value).length > 0; }
get isFilterActive(): boolean { return this.selectedFilter.value !== null; }
get currentCardSize() {
return this.coverScalePreferenceService.currentCardSize;
}
get gridColumnMinWidth(): string {
return this.coverScalePreferenceService.gridColumnMinWidth;
}
get viewIcon(): string {
return this.currentViewMode === VIEW_MODES.GRID ? 'pi pi-objects-column' : 'pi pi-table';
}
get hasSidebarFilters(): boolean {
return !!this.selectedFilter.value && Object.keys(this.selectedFilter.value).length > 0;
}
get isFilterActive(): boolean {
return this.selectedFilter.value !== null;
}
ngOnInit(): void {
this.coverScalePreferenceService.scaleChange$.pipe(debounceTime(1000)).subscribe();
@@ -197,23 +214,22 @@ export class BookBrowserComponent implements OnInit, AfterViewInit {
() => this.multiBookEditMetadata()
);
this.tieredMenuItems = this.bookMenuService.getTieredMenuItems(this.selectedBooks);
}
ngAfterViewInit(): void {
combineLatest({
paramMap: this.activatedRoute.queryParamMap,
user: this.userService.userState$.pipe(
filter(userState => !!userState?.user && userState.loaded),
take(1)
)
}).subscribe(({paramMap, user}) => {
// --- NEW: Subscribe to query params + user changes for reactive updates ---
combineLatest([
this.activatedRoute.paramMap,
this.activatedRoute.queryParamMap,
this.userService.userState$.pipe(filter(u => !!u?.user && u.loaded))
]).subscribe(([paramMap, queryParamMap, user]) => {
const viewParam = paramMap.get(QUERY_PARAMS.VIEW);
const sortParam = paramMap.get(QUERY_PARAMS.SORT);
const directionParam = paramMap.get(QUERY_PARAMS.DIRECTION);
const filterParams = paramMap.get(QUERY_PARAMS.FILTER);
const sidebarParam = paramMap.get(QUERY_PARAMS.SIDEBAR);
this.showFilter = sidebarParam === null ? true : sidebarParam === 'true';
const viewParam = queryParamMap.get(QUERY_PARAMS.VIEW);
const sortParam = queryParamMap.get(QUERY_PARAMS.SORT);
const directionParam = queryParamMap.get(QUERY_PARAMS.DIRECTION);
const filterParams = queryParamMap.get(QUERY_PARAMS.FILTER);
this.sidebarFilterTogglePrefService.showFilter$.subscribe(value => {
this.showFilter = value;
});
const parsedFilters: Record<string, string[]> = {};
@@ -229,8 +245,10 @@ export class BookBrowserComponent implements OnInit, AfterViewInit {
});
this.selectedFilter.next(parsedFilters);
this.bookFilterComponent.setFilters?.(parsedFilters);
this.bookFilterComponent.onFiltersChanged?.();
if(this.bookFilterComponent) {
this.bookFilterComponent.setFilters?.(parsedFilters);
this.bookFilterComponent.onFiltersChanged?.();
}
const firstFilter = filterParams.split(',')[0];
const [key, ...values] = firstFilter.split(':');
@@ -256,7 +274,6 @@ export class BookBrowserComponent implements OnInit, AfterViewInit {
this.columnPreferenceService.initPreferences(user.user?.userSettings?.tableColumnPreference);
this.visibleColumns = this.columnPreferenceService.visibleColumns;
const override = this.entityViewPreferences?.overrides?.find(o =>
o.entityType?.toUpperCase() === currentEntityTypeStr &&
o.entityId === this.entity?.id
@@ -289,7 +306,7 @@ export class BookBrowserComponent implements OnInit, AfterViewInit {
direction: SortDirection.DESCENDING
};
const fromParam = paramMap.get(QUERY_PARAMS.FROM);
const fromParam = queryParamMap.get(QUERY_PARAMS.FROM);
this.currentViewMode = fromParam === 'toggle'
? (viewParam === VIEW_MODES.TABLE || viewParam === VIEW_MODES.GRID
? viewParam
@@ -306,8 +323,7 @@ export class BookBrowserComponent implements OnInit, AfterViewInit {
const queryParams: any = {
[QUERY_PARAMS.VIEW]: this.currentViewMode,
[QUERY_PARAMS.SORT]: this.bookSorter.selectedSort.field,
[QUERY_PARAMS.DIRECTION]: this.bookSorter.selectedSort.direction === SortDirection.ASCENDING ? SORT_DIRECTION.ASCENDING : SORT_DIRECTION.DESCENDING,
[QUERY_PARAMS.SIDEBAR]: this.showFilter.toString()
[QUERY_PARAMS.DIRECTION]: this.bookSorter.selectedSort.direction === SortDirection.ASCENDING ? SORT_DIRECTION.ASCENDING : SORT_DIRECTION.DESCENDING
};
if (Object.keys(parsedFilters).length > 0) {
@@ -316,29 +332,13 @@ export class BookBrowserComponent implements OnInit, AfterViewInit {
const currentParams = this.activatedRoute.snapshot.queryParams;
const changed = Object.keys(queryParams).some(k => currentParams[k] !== queryParams[k]);
if (changed) {
const mergedParams = {...currentParams, ...queryParams};
this.router.navigate([], {
queryParams,
queryParams: mergedParams,
replaceUrl: true
});
}
this.changeDetectorRef.detectChanges();
});
this.bookFilterComponent.filterSelected.subscribe((filters: Record<string, any> | null) => {
if (this.settingFiltersFromUrl) return;
this.selectedFilter.next(filters);
this.rawFilterParamFromUrl = null;
const hasSidebarFilters = !!filters && Object.keys(filters).length > 0;
this.currentFilterLabel = hasSidebarFilters ? 'All Books (Filtered)' : 'All Books';
});
this.bookFilterComponent.filterModeChanged.subscribe((mode: 'and' | 'or') => {
this.selectedFilterMode.next(mode);
});
this.searchTerm$.subscribe(term => {
@@ -346,6 +346,25 @@ export class BookBrowserComponent implements OnInit, AfterViewInit {
});
}
onFilterSelected(filters: Record<string, any> | null): void {
if (this.settingFiltersFromUrl) return;
this.selectedFilter.next(filters);
this.rawFilterParamFromUrl = null;
const hasSidebarFilters = !!filters && Object.keys(filters).length > 0;
this.currentFilterLabel = hasSidebarFilters ? 'All Books (Filtered)' : 'All Books';
}
onFilterModeChanged(mode: 'and' | 'or'): void {
this.selectedFilterMode.next(mode);
}
toggleSidebar(): void {
this.showFilter = !this.showFilter;
this.sidebarFilterTogglePrefService.selectedShowFilter = this.showFilter;
}
updateScale(): void {
this.coverScalePreferenceService.setScale(this.coverScalePreferenceService.scaleFactor);
}
@@ -476,18 +495,6 @@ export class BookBrowserComponent implements OnInit, AfterViewInit {
this.clearSearch();
}
toggleFilterSidebar() {
this.showFilter = !this.showFilter;
const currentParams = this.activatedRoute.snapshot.queryParams;
this.router.navigate([], {
queryParams: {
...currentParams,
[QUERY_PARAMS.SIDEBAR]: this.showFilter.toString()
},
replaceUrl: true
});
}
toggleTableGrid(): void {
this.currentViewMode = this.currentViewMode === VIEW_MODES.GRID ? VIEW_MODES.TABLE : VIEW_MODES.GRID;
this.router.navigate([], {
@@ -14,7 +14,7 @@
<div class="flex-1 overflow-y-auto pb-4 pr-1" style="overscroll-behavior: contain;">
<p-accordion [value]="expandedPanels">
@for (filterType of filterTypes; track filterType; let i = $index) {
@for (filterType of filterTypes; track trackByFilterType(i, filterType); let i = $index) {
<p-accordion-panel [value]="i">
<p-accordion-header>
<span class="inline-flex items-center gap-1">
@@ -32,7 +32,7 @@
<div
class="max-h-[27.5rem] overflow-y-auto overscroll-contain pr-1"
style="overscroll-behavior: contain;">
@for (filter of filters; track filter) {
@for (filter of filters; track trackByFilter(j, filter); let j = $index) {
<div
class="cursor-pointer transition-colors duration-200 ease-in-out pb-1 flex items-center gap-2"
[ngClass]="{
@@ -1,6 +1,6 @@
import {Component, EventEmitter, inject, Input, OnDestroy, OnInit, Output} from '@angular/core';
import {combineLatest, Observable, of, Subject, takeUntil} from 'rxjs';
import {distinctUntilChanged, map} from 'rxjs/operators';
import {ChangeDetectionStrategy, Component, EventEmitter, inject, Input, OnDestroy, OnInit, Output} from '@angular/core';
import {combineLatest, distinctUntilChanged, Observable, of, shareReplay, Subject, takeUntil} from 'rxjs';
import {map} from 'rxjs/operators';
import {BookService} from '../../../service/book.service';
import {Library} from '../../../model/library.model';
import {Shelf} from '../../../model/shelf.model';
@@ -133,6 +133,7 @@ function getReadStatusName(status?: ReadStatus | null): string {
selector: 'app-book-filter',
templateUrl: './book-filter.component.html',
styleUrls: ['./book-filter.component.scss'],
changeDetection: ChangeDetectionStrategy.OnPush,
standalone: true,
imports: [
Accordion,
@@ -148,6 +149,8 @@ function getReadStatusName(status?: ReadStatus | null): string {
]
})
export class BookFilterComponent implements OnInit, OnDestroy {
private filterChangeSubject = new Subject<Record<string, any> | null>();
@Output() filterSelected = new EventEmitter<Record<string, any> | null>();
@Output() filterModeChanged = new EventEmitter<'and' | 'or'>();
@@ -199,8 +202,9 @@ export class BookFilterComponent implements OnInit, OnDestroy {
.pipe(takeUntil(this.destroy$))
.subscribe(([sortMode]) => {
this.filterStreams = {
author: this.getFilterStream((book: Book) => book.metadata?.authors!.map(name => ({id: name, name})) || [], 'id', 'name', sortMode),
category: this.getFilterStream((book: Book) => book.metadata?.categories!.map(name => ({id: name, name})) || [], 'id', 'name', sortMode),
// Temporarily disabled until we can optimize for large libraries
/*author: this.getFilterStream((book: Book) => book.metadata?.authors!.map(name => ({id: name, name})) || [], 'id', 'name', sortMode),
category: this.getFilterStream((book: Book) => book.metadata?.categories!.map(name => ({id: name, name})) || [], 'id', 'name', sortMode),*/
series: this.getFilterStream((book) => (book.metadata?.seriesName ? [{id: book.metadata.seriesName, name: book.metadata.seriesName}] : []), 'id', 'name', sortMode),
publisher: this.getFilterStream((book) => (book.metadata?.publisher ? [{id: book.metadata.publisher, name: book.metadata.publisher}] : []), 'id', 'name', sortMode),
readStatus: this.getFilterStream((book: Book) => {
@@ -226,6 +230,10 @@ export class BookFilterComponent implements OnInit, OnDestroy {
this.setExpandedPanels();
});
this.filterChangeSubject.pipe(
takeUntil(this.destroy$)
).subscribe(value => this.filterSelected.emit(value));
if (this.resetFilter$) {
this.resetFilter$.pipe(takeUntil(this.destroy$)).subscribe(() => this.clearActiveFilter());
}
@@ -270,7 +278,8 @@ export class BookFilterComponent implements OnInit, OnDestroy {
a.value[nameKey].toString().localeCompare(b.value[nameKey].toString())
);
});
})
}),
shareReplay({bufferSize: 1, refCount: true})
);
}
@@ -281,6 +290,9 @@ export class BookFilterComponent implements OnInit, OnDestroy {
set selectedFilterMode(mode: 'and' | 'or') {
this._selectedFilterMode = mode;
this.filterModeChanged.emit(mode);
this.filterChangeSubject.next(
Object.keys(this.activeFilters).length ? {...this.activeFilters} : null
);
}
private filterBooksByEntityType(books: Book[], entity: any, entityType: EntityType): Book[] {
@@ -320,11 +332,7 @@ export class BookFilterComponent implements OnInit, OnDestroy {
this.activeFilters[filterType].push(value);
}
if (Object.keys(this.activeFilters).length === 0) {
this.filterSelected.emit(null);
} else {
this.filterSelected.emit({...this.activeFilters});
}
this.filterChangeSubject.next(Object.keys(this.activeFilters).length ? {...this.activeFilters} : null);
}
setFilters(filters: Record<string, any>) {
@@ -337,12 +345,12 @@ export class BookFilterComponent implements OnInit, OnDestroy {
this.activeFilters[key] = [value];
}
}
this.filterSelected.emit({...this.activeFilters});
this.filterChangeSubject.next({...this.activeFilters});
}
clearActiveFilter() {
this.activeFilters = {};
this.filterSelected.emit(null);
this.filterChangeSubject.next(null);
}
setExpandedPanels(): void {
@@ -356,6 +364,14 @@ export class BookFilterComponent implements OnInit, OnDestroy {
this.setExpandedPanels();
}
trackByFilterType(_: number, type: string): string {
return type;
}
trackByFilter(_: number, filter: Filter<any>): any {
return filter.value.id ?? filter.value;
}
ngOnDestroy(): void {
this.destroy$.next();
this.destroy$.complete();
@@ -1,7 +1,7 @@
import {BookFilter} from './BookFilter';
import {BookState} from '../../../model/state/book-state.model';
import {Observable} from 'rxjs';
import {map} from 'rxjs/operators';
import {Observable, of} from 'rxjs';
import {map, debounceTime, distinctUntilChanged, switchMap} from 'rxjs/operators';
export class HeaderFilter implements BookFilter {
@@ -13,21 +13,35 @@ export class HeaderFilter implements BookFilter {
str.normalize('NFD').replace(/[\u0300-\u036f]/g, '').toLowerCase();
return this.searchTerm$.pipe(
map(term => {
const normalizedTerm = normalize(term || '');
if (normalizedTerm && normalizedTerm.trim() !== '') {
const filteredBooks = bookState.books?.filter(book => {
const title = book.metadata?.title || '';
const series = book.metadata?.seriesName || '';
const authors = book.metadata?.authors || [];
const matchesTitle = normalize(title).includes(normalizedTerm);
const matchesSeries = normalize(series).includes(normalizedTerm);
const matchesAuthor = authors.some(author => normalize(author).includes(normalizedTerm));
return matchesTitle || matchesSeries || matchesAuthor;
}) || null;
return {...bookState, books: filteredBooks};
distinctUntilChanged(),
switchMap(term => {
const normalizedTerm = normalize(term || '').trim();
if (!normalizedTerm) {
return of(bookState);
}
return bookState;
return of(normalizedTerm).pipe(
debounceTime(500),
map(nTerm => {
const filteredBooks = bookState.books?.filter(book => {
const title = book.metadata?.title || '';
const series = book.metadata?.seriesName || '';
const authors = book.metadata?.authors || [];
const categories = book.metadata?.categories || [];
const isbn = book.metadata?.isbn10 || '';
const isbn13 = book.metadata?.isbn13 || '';
const matchesTitle = normalize(title).includes(nTerm);
const matchesSeries = normalize(series).includes(nTerm);
const matchesAuthor = authors.some(author => normalize(author).includes(nTerm));
const matchesCategory = categories.some(category => normalize(category).includes(nTerm));
const matchesIsbn = normalize(isbn).includes(nTerm) || normalize(isbn13).includes(nTerm);
return matchesTitle || matchesSeries || matchesAuthor || matchesCategory || matchesIsbn;
}) || null;
return {...bookState, books: filteredBooks};
})
);
})
);
}
@@ -0,0 +1,56 @@
import {inject, Injectable} from '@angular/core';
import {BehaviorSubject} from 'rxjs';
import {MessageService} from 'primeng/api';
import {LocalStorageService} from '../../../../core/service/local-storage-service';
@Injectable({
providedIn: 'root'
})
export class SidebarFilterTogglePrefService {
private readonly STORAGE_KEY = 'showSidebarFilter';
private readonly messageService = inject(MessageService);
private readonly localStorageService = inject(LocalStorageService);
private readonly showFilterSubject = new BehaviorSubject<boolean>(true);
readonly showFilter$ = this.showFilterSubject.asObservable();
constructor() {
this.loadFromStorage();
}
get selectedShowFilter(): boolean {
return this.showFilterSubject.value;
}
set selectedShowFilter(value: boolean) {
if (this.showFilterSubject.value !== value) {
this.showFilterSubject.next(value);
this.savePreference(value);
}
}
toggle(): void {
this.selectedShowFilter = !this.selectedShowFilter;
}
private savePreference(value: boolean): void {
try {
this.localStorageService.set(this.STORAGE_KEY, value);
} catch (e) {
this.messageService.add({
severity: 'error',
summary: 'Save Failed',
detail: 'Could not save sidebar filter preference locally.',
life: 3000
});
}
}
private loadFromStorage(): void {
const saved = this.localStorageService.get<boolean>(this.STORAGE_KEY);
if (saved !== null) {
this.showFilterSubject.next(saved);
}
}
}
@@ -7,7 +7,7 @@
pInputText
[(ngModel)]="searchQuery"
(input)="onSearchInputChange()"
placeholder="Search books by title or author..."
placeholder="Title, Author, Series, Genre, or ISBN..."
class="w-full pr-10"
/>
@if (searchQuery) {
@@ -22,29 +22,6 @@
}
</p-iconfield>
<!--<div class="sm:hidden flex items-center">
<p-button
icon="pi pi-search"
(click)="toggleSearchInputDropdown()"
[rounded]="true">
</p-button>
</div>
&lt;!&ndash; Dropdown input for small screens &ndash;&gt;
@if (isSearchDropdownOpen) {
<div class="absolute z-10 shadow-md rounded-md mt-2 w-56 sm:hidden">
<input
type="text"
pInputText
[(ngModel)]="searchQuery"
(input)="onSearchInputChange()"
(blur)="closeSearchDropdown()"
placeholder="Search books..."
class="w-full"
/>
</div>
}-->
<!-- Search results below small screen search input -->
@if (books.length > 0 || searchQuery) {
<div
@@ -1,6 +1,6 @@
import {Component, inject, OnDestroy, OnInit} from '@angular/core';
import {of, Subject, Subscription} from 'rxjs';
import {catchError, debounceTime, distinctUntilChanged, switchMap} from 'rxjs/operators';
import {BehaviorSubject, of, Subject, Subscription} from 'rxjs';
import {catchError, switchMap} from 'rxjs/operators';
import {Book} from '../../model/book.model';
import {FormsModule} from '@angular/forms';
import {InputTextModule} from 'primeng/inputtext';
@@ -12,6 +12,7 @@ import {UrlHelperService} from '../../../utilities/service/url-helper.service';
import {Router} from '@angular/router';
import {IconField} from 'primeng/iconfield';
import {InputIcon} from 'primeng/inputicon';
import {HeaderFilter} from '../book-browser/filters/HeaderFilter';
@Component({
selector: 'app-book-searcher',
@@ -31,41 +32,29 @@ import {InputIcon} from 'primeng/inputicon';
export class BookSearcherComponent implements OnInit, OnDestroy {
searchQuery: string = '';
books: Book[] = [];
#searchSubject = new Subject<string>();
#searchSubject = new BehaviorSubject<string>('');
#subscription!: Subscription;
private bookService = inject(BookService);
private router = inject(Router);
protected urlHelper = inject(UrlHelperService);
isSearchDropdownOpen = false;
toggleSearchInputDropdown() {
this.isSearchDropdownOpen = !this.isSearchDropdownOpen;
}
closeSearchDropdown() {
this.isSearchDropdownOpen = false;
}
private headerFilter = new HeaderFilter(this.#searchSubject.asObservable());
ngOnInit(): void {
this.initializeSearch();
}
initializeSearch(): void {
this.#subscription = this.#searchSubject.pipe(
debounceTime(350),
distinctUntilChanged(),
switchMap((query) => {
const result = this.bookService.searchBooks(query);
return of(result);
}),
this.#subscription = this.bookService.bookState$.pipe(
switchMap(bookState => this.headerFilter.filter(bookState)),
catchError((error) => {
console.error('Error while searching books:', error);
return of([]);
return of({books: [], loaded: true, error: null});
})
).subscribe({
next: (result: Book[]) => this.books = result,
next: (filteredState) => {
this.books = this.searchQuery.trim() ? (filteredState.books || []) : [];
},
error: (error) => console.error('Subscription error:', error)
});
}
@@ -1,56 +1,80 @@
<div class="comic-reader-container">
<div class="comic-reader-container" tabindex="0">
<div class="navigation">
<div class="goto-page-controls" style="display: flex; align-items: center; margin-right: auto;">
<input
type="number"
[(ngModel)]="goToPageInput"
[min]="1"
[max]="pages.length"
placeholder="Page"
/>
<button
(click)="goToPageInput !== null && goToPage(goToPageInput)"
[disabled]="goToPageInput === null || goToPageInput < 1 || goToPageInput > pages.length">
Go
<div class="goto-page-controls">
<div class="input-group">
<input
type="number"
[(ngModel)]="goToPageInput"
[min]="1"
[max]="pages.length"
placeholder="Page"
class="page-input"
/>
<button
class="go-button"
(click)="goToPageInput !== null && goToPage(goToPageInput)"
[disabled]="goToPageInput === null || goToPageInput < 1 || goToPageInput > pages.length">
Go
</button>
</div>
</div>
<div class="page-controls">
<button class="nav-button first-page" (click)="goToPage(1)" [disabled]="currentPage === 0" title="First Page">
<span>⟨⟨</span>
</button>
<button class="nav-button prev-page" (click)="previousPage()" [disabled]="currentPage === 0" title="Previous Page">
<span>⟨</span>
</button>
<div class="page-info">
<span class="current-page">{{ currentPage + 1 }}</span>
<span class="page-separator">{{ isTwoPageView && imageUrls.length > 1 ? '-' + (currentPage + 2) : '' }}</span>
<span class="total-pages"> of {{ pages.length }}</span>
</div>
<button class="nav-button next-page" (click)="nextPage()" [disabled]="currentPage >= pages.length - 1" title="Next Page">
<span>⟩</span>
</button>
<button class="nav-button last-page" (click)="goToPage(pages.length)" [disabled]="currentPage >= pages.length - 1" title="Last Page">
<span>⟩⟩</span>
</button>
</div>
<div class="page-controls" style="display: flex; align-items: center; justify-content: center; flex-grow: 1;">
<button class="mr-2" (click)="goToPage(1)" [disabled]="currentPage === 0">&lt;&lt;</button>
<button (click)="previousPage()" [disabled]="currentPage === 0">&lt;</button>
<span>
Page {{ currentPage + 1 }}
{{ isTwoPageView && imageUrls.length > 1 ? '-' + (currentPage + 2) : '' }} of {{ pages.length }}
</span>
<button (click)="nextPage()" [disabled]="currentPage >= pages.length - 1">&gt;</button>
<button class="ml-2" (click)="goToPage(pages.length)" [disabled]="currentPage >= pages.length - 1">&gt;&gt;</button>
</div>
<div class="spread-controls" style="display: flex; align-items: center; margin-left: auto;">
<div class="spread-controls">
@if (isTwoPageView) {
<button (click)="toggleSpreadDirection()" title="Toggle Spread Direction">
{{ pageSpread === 'ODD' ? '⬅️' : '➡️' }}
<button class="view-button spread-toggle" (click)="toggleSpreadDirection()" title="Toggle Spread Direction">
<span>{{ pageSpread === 'ODD' ? '⬅️' : '➡️' }}</span>
</button>
}
<button (click)="toggleView()" title="Toggle View">
{{ isTwoPageView ? '1️⃣' : '2️⃣' }}
<button class="view-button layout-toggle" (click)="toggleView()" title="Toggle View">
<span>{{ isTwoPageView ? '📄' : '📖' }}</span>
</button>
<button class="view-button background-toggle" (click)="toggleBackground()" title="Toggle Background Color">
<span>{{ backgroundColorIcon }}</span>
</button>
</div>
</div>
<div class="image-container" [class.two-page-view]="isTwoPageView">
<div class="image-container"
[class.two-page-view]="isTwoPageView"
[class.bg-black]="backgroundColor === 'black'"
[class.bg-gray]="backgroundColor === 'gray'"
[class.bg-white]="backgroundColor === 'white'">
@if (!isLoading) {
@if (pages.length > 0) {
@for (url of imageUrls; track url) {
<img [src]="url" alt="Page Image"/>
}
<div class="pages-wrapper">
@for (url of imageUrls; track url) {
<img [src]="url" alt="Page Image" class="page-image"/>
}
</div>
} @else {
<p>No pages available.</p>
<div class="no-pages">
<p>No pages available.</p>
</div>
}
} @else {
<div style="display: flex; flex-direction: column; justify-content: center; align-items: center; height: 100%;">
<p-progressSpinner></p-progressSpinner>
<p style="margin-top: 1rem; color: #ccc;">Processing pages... This may take a few seconds on first load. Future loads will be significantly faster.</p>
<div class="loading-container">
<p-progressSpinner styleClass="custom-spinner"></p-progressSpinner>
<p class="loading-text">Processing pages... This may take a few seconds on first load. Future loads will be significantly faster.</p>
</div>
}
</div>
@@ -1,115 +1,267 @@
.comic-reader-container {
display: flex;
flex-direction: column;
align-items: center;
height: 100dvh;
width: 100vw;
overflow-x: hidden;
overflow: hidden;
box-sizing: border-box;
background: #1a1a1a;
color: #ffffff;
&:focus {
outline: none;
}
.navigation {
position: relative;
flex-shrink: 0;
width: 100%;
margin: 1rem;
background: linear-gradient(135deg, #2d2d2d 0%, #1f1f1f 100%);
border-bottom: 1px solid #404040;
padding: 0.25rem 0.5rem;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
display: flex;
align-items: center;
justify-content: space-between;
z-index: 1000;
min-width: 0;
.goto-page-controls {
flex: 0 0 auto;
order: 1;
min-width: fit-content;
.input-group {
display: flex;
align-items: center;
gap: 0.125rem;
background: rgba(51, 51, 51, 0.9);
border-radius: 4px;
padding: 1px;
border: 1px solid #555;
.page-input {
width: 55px;
padding: 4px 6px;
border: none;
border-radius: 3px;
background: #404040;
color: #ffffff;
font-size: 12px;
text-align: center;
transition: all 0.2s ease;
&:focus {
outline: none;
background: #4a4a4a;
box-shadow: 0 0 0 1px rgba(74, 144, 226, 0.5);
}
&::placeholder {
color: #999;
}
}
.go-button {
padding: 4px 8px;
background: #4a90e2;
color: white;
border: none;
border-radius: 3px;
font-size: 12px;
font-weight: 500;
cursor: pointer;
transition: all 0.2s ease;
&:hover:not(:disabled) {
background: #357abd;
}
&:disabled {
background: #666;
cursor: not-allowed;
opacity: 0.6;
}
}
}
}
.page-controls {
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
flex: 1;
display: flex;
align-items: center;
white-space: nowrap;
justify-content: center;
gap: 0.25rem;
order: 2;
min-width: 0;
span {
min-width: 8rem;
display: inline-block;
text-align: center;
}
button {
padding: 0 0.25rem;
text-align: center;
white-space: nowrap;
.nav-button {
width: 24px;
height: 28px;
border: 1px solid #555;
background: rgba(51, 51, 51, 0.9);
color: #ffffff;
border-radius: 4px;
cursor: pointer;
transition: all 0.2s ease;
display: flex;
align-items: center;
justify-content: center;
span {
font-size: 11px;
font-weight: bold;
}
&:hover:not(:disabled) {
background: #4a4a4a;
border-color: #666;
}
&:disabled {
cursor: default;
color: #999;
background: #2a2a2a;
color: #666;
cursor: not-allowed;
border-color: #333;
}
}
.page-info {
margin: 0 0.5rem;
padding: 2px 8px;
background: rgba(255, 255, 255, 0.1);
border-radius: 4px;
font-weight: 500;
font-size: 12px;
min-width: 80px;
text-align: center;
.current-page {
color: #4a90e2;
font-weight: 600;
}
.page-separator {
color: #4a90e2;
font-weight: 600;
}
.total-pages {
color: #ccc;
}
}
}
.spread-controls {
position: absolute;
right: 0;
top: 50%;
transform: translateY(-50%);
flex: 0 0 auto;
display: flex;
gap: 0.5rem;
align-items: center;
gap: 0.25rem;
order: 3;
min-width: fit-content;
button {
padding-left: 0.5rem;
padding-right: 0.5rem;
.view-button {
width: 28px;
height: 28px;
border: 1px solid #555;
background: rgba(51, 51, 51, 0.9);
color: #ffffff;
border-radius: 4px;
cursor: pointer;
transition: all 0.2s ease;
display: flex;
align-items: center;
justify-content: center;
span {
font-size: 13px;
}
&:hover {
background: #4a4a4a;
border-color: #666;
}
}
}
}
.image-container {
flex-grow: 1;
width: 100%;
flex: 1;
display: flex;
justify-content: center;
align-items: center;
gap: 1rem;
overflow: hidden;
padding: 0 1rem;
box-sizing: border-box;
padding: 0.5rem;
background: #0f0f0f;
min-height: 0;
&.bg-black {
background: #000000;
}
&.bg-gray {
background: #0f0f0f;
}
&.bg-white {
background: #ffffff;
}
.pages-wrapper {
display: flex;
justify-content: center;
align-items: center;
gap: 1rem;
height: 100%;
width: 100%;
}
&.two-page-view {
img {
.page-image {
max-width: calc(50% - 0.5rem);
max-height: 100%;
}
}
&:not(.two-page-view) {
img {
.page-image {
max-width: 100%;
max-height: 100%;
}
}
img {
max-height: 100%;
.page-image {
height: auto;
width: auto;
object-fit: contain;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
flex-shrink: 1;
margin: 0;
display: block;
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
border-radius: 4px;
transition: transform 0.2s ease;
&:hover {
transform: scale(1.02);
}
}
.no-pages {
text-align: center;
color: #999;
font-size: 18px;
}
.loading-container {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
gap: 1.5rem;
text-align: center;
.loading-text {
color: #ccc;
font-size: 16px;
max-width: 400px;
line-height: 1.5;
margin: 0;
}
}
}
.goto-page-controls {
position: absolute;
left: 0;
top: 50%;
transform: translateY(-50%);
display: flex;
gap: 0.5rem;
align-items: center;
padding-left: 6px;
}
.goto-page-controls input[type="number"] {
width: 40px;
border-radius: 0.25rem;
font-size: 0.875rem;
}
.goto-page-controls button:disabled {
cursor: default;
color: #999;
}
}
@@ -1,5 +1,4 @@
import {Component, HostListener, inject, OnInit} from '@angular/core';
import {ActivatedRoute} from '@angular/router';
import {CbxReaderService} from '../../service/cbx-reader.service';
import {BookService} from '../../service/book.service';
@@ -31,6 +30,8 @@ export class CbxReaderComponent implements OnInit {
pageSpread: CbxPageSpread | PdfPageSpread = CbxPageSpread.ODD;
pageViewMode: CbxPageViewMode | PdfPageViewMode = CbxPageViewMode.SINGLE_PAGE;
backgroundColor: 'black' | 'gray' | 'white' = 'gray';
private touchStartX = 0;
private touchEndX = 0;
@@ -111,6 +112,29 @@ export class CbxReaderComponent implements OnInit {
return this.pageViewMode === CbxPageViewMode.TWO_PAGE || this.pageViewMode === PdfPageViewMode.TWO_PAGE;
}
get backgroundColorIcon(): string {
switch (this.backgroundColor) {
case 'black': return '⚫';
case 'gray': return '🔘';
case 'white': return '⚪';
default: return '🔘';
}
}
toggleBackground(): void {
switch (this.backgroundColor) {
case 'black':
this.backgroundColor = 'gray';
break;
case 'gray':
this.backgroundColor = 'white';
break;
case 'white':
this.backgroundColor = 'black';
break;
}
}
toggleView() {
if (!this.isTwoPageView && this.isPhonePortrait()) return;
this.pageViewMode = this.isTwoPageView ? (this.bookType === "CBX" ? CbxPageViewMode.SINGLE_PAGE : PdfPageViewMode.SINGLE_PAGE) : (this.bookType === "CBX" ? CbxPageViewMode.TWO_PAGE : PdfPageViewMode.TWO_PAGE);
@@ -222,7 +246,10 @@ export class CbxReaderComponent implements OnInit {
get imageUrls(): string[] {
if (!this.pages.length) return [];
const urls = [this.getPageImageUrl(this.currentPage)];
const urls: string[] = [];
urls.push(this.getPageImageUrl(this.currentPage));
if (this.isTwoPageView && this.currentPage + 1 < this.pages.length) {
urls.push(this.getPageImageUrl(this.currentPage + 1));
}
@@ -233,17 +260,17 @@ export class CbxReaderComponent implements OnInit {
private updateViewerSetting(): void {
const bookSetting: BookSetting = this.bookType === "CBX"
? {
cbxSettings: {
pageSpread: this.pageSpread as CbxPageSpread,
pageViewMode: this.pageViewMode as CbxPageViewMode,
}
cbxSettings: {
pageSpread: this.pageSpread as CbxPageSpread,
pageViewMode: this.pageViewMode as CbxPageViewMode,
}
}
: {
newPdfSettings: {
pageSpread: this.pageSpread as PdfPageSpread,
pageViewMode: this.pageViewMode as PdfPageViewMode,
}
};
newPdfSettings: {
pageSpread: this.pageSpread as PdfPageSpread,
pageViewMode: this.pageViewMode as PdfPageViewMode,
}
};
this.bookService.updateViewerSetting(bookSetting, this.bookId).subscribe();
}
@@ -252,13 +279,14 @@ export class CbxReaderComponent implements OnInit {
? Math.round(((this.currentPage + 1) / this.pages.length) * 1000) / 10
: 0;
if(this.bookType === 'CBX') {
if (this.bookType === 'CBX') {
this.bookService.saveCbxProgress(this.bookId, this.currentPage + 1, percentage).subscribe();
}
if(this.bookType === 'PDF') {
if (this.bookType === 'PDF') {
this.bookService.savePdfProgress(this.bookId, this.currentPage + 1, percentage).subscribe();
}
}
goToPage(page: number): void {
if (page < 1 || page > this.pages.length) return;
@@ -191,21 +191,6 @@ export class BookService {
this.updateLastReadTime(book.id);
}
searchBooks(query: string): Book[] {
if (query.length < 2) {
return [];
}
const normalize = (str: string): string => str.normalize('NFD').replace(/[\u0300-\u036f]/g, '').toLowerCase();
const normalizedQuery = normalize(query);
const state = this.bookStateSubject.value;
return (state.books || []).filter(book => {
const title = book.metadata?.title;
const authors = book.metadata?.authors || [];
return (title && normalize(title).includes(normalizedQuery)) ||
authors.some(author => normalize(author).includes(normalizedQuery));
});
}
getFileContent(bookId: number): Observable<Blob> {
return this.http.get<Blob>(`${this.url}/${bookId}/content`, {responseType: 'blob' as 'json'});
}
@@ -331,7 +316,7 @@ export class BookService {
if (currentState.books) {
const updatedBooks = currentState.books.map(book => {
if (book.id === bookId) {
return { ...book, dateFinished: dateFinished || undefined };
return {...book, dateFinished: dateFinished || undefined};
}
return book;
});
@@ -90,6 +90,11 @@ export interface PublicReviewSettings {
providers: ReviewProviderConfig[];
}
export interface KoboSettings {
convertToKepub: boolean;
conversionLimitInMb: number;
}
export interface AppSettings {
autoBookSearch: boolean;
similarBookRecommendation: boolean;
@@ -107,6 +112,7 @@ export interface AppSettings {
metadataMatchWeights: MetadataMatchWeights;
metadataPersistenceSettings: MetadataPersistenceSettings;
metadataPublicReviewsSettings: PublicReviewSettings;
koboSettings: KoboSettings;
metadataDownloadOnBookdrop: boolean;
}
@@ -126,5 +132,6 @@ export enum AppSettingKey {
METADATA_MATCH_WEIGHTS = 'METADATA_MATCH_WEIGHTS',
METADATA_PERSISTENCE_SETTINGS = 'METADATA_PERSISTENCE_SETTINGS',
METADATA_DOWNLOAD_ON_BOOKDROP = 'METADATA_DOWNLOAD_ON_BOOKDROP',
METADATA_PUBLIC_REVIEWS_SETTINGS = 'METADATA_PUBLIC_REVIEWS_SETTINGS'
METADATA_PUBLIC_REVIEWS_SETTINGS = 'METADATA_PUBLIC_REVIEWS_SETTINGS',
KOBO_SETTINGS = 'KOBO_SETTINGS'
}
@@ -129,9 +129,9 @@
&::after {
content: '';
position: absolute;
bottom: -12px;
left: 15%;
right: 15%;
bottom: -8px;
left: 10%;
right: 10%;
height: 5px;
background: linear-gradient(
90deg,
@@ -149,8 +149,8 @@
@media (max-width: 767px) {
.dashboard-scroller-card {
height: 184px; /* 80% of 230px */
width: 108px; /* 80% of 135px */
height: 184px;
width: 108px;
flex-basis: 108px;
}
@@ -47,9 +47,40 @@
.dashboard-scroller-card {
width: 115px;
flex-basis: 115px;
flex-shrink: 0;
flex-grow: 0;
flex-basis: 115px;
scroll-snap-align: start;
transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
position: relative;
border-radius: 8px;
&:hover {
transform: translateY(-4px);
&::after {
opacity: 1;
}
}
&::after {
content: '';
position: absolute;
bottom: 0;
left: 7%;
right: 7%;
height: 4px;
background: linear-gradient(
90deg,
transparent,
var(--p-primary-500),
transparent
);
border-radius: 50%;
opacity: 0;
transition: all 0.4s ease;
filter: blur(4px);
}
}
.description-container {
@@ -138,4 +169,3 @@
::ng-deep .custom-tag-padding {
padding: 0.1rem !important;
}
@@ -1,7 +1,7 @@
<p-confirmDialog></p-confirmDialog>
<p class="text-lg flex items-center gap-2 px-4 pt-4 pb-2">
Kobo Sync Settings:
Kobo Integration Token:
<i class="pi pi-info-circle text-sky-600"
pTooltip="Click to view Kobo setup documentation"
tooltipPosition="right"
@@ -10,7 +10,7 @@
</i>
</p>
@if (hasPermission) {
@if (hasKoboTokenPermission) {
<form #koboForm="ngForm" class="px-4 py-2">
<div class="flex flex-col px-4 py-4 space-y-4">
<div class="flex flex-col gap-1 max-w-[33rem]">
@@ -50,6 +50,50 @@
</p-button>
</div>
</form>
@if (isAdmin) {
<div class="px-4 py-4">
<p class="text-lg mb-4">Kobo Settings (Admin Only):</p>
<div class="flex flex-col px-4 py-4 space-y-6 max-w-[75rem]">
<div class="flex flex-col gap-2">
<div class="flex items-center gap-2">
<p-toggle-switch
id="convertToKepub"
[(ngModel)]="koboSettings.convertToKepub"
(ngModelChange)="onToggleChange()">
</p-toggle-switch>
<label for="convertToKepub" class="font-medium">Convert to KEPUB</label>
</div>
<p class="text-zinc-400 text-sm">
<strong>Pros:</strong> KEPUB format enables enhanced Kobo features like better typography, reading stats, and faster page turns.
<br>
<strong>Cons:</strong> Conversion takes extra processing time and may occasionally fail for complex layouts.
Books over the size limit below will skip conversion automatically.
</p>
</div>
<div class="flex flex-col gap-4">
<div class="flex items-center gap-6">
<label for="conversionLimit" class="font-medium">Conversion Size Limit: {{ koboSettings.conversionLimitInMb }} MB</label>
</div>
<p-slider
class="max-w-64"
id="conversionLimit"
[(ngModel)]="koboSettings.conversionLimitInMb"
[min]="1"
[max]="250"
[step]="1"
(ngModelChange)="onSliderChange()">
</p-slider>
<p class="text-zinc-400 text-sm">
Large files (100MB+) can cause conversion timeouts and server strain. Lower limits ensure faster syncing but may skip conversion of larger books.
<br>
<strong>Recommended:</strong> 50-100MB for most libraries. Very large books will sync as regular EPUB regardless of this setting.
</p>
</div>
</div>
</div>
}
} @else {
<div class="px-4 py-4 m-4 rounded-lg bg-red-700/30 border border-red-600 text-red-200 flex items-center gap-2 max-w-lg">
<i class="pi pi-lock text-red-400 text-xl"></i>
@@ -8,15 +8,20 @@ import {InputText} from 'primeng/inputtext';
import {ConfirmDialog} from 'primeng/confirmdialog';
import {UserService} from '../../user-management/user.service';
import {Subject} from 'rxjs';
import {filter, takeUntil} from 'rxjs/operators';
import {debounceTime, filter, take, takeUntil} from 'rxjs/operators';
import {Tooltip} from 'primeng/tooltip';
import {ToggleSwitch} from 'primeng/toggleswitch';
import {Slider} from 'primeng/slider';
import {AppSettingsService} from '../../../core/service/app-settings.service';
import {SettingsHelperService} from '../../../core/service/settings-helper.service';
import {AppSettingKey, KoboSettings} from '../../../core/model/app-settings.model';
@Component({
selector: 'app-kobo-sync-setting-component',
standalone: true,
templateUrl: './kobo-sync-settings-component.html',
styleUrl: './kobo-sync-settings-component.scss',
imports: [FormsModule, Button, InputText, ConfirmDialog, Tooltip],
imports: [FormsModule, Button, InputText, ConfirmDialog, Tooltip, ToggleSwitch, Slider],
providers: [MessageService, ConfirmationService]
})
export class KoboSyncSettingsComponent implements OnInit, OnDestroy {
@@ -25,34 +30,77 @@ export class KoboSyncSettingsComponent implements OnInit, OnDestroy {
private confirmationService = inject(ConfirmationService);
private clipboard = inject(Clipboard);
protected userService = inject(UserService);
protected appSettingsService = inject(AppSettingsService);
protected settingsHelperService = inject(SettingsHelperService);
private readonly destroy$ = new Subject<void>();
hasPermission = false;
private readonly sliderChange$ = new Subject<void>();
hasKoboTokenPermission = false;
isAdmin = false;
koboToken = '';
credentialsSaved = false;
showToken = false;
koboSettings: KoboSettings = {
convertToKepub: false,
conversionLimitInMb: 100
};
ngOnInit() {
this.setupSliderDebouncing();
this.setupUserStateSubscription();
}
private setupSliderDebouncing() {
this.sliderChange$.pipe(
debounceTime(500),
takeUntil(this.destroy$)
).subscribe(() => {
this.saveSettings();
});
}
private setupUserStateSubscription() {
this.userService.userState$.pipe(
filter(userState => !!userState?.user && userState.loaded),
takeUntil(this.destroy$)
).subscribe(userState => {
this.hasPermission = (userState.user?.permissions.canSyncKobo || userState.user?.permissions.admin) ?? false;
if (this.hasPermission) {
this.koboService.getUser().subscribe({
next: (settings: KoboSyncSettings) => {
this.koboToken = settings.token;
this.credentialsSaved = !!settings.token;
},
error: () => {
this.messageService.add({severity: 'error', summary: 'Error', detail: 'Failed to load Kobo settings'});
}
});
this.hasKoboTokenPermission = (userState.user?.permissions.canSyncKobo) ?? false;
this.isAdmin = userState.user?.permissions.admin ?? false;
if (this.hasKoboTokenPermission) {
this.loadKoboToken();
}
if (this.isAdmin) {
this.loadKoboSettings();
}
});
}
private loadKoboToken() {
this.koboService.getUser().subscribe({
next: (settings: KoboSyncSettings) => {
this.koboToken = settings.token;
this.credentialsSaved = !!settings.token;
},
error: () => {
this.messageService.add({severity: 'error', summary: 'Error', detail: 'Failed to load Kobo settings'});
}
});
}
private loadKoboSettings() {
this.appSettingsService.appSettings$
.pipe(
filter(settings => settings != null),
take(1),
)
.subscribe(settings => {
this.koboSettings.convertToKepub = settings?.koboSettings?.convertToKepub ?? true;
this.koboSettings.conversionLimitInMb = settings?.koboSettings?.conversionLimitInMb ?? 100;
});
}
copyText(text: string) {
this.clipboard.copy(text);
this.messageService.add({severity: 'success', summary: 'Copied', detail: 'Token copied to clipboard'});
@@ -84,6 +132,34 @@ export class KoboSyncSettingsComponent implements OnInit, OnDestroy {
});
}
onToggleChange() {
this.saveSettings();
}
onSliderChange() {
this.sliderChange$.next();
}
saveSettings() {
this.settingsHelperService.saveSetting(AppSettingKey.KOBO_SETTINGS, this.koboSettings)
.subscribe({
next: () => {
this.messageService.add({
severity: 'success',
summary: 'Settings Saved',
detail: 'Kobo settings updated successfully'
});
},
error: () => {
this.messageService.add({
severity: 'error',
summary: 'Save Failed',
detail: 'Failed to save Kobo settings'
});
}
});
}
openKoboDocumentation(): void {
window.open('https://booklore-app.github.io/booklore-docs/docs/devices/kobo', '_blank');
}