Add koreader sync support for book progress tracking
This commit is contained in:
+14
-4
@@ -1,7 +1,7 @@
|
||||
<div class="book-card"
|
||||
[class.selected]="isSelected"
|
||||
(mouseover)="isHovered = true"
|
||||
(mouseout)="isHovered = false">
|
||||
[class.selected]="isSelected"
|
||||
(mouseover)="isHovered = true"
|
||||
(mouseout)="isHovered = false">
|
||||
|
||||
<div class="cover-container" [ngClass]="{ 'shimmer': !isImageLoaded, 'center-info-btn': readButtonHidden }">
|
||||
<div
|
||||
@@ -16,7 +16,7 @@
|
||||
[class.loaded]="isImageLoaded"
|
||||
alt="Cover of {{ book.metadata?.title }}"
|
||||
loading="lazy"
|
||||
(load)="onImageLoad()" />
|
||||
(load)="onImageLoad()"/>
|
||||
</div>
|
||||
|
||||
@if (book.metadata?.seriesNumber != null) {
|
||||
@@ -52,6 +52,16 @@
|
||||
[ngClass]="{ 'progress-complete': progressPercentage === 100, 'progress-incomplete': progressPercentage < 100 }">
|
||||
</p-progressBar>
|
||||
}
|
||||
@if (koProgressPercentage !== null) {
|
||||
<p-progressBar
|
||||
[value]="koProgressPercentage"
|
||||
[showValue]="false"
|
||||
[ngClass]="[
|
||||
progressPercentage == null ? 'cover-progress-bar-ko-only' : 'cover-progress-bar-ko-both',
|
||||
koProgressPercentage === 100 ? 'progress-complete-ko' : 'progress-incomplete-ko'
|
||||
]">
|
||||
</p-progressBar>
|
||||
}
|
||||
</div>
|
||||
|
||||
<div [hidden]="bottomBarHidden">
|
||||
|
||||
+24
-3
@@ -119,16 +119,29 @@
|
||||
visibility: visible;
|
||||
}
|
||||
|
||||
.cover-progress-bar {
|
||||
.cover-progress-bar,
|
||||
.cover-progress-bar-ko-both,
|
||||
.cover-progress-bar-ko-only {
|
||||
position: absolute;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
height: 5px;
|
||||
height: 2.5px;
|
||||
z-index: 1;
|
||||
opacity: 0.9;
|
||||
}
|
||||
|
||||
.cover-progress-bar {
|
||||
bottom: 2.5px;
|
||||
}
|
||||
|
||||
.cover-progress-bar-ko-both {
|
||||
bottom: 0;
|
||||
}
|
||||
|
||||
.cover-progress-bar-ko-only {
|
||||
bottom: 2.5px;
|
||||
}
|
||||
|
||||
.series-number-overlay {
|
||||
position: absolute;
|
||||
top: 4px;
|
||||
@@ -166,6 +179,14 @@
|
||||
background-color: #22c55e;
|
||||
}
|
||||
|
||||
::ng-deep .progress-incomplete-ko .p-progressbar-value {
|
||||
background-color: #fbbf24;
|
||||
}
|
||||
|
||||
::ng-deep .progress-complete-ko .p-progressbar-value {
|
||||
background-color: #8b5cf6;
|
||||
}
|
||||
|
||||
::ng-deep p-progressbar {
|
||||
--p-progressbar-border-radius: 0 !important;
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ import {ProgressBar} from 'primeng/progressbar';
|
||||
import {BookMetadataCenterComponent} from '../../../../metadata/book-metadata-center-component/book-metadata-center.component';
|
||||
import {takeUntil} from 'rxjs/operators';
|
||||
import {readStatusLabels} from '../book-filter/book-filter.component';
|
||||
import {ResetProgressTypes} from '../../../../shared/constants/reset-progress-type';
|
||||
|
||||
@Component({
|
||||
selector: 'app-book-card',
|
||||
@@ -83,6 +84,16 @@ export class BookCardComponent implements OnInit, OnDestroy {
|
||||
if (this.book.pdfProgress?.percentage != null) {
|
||||
return this.book.pdfProgress.percentage;
|
||||
}
|
||||
if (this.book.cbxProgress?.percentage != null) {
|
||||
return this.book.cbxProgress.percentage;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
get koProgressPercentage(): number | null {
|
||||
if (this.book.koreaderProgress?.percentage != null) {
|
||||
return this.book.koreaderProgress.percentage;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -266,7 +277,7 @@ export class BookCardComponent implements OnInit, OnDestroy {
|
||||
if (this.hasEditMetadataPermission()) {
|
||||
items.push({
|
||||
label: 'More Actions',
|
||||
icon: 'pi pi-ellipsis-v',
|
||||
icon: 'pi pi-ellipsis-h',
|
||||
items: [
|
||||
{
|
||||
label: 'Read Status',
|
||||
@@ -296,15 +307,15 @@ export class BookCardComponent implements OnInit, OnDestroy {
|
||||
}))
|
||||
},
|
||||
{
|
||||
label: 'Reset Progress',
|
||||
label: 'Reset Booklore Progress',
|
||||
icon: 'pi pi-undo',
|
||||
command: () => {
|
||||
this.bookService.resetProgress(this.book.id).subscribe({
|
||||
this.bookService.resetProgress(this.book.id, ResetProgressTypes.BOOKLORE).subscribe({
|
||||
next: () => {
|
||||
this.messageService.add({
|
||||
severity: 'success',
|
||||
summary: 'Progress Reset',
|
||||
detail: 'Reading progress has been reset.',
|
||||
detail: 'Booklore reading progress has been reset.',
|
||||
life: 1500
|
||||
});
|
||||
},
|
||||
@@ -312,7 +323,31 @@ export class BookCardComponent implements OnInit, OnDestroy {
|
||||
this.messageService.add({
|
||||
severity: 'error',
|
||||
summary: 'Failed',
|
||||
detail: 'Could not reset progress.',
|
||||
detail: 'Could not reset Booklore progress.',
|
||||
life: 1500
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
},
|
||||
{
|
||||
label: 'Reset KOReader Progress',
|
||||
icon: 'pi pi-undo',
|
||||
command: () => {
|
||||
this.bookService.resetProgress(this.book.id, ResetProgressTypes.KOREADER).subscribe({
|
||||
next: () => {
|
||||
this.messageService.add({
|
||||
severity: 'success',
|
||||
summary: 'Progress Reset',
|
||||
detail: 'KOReader reading progress has been reset.',
|
||||
life: 1500
|
||||
});
|
||||
},
|
||||
error: () => {
|
||||
this.messageService.add({
|
||||
severity: 'error',
|
||||
summary: 'Failed',
|
||||
detail: 'Could not reset KOReader progress.',
|
||||
life: 1500
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user