Fix: Add missing kobo progress bar and stats (#1942)

* fix: added missing kobo progress bar from book card

* fix: added kobo progress bar to metadata viewer

* fix: consider kobo progress in stats
This commit is contained in:
Pedro Nave
2025-12-19 18:59:31 -07:00
committed by GitHub
parent 32a1a2ac34
commit bfa08054b5
10 changed files with 142 additions and 78 deletions
@@ -49,25 +49,36 @@
(onChange)="toggleSelection($event)"> (onChange)="toggleSelection($event)">
</p-checkbox> </p-checkbox>
} }
<div class="cover-progress-bar-container">
@if (progressPercentage !== null) { @if (progressPercentage !== null) {
<p-progressBar <p-progressBar
[value]="progressPercentage" [value]="progressPercentage"
[showValue]="false" [showValue]="false"
class="cover-progress-bar" class="cover-progress-bar"
[ngClass]="{ 'progress-complete': progressPercentage === 100, 'progress-incomplete': progressPercentage < 100 }"> [ngClass]="{ 'progress-complete': progressPercentage === 100, 'progress-incomplete': progressPercentage < 100 }">
</p-progressBar> </p-progressBar>
} }
@if (koProgressPercentage !== null) { @if (koProgressPercentage !== null) {
<p-progressBar <p-progressBar
[value]="koProgressPercentage" [value]="koProgressPercentage"
[showValue]="false" [showValue]="false"
[ngClass]="[ class="cover-progress-bar"
progressPercentage == null ? 'cover-progress-bar-ko-only' : 'cover-progress-bar-ko-both', [ngClass]="[
koProgressPercentage === 100 ? 'progress-complete-ko' : 'progress-incomplete-ko' koProgressPercentage === 100 ? 'progress-complete-ko' : 'progress-incomplete-ko'
]"> ]">
</p-progressBar> </p-progressBar>
} }
@if (koboProgressPercentage !== null) {
<p-progressBar
[value]="koboProgressPercentage"
[showValue]="false"
class="cover-progress-bar"
[ngClass]="[
koboProgressPercentage === 100 ? 'progress-complete-kobo' : 'progress-incomplete-kobo'
]">
</p-progressBar>
}
</div>
</div> </div>
<div [hidden]="bottomBarHidden"> <div [hidden]="bottomBarHidden">
@@ -123,10 +123,19 @@
visibility: visible; visibility: visible;
} }
.cover-progress-bar, .cover-progress-bar-container {
.cover-progress-bar-ko-both,
.cover-progress-bar-ko-only {
position: absolute; position: absolute;
bottom: 0;
left: 0;
right: 0;
height: 7.5px;
z-index: 2;
display: flex;
flex-direction: column;
justify-content: flex-end;
}
.cover-progress-bar {
left: 0; left: 0;
right: 0; right: 0;
height: 2.5px; height: 2.5px;
@@ -134,18 +143,6 @@
opacity: 0.9; 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 { .series-number-overlay {
position: absolute; position: absolute;
top: 8px; top: 8px;
@@ -231,7 +228,15 @@
background-color: #8b5cf6; background-color: #8b5cf6;
} }
::ng-deep p-progressbar { ::ng-deep .progress-incomplete-kobo .p-progressbar-value {
background-color: #bf0000;
}
::ng-deep .progress-complete-kobo .p-progressbar-value {
background-color: #f65c9c;
}
::ng-deep .cover-progress-bar {
--p-progressbar-border-radius: 0 !important; --p-progressbar-border-radius: 0 !important;
} }
@@ -110,6 +110,13 @@ export class BookCardComponent implements OnInit, OnChanges, OnDestroy {
return null; return null;
} }
get koboProgressPercentage(): number | null {
if (this.book.koboProgress?.percentage != null) {
return this.book.koboProgress.percentage;
}
return null;
}
get displayTitle(): string | undefined { get displayTitle(): string | undefined {
return (this.isSeriesCollapsed && this.book.metadata?.seriesName) ? this.book.metadata?.seriesName : this.book.metadata?.title; return (this.isSeriesCollapsed && this.book.metadata?.seriesName) ? this.book.metadata?.seriesName : this.book.metadata?.title;
} }
@@ -19,32 +19,46 @@
</div> </div>
} }
@let progress = getProgressPercent(book); <div
@if (progress !== null) { class="cover-progress-bar-container"
<p-progressBar [style.--progress-count]="getProgressCount(book)">
[value]="progress" @let progress = getProgressPercent(book);
[showValue]="false" @if (progress !== null) {
class="cover-progress-bar" <p-progressBar
[ngClass]="{ [value]="progress"
'progress-complete': progress === 100, [showValue]="false"
'progress-incomplete': progress < 100 class="cover-progress-bar"
}" [ngClass]="{
[style]="{ height: '6px' }" 'progress-complete': progress === 100,
></p-progressBar> 'progress-incomplete': progress < 100
} }"
></p-progressBar>
}
@if (getKoProgressPercent(book) !== null) { @if (getKoProgressPercent(book) !== null) {
<p-progressBar <p-progressBar
[value]="getKoProgressPercent(book)" [value]="getKoProgressPercent(book)"
[showValue]="false" [showValue]="false"
[ngClass]="[ class="cover-progress-bar"
getProgressPercent(book) == null ? 'cover-progress-bar-ko-only' : 'cover-progress-bar-ko-both', [ngClass]="[
getKoProgressPercent(book) === 100 ? 'progress-complete-ko' : 'progress-incomplete-ko' getKoProgressPercent(book) === 100 ? 'progress-complete-ko' : 'progress-incomplete-ko'
]" ]"
[style]="{ height: '6px' }" >
> </p-progressBar>
</p-progressBar> }
}
@if (getKoboProgressPercent(book) !== null) {
<p-progressBar
[value]="getKoboProgressPercent(book)"
[showValue]="false"
class="cover-progress-bar"
[ngClass]="[
getKoboProgressPercent(book) === 100 ? 'progress-complete-kobo' : 'progress-incomplete-kobo'
]"
>
</p-progressBar>
}
</div>
</div> </div>
@if (navigationState$ | async) { @if (navigationState$ | async) {
@@ -63,28 +63,28 @@
z-index: 2; z-index: 2;
} }
.cover-progress-bar, .cover-progress-bar-container {
.cover-progress-bar-ko-both,
.cover-progress-bar-ko-only {
position: absolute; position: absolute;
bottom: 0;
left: 0; left: 0;
right: 0; right: 0;
z-index: 2; z-index: 2;
pointer-events: none; border-radius: 9999px;
overflow: hidden;
display: flex;
flex-direction: column;
height: calc(var(--progress-count, 0) * 6px);
} }
.cover-progress-bar { .cover-progress-bar {
bottom: 0; z-index: 2;
pointer-events: none;
height: 6px;
flex-shrink: 0;
} }
.cover-progress-bar-ko-both { ::ng-deep .cover-progress-bar {
bottom: 0; --p-progressbar-border-radius: 0 !important;
height: 12px;
z-index: 3;
}
.cover-progress-bar-ko-only {
bottom: 0;
} }
::ng-deep .progress-incomplete .p-progressbar-value { ::ng-deep .progress-incomplete .p-progressbar-value {
@@ -96,11 +96,19 @@
} }
::ng-deep .progress-incomplete-ko .p-progressbar-value { ::ng-deep .progress-incomplete-ko .p-progressbar-value {
background-color: var(--primary-text-color); background-color: #fbbf24;
} }
::ng-deep .progress-complete-ko .p-progressbar-value { ::ng-deep .progress-complete-ko .p-progressbar-value {
background-color: var(--primary-hover-color); background-color: #8b5cf6;
}
::ng-deep .progress-incomplete-kobo .p-progressbar-value {
background-color: #bf0000;
}
::ng-deep .progress-complete-kobo .p-progressbar-value {
background-color: #f65c9c;
} }
.info-section { .info-section {
@@ -659,6 +659,21 @@ export class MetadataViewerComponent implements OnInit, OnChanges {
return null; return null;
} }
getKoboProgressPercent(book: Book): number | null {
if (book.koboProgress?.percentage != null) {
return book.koboProgress.percentage;
}
return null;
}
getProgressCount(book: Book): number {
let count = 0;
if (this.getProgressPercent(book) !== null) count++;
if (this.getKoProgressPercent(book) !== null) count++;
if (this.getKoboProgressPercent(book) !== null) count++;
return count;
}
getFileExtension(filePath?: string): string | null { getFileExtension(filePath?: string): string | null {
if (!filePath) return null; if (!filePath) return null;
const parts = filePath.split('.'); const parts = filePath.split('.');
@@ -390,7 +390,8 @@ export class ReadingDNAChartService implements OnDestroy {
book.epubProgress?.percentage || 0, book.epubProgress?.percentage || 0,
book.pdfProgress?.percentage || 0, book.pdfProgress?.percentage || 0,
book.cbxProgress?.percentage || 0, book.cbxProgress?.percentage || 0,
book.koreaderProgress?.percentage || 0 book.koreaderProgress?.percentage || 0,
book.koboProgress?.percentage || 0
); );
return progress > 50; return progress > 50;
}); });
@@ -309,7 +309,8 @@ export class ReadingHabitsChartService implements OnDestroy {
book.epubProgress?.percentage || 0, book.epubProgress?.percentage || 0,
book.pdfProgress?.percentage || 0, book.pdfProgress?.percentage || 0,
book.cbxProgress?.percentage || 0, book.cbxProgress?.percentage || 0,
book.koreaderProgress?.percentage || 0 book.koreaderProgress?.percentage || 0,
book.koboProgress?.percentage || 0
); );
return progress > 0 && progress < 100; return progress > 0 && progress < 100;
}); });
@@ -228,6 +228,7 @@ export class ReadingProgressChartService implements OnDestroy {
if (book.epubProgress?.percentage) return book.epubProgress.percentage; if (book.epubProgress?.percentage) return book.epubProgress.percentage;
if (book.cbxProgress?.percentage) return book.cbxProgress.percentage; if (book.cbxProgress?.percentage) return book.cbxProgress.percentage;
if (book.koreaderProgress?.percentage) return book.koreaderProgress.percentage; if (book.koreaderProgress?.percentage) return book.koreaderProgress.percentage;
if (book.koboProgress?.percentage) return book.koboProgress.percentage;
return 0; return 0;
} }
@@ -283,8 +283,9 @@ export class ReadingVelocityChartService implements OnDestroy {
const pdfProgress = book.pdfProgress?.percentage || 0; const pdfProgress = book.pdfProgress?.percentage || 0;
const cbxProgress = book.cbxProgress?.percentage || 0; const cbxProgress = book.cbxProgress?.percentage || 0;
const koreaderProgress = book.koreaderProgress?.percentage || 0; const koreaderProgress = book.koreaderProgress?.percentage || 0;
const koboProgress = book.koboProgress?.percentage || 0;
return Math.max(epubProgress, pdfProgress, cbxProgress, koreaderProgress) / 100; return Math.max(epubProgress, pdfProgress, cbxProgress, koreaderProgress, koboProgress) / 100;
} }
private calculateAverageRating(books: Book[]): number { private calculateAverageRating(books: Book[]): number {