Implement sorting and display of file size in the table view
* Display the file size in the Book Metadata details section * Implement sorting and display of file size in the table view * Implement AppMigration feature * Populate missing file sizes for books with null file size in 'populateFileSizes' migration * Implement sorting and display of file size in the table view --------- Co-authored-by: adityachandelgit
This commit is contained in:
co-authored by
adityachandelgit
parent
2df8e193cc
commit
d855acd426
@@ -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')},
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
<th>Published</th>
|
||||
<th>Last Read</th>
|
||||
<th>Added</th>
|
||||
<th>File Size</th>
|
||||
<th>Lang</th>
|
||||
<th>Pages</th>
|
||||
<th>Amazon</th>
|
||||
@@ -67,6 +68,10 @@
|
||||
<td class="min-w-[9rem] max-w-[9rem] overflow-hidden truncate text-right">
|
||||
{{ book.addedOn ? (book.addedOn | date: 'dd-MMM-yyyy') : '' }}
|
||||
</td>
|
||||
<td class="min-w-[7rem] max-w-[9rem] overflow-hidden truncate"
|
||||
[title]="book.fileSizeKb + ' KB'">
|
||||
{{ formatFileSize(book.fileSizeKb) }}
|
||||
</td>
|
||||
<td class="min-w-[6rem] max-w-[6rem] overflow-hidden truncate">{{ metadata.language }}</td>
|
||||
<td class="min-w-[4rem] max-w-[5rem] overflow-hidden truncate">{{ metadata.pageCount }}</td>
|
||||
<td class="min-w-[10rem] max-w-[10rem] overflow-hidden truncate">
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user