diff --git a/booklore-ui/src/app/book/components/book-browser/book-browser.component.ts b/booklore-ui/src/app/book/components/book-browser/book-browser.component.ts
index 559e20cd0..937854760 100644
--- a/booklore-ui/src/app/book/components/book-browser/book-browser.component.ts
+++ b/booklore-ui/src/app/book/components/book-browser/book-browser.component.ts
@@ -117,6 +117,7 @@ export class BookBrowserComponent implements OnInit, AfterViewInit {
{label: 'Author', icon: '', field: 'author', command: () => this.sortBooks('author')},
{label: 'Last Read', field: 'lastReadTime', command: () => this.sortBooks('lastReadTime')},
{label: 'Added On', field: 'addedOn', command: () => this.sortBooks('addedOn')},
+ {label: 'File Size', icon: '', field: 'fileSizeKb', command: () => this.sortBooks('fileSizeKb')},
{label: 'Locked', icon: '', field: 'locked', command: () => this.sortBooks('locked')},
{label: 'Publisher', icon: '', field: 'publisher', command: () => this.sortBooks('publisher')},
{label: 'Published Date', icon: '', field: 'publishedDate', command: () => this.sortBooks('publishedDate')},
diff --git a/booklore-ui/src/app/book/components/book-browser/book-table/book-table.component.html b/booklore-ui/src/app/book/components/book-browser/book-table/book-table.component.html
index 7665f458a..c4d0c9fea 100644
--- a/booklore-ui/src/app/book/components/book-browser/book-table/book-table.component.html
+++ b/booklore-ui/src/app/book/components/book-browser/book-table/book-table.component.html
@@ -25,6 +25,7 @@
Published |
Last Read |
Added |
+ File Size |
Lang |
Pages |
Amazon |
@@ -67,6 +68,10 @@
{{ book.addedOn ? (book.addedOn | date: 'dd-MMM-yyyy') : '' }}
|
+
+ {{ formatFileSize(book.fileSizeKb) }}
+ |
{{ metadata.language }} |
{{ metadata.pageCount }} |
diff --git a/booklore-ui/src/app/book/components/book-browser/book-table/book-table.component.ts b/booklore-ui/src/app/book/components/book-browser/book-table/book-table.component.ts
index ace7eecae..e9a12756a 100644
--- a/booklore-ui/src/app/book/components/book-browser/book-table/book-table.component.ts
+++ b/booklore-ui/src/app/book/components/book-browser/book-table/book-table.component.ts
@@ -106,6 +106,12 @@ export class BookTableComponent implements OnChanges {
.every(key => metadata[key] === true);
}
+ formatFileSize(kb?: number): string {
+ if (kb == null || isNaN(kb)) return '-';
+ const mb = kb / 1024;
+ return mb >= 1 ? `${mb.toFixed(1)} MB` : `${mb.toFixed(2)} MB`;
+ }
+
toggleMetadataLock(metadata: BookMetadata): void {
const lockKeys = Object.keys(metadata).filter(key => key.endsWith('Locked'));
const allLocked = lockKeys.every(key => metadata[key] === true);
diff --git a/booklore-ui/src/app/book/service/sort.service.ts b/booklore-ui/src/app/book/service/sort.service.ts
index 89a59e417..5525471d8 100644
--- a/booklore-ui/src/app/book/service/sort.service.ts
+++ b/booklore-ui/src/app/book/service/sort.service.ts
@@ -24,7 +24,8 @@ export class SortService {
.filter((key) => key.endsWith('Locked'))
.every((key) => book.metadata?.[key] === true),
lastReadTime: (book) => book.lastReadTime ? new Date(book.lastReadTime).getTime() : null,
- addedOn: (book) => book.addedOn ? new Date(book.addedOn).getTime() : null
+ addedOn: (book) => book.addedOn ? new Date(book.addedOn).getTime() : null,
+ fileSizeKb: (book) => book.fileSizeKb || null
};
applySort(books: Book[], selectedSort: SortOption | null): Book[] {
|