}
@for (field of metadataFieldsBottom; track field) {
-
+
diff --git a/booklore-ui/src/app/features/bookdrop/component/bookdrop-file-metadata-picker/bookdrop-file-metadata-picker.component.scss b/booklore-ui/src/app/features/bookdrop/component/bookdrop-file-metadata-picker/bookdrop-file-metadata-picker.component.scss
index 28d489479..da39bddfe 100644
--- a/booklore-ui/src/app/features/bookdrop/component/bookdrop-file-metadata-picker/bookdrop-file-metadata-picker.component.scss
+++ b/booklore-ui/src/app/features/bookdrop/component/bookdrop-file-metadata-picker/bookdrop-file-metadata-picker.component.scss
@@ -1,38 +1,57 @@
.thumbnail {
- width: 10rem;
- height: 14rem;
+ border: 1px solid var(--border-color);
border-radius: 0.5rem;
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
margin: 0 auto 1rem;
+}
+
+::ng-deep .metapicker .thumbnail {
+ img {
+ border-radius: 0.5rem;
+ max-height: 14rem;
+ max-width: 10em;
+ }
@media (max-width: 768px) {
- max-width: 50%;
+ margin-bottom: 0;
}
}
-.metaeditor .thumbnail {
- width: 100%;
+
+.metapicker div.thumbnail {
+ background-color: var(--p-inputtext-disabled-background);
+ color: var(--p-inputtext-disabled-color);
+ width: 9rem;
+ height: 14rem;
+ padding: 1rem;
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+ justify-content: center;
+ text-align: center;
+}
+
+::ng-deep .metaeditor img.thumbnail {
+ border-radius: 0.5rem;
+ max-width: 100%;
+ max-height: 100%;
height: auto;
+ width: auto;
+
+ @media (max-width: 768px) {
+ max-height: 14em;
+ }
}
-.arrow-button {
- padding-left: 1rem;
- padding-right: 1rem;
+.metaeditor .arrow-button {
+ padding: 0;
}
-.green-outlined-button {
- --p-button-outlined-primary-border-color: forestgreen;
- --p-button-outlined-primary-color: forestgreen;
-}
-
-.red-outlined-button {
- --p-button-outlined-primary-border-color: #E32636;
- --p-button-outlined-primary-color: #E32636;
-}
-
-input.outlined-input-green,
-textarea.outlined-input-green,
-::ng-deep p-autocomplete.outlined-input-green ul.p-autocomplete-input-multiple {
- border: 1px solid forestgreen !important;
+.thumbnail.changed,
+input.changed,
+textarea.changed,
+::ng-deep p-datepicker.changed input,
+::ng-deep p-autocomplete.changed ul.p-autocomplete-input-multiple {
+ border: 1px solid var(--p-button-outlined-warn-border-color) !important;
}
::ng-deep .p-inputchips {
@@ -52,14 +71,58 @@ textarea.outlined-input-green,
}
.metapicker label,
-.metaeditor label {
+.metaeditor label,
+.missingmd {
color: var(--text-color-secondary);
}
+::ng-deep .metapicker {
+ .dest, .src {
+ width: calc(50% - 2rem);
+ }
+
+ .arrow-button {
+ margin: auto 1rem;
+ }
+
+ @media (min-width: 768px) {
+ .arrow-button.nosrc button[disabled] {
+ display: none;
+ }
+ }
+
+ input.diff,
+ textarea.diff,
+ .p-autocomplete.diff .p-chip-label {
+ color: var(--p-primary-color) !important;
+ }
+
+ .src .p-chip.p-disabled {
+ color: var(--p-inputtext-disabled-color) !important;
+ opacity: 1;
+ }
+
+ .src .p-chip-remove-icon {
+ display: none;
+ }
+
+ .src li.p-autocomplete-input-chip {
+ width: 1px;
+ }
+}
+
.metaheader {
- border-bottom: 1px solid var(--border-color);
+ border-bottom: 1px dotted var(--border-color);
padding: 1rem;
justify-content: space-between;
+
+ p {
+ text-align: center;
+
+ @media (max-width: 768px) {
+ font-size: 0.875rem;
+ }
+ }
}
.metaheader .midbuttons {
@@ -69,12 +132,42 @@ textarea.outlined-input-green,
.metacontent {
padding: 1rem;
}
+
.metaeditor .metacontent {
padding: 0 0 0 1rem;
@media (max-width: 768px) {
padding: 0;
}
+
+ ::ng-deep button {
+ border-left-width: 0;
+ border-radius: 0 6px 6px 0;
+
+ &:disabled {
+ opacity: 1;
+ border-color: var(--p-inputtext-border-color) !important;
+
+ span {
+ opacity: 0.6;
+ }
+ }
+ }
+
+ ::ng-deep input,
+ ::ng-deep ul,
+ textarea {
+ border-radius: 6px 0 0 6px;
+ }
+
+ .field-authors,
+ .field-categories,
+ .field-moods,
+ .field-tags {
+ ::ng-deep button {
+ line-height: 2em;
+ }
+ }
}
.metadata-status {
@@ -91,55 +184,54 @@ textarea.outlined-input-green,
}
}
+@media (min-width: 768px) {
+ .metaheader,
+ .metapicker .metacontent,
+ .metaeditor .metabody {
+ padding-left: 3.25rem;
+ }
+}
+
.meta-row {
+ display: flex;
+ align-items: center;
margin-bottom: 0.5em;
+
+ label {
+ margin: auto 0;
+ }
+}
+
+.meta-fields {
+ display: flex;
+ align-items: center;
+ width: 100%;
+
+}
+
+.field-description .meta-fields {
+ align-items: stretch;
+
+ .src {
+ resize: none;
+ }
}
@media (max-width: 768px) {
.meta-row {
- margin-bottom: 1em;
- }
-
- .metapicker .meta-row {
flex-wrap: wrap;
-
+ margin-bottom: 1em;
+
label {
width: 100%;
}
}
-
- .metapicker .meta-fields {
- justify-content: center;
-
- .dest {
- width: 50%;
- order: 1;
- margin-right: 0.25rem;
- }
-
- p-button {
- padding: 0;
- order: 3;
- }
-
- ::ng-deep button {
- border-left-width: 0;
- border-radius: 0 6px 6px 0;
- }
-
- .src {
- width: 50%;
- order: 2;
- border-radius: 6px 0 0 6px;
- margin-left: 0.25rem;
-
- ::ng-deep ul {
- border-radius: 6px 0 0 6px;
- }
- }
- }
.metapicker {
+ .field-thumbnail label {
+ display: none;
+ }
+
.field-title,
.field-subtitle,
.field-publisher,
@@ -156,13 +248,31 @@ textarea.outlined-input-green,
}
.dest {
- width: 100% !important;
+ flex: 1 !important;
+ width: auto !important;
margin: 0 0 2px 0;
+
+ &:not(:only-child) {
+ border-radius: 6px 0 0 6px;
+
+ ::ng-deep ul {
+ border-radius: 6px 0 0 6px;
+ }
+ }
+ }
+
+ .arrow-button {
+ margin: 0;
+ padding: 0;
+ }
+
+ ::ng-deep button {
+ border-left-width: 0;
+ border-radius: 0 6px 6px 0;
}
.src {
- flex: 1 !important;
- width: auto !important;
+ width: 100% !important;
margin: 0;
}
}
diff --git a/booklore-ui/src/app/features/bookdrop/component/bookdrop-file-metadata-picker/bookdrop-file-metadata-picker.component.ts b/booklore-ui/src/app/features/bookdrop/component/bookdrop-file-metadata-picker/bookdrop-file-metadata-picker.component.ts
index 3cbd385d5..860460280 100644
--- a/booklore-ui/src/app/features/bookdrop/component/bookdrop-file-metadata-picker/bookdrop-file-metadata-picker.component.ts
+++ b/booklore-ui/src/app/features/bookdrop/component/bookdrop-file-metadata-picker/bookdrop-file-metadata-picker.component.ts
@@ -11,6 +11,7 @@ import {AutoComplete} from 'primeng/autocomplete';
import {Image} from 'primeng/image';
import {LazyLoadImageModule} from 'ng-lazyload-image';
import {ConfirmationService} from 'primeng/api';
+import {DatePicker} from 'primeng/datepicker';
@Component({
selector: 'app-bookdrop-file-metadata-picker-component',
@@ -24,7 +25,8 @@ import {ConfirmationService} from 'primeng/api';
Textarea,
AutoComplete,
Image,
- LazyLoadImageModule
+ LazyLoadImageModule,
+ DatePicker,
],
templateUrl: './bookdrop-file-metadata-picker.component.html',
styleUrl: './bookdrop-file-metadata-picker.component.scss'
@@ -47,6 +49,9 @@ export class BookdropFileMetadataPickerComponent {
{label: 'Title', controlName: 'title', fetchedKey: 'title'},
{label: 'Subtitle', controlName: 'subtitle', fetchedKey: 'subtitle'},
{label: 'Publisher', controlName: 'publisher', fetchedKey: 'publisher'},
+ ];
+
+ metadataPublishDate = [
{label: 'Publish Date', controlName: 'publishedDate', fetchedKey: 'publishedDate'}
];
@@ -113,16 +118,31 @@ export class BookdropFileMetadataPickerComponent {
copyFetchedToCurrent(field: string): void {
const value = this.fetchedMetadata[field];
- if (value && !this.copiedFields[field]) {
+ if (value) {
this.metadataForm.get(field)?.setValue(value);
this.copiedFields[field] = true;
- this.highlightCopiedInput(field);
this.metadataCopied.emit(true);
}
}
- highlightCopiedInput(field: string): void {
- this.copiedFields[field] = true;
+ isValueChanged(field: string): boolean {
+ const [value, original] = this.prepFieldComparison(this.metadataForm.get(field)?.value, this.originalMetadata?.[field]);
+ return (value && value != original) || (!value && original);
+ }
+
+ isFetchedDifferent(field: string): boolean {
+ const [value, fetched] = this.prepFieldComparison(this.metadataForm.get(field)?.value, this.fetchedMetadata[field]);
+ return (fetched && fetched != value);
+ }
+
+ private prepFieldComparison(field1: any, field2: any) {
+ if (Array.isArray(field1)) {
+ field1 = field1.length > 0 ? JSON.stringify(field1.sort()) : undefined;
+ }
+ if (Array.isArray(field2)) {
+ field2 = field2.length > 0 ? JSON.stringify(field2.sort()) : undefined;
+ }
+ return [field1, field2];
}
isValueCopied(field: string): boolean {
@@ -133,22 +153,9 @@ export class BookdropFileMetadataPickerComponent {
return this.savedFields[field];
}
- hoveredFields: { [key: string]: boolean } = {};
-
- onMouseEnter(controlName: string): void {
- if (this.isValueCopied(controlName) && !this.isValueSaved(controlName)) {
- this.hoveredFields[controlName] = true;
- }
- }
-
- onMouseLeave(controlName: string): void {
- this.hoveredFields[controlName] = false;
- }
-
resetField(field: string) {
this.metadataForm.get(field)?.setValue(this.originalMetadata?.[field]);
this.copiedFields[field] = false;
- this.hoveredFields[field] = false;
if (field === 'thumbnailUrl') {
this.metadataForm.get('thumbnailUrl')?.setValue(this.urlHelper.getBookdropCoverUrl(this.bookdropFileId));
}
@@ -216,7 +223,6 @@ export class BookdropFileMetadataPickerComponent {
});
}
this.copiedFields = {};
- this.hoveredFields = {};
this.metadataCopied.emit(false);
}
}
diff --git a/booklore-ui/src/app/features/bookdrop/component/bookdrop-file-review/bookdrop-file-review.component.html b/booklore-ui/src/app/features/bookdrop/component/bookdrop-file-review/bookdrop-file-review.component.html
index 3b9cfe3c2..65d8d54f0 100644
--- a/booklore-ui/src/app/features/bookdrop/component/bookdrop-file-review/bookdrop-file-review.component.html
+++ b/booklore-ui/src/app/features/bookdrop/component/bookdrop-file-review/bookdrop-file-review.component.html
@@ -155,7 +155,7 @@
@for (file of bookdropFileUis; track file) {
-
+
+
+
();
isAutoFetching = false;
@@ -683,6 +684,40 @@ export class MetadataEditorComponent implements OnInit {
});
}
+ generateCustomCover(bookId: number) {
+ this.isGeneratingCover = true;
+ this.bookService.generateCustomCover(bookId)
+ .pipe(finalize(() => this.isGeneratingCover = false))
+ .subscribe({
+ next: () => {
+ this.bookService.getBookByIdFromAPI(bookId, false).subscribe({
+ next: (updatedBook) => {
+ this.bookService.handleBookUpdate(updatedBook);
+ this.messageService.add({
+ severity: "success",
+ summary: "Success",
+ detail: "Custom cover generated successfully.",
+ });
+ },
+ error: () => {
+ this.messageService.add({
+ severity: "warning",
+ summary: "Partial Success",
+ detail: "Cover generated but failed to refresh display. Please refresh the page.",
+ });
+ },
+ });
+ },
+ error: (err) => {
+ this.messageService.add({
+ severity: "error",
+ summary: "Error",
+ detail: "Failed to generate custom cover",
+ });
+ }
+ });
+ }
+
autoFetch(bookId: number) {
this.refreshingBookIds.add(bookId);
this.isAutoFetching = true;
diff --git a/booklore-ui/src/app/features/readers/epub-reader/component/epub-reader.component.html b/booklore-ui/src/app/features/readers/epub-reader/component/epub-reader.component.html
index c6316cacc..536a79cd4 100644
--- a/booklore-ui/src/app/features/readers/epub-reader/component/epub-reader.component.html
+++ b/booklore-ui/src/app/features/readers/epub-reader/component/epub-reader.component.html
@@ -19,101 +19,101 @@
Progress: {{ progressPercentage }}%
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- @for (chapter of chapters; track chapter) {
- -
-
- {{ chapter.label }}
-
- }
-
-
-
-
-
-
- @if (filteredBookmarks.length === 0) {
-
-
-
No bookmarks found
-
{{ filterText ? 'Try a different search term' : 'Tap the bookmark icon to save your place' }}
-
- } @else {
-
- @for (bookmark of filteredBookmarks; track bookmark.id) {
- -
-
- {{ bookmark.title }}
-
-
-
-
+
+
+
+
+
+
+
+
-
- }
-
- }
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+ @for (chapter of chapters; track chapter) {
+ -
+
+ {{ chapter.label }}
+
+ }
+
+
+
+
+
+
+ @if (filteredBookmarks.length === 0) {
+
+
+
No bookmarks found
+
{{ filterText ? 'Try a different search term' : 'Tap the bookmark icon to save your place' }}
+
+ } @else {
+
+ @for (bookmark of filteredBookmarks; track bookmark.id) {
+ -
+
+ {{ bookmark.title }}
+
+
+
+
+
+
+ }
+
+ }
+
+
+
+
+
}
-
-
-
-
+
+
+
+
diff --git a/booklore-ui/src/app/features/readers/epub-reader/component/epub-reader.component.ts b/booklore-ui/src/app/features/readers/epub-reader/component/epub-reader.component.ts
index 4824c34d9..030b7c31e 100644
--- a/booklore-ui/src/app/features/readers/epub-reader/component/epub-reader.component.ts
+++ b/booklore-ui/src/app/features/readers/epub-reader/component/epub-reader.component.ts
@@ -65,6 +65,9 @@ export class EpubReaderComponent implements OnInit, OnDestroy {
private hideHeaderTimeout?: number;
private isMouseInTopRegion = false;
private headerShownByMobileTouch = false;
+ private currentIframe: HTMLIFrameElement | null = null;
+ private iframeTouchHandler: ((event: TouchEvent) => void) | null = null;
+ private iframeClickHandler: ((event: MouseEvent) => void) | null = null;
editingBookmark: BookMark | null = null;
showEditBookmarkDialog = false;
@@ -388,65 +391,183 @@ export class EpubReaderComponent implements OnInit, OnDestroy {
}
private setupTouchListener(): void {
- if (!this.isMobileDevice() || !this.rendition) return;
+ if (!this.isMobileDevice()) return;
+
+ const container = this.epubContainer.nativeElement;
+
+ container.addEventListener('touchend', (event: TouchEvent) => {
+ event.stopPropagation();
+ this.ngZone.run(() => {
+ this.handleTouchEnd(event);
+ });
+ }, { passive: false });
+
+ container.addEventListener('click', (event: MouseEvent) => {
+ event.stopPropagation();
+ this.ngZone.run(() => {
+ this.handleClickAsTap(event);
+ });
+ }, { capture: true });
this.rendition.on('rendered', () => {
const iframe = this.epubContainer.nativeElement.querySelector('iframe');
- if (iframe && iframe.contentDocument) {
- iframe.contentDocument.addEventListener('touchstart', () => {
- this.ngZone.run(() => {
- this.onBookTouch();
- });
- });
+
+ if (iframe && iframe !== this.currentIframe) {
+ if (this.currentIframe && this.currentIframe.contentDocument) {
+ if (this.iframeTouchHandler) {
+ this.currentIframe.contentDocument.removeEventListener('touchend', this.iframeTouchHandler, true);
+ }
+ if (this.iframeClickHandler) {
+ this.currentIframe.contentDocument.removeEventListener('click', this.iframeClickHandler, true);
+ }
+ }
+
+ this.currentIframe = iframe;
+
+ if (iframe.contentDocument) {
+ this.iframeTouchHandler = (event: TouchEvent) => {
+ event.stopPropagation();
+ event.preventDefault();
+ this.ngZone.run(() => {
+ this.handleTouchEnd(event);
+ });
+ };
+
+ this.iframeClickHandler = (event: MouseEvent) => {
+ event.stopPropagation();
+ event.preventDefault();
+ this.ngZone.run(() => {
+ this.handleClickAsTap(event);
+ });
+ };
+
+ iframe.contentDocument.addEventListener('touchend', this.iframeTouchHandler, { passive: false, capture: true });
+ iframe.contentDocument.addEventListener('click', this.iframeClickHandler, { capture: true });
+ }
}
});
}
- public isMobileDevice(): boolean {
- return window.innerWidth <= 768;
- }
+ public handleTouchEnd(event: TouchEvent): void {
+ if (!this.isMobileDevice()) return;
- prevPage(): void {
- if (this.rendition) {
- this.rendition.prev().then(() => {
- const location = this.rendition.currentLocation();
- this.readingSessionService.updateProgress(
- location?.start?.cfi,
- this.progressPercentage
- );
- });
+ const touch = event.changedTouches[0];
+ let touchX = touch.clientX;
+ let touchY = touch.clientY;
+
+ if (event.target && (event.target as HTMLElement).ownerDocument !== document) {
+ const iframe = this.currentIframe;
+ if (iframe) {
+ const iframeRect = iframe.getBoundingClientRect();
+ touchX = touch.clientX + iframeRect.left;
+ touchY = touch.clientY + iframeRect.top;
+ }
+ }
+
+ const screenWidth = window.innerWidth;
+ const screenHeight = window.innerHeight;
+
+ const isTopTouch = touchY < screenHeight * 0.2;
+ const isInTapZoneVertically = touchY >= screenHeight * 0.2;
+
+ if (isTopTouch) {
+ if (!this.showHeader) {
+ this.showHeader = true;
+ this.headerShownByMobileTouch = true;
+ this.clearHeaderTimeout();
+ this.startHeaderAutoHide();
+ } else if (this.headerShownByMobileTouch) {
+ this.showHeader = false;
+ this.headerShownByMobileTouch = false;
+ this.clearHeaderTimeout();
+ }
+ return;
+ }
+
+ if (isInTapZoneVertically) {
+ const leftZoneEnd = screenWidth / 3;
+ const rightZoneStart = screenWidth * (2 / 3);
+
+ if (touchX < leftZoneEnd) {
+ this.prevPage();
+ return;
+ }
+
+ if (touchX > rightZoneStart) {
+ this.nextPage();
+ return;
+ }
+
+ this.showControlsTemporarily();
}
}
- nextPage(): void {
- if (this.rendition) {
- this.rendition.next().then(() => {
- const location = this.rendition.currentLocation();
- this.readingSessionService.updateProgress(
- location?.start?.cfi,
- this.progressPercentage
- );
- });
+ private handleClickAsTap(event: MouseEvent): void {
+ if (!this.isMobileDevice()) return;
+
+ let clickX = event.clientX;
+ let clickY = event.clientY;
+
+ if (event.target && (event.target as HTMLElement).ownerDocument !== document) {
+ const iframe = this.currentIframe;
+ if (iframe) {
+ const iframeRect = iframe.getBoundingClientRect();
+ clickX = event.clientX + iframeRect.left;
+ clickY = event.clientY + iframeRect.top;
+ }
+ }
+
+ const screenWidth = window.innerWidth;
+ const screenHeight = window.innerHeight;
+
+ const isTopClick = clickY < screenHeight * 0.2;
+ const isInTapZoneVertically = clickY >= screenHeight * 0.2;
+
+ if (isTopClick) {
+ if (!this.showHeader) {
+ this.showHeader = true;
+ this.headerShownByMobileTouch = true;
+ this.clearHeaderTimeout();
+ this.startHeaderAutoHide();
+ } else if (this.headerShownByMobileTouch) {
+ this.showHeader = false;
+ this.headerShownByMobileTouch = false;
+ this.clearHeaderTimeout();
+ }
+ return;
+ }
+
+ if (isInTapZoneVertically) {
+ const leftZoneEnd = screenWidth / 3;
+ const rightZoneStart = screenWidth * (2 / 3);
+
+ if (clickX < leftZoneEnd) {
+ this.prevPage();
+ return;
+ }
+
+ if (clickX > rightZoneStart) {
+ this.nextPage();
+ return;
+ }
+
+ this.showControlsTemporarily();
}
}
- navigateToChapter(chapter: { label: string; href: string; level: number }): void {
- if (this.book && chapter.href) {
- this.book.rendition.display(chapter.href).then(() => {
- const location = this.rendition.currentLocation();
- this.readingSessionService.updateProgress(
- location?.start?.cfi,
- this.progressPercentage
- );
- });
+ closeReader(): void {
+ if (this.readingSessionService.isSessionActive()) {
+ this.readingSessionService.endSession(
+ this.currentCfi || undefined,
+ this.progressPercentage
+ );
}
+ this.location.back();
}
toggleDrawer(): void {
this.isDrawerVisible = !this.isDrawerVisible;
if (this.isDrawerVisible) {
- this.showHeader = true;
- this.headerShownByMobileTouch = false;
this.clearHeaderTimeout();
} else {
this.startHeaderAutoHide();
@@ -456,14 +577,40 @@ export class EpubReaderComponent implements OnInit, OnDestroy {
toggleSettingsDrawer(): void {
this.isSettingsDrawerVisible = !this.isSettingsDrawerVisible;
if (this.isSettingsDrawerVisible) {
- this.showHeader = true;
- this.headerShownByMobileTouch = false;
this.clearHeaderTimeout();
} else {
this.startHeaderAutoHide();
}
}
+ navigateToChapter(chapter: { label: string; href: string; level: number }): void {
+ if (this.rendition) {
+ this.rendition.display(chapter.href).then(() => {
+ const location = this.rendition.currentLocation();
+ this.readingSessionService.updateProgress(
+ location?.start?.cfi,
+ this.progressPercentage
+ );
+ });
+ }
+ }
+
+ prevPage(): void {
+ if (this.rendition) {
+ this.rendition.prev();
+ }
+ }
+
+ nextPage(): void {
+ if (this.rendition) {
+ this.rendition.next();
+ }
+ }
+
+ isMobileDevice(): boolean {
+ return window.innerWidth <= 768;
+ }
+
private trackProgress(): void {
if (!this.book || !this.rendition) return;
this.rendition.on('relocated', (location: any) => {
@@ -528,6 +675,15 @@ export class EpubReaderComponent implements OnInit, OnDestroy {
this.routeSubscription?.unsubscribe();
+ if (this.currentIframe && this.currentIframe.contentDocument) {
+ if (this.iframeTouchHandler) {
+ this.currentIframe.contentDocument.removeEventListener('touchend', this.iframeTouchHandler, true);
+ }
+ if (this.iframeClickHandler) {
+ this.currentIframe.contentDocument.removeEventListener('click', this.iframeClickHandler, true);
+ }
+ }
+
if (this.rendition) {
this.rendition.off('keyup', this.keyListener);
}
@@ -550,23 +706,14 @@ export class EpubReaderComponent implements OnInit, OnDestroy {
}
onBookClick(event: MouseEvent): void {
+
+ const clickX = event.clientX;
const clickY = event.clientY;
+ const screenWidth = window.innerWidth;
const screenHeight = window.innerHeight;
if (this.isMobileDevice()) {
- const isTopClick = clickY < screenHeight * 0.2;
- const isBottomClick = clickY > screenHeight * 0.2;
-
- if (isTopClick && !this.showHeader) {
- this.showHeader = true;
- this.headerShownByMobileTouch = true;
- this.clearHeaderTimeout();
- this.startHeaderAutoHide();
- } else if (isBottomClick && this.showHeader && this.headerShownByMobileTouch) {
- this.showHeader = false;
- this.headerShownByMobileTouch = false;
- this.clearHeaderTimeout();
- }
+ this.handleClickAsTap(event);
} else {
const isTopClick = clickY < screenHeight * 0.1;
if (isTopClick) {
@@ -615,28 +762,36 @@ export class EpubReaderComponent implements OnInit, OnDestroy {
}
}
- onBookTouch(): void {
+ onBookTouch(event?: TouchEvent): void {
if (this.isMobileDevice()) {
- this.showControls = true;
- this.showHeader = true;
- this.headerShownByMobileTouch = false;
- this.clearHeaderTimeout();
-
- if (this.hideControlsTimeout) {
- window.clearTimeout(this.hideControlsTimeout);
+ if (event) {
+ this.handleTouchEnd(event);
+ } else {
+ this.showControlsTemporarily();
}
-
- this.hideControlsTimeout = window.setTimeout(() => {
- this.ngZone.run(() => {
- this.showControls = false;
- if (!this.isDrawerVisible && !this.isSettingsDrawerVisible) {
- this.showHeader = false;
- }
- });
- }, 2000);
}
}
+ private showControlsTemporarily(): void {
+ this.showControls = true;
+ this.showHeader = true;
+ this.headerShownByMobileTouch = false;
+ this.clearHeaderTimeout();
+
+ if (this.hideControlsTimeout) {
+ window.clearTimeout(this.hideControlsTimeout);
+ }
+
+ this.hideControlsTimeout = window.setTimeout(() => {
+ this.ngZone.run(() => {
+ this.showControls = false;
+ if (!this.isDrawerVisible && !this.isSettingsDrawerVisible) {
+ this.showHeader = false;
+ }
+ });
+ }, 2000);
+ }
+
startHeaderAutoHide(): void {
this.clearHeaderTimeout();
@@ -834,14 +989,4 @@ export class EpubReaderComponent implements OnInit, OnDestroy {
this.showEditBookmarkDialog = false;
this.editingBookmark = null;
}
-
- closeReader(): void {
- if (this.readingSessionService.isSessionActive()) {
- this.readingSessionService.endSession(
- this.currentCfi || undefined,
- this.progressPercentage
- );
- }
- this.location.back();
- }
}
diff --git a/booklore-ui/src/app/features/settings/user-management/create-user-dialog/create-user-dialog.component.html b/booklore-ui/src/app/features/settings/user-management/create-user-dialog/create-user-dialog.component.html
index 6f6cbdabd..d9c6dc02b 100644
--- a/booklore-ui/src/app/features/settings/user-management/create-user-dialog/create-user-dialog.component.html
+++ b/booklore-ui/src/app/features/settings/user-management/create-user-dialog/create-user-dialog.component.html
@@ -327,6 +327,105 @@
+
+
+
+ Metadata Editing
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Bulk Reset
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/booklore-ui/src/app/features/settings/user-management/create-user-dialog/create-user-dialog.component.ts b/booklore-ui/src/app/features/settings/user-management/create-user-dialog/create-user-dialog.component.ts
index 2bc581cec..160db6b75 100644
--- a/booklore-ui/src/app/features/settings/user-management/create-user-dialog/create-user-dialog.component.ts
+++ b/booklore-ui/src/app/features/settings/user-management/create-user-dialog/create-user-dialog.component.ts
@@ -62,6 +62,15 @@ export class CreateUserDialogComponent implements OnInit {
permissionManageGlobalPreferences: [false],
permissionManageIcons: [false],
permissionAdmin: [false],
+ permissionBulkAutoFetchMetadata: [false],
+ permissionBulkCustomFetchMetadata: [false],
+ permissionBulkEditMetadata: [false],
+ permissionBulkRegenerateCover: [false],
+ permissionMoveOrganizeFiles: [false],
+ permissionBulkLockUnlockMetadata: [false],
+ permissionBulkResetBookloreReadProgress: [false],
+ permissionBulkResetKoReaderReadProgress: [false],
+ permissionBulkResetBookReadStatus: [false],
});
}
diff --git a/booklore-ui/src/app/features/settings/user-management/user-management.component.html b/booklore-ui/src/app/features/settings/user-management/user-management.component.html
index bb1d35e2f..29eb5e377 100644
--- a/booklore-ui/src/app/features/settings/user-management/user-management.component.html
+++ b/booklore-ui/src/app/features/settings/user-management/user-management.component.html
@@ -61,15 +61,21 @@
|
|
-
-
- |
|
|
+
+
+ |
+
+
+ |
+
+
+ |
|
-
+
- {{ getBookManagementPermissionsCount(user) }}/6
-
-
- |
-
-
-
- {{ getDeviceSyncPermissionsCount(user) }}/3
+ {{ getBookManagementPermissionsCount(user) }}/5
|
@@ -158,6 +157,27 @@
+
+
+
+ {{ getMetadataEditingPermissionsCount(user) }}/7
+
+
+ |
+
+
+
+ {{ getDeviceSyncPermissionsCount(user) }}/3
+
+
+ |
+
+
+
+ {{ getBulkResetPermissionsCount(user) }}/3
+
+
+ |
@if (!user.isEditing) {
@@ -185,6 +205,7 @@
icon="pi pi-times"
severity="danger"
[rounded]="true"
+ text
(onClick)="toggleEdit(user)"
tooltipPosition="top"
pTooltip="Cancel">
@@ -216,7 +237,7 @@
@if (isRowExpanded(user)) {
- |
+ |
@@ -264,10 +285,6 @@
-
@@ -279,24 +296,6 @@
-
-
System Access
@@ -337,6 +336,76 @@
+
+ Metadata Editing
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Bulk Reset
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Administration
diff --git a/booklore-ui/src/app/features/settings/user-management/user-management.component.scss b/booklore-ui/src/app/features/settings/user-management/user-management.component.scss
index 7ae72e25e..adaf0549e 100644
--- a/booklore-ui/src/app/features/settings/user-management/user-management.component.scss
+++ b/booklore-ui/src/app/features/settings/user-management/user-management.component.scss
@@ -246,61 +246,57 @@
&[data-count="0"] {
background: color-mix(in srgb, #6b7280 20%, var(--card-background));
border-color: #6b7280;
-
- .permission-count {
- color: #6b7280;
- }
+ .permission-count { color: #6b7280; }
}
- &[data-total="6"][data-count="1"],
- &[data-total="6"][data-count="2"],
+ &[data-total="5"][data-count="1"],
+ &[data-total="5"][data-count="2"],
+ &[data-total="7"][data-count="1"],
+ &[data-total="7"][data-count="2"],
&[data-total="3"][data-count="1"],
- &[data-total="2"][data-count="1"],
&[data-total="4"][data-count="1"] {
background: color-mix(in srgb, #ef4444 20%, var(--card-background));
border-color: #ef4444;
-
- .permission-count {
- color: #ef4444;
- font-weight: 700;
- }
+ .permission-count { color: #ef4444; font-weight: 700; }
}
- &[data-total="6"][data-count="3"],
- &[data-total="6"][data-count="4"],
+ &[data-total="5"][data-count="3"],
+ &[data-total="7"][data-count="3"],
+ &[data-total="7"][data-count="4"],
+ &[data-total="7"][data-count="5"],
&[data-total="3"][data-count="2"],
- &[data-total="4"][data-count="2"] {
+ &[data-total="4"][data-count="2"],
+ &[data-total="4"][data-count="3"] {
background: color-mix(in srgb, #f59e0b 20%, var(--card-background));
border-color: #f59e0b;
-
- .permission-count {
- color: #f59e0b;
- font-weight: 700;
- }
+ .permission-count { color: #f59e0b; font-weight: 700; }
}
- &[data-total="6"][data-count="5"],
- &[data-total="4"][data-count="3"] {
- background: color-mix(in srgb, #3b82f6 20%, var(--card-background));
- border-color: #3b82f6;
-
- .permission-count {
- color: #3b82f6;
- font-weight: 700;
- }
- }
-
- &[data-total="6"][data-count="6"],
+ &[data-total="5"][data-count="4"],
+ &[data-total="5"][data-count="5"],
+ &[data-total="7"][data-count="6"],
+ &[data-total="7"][data-count="7"],
&[data-total="3"][data-count="3"],
- &[data-total="2"][data-count="2"],
&[data-total="4"][data-count="4"] {
background: color-mix(in srgb, #10b981 20%, var(--card-background));
border-color: #10b981;
+ .permission-count { color: #10b981; font-weight: 700; }
+ }
- .permission-count {
- color: #10b981;
- font-weight: 700;
- }
+ &[data-total="3"][data-count="1"] {
+ background: color-mix(in srgb, #ef4444 20%, var(--card-background));
+ border-color: #ef4444;
+ .permission-count { color: #ef4444; font-weight: 700; }
+ }
+ &[data-total="3"][data-count="2"] {
+ background: color-mix(in srgb, #f59e0b 20%, var(--card-background));
+ border-color: #f59e0b;
+ .permission-count { color: #f59e0b; font-weight: 700; }
+ }
+ &[data-total="3"][data-count="3"] {
+ background: color-mix(in srgb, #10b981 20%, var(--card-background));
+ border-color: #10b981;
+ .permission-count { color: #10b981; font-weight: 700; }
}
}
diff --git a/booklore-ui/src/app/features/settings/user-management/user-management.component.ts b/booklore-ui/src/app/features/settings/user-management/user-management.component.ts
index 69534bc7c..8fbc28c0f 100644
--- a/booklore-ui/src/app/features/settings/user-management/user-management.component.ts
+++ b/booklore-ui/src/app/features/settings/user-management/user-management.component.ts
@@ -224,7 +224,6 @@ export class UserManagementComponent implements OnInit, OnDestroy {
if (permissions.canUpload) count++;
if (permissions.canDownload) count++;
if (permissions.canDeleteBook) count++;
- if (permissions.canEditMetadata) count++;
if (permissions.canManageLibrary) count++;
if (permissions.canEmailBook) count++;
return count;
@@ -258,6 +257,28 @@ export class UserManagementComponent implements OnInit, OnDestroy {
return count;
}
+ getMetadataEditingPermissionsCount(user: User): number {
+ const permissions = user.permissions;
+ let count = 0;
+ if (permissions.canEditMetadata) count++;
+ if (permissions.canBulkAutoFetchMetadata) count++;
+ if (permissions.canBulkCustomFetchMetadata) count++;
+ if (permissions.canBulkEditMetadata) count++;
+ if (permissions.canBulkRegenerateCover) count++;
+ if (permissions.canMoveOrganizeFiles) count++;
+ if (permissions.canBulkLockUnlockMetadata) count++;
+ return count;
+ }
+
+ getBulkResetPermissionsCount(user: User): number {
+ const permissions = user.permissions;
+ let count = 0;
+ if (permissions.canBulkResetBookloreReadProgress) count++;
+ if (permissions.canBulkResetKoReaderReadProgress) count++;
+ if (permissions.canBulkResetBookReadStatus) count++;
+ return count;
+ }
+
toggleRowExpansion(user: User) {
if (this.expandedRows[user.id]) {
delete this.expandedRows[user.id];
@@ -289,6 +310,15 @@ export class UserManagementComponent implements OnInit, OnDestroy {
user.permissions.canAccessTaskManager = true;
user.permissions.canManageEmailConfig = true;
user.permissions.canManageIcons = true;
+ user.permissions.canBulkAutoFetchMetadata = true;
+ user.permissions.canBulkCustomFetchMetadata = true;
+ user.permissions.canBulkEditMetadata = true;
+ user.permissions.canBulkRegenerateCover = true;
+ user.permissions.canMoveOrganizeFiles = true;
+ user.permissions.canBulkLockUnlockMetadata = true;
+ user.permissions.canBulkResetBookloreReadProgress = true;
+ user.permissions.canBulkResetKoReaderReadProgress = true;
+ user.permissions.canBulkResetBookReadStatus = true;
}
}
diff --git a/booklore-ui/src/app/features/settings/user-management/user-stats.service.ts b/booklore-ui/src/app/features/settings/user-management/user-stats.service.ts
index e7abf734f..08f35bc34 100644
--- a/booklore-ui/src/app/features/settings/user-management/user-stats.service.ts
+++ b/booklore-ui/src/app/features/settings/user-management/user-stats.service.ts
@@ -59,14 +59,14 @@ export class UserStatsService {
getHeatmapForYear(year: number): Observable {
return this.http.get(
`${this.readingSessionsUrl}/heatmap`,
- { params: { year: year.toString() } }
+ {params: {year: year.toString()}}
);
}
- getTimelineForWeek(year: number, month: number, week: number): Observable {
+ getTimelineForWeek(year: number, week: number): Observable {
return this.http.get(
`${this.readingSessionsUrl}/timeline`,
- { params: { year: year.toString(), month: month.toString(), week: week.toString() } }
+ {params: {year: year.toString(), week: week.toString()}}
);
}
@@ -79,7 +79,7 @@ export class UserStatsService {
getCompletionTimelineForYear(year: number): Observable {
return this.http.get(
`${this.readingSessionsUrl}/completion-timeline`,
- { params: { year: year.toString() } }
+ {params: {year: year.toString()}}
);
}
diff --git a/booklore-ui/src/app/features/settings/user-management/user.service.ts b/booklore-ui/src/app/features/settings/user-management/user.service.ts
index 2be4b81e0..f10828472 100644
--- a/booklore-ui/src/app/features/settings/user-management/user.service.ts
+++ b/booklore-ui/src/app/features/settings/user-management/user.service.ts
@@ -21,7 +21,7 @@ export interface EntityViewPreference {
}
export interface EntityViewPreferenceOverride {
- entityType: 'LIBRARY' | 'SHELF';
+ entityType: 'LIBRARY' | 'SHELF' | 'MAGIC_SHELF';
entityId: number;
preferences: EntityViewPreference;
}
@@ -171,6 +171,15 @@ export interface User {
canManageGlobalPreferences: boolean;
canManageIcons: boolean;
demoUser: boolean;
+ canBulkAutoFetchMetadata: boolean;
+ canBulkCustomFetchMetadata: boolean;
+ canBulkEditMetadata: boolean;
+ canBulkRegenerateCover: boolean;
+ canMoveOrganizeFiles: boolean;
+ canBulkLockUnlockMetadata: boolean;
+ canBulkResetBookloreReadProgress?: boolean;
+ canBulkResetKoReaderReadProgress?: boolean;
+ canBulkResetBookReadStatus?: boolean;
};
userSettings: UserSettings;
provisioningMethod?: 'LOCAL' | 'OIDC' | 'REMOTE';
diff --git a/booklore-ui/src/app/features/settings/view-preferences-parent/view-preferences/view-preferences.component.ts b/booklore-ui/src/app/features/settings/view-preferences-parent/view-preferences/view-preferences.component.ts
index 043494672..bc319c552 100644
--- a/booklore-ui/src/app/features/settings/view-preferences-parent/view-preferences/view-preferences.component.ts
+++ b/booklore-ui/src/app/features/settings/view-preferences-parent/view-preferences/view-preferences.component.ts
@@ -7,6 +7,7 @@ import {TableModule} from 'primeng/table';
import {User, UserService} from '../../user-management/user.service';
import {LibraryService} from '../../../book/service/library.service';
import {ShelfService} from '../../../book/service/shelf.service';
+import {MagicShelfService} from '../../../magic-shelf/service/magic-shelf.service';
import {combineLatest, Subject} from 'rxjs';
import {FormsModule} from '@angular/forms';
import {ToastModule} from 'primeng/toast';
@@ -52,7 +53,8 @@ export class ViewPreferencesComponent implements OnInit, OnDestroy {
entityTypeOptions = [
{label: 'Library', value: 'LIBRARY'},
- {label: 'Shelf', value: 'SHELF'}
+ {label: 'Shelf', value: 'SHELF'},
+ {label: 'Magic Shelf', value: 'MAGIC_SHELF'}
];
sortDirectionOptions = [
@@ -67,13 +69,14 @@ export class ViewPreferencesComponent implements OnInit, OnDestroy {
libraryOptions: { label: string; value: number }[] = [];
shelfOptions: { label: string; value: number }[] = [];
+ magicShelfOptions: { label: string; value: number }[] = [];
selectedSort: string = 'title';
selectedSortDir: 'ASC' | 'DESC' = 'ASC';
selectedView: 'GRID' | 'TABLE' = 'GRID';
overrides: {
- entityType: 'LIBRARY' | 'SHELF';
+ entityType: 'LIBRARY' | 'SHELF' | 'MAGIC_SHELF';
library: number;
sort: string;
sortDir: 'ASC' | 'DESC';
@@ -85,6 +88,7 @@ export class ViewPreferencesComponent implements OnInit, OnDestroy {
private libraryService = inject(LibraryService);
private shelfService = inject(ShelfService);
+ private magicShelfService = inject(MagicShelfService);
private userService = inject(UserService);
private messageService = inject(MessageService);
@@ -93,9 +97,10 @@ export class ViewPreferencesComponent implements OnInit, OnDestroy {
this.userService.userState$.pipe(filter(userState => !!userState?.user && userState.loaded), take(1)),
this.libraryService.libraryState$.pipe(filter(libraryState => !!libraryState?.libraries && libraryState.loaded), take(1)),
this.shelfService.shelfState$.pipe(filter(shelfState => !!shelfState?.shelves && shelfState.loaded), take(1)),
+ this.magicShelfService.shelvesState$.pipe(filter(magicState => !!magicState?.shelves && magicState.loaded), take(1))
]).pipe(
takeUntil(this.destroy$)
- ).subscribe(([userState, librariesState, shelfState]) => {
+ ).subscribe(([userState, librariesState, shelfState, magicState]) => {
this.user = userState.user;
const prefs = userState.user?.userSettings?.entityViewPreferences;
@@ -121,6 +126,11 @@ export class ViewPreferencesComponent implements OnInit, OnDestroy {
label: s.name,
value: s.id!
}));
+
+ this.magicShelfOptions = (magicState?.shelves ?? []).filter(s => s.id !== undefined).map(s => ({
+ label: s.name,
+ value: s.id!
+ }));
});
}
@@ -129,19 +139,34 @@ export class ViewPreferencesComponent implements OnInit, OnDestroy {
this.destroy$.complete();
}
- getAvailableEntities(index: number, type: 'LIBRARY' | 'SHELF') {
+ getAvailableEntities(index: number, type: 'LIBRARY' | 'SHELF' | 'MAGIC_SHELF') {
const selected = this.overrides.map((o, i) => i !== index ? o.library : null);
- const source = type === 'LIBRARY' ? this.libraryOptions : this.shelfOptions;
+ let source: { label: string; value: number }[];
+ switch (type) {
+ case 'LIBRARY':
+ source = this.libraryOptions;
+ break;
+ case 'SHELF':
+ source = this.shelfOptions;
+ break;
+ case 'MAGIC_SHELF':
+ source = this.magicShelfOptions;
+ break;
+ default:
+ source = [];
+ }
return source.filter(opt => !selected.includes(opt.value) || this.overrides[index]?.library === opt.value);
}
get availableLibraries() {
const used = new Set(this.overrides.map(o => `${o.entityType}_${o.library}`));
- const withEntityType = (options: { label: string; value: number }[], entityType: 'LIBRARY' | 'SHELF') =>
+ const withEntityType = (options: { label: string; value: number }[], entityType: 'LIBRARY' | 'SHELF' | 'MAGIC_SHELF') =>
options.map(opt => ({...opt, entityType}));
- return [...withEntityType(this.libraryOptions, 'LIBRARY'), ...withEntityType(this.shelfOptions, 'SHELF')]
+ return [...withEntityType(this.libraryOptions, 'LIBRARY'),
+ ...withEntityType(this.shelfOptions, 'SHELF'),
+ ...withEntityType(this.magicShelfOptions, 'MAGIC_SHELF')]
.filter(opt => !used.has(`${opt.entityType}_${opt.value}`));
}
diff --git a/booklore-ui/src/app/features/stats/component/favorite-days-chart/favorite-days-chart.component.ts b/booklore-ui/src/app/features/stats/component/favorite-days-chart/favorite-days-chart.component.ts
index d105918ba..bd3638994 100644
--- a/booklore-ui/src/app/features/stats/component/favorite-days-chart/favorite-days-chart.component.ts
+++ b/booklore-ui/src/app/features/stats/component/favorite-days-chart/favorite-days-chart.component.ts
@@ -1,4 +1,4 @@
-import {Component, inject, Input, OnDestroy, OnInit} from '@angular/core';
+import {Component, inject, OnDestroy, OnInit} from '@angular/core';
import {CommonModule} from '@angular/common';
import {BaseChartDirective} from 'ng2-charts';
import {ChartConfiguration, ChartData} from 'chart.js';
@@ -32,19 +32,19 @@ export class FavoriteDaysChartComponent implements OnInit, OnDestroy {
public selectedMonth: number | null = null;
public yearOptions: { label: string; value: number | null }[] = [];
public monthOptions: { label: string; value: number | null }[] = [
- { label: 'All Months', value: null },
- { label: 'January', value: 1 },
- { label: 'February', value: 2 },
- { label: 'March', value: 3 },
- { label: 'April', value: 4 },
- { label: 'May', value: 5 },
- { label: 'June', value: 6 },
- { label: 'July', value: 7 },
- { label: 'August', value: 8 },
- { label: 'September', value: 9 },
- { label: 'October', value: 10 },
- { label: 'November', value: 11 },
- { label: 'December', value: 12 }
+ {label: 'All Months', value: null},
+ {label: 'January', value: 1},
+ {label: 'February', value: 2},
+ {label: 'March', value: 3},
+ {label: 'April', value: 4},
+ {label: 'May', value: 5},
+ {label: 'June', value: 6},
+ {label: 'July', value: 7},
+ {label: 'August', value: 8},
+ {label: 'September', value: 9},
+ {label: 'October', value: 10},
+ {label: 'November', value: 11},
+ {label: 'December', value: 12}
];
constructor() {
@@ -161,7 +161,7 @@ export class FavoriteDaysChartComponent implements OnInit, OnDestroy {
ticks: {
color: '#ffffff',
font: {family: "'Inter', sans-serif", size: 11},
- callback: function(value) {
+ callback: function (value) {
return (typeof value === 'number' ? value.toFixed(1) : '0.0') + 'h';
}
},
@@ -186,9 +186,9 @@ export class FavoriteDaysChartComponent implements OnInit, OnDestroy {
private initializeYearOptions(): void {
const currentYear = new Date().getFullYear();
- this.yearOptions = [{ label: 'All Years', value: null }];
+ this.yearOptions = [{label: 'All Years', value: null}];
for (let year = currentYear; year >= currentYear - 10; year--) {
- this.yearOptions.push({ label: year.toString(), value: year });
+ this.yearOptions.push({label: year.toString(), value: year});
}
}
@@ -216,7 +216,7 @@ export class FavoriteDaysChartComponent implements OnInit, OnDestroy {
private updateChartData(favoriteDays: FavoriteDaysResponse[]): void {
const dayMap = new Map();
favoriteDays.forEach(item => {
- dayMap.set(item.dayOfWeek, item);
+ dayMap.set(item.dayOfWeek - 1, item);
});
const labels = this.allDays;
diff --git a/booklore-ui/src/app/features/stats/component/reading-heatmap-chart/reading-heatmap-chart.component.ts b/booklore-ui/src/app/features/stats/component/reading-heatmap-chart/reading-heatmap-chart.component.ts
index 41b483c82..54e05cec1 100644
--- a/booklore-ui/src/app/features/stats/component/reading-heatmap-chart/reading-heatmap-chart.component.ts
+++ b/booklore-ui/src/app/features/stats/component/reading-heatmap-chart/reading-heatmap-chart.component.ts
@@ -44,7 +44,7 @@ export class ReadingHeatmapChartComponent implements OnInit, OnDestroy {
maintainAspectRatio: false,
layout: {
padding: {
- top: 30
+ top: 20
}
},
plugins: {
@@ -102,6 +102,7 @@ export class ReadingHeatmapChartComponent implements OnInit, OnDestroy {
},
y: {
type: 'linear',
+ offset: true,
ticks: {
stepSize: 1,
callback: (value) => this.yearLabels[value as number] || '',
@@ -150,7 +151,6 @@ export class ReadingHeatmapChartComponent implements OnInit, OnDestroy {
private updateChartData(yearMonthData: YearMonthData[]): void {
const currentYear = new Date().getFullYear();
- const currentMonth = new Date().getMonth();
const years = Array.from({length: 10}, (_, i) => currentYear - 9 + i);
this.yearLabels = years.map(String);
@@ -159,9 +159,7 @@ export class ReadingHeatmapChartComponent implements OnInit, OnDestroy {
const heatmapData: MatrixDataPoint[] = [];
years.forEach((year, yearIndex) => {
- const maxMonth = year === currentYear ? currentMonth : 11;
-
- for (let month = 0; month <= maxMonth; month++) {
+ for (let month = 0; month <= 11; month++) {
const dataPoint = yearMonthData.find(d => d.year === year && d.month === month + 1);
heatmapData.push({
x: month,
@@ -172,7 +170,7 @@ export class ReadingHeatmapChartComponent implements OnInit, OnDestroy {
});
if (this.chartOptions?.scales?.['y']) {
- (this.chartOptions.scales['y'] as any).max = years.length - 0.5;
+ (this.chartOptions.scales['y'] as any).max = years.length - 1;
}
this.chartDataSubject.next({
diff --git a/booklore-ui/src/app/features/stats/component/reading-session-timeline/reading-session-timeline.component.ts b/booklore-ui/src/app/features/stats/component/reading-session-timeline/reading-session-timeline.component.ts
index 863247940..117b2a081 100644
--- a/booklore-ui/src/app/features/stats/component/reading-session-timeline/reading-session-timeline.component.ts
+++ b/booklore-ui/src/app/features/stats/component/reading-session-timeline/reading-session-timeline.component.ts
@@ -7,6 +7,16 @@ import {catchError} from 'rxjs/operators';
import {of} from 'rxjs';
import {Select} from 'primeng/select';
import {FormsModule} from '@angular/forms';
+import {
+ addWeeks,
+ endOfISOWeek,
+ getISOWeek,
+ getISOWeeksInYear,
+ getISOWeekYear,
+ setISOWeek,
+ setISOWeekYear,
+ startOfISOWeek
+} from 'date-fns';
interface ReadingSession {
startTime: Date;
@@ -47,7 +57,7 @@ interface DayTimeline {
})
export class ReadingSessionTimelineComponent implements OnInit {
@Input() initialYear: number = new Date().getFullYear();
- @Input() weekNumber: number = this.getCurrentWeekNumber();
+ @Input() weekNumber: number = getISOWeek(new Date());
private userStatsService = inject(UserStatsService);
private urlHelperService = inject(UrlHelperService);
@@ -56,8 +66,8 @@ export class ReadingSessionTimelineComponent implements OnInit {
public hourLabels: string[] = [];
public timelineData: DayTimeline[] = [];
public currentYear: number = new Date().getFullYear();
- public currentWeek: number = this.getCurrentWeekNumber();
- public currentMonth: number = new Date().getMonth() + 1;
+ public currentWeek: number = getISOWeek(new Date());
+ private currentDate: Date = new Date();
public yearOptions: { label: string; value: number }[] = [];
public weekOptions: { label: string; value: number }[] = [];
@@ -65,8 +75,9 @@ export class ReadingSessionTimelineComponent implements OnInit {
ngOnInit(): void {
this.currentYear = this.initialYear;
this.currentWeek = this.weekNumber;
- this.updateCurrentMonth();
+ this.updateDateFromYearAndWeek();
this.initializeYearOptions();
+ this.ensureYearInOptions();
this.updateWeekOptions();
this.initializeHourLabels();
this.loadReadingSessions();
@@ -76,30 +87,31 @@ export class ReadingSessionTimelineComponent implements OnInit {
const currentYear = new Date().getFullYear();
this.yearOptions = [];
for (let year = currentYear; year >= currentYear - 10; year--) {
- this.yearOptions.push({ label: year.toString(), value: year });
+ this.yearOptions.push({label: year.toString(), value: year});
}
}
private updateWeekOptions(): void {
- const weeksInYear = this.getWeeksInYear(this.currentYear);
+ const weeksInYear = getISOWeeksInYear(this.currentDate);
this.weekOptions = [];
for (let week = 1; week <= weeksInYear; week++) {
- this.weekOptions.push({ label: `Week ${week}`, value: week });
+ this.weekOptions.push({label: `Week ${week}`, value: week});
}
}
public onYearChange(): void {
- this.updateWeekOptions();
- const maxWeeks = this.getWeeksInYear(this.currentYear);
+ this.updateDateFromYearAndWeek();
+ const maxWeeks = getISOWeeksInYear(this.currentDate);
if (this.currentWeek > maxWeeks) {
this.currentWeek = maxWeeks;
+ this.updateDateFromYearAndWeek();
}
- this.updateCurrentMonth();
+ this.updateWeekOptions();
this.loadReadingSessions();
}
public onWeekChange(): void {
- this.updateCurrentMonth();
+ this.updateDateFromYearAndWeek();
this.loadReadingSessions();
}
@@ -112,7 +124,7 @@ export class ReadingSessionTimelineComponent implements OnInit {
}
private loadReadingSessions(): void {
- this.userStatsService.getTimelineForWeek(this.currentYear, this.currentMonth, this.currentWeek)
+ this.userStatsService.getTimelineForWeek(this.currentYear, this.currentWeek)
.pipe(
catchError((error) => {
console.error('Error loading reading sessions:', error);
@@ -148,59 +160,30 @@ export class ReadingSessionTimelineComponent implements OnInit {
return sessions.sort((a, b) => a.startTime.getTime() - b.startTime.getTime());
}
- private getCurrentWeekNumber(): number {
- const now = new Date();
- const startOfYear = new Date(now.getFullYear(), 0, 1);
- const days = Math.floor((now.getTime() - startOfYear.getTime()) / (24 * 60 * 60 * 1000));
- return Math.ceil((days + startOfYear.getDay() + 1) / 7);
- }
-
public changeWeek(delta: number): void {
- this.currentWeek += delta;
+ this.currentDate = addWeeks(this.currentDate, delta);
+ this.currentYear = getISOWeekYear(this.currentDate);
+ this.currentWeek = getISOWeek(this.currentDate);
- const weeksInYear = this.getWeeksInYear(this.currentYear);
- if (this.currentWeek > weeksInYear) {
- this.currentWeek = 1;
- this.currentYear++;
- this.updateWeekOptions();
- } else if (this.currentWeek < 1) {
- this.currentYear--;
- this.currentWeek = this.getWeeksInYear(this.currentYear);
- this.updateWeekOptions();
- }
-
- this.updateCurrentMonth();
+ this.ensureYearInOptions();
+ this.updateWeekOptions();
this.loadReadingSessions();
}
- private updateCurrentMonth(): void {
- const startOfYear = new Date(this.currentYear, 0, 1);
- const daysToAdd = (this.currentWeek - 1) * 7;
- const weekStart = new Date(startOfYear.getTime() + daysToAdd * 24 * 60 * 60 * 1000);
-
- const dayOfWeek = weekStart.getDay();
- weekStart.setDate(weekStart.getDate() - dayOfWeek);
-
- this.currentMonth = weekStart.getMonth() + 1;
+ private ensureYearInOptions(): void {
+ if (!this.yearOptions.some(option => option.value === this.currentYear)) {
+ this.yearOptions.unshift({label: this.currentYear.toString(), value: this.currentYear});
+ this.yearOptions.sort((a, b) => b.value - a.value);
+ }
}
- private getWeeksInYear(year: number): number {
- const lastDay = new Date(year, 11, 31);
- const startOfYear = new Date(year, 0, 1);
- const days = Math.floor((lastDay.getTime() - startOfYear.getTime()) / (24 * 60 * 60 * 1000));
- return Math.ceil((days + startOfYear.getDay() + 1) / 7);
+ private updateDateFromYearAndWeek(): void {
+ this.currentDate = setISOWeek(setISOWeekYear(new Date(), this.currentYear), this.currentWeek);
}
public getWeekDateRange(): string {
- const startOfYear = new Date(this.currentYear, 0, 1);
- const daysToAdd = (this.currentWeek - 1) * 7;
- const weekStart = new Date(startOfYear.getTime() + daysToAdd * 24 * 60 * 60 * 1000);
-
- const dayOfWeek = weekStart.getDay();
- weekStart.setDate(weekStart.getDate() - dayOfWeek);
-
- const weekEnd = new Date(weekStart);
- weekEnd.setDate(weekStart.getDate() + 6);
+ const weekStart = startOfISOWeek(this.currentDate);
+ const weekEnd = endOfISOWeek(this.currentDate);
const formatDate = (date: Date) => {
const month = date.toLocaleDateString('en-US', {month: 'short'});
diff --git a/booklore-ui/src/app/shared/models/api-exception.model.ts b/booklore-ui/src/app/shared/models/api-exception.model.ts
new file mode 100644
index 000000000..ac677b74b
--- /dev/null
+++ b/booklore-ui/src/app/shared/models/api-exception.model.ts
@@ -0,0 +1,6 @@
+export interface APIException {
+ status: number;
+ message: string;
+ timestamp?: string;
+ error?: string;
+}
diff --git a/booklore-ui/src/assets/layout/styles/layout/_content.scss b/booklore-ui/src/assets/layout/styles/layout/_content.scss
index b2abe2c33..a87e54459 100644
--- a/booklore-ui/src/assets/layout/styles/layout/_content.scss
+++ b/booklore-ui/src/assets/layout/styles/layout/_content.scss
@@ -5,7 +5,7 @@
flex-direction: column;
min-height: 100dvh;
justify-content: space-between;
- padding: 5rem 1.1rem 2rem 3.6rem;
+ padding: 5rem 1.1rem 1.1rem 3.6rem;
transition: margin-left variables.$transitionDuration;
position: fixed;
width: 100%;
diff --git a/booklore-ui/src/assets/layout/styles/layout/_menu.scss b/booklore-ui/src/assets/layout/styles/layout/_menu.scss
index defad5957..15c16de2f 100644
--- a/booklore-ui/src/assets/layout/styles/layout/_menu.scss
+++ b/booklore-ui/src/assets/layout/styles/layout/_menu.scss
@@ -4,11 +4,11 @@
.layout-sidebar {
position: fixed;
width: 225px;
- height: calc(100dvh - 6rem);
+ height: calc(100dvh - 6.1rem);
z-index: 999;
overflow-y: auto;
user-select: none;
- top: 4.9rem;
+ top: 5rem;
left: 1.1rem;
transition: transform variables.$transitionDuration, left variables.$transitionDuration;
background-color: var(--card-background);
diff --git a/booklore-ui/src/assets/layout/styles/layout/_responsive.scss b/booklore-ui/src/assets/layout/styles/layout/_responsive.scss
index 1cf8fce93..abe72abce 100644
--- a/booklore-ui/src/assets/layout/styles/layout/_responsive.scss
+++ b/booklore-ui/src/assets/layout/styles/layout/_responsive.scss
@@ -14,7 +14,7 @@
&.layout-overlay {
.layout-main-container {
margin-left: 0;
- padding: 5rem 1.1rem 2rem 3.6rem;
+ padding: 5rem 1.1rem 1.1rem 3.6rem;
}
.layout-sidebar {
@@ -47,7 +47,7 @@
.layout-main-container {
margin-left: 0;
- padding: 5rem 1rem 2rem 1.5rem;
+ padding: 5rem 1.1rem 1.1rem 1.1rem;
}
}
}
@@ -65,7 +65,7 @@
.layout-wrapper {
.layout-main-container {
- padding: 4.4rem 0.5rem 0.5rem 0.5rem;
+ padding-left: 1.1rem;
}
.layout-sidebar {
@@ -100,3 +100,11 @@
}
}
}
+
+@media (max-width: 768px) {
+ .layout-wrapper {
+ .layout-main-container {
+ padding: 4.4rem 0 0;
+ }
+ }
+}
\ No newline at end of file
| |