Merge pull request #1294 from booklore-app/develop
Merge develop into master for release
This commit is contained in:
@@ -157,16 +157,10 @@ public class BookService {
|
||||
.percentage(userProgress.getEpubProgressPercent())
|
||||
.build());
|
||||
if (userProgress.getKoreaderProgressPercent() != null) {
|
||||
var userReadProgress = userProgress.getKoreaderProgressPercent() * 100;
|
||||
book.getKoreaderProgress().setPercentage(userReadProgress);
|
||||
if (userReadProgress >= 99.5f) {
|
||||
book.setReadStatus(String.valueOf(ReadStatus.READ));
|
||||
} else if (userReadProgress > 0.01f) {
|
||||
book.setReadStatus(String.valueOf(ReadStatus.READING));
|
||||
} else {
|
||||
book.setReadStatus(String.valueOf(ReadStatus.UNREAD));
|
||||
if (book.getKoreaderProgress() == null) {
|
||||
book.setKoreaderProgress(KoProgress.builder().build());
|
||||
}
|
||||
|
||||
book.getKoreaderProgress().setPercentage(userProgress.getKoreaderProgressPercent() * 100);
|
||||
}
|
||||
}
|
||||
if (bookEntity.getBookType() == BookFileType.CBX) {
|
||||
|
||||
+24
-22
@@ -68,11 +68,32 @@ public class KoreaderService {
|
||||
|
||||
UserBookProgressEntity userProgress = getOrCreateUserProgress(user, book);
|
||||
updateProgressData(userProgress, koProgress);
|
||||
|
||||
progressRepository.save(userProgress);
|
||||
|
||||
log.info("saveProgress: saved progress='{}' percentage={} for userId={} bookHash={}",
|
||||
koProgress.getProgress(), koProgress.getPercentage(),
|
||||
authDetails.getBookLoreUserId(), bookHash);
|
||||
log.info("saveProgress: saved progress='{}' percentage={} for userId={} bookHash={}", koProgress.getProgress(), koProgress.getPercentage(), authDetails.getBookLoreUserId(), bookHash);
|
||||
}
|
||||
|
||||
private void updateProgressData(UserBookProgressEntity userProgress, KoreaderProgress koProgress) {
|
||||
userProgress.setKoreaderProgress(koProgress.getProgress());
|
||||
userProgress.setKoreaderProgressPercent(koProgress.getPercentage());
|
||||
userProgress.setKoreaderDevice(koProgress.getDevice());
|
||||
userProgress.setKoreaderDeviceId(koProgress.getDevice_id());
|
||||
userProgress.setKoreaderLastSyncTime(Instant.now());
|
||||
userProgress.setLastReadTime(Instant.now());
|
||||
|
||||
updateReadStatus(userProgress, koProgress.getPercentage());
|
||||
}
|
||||
|
||||
private void updateReadStatus(UserBookProgressEntity userProgress, double progressFraction) {
|
||||
double progressPercent = progressFraction * 100.0;
|
||||
if (progressPercent >= 99.5) {
|
||||
userProgress.setReadStatus(ReadStatus.READ);
|
||||
} else if (progressPercent >= 0.25) {
|
||||
userProgress.setReadStatus(ReadStatus.READING);
|
||||
} else {
|
||||
userProgress.setReadStatus(ReadStatus.UNREAD);
|
||||
}
|
||||
}
|
||||
|
||||
private KoreaderUserDetails getAuthDetails() {
|
||||
@@ -131,25 +152,6 @@ public class KoreaderService {
|
||||
});
|
||||
}
|
||||
|
||||
private void updateProgressData(UserBookProgressEntity userProgress, KoreaderProgress koProgress) {
|
||||
userProgress.setKoreaderProgress(koProgress.getProgress());
|
||||
userProgress.setKoreaderProgressPercent(koProgress.getPercentage());
|
||||
userProgress.setKoreaderDevice(koProgress.getDevice());
|
||||
userProgress.setKoreaderDeviceId(koProgress.getDevice_id());
|
||||
userProgress.setKoreaderLastSyncTime(Instant.now());
|
||||
userProgress.setLastReadTime(Instant.now());
|
||||
|
||||
updateReadStatus(userProgress, koProgress.getPercentage());
|
||||
}
|
||||
|
||||
private void updateReadStatus(UserBookProgressEntity userProgress, double percentage) {
|
||||
if (percentage >= 99.5) {
|
||||
userProgress.setReadStatus(ReadStatus.READ);
|
||||
} else if (percentage >= 0.5) {
|
||||
userProgress.setReadStatus(ReadStatus.READING);
|
||||
}
|
||||
}
|
||||
|
||||
private void ensureSyncEnabled(KoreaderUserDetails details) {
|
||||
if (!details.isSyncEnabled()) {
|
||||
log.warn("Sync is disabled for user '{}'", details.getUsername());
|
||||
|
||||
+3
-3
@@ -113,7 +113,7 @@
|
||||
<p-divider></p-divider>
|
||||
|
||||
<div class="flex items-center gap-2">
|
||||
<label id="spread-label" class="block font-semibold text-gray-200">Page Spead:</label>
|
||||
<label id="spread-label" class="block font-semibold text-gray-200">Page Spread:</label>
|
||||
<div class="flex gap-4" role="radiogroup" aria-labelledby="spread-label">
|
||||
<div class="flex items-center gap-1.5">
|
||||
<p-radioButton
|
||||
@@ -175,10 +175,10 @@
|
||||
</div>
|
||||
<div id="epubContainer" #epubContainer></div>
|
||||
@if (selectedFlow !== 'scrolled') {
|
||||
<button class="epub-controls-left" (click)="prevPage()">←</button>
|
||||
<button class="epub-controls-left" [class.visible]="showControls" (click)="prevPage(); onBookTouch()">←</button>
|
||||
}
|
||||
@if (selectedFlow !== 'scrolled') {
|
||||
<button class="epub-controls-right" (click)="nextPage()">→</button>
|
||||
<button class="epub-controls-right" [class.visible]="showControls" (click)="nextPage(); onBookTouch()">→</button>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
|
||||
+8
-13
@@ -61,16 +61,6 @@
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
overflow: hidden;
|
||||
|
||||
@media (max-width: 768px) {
|
||||
touch-action: manipulation;
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
iframe {
|
||||
pointer-events: auto;
|
||||
touch-action: manipulation;
|
||||
}
|
||||
}
|
||||
|
||||
.menu-toggle-button,
|
||||
@@ -100,10 +90,16 @@
|
||||
background: none;
|
||||
border: none;
|
||||
padding: 10px;
|
||||
transition: color 0.3s ease, transform 0.2s ease;
|
||||
transition: color 0.3s ease, transform 0.2s ease, opacity 0.3s ease;
|
||||
|
||||
@media (max-width: 768px) {
|
||||
display: none;
|
||||
opacity: 0;
|
||||
pointer-events: none;
|
||||
|
||||
&.visible {
|
||||
opacity: 1;
|
||||
pointer-events: auto;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -178,4 +174,3 @@
|
||||
::ng-deep .p-divider.p-divider-horizontal {
|
||||
margin: 0.25rem 0 0.5rem 0 !important;
|
||||
}
|
||||
|
||||
|
||||
+33
-49
@@ -1,4 +1,4 @@
|
||||
import {Component, ElementRef, inject, OnDestroy, OnInit, ViewChild, AfterViewInit} from '@angular/core';
|
||||
import {Component, ElementRef, inject, OnDestroy, OnInit, ViewChild, AfterViewInit, NgZone} from '@angular/core';
|
||||
import ePub from 'epubjs';
|
||||
import {Drawer} from 'primeng/drawer';
|
||||
import {Button} from 'primeng/button';
|
||||
@@ -40,6 +40,9 @@ export class EpubViewerComponent implements OnInit, OnDestroy {
|
||||
public exactProgress = 0;
|
||||
public progressPercentage = 0;
|
||||
|
||||
showControls = !this.isMobileDevice();
|
||||
private hideControlsTimeout?: number;
|
||||
|
||||
private book: any;
|
||||
private rendition: any;
|
||||
private keyListener: (e: KeyboardEvent) => void = () => {
|
||||
@@ -73,14 +76,10 @@ export class EpubViewerComponent implements OnInit, OnDestroy {
|
||||
private userService = inject(UserService);
|
||||
private bookService = inject(BookService);
|
||||
private messageService = inject(MessageService);
|
||||
private ngZone = inject(NgZone);
|
||||
|
||||
epub!: Book;
|
||||
|
||||
private touchStartX: number = 0;
|
||||
private touchStartY: number = 0;
|
||||
private minSwipeDistance: number = 50;
|
||||
private maxVerticalDistance: number = 100;
|
||||
|
||||
ngOnInit(): void {
|
||||
this.route.paramMap.subscribe((params) => {
|
||||
this.isLoading = true;
|
||||
@@ -161,8 +160,8 @@ export class EpubViewerComponent implements OnInit, OnDestroy {
|
||||
|
||||
displayPromise.then(() => {
|
||||
this.setupKeyListener();
|
||||
this.setupTouchListeners();
|
||||
this.trackProgress();
|
||||
this.setupTouchListener();
|
||||
this.isLoading = false;
|
||||
});
|
||||
};
|
||||
@@ -204,7 +203,6 @@ export class EpubViewerComponent implements OnInit, OnDestroy {
|
||||
this.rendition.themes.override('font-size', `${this.fontSize}%`);
|
||||
this.applyCombinedTheme();
|
||||
this.setupKeyListener();
|
||||
this.setupTouchListeners();
|
||||
this.rendition.display(cfi || undefined);
|
||||
this.updateViewerSetting();
|
||||
}
|
||||
@@ -227,7 +225,6 @@ export class EpubViewerComponent implements OnInit, OnDestroy {
|
||||
this.rendition.themes.override('font-size', `${this.fontSize}%`);
|
||||
this.applyCombinedTheme();
|
||||
this.setupKeyListener();
|
||||
this.setupTouchListeners();
|
||||
this.rendition.display(cfi || undefined);
|
||||
this.updateViewerSetting();
|
||||
}
|
||||
@@ -313,50 +310,19 @@ export class EpubViewerComponent implements OnInit, OnDestroy {
|
||||
document.addEventListener('keyup', this.keyListener);
|
||||
}
|
||||
|
||||
private setupTouchListeners(): void {
|
||||
if (!this.isMobileDevice() || this.selectedFlow === 'scrolled') return;
|
||||
private setupTouchListener(): void {
|
||||
if (!this.isMobileDevice() || !this.rendition) return;
|
||||
|
||||
const container = this.epubContainer.nativeElement;
|
||||
container.removeEventListener('touchstart', this.onTouchStart.bind(this));
|
||||
container.removeEventListener('touchend', this.onTouchEnd.bind(this));
|
||||
|
||||
container.addEventListener('touchstart', this.onTouchStart.bind(this), {passive: true});
|
||||
container.addEventListener('touchend', this.onTouchEnd.bind(this), {passive: true});
|
||||
|
||||
setTimeout(() => {
|
||||
this.rendition.on('rendered', () => {
|
||||
const iframe = this.epubContainer.nativeElement.querySelector('iframe');
|
||||
if (iframe && iframe.contentDocument) {
|
||||
const iframeDoc = iframe.contentDocument;
|
||||
iframeDoc.addEventListener('touchstart', this.onTouchStart.bind(this), {passive: true});
|
||||
iframeDoc.addEventListener('touchend', this.onTouchEnd.bind(this), {passive: true});
|
||||
iframe.contentDocument.addEventListener('touchstart', () => {
|
||||
this.ngZone.run(() => {
|
||||
this.onBookTouch();
|
||||
});
|
||||
});
|
||||
}
|
||||
}, 500);
|
||||
}
|
||||
|
||||
onTouchStart(event: TouchEvent): void {
|
||||
if (this.selectedFlow === 'scrolled') return;
|
||||
|
||||
this.touchStartX = event.touches[0].clientX;
|
||||
this.touchStartY = event.touches[0].clientY;
|
||||
}
|
||||
|
||||
onTouchEnd(event: TouchEvent): void {
|
||||
if (this.selectedFlow === 'scrolled') return;
|
||||
|
||||
const touchEndX = event.changedTouches[0].clientX;
|
||||
const touchEndY = event.changedTouches[0].clientY;
|
||||
|
||||
const deltaX = touchEndX - this.touchStartX;
|
||||
const deltaY = Math.abs(touchEndY - this.touchStartY);
|
||||
|
||||
if (Math.abs(deltaX) > this.minSwipeDistance && deltaY < this.maxVerticalDistance) {
|
||||
event.preventDefault();
|
||||
if (deltaX > 0) {
|
||||
this.prevPage();
|
||||
} else {
|
||||
this.nextPage();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public isMobileDevice(): boolean {
|
||||
@@ -435,6 +401,10 @@ export class EpubViewerComponent implements OnInit, OnDestroy {
|
||||
this.rendition.off('keyup', this.keyListener);
|
||||
}
|
||||
document.removeEventListener('keyup', this.keyListener);
|
||||
|
||||
if (this.hideControlsTimeout) {
|
||||
window.clearTimeout(this.hideControlsTimeout);
|
||||
}
|
||||
}
|
||||
|
||||
getThemeColor(themeKey: string | undefined): string {
|
||||
@@ -456,4 +426,18 @@ export class EpubViewerComponent implements OnInit, OnDestroy {
|
||||
this.selectedTheme = themeKey;
|
||||
this.changeThemes();
|
||||
}
|
||||
|
||||
onBookTouch(): void {
|
||||
if (this.isMobileDevice()) {
|
||||
this.showControls = true;
|
||||
if (this.hideControlsTimeout) {
|
||||
window.clearTimeout(this.hideControlsTimeout);
|
||||
}
|
||||
this.hideControlsTimeout = window.setTimeout(() => {
|
||||
this.ngZone.run(() => {
|
||||
this.showControls = false;
|
||||
});
|
||||
}, 3000);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+8
-1
@@ -533,7 +533,14 @@ export class MetadataPickerComponent implements OnInit {
|
||||
copyMissing(): void {
|
||||
Object.keys(this.fetchedMetadata).forEach((field) => {
|
||||
const isLocked = this.metadataForm.get(`${field}Locked`)?.value;
|
||||
if (!isLocked && !this.metadataForm.get(field)?.value && this.fetchedMetadata[field]) {
|
||||
const currentValue = this.metadataForm.get(field)?.value;
|
||||
const fetchedValue = this.fetchedMetadata[field];
|
||||
|
||||
const isEmpty = Array.isArray(currentValue)
|
||||
? currentValue.length === 0
|
||||
: !currentValue;
|
||||
|
||||
if (!isLocked && isEmpty && fetchedValue) {
|
||||
this.copyFetchedToCurrent(field);
|
||||
}
|
||||
});
|
||||
|
||||
+1
-1
@@ -6,7 +6,7 @@
|
||||
<i class="pi pi-tablet"></i>
|
||||
Kobo Integration Settings
|
||||
<i class="pi pi-external-link external-link-icon"
|
||||
pTooltip="Click to view Kobo setup documentation"
|
||||
pTooltip="View documentation"
|
||||
tooltipPosition="right"
|
||||
(click)="openKoboDocumentation()"
|
||||
style="cursor: pointer;">
|
||||
|
||||
+1
-1
@@ -206,7 +206,7 @@ export class KoboSyncSettingsComponent implements OnInit, OnDestroy {
|
||||
}
|
||||
|
||||
openKoboDocumentation(): void {
|
||||
window.open('https://booklore-app.github.io/booklore-docs/docs/devices/kobo', '_blank');
|
||||
window.open('https://booklore-app.github.io/booklore-docs/docs/integration/kobo', '_blank');
|
||||
}
|
||||
|
||||
ngOnDestroy(): void {
|
||||
|
||||
+1
-1
@@ -6,7 +6,7 @@
|
||||
<i class="pi pi-mobile"></i>
|
||||
KOReader Sync Settings
|
||||
<i class="pi pi-external-link external-link-icon"
|
||||
pTooltip="Click to view KOReader setup documentation"
|
||||
pTooltip="View documentation"
|
||||
tooltipPosition="right"
|
||||
(click)="openKoReaderDocumentation()"
|
||||
style="cursor: pointer;">
|
||||
|
||||
+1
-1
@@ -132,6 +132,6 @@ export class KoreaderSettingsComponent implements OnInit, OnDestroy {
|
||||
}
|
||||
|
||||
openKoReaderDocumentation() {
|
||||
window.open('https://booklore-app.github.io/booklore-docs/docs/devices/koreader', '_blank');
|
||||
window.open('https://booklore-app.github.io/booklore-docs/docs/integration/koreader', '_blank');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<i class="pi pi-envelope"></i>
|
||||
Email Providers
|
||||
<i class="pi pi-external-link external-link-icon"
|
||||
pTooltip="Click to view email setup documentation"
|
||||
pTooltip="View documentation"
|
||||
tooltipPosition="right"
|
||||
(click)="navigateToEmailDocumentation()"
|
||||
style="cursor: pointer;">
|
||||
|
||||
+2
-2
@@ -33,7 +33,7 @@
|
||||
<div class="config-label-row">
|
||||
<label class="config-label">Cookie (Optional, but highly recommended)</label>
|
||||
<i class="pi pi-external-link external-link-icon"
|
||||
pTooltip="Click to view Amazon cookie setup documentation"
|
||||
pTooltip="View documentation"
|
||||
tooltipPosition="right"
|
||||
(click)="navigateToAmazonCookieDocumentation()"
|
||||
style="cursor: pointer;">
|
||||
@@ -89,7 +89,7 @@
|
||||
<div class="config-label-row">
|
||||
<label class="config-label">API Token</label>
|
||||
<i class="pi pi-external-link external-link-icon"
|
||||
pTooltip="Click to view Hardcover API documentation"
|
||||
pTooltip="View documentation"
|
||||
tooltipPosition="right"
|
||||
(click)="navigateToHardcoverTokenDocumentation()"
|
||||
style="cursor: pointer;">
|
||||
|
||||
+6
@@ -3,6 +3,12 @@
|
||||
<h2 class="settings-title">
|
||||
<i class="pi pi-database"></i>
|
||||
Library Metadata Configuration
|
||||
<i class="pi pi-external-link external-link-icon"
|
||||
pTooltip="View documentation"
|
||||
tooltipPosition="right"
|
||||
(click)="navigateMetadataDoc()"
|
||||
style="cursor: pointer;">
|
||||
</i>
|
||||
</h2>
|
||||
<p class="settings-description">
|
||||
Configure metadata fetch behavior for your libraries. Set global defaults and create library-specific overrides to control how book metadata is retrieved from different providers.
|
||||
|
||||
+5
@@ -16,6 +16,11 @@
|
||||
background: var(--p-content-background);
|
||||
}
|
||||
|
||||
.external-link-icon {
|
||||
color: #0ea5e9 !important;
|
||||
font-size: 0.875rem !important;
|
||||
}
|
||||
|
||||
.settings-header {
|
||||
margin-top: 1rem;
|
||||
margin-bottom: 2rem;
|
||||
|
||||
+6
-1
@@ -12,11 +12,12 @@ import {MetadataRefreshOptions} from '../../metadata/model/request/metadata-refr
|
||||
import {MetadataAdvancedFetchOptionsComponent} from '../../metadata/metadata-options-dialog/metadata-advanced-fetch-options/metadata-advanced-fetch-options.component';
|
||||
import {AppSettings, AppSettingKey} from '../../core/model/app-settings.model';
|
||||
import {AppSettingsService} from '../../core/service/app-settings.service';
|
||||
import {Tooltip} from 'primeng/tooltip';
|
||||
|
||||
@Component({
|
||||
selector: 'app-library-metadata-settings-component',
|
||||
standalone: true,
|
||||
imports: [CommonModule, FormsModule, MetadataAdvancedFetchOptionsComponent, AccordionModule],
|
||||
imports: [CommonModule, FormsModule, MetadataAdvancedFetchOptionsComponent, AccordionModule, Tooltip],
|
||||
templateUrl: './library-metadata-settings.component.html',
|
||||
styleUrls: ['./library-metadata-settings.component.scss']
|
||||
})
|
||||
@@ -219,4 +220,8 @@ export class LibraryMetadataSettingsComponent implements OnInit {
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
navigateMetadataDoc(): void {
|
||||
window.open('https://booklore-app.github.io/booklore-docs/docs/metadata/metadata-fetch-configuration', '_blank');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<i class="pi pi-server"></i>
|
||||
OPDS Settings (New)
|
||||
<i class="pi pi-external-link external-link-icon"
|
||||
pTooltip="Click to view OPDS setup documentation"
|
||||
pTooltip="View documentation"
|
||||
tooltipPosition="right"
|
||||
(click)="navigateToOpdsDoc()"
|
||||
style="cursor: pointer;">
|
||||
|
||||
+5
-4
@@ -145,9 +145,7 @@ export class FileMoverComponent implements OnDestroy {
|
||||
|
||||
applyPattern(): void {
|
||||
this.filePreviews = this.books.map(book => {
|
||||
const meta = book.metadata!;
|
||||
const fileName = book.fileName ?? '';
|
||||
const extension = fileName.match(/\.[^.]+$/)?.[0] ?? '';
|
||||
const fileSubPath = book.fileSubPath ? `${book.fileSubPath.replace(/\/+$/g, '')}/` : '';
|
||||
|
||||
const relativeOriginalPath = `${fileSubPath}${fileName}`;
|
||||
@@ -155,7 +153,6 @@ export class FileMoverComponent implements OnDestroy {
|
||||
const currentLibraryId = book.libraryId ?? book.libraryPath?.id ?? (book as any).library?.id ?? null;
|
||||
const currentLibraryName = this.getLibraryNameById(currentLibraryId);
|
||||
|
||||
// Initially set target library to current library
|
||||
const targetLibraryId = currentLibraryId;
|
||||
const targetLibraryName = currentLibraryName;
|
||||
|
||||
@@ -265,8 +262,12 @@ export class FileMoverComponent implements OnDestroy {
|
||||
|
||||
formatYear(dateStr?: string): string {
|
||||
if (!dateStr) return '';
|
||||
const yearMatch = dateStr.match(/^(\d{4})/);
|
||||
if (yearMatch) {
|
||||
return yearMatch[1];
|
||||
}
|
||||
const date = new Date(dateStr);
|
||||
return isNaN(date.getTime()) ? '' : date.getFullYear().toString();
|
||||
return isNaN(date.getTime()) ? '' : date.getUTCFullYear().toString();
|
||||
}
|
||||
|
||||
formatSeriesIndex(seriesNumber?: number): string {
|
||||
|
||||
Reference in New Issue
Block a user