Enhance file path display with collapsible toggle and styled file type tag
This commit is contained in:
committed by
Aditya Chandel
parent
99650f0839
commit
17167dfd03
+37
-6
@@ -7,7 +7,9 @@
|
||||
class="book-cover placeholder"
|
||||
alt="Cover of {{ metadata.title }}"
|
||||
loading="lazy"
|
||||
width="225"/>
|
||||
width="225"
|
||||
style="min-width: 225px;"
|
||||
/>
|
||||
|
||||
<p-progressBar
|
||||
*ngIf="getProgressPercent() !== null"
|
||||
@@ -80,26 +82,55 @@
|
||||
<p-tag *ngFor="let category of metadata.categories" [value]="category" class="shrink-0"></p-tag>
|
||||
</div>
|
||||
|
||||
<div class="grid gap-x-20 gap-y-2 pt-6" style="grid-template-columns: repeat(4, max-content);">
|
||||
<div class="grid gap-x-20 gap-y-2 pt-6" style="grid-template-columns: repeat(5, max-content);">
|
||||
<p class="whitespace-nowrap flex items-center gap-2">
|
||||
<span class="font-bold">File Type:</span>
|
||||
<span
|
||||
class="inline-block px-2 py-0.5 rounded-full text-xs font-bold text-white"
|
||||
[ngClass]="getFileTypeColorClass(getFileExtension(book?.filePath))">
|
||||
{{ getFileExtension(book?.filePath) || '-' }}
|
||||
</span>
|
||||
</p>
|
||||
<p class="whitespace-nowrap"><span class="font-bold">Publisher:</span> {{ metadata.publisher || '-' }}</p>
|
||||
<p class="whitespace-nowrap"><span class="font-bold">Published:</span> {{ metadata.publishedDate || '-' }}</p>
|
||||
<p class="whitespace-nowrap"><span class="font-bold">Language:</span> {{ metadata.language || '-' }}</p>
|
||||
<p class="whitespace-nowrap"><span class="font-bold">ISBN 10:</span> {{ metadata.isbn10 || '-' }}</p>
|
||||
<p class="whitespace-nowrap"><span class="font-bold">ISBN 13:</span> {{ metadata.isbn13 || '-' }}</p>
|
||||
<p class="whitespace-nowrap"><span class="font-bold">ASIN:</span> {{ metadata.asin || '-' }}</p>
|
||||
<p class="whitespace-nowrap"><span class="font-bold">Page Count:</span> {{ metadata.pageCount || '-' }}</p>
|
||||
<p class="whitespace-nowrap"><span class="font-bold">File Size:</span> {{ getFileSizeInMB() }}</p>
|
||||
<p class="whitespace-nowrap"><span class="font-bold">Progress:</span> {{ getProgressPercent() !== null ? getProgressPercent() + '%' : '-' }}</p>
|
||||
</div>
|
||||
|
||||
<p class="pt-2"><span class="font-bold">File Path:</span> {{ book?.filePath }}</p>
|
||||
<div class="pt-2 flex items-center gap-2 w-full">
|
||||
<span class="font-semibold flex-shrink-0">File Path:</span>
|
||||
<p-toggleButton
|
||||
[(ngModel)]="showFilePath"
|
||||
onIcon="pi pi-eye-slash"
|
||||
offIcon="pi pi-eye"
|
||||
onLabel=""
|
||||
offLabel=""
|
||||
size="small"
|
||||
class="flex-shrink-0"></p-toggleButton>
|
||||
<div
|
||||
class="flex items-center gap-4 flex-grow"
|
||||
*ngIf="showFilePath"
|
||||
style="min-width: 0;">
|
||||
<p
|
||||
class="font-mono text-sm text-gray-400 overflow-x-auto whitespace-nowrap flex-grow"
|
||||
style="min-width: 0;">
|
||||
{{ book?.filePath }}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div *ngIf="userService.userData$ | async as userData" class="pl-6 pt-4 flex flex-row w-full gap-4">
|
||||
<p-button label="Read" icon="pi pi-book" severity="info" (onClick)="read(metadata.bookId)"></p-button>
|
||||
<p-button label="Assign Shelf" icon="pi pi-folder" severity="info" outlined (onClick)="assignShelf(metadata.bookId)"></p-button>
|
||||
<p-button *ngIf="userData.permissions.canDownload || userData.permissions.admin" label="Download" icon="pi pi-download" severity="info" outlined (onClick)="download(metadata.bookId)"></p-button>
|
||||
<p-splitbutton *ngIf="userData.permissions.canEmailBook || userData.permissions.admin" label="Quick Send" icon="pi pi-send" [model]="items" (onClick)="quickSend(metadata.bookId)" outlined severity="info"/>
|
||||
<p-button *ngIf="userData.permissions.canDownload || userData.permissions.admin" label="Download" icon="pi pi-download" severity="info" outlined
|
||||
(onClick)="download(metadata.bookId)"></p-button>
|
||||
<p-splitbutton *ngIf="userData.permissions.canEmailBook || userData.permissions.admin" label="Quick Send" icon="pi pi-send" [model]="items"
|
||||
(onClick)="quickSend(metadata.bookId)" outlined severity="info"/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
+34
-2
@@ -1,4 +1,4 @@
|
||||
import {Component, DestroyRef, inject, Input, OnInit, OnChanges, SimpleChanges, ViewChild} from '@angular/core';
|
||||
import {Component, DestroyRef, inject, Input, OnChanges, OnInit, SimpleChanges, ViewChild} from '@angular/core';
|
||||
import {Button, ButtonDirective} from 'primeng/button';
|
||||
import {AsyncPipe, DecimalPipe, NgClass, NgForOf, NgIf} from '@angular/common';
|
||||
import {first, Observable} from 'rxjs';
|
||||
@@ -23,13 +23,14 @@ import {BookCardComponent} from '../../../components/book-browser/book-card/book
|
||||
import {takeUntilDestroyed} from '@angular/core/rxjs-interop';
|
||||
import {Editor} from 'primeng/editor';
|
||||
import {ProgressBar} from 'primeng/progressbar';
|
||||
import {ToggleButton} from 'primeng/togglebutton';
|
||||
|
||||
@Component({
|
||||
selector: 'app-metadata-viewer',
|
||||
standalone: true,
|
||||
templateUrl: './metadata-viewer.component.html',
|
||||
styleUrl: './metadata-viewer.component.scss',
|
||||
imports: [Button, NgForOf, NgIf, AsyncPipe, Rating, FormsModule, Tag, Divider, SplitButton, NgClass, Tooltip, DecimalPipe, InfiniteScrollDirective, BookCardComponent, ButtonDirective, Editor, ProgressBar]
|
||||
imports: [Button, NgForOf, NgIf, AsyncPipe, Rating, FormsModule, Tag, Divider, SplitButton, NgClass, Tooltip, DecimalPipe, InfiniteScrollDirective, BookCardComponent, ButtonDirective, Editor, ProgressBar, ToggleButton]
|
||||
})
|
||||
export class MetadataViewerComponent implements OnInit, OnChanges {
|
||||
|
||||
@@ -52,6 +53,7 @@ export class MetadataViewerComponent implements OnInit, OnChanges {
|
||||
items: MenuItem[] | undefined;
|
||||
bookInSeries: Book[] = [];
|
||||
isExpanded = false;
|
||||
showFilePath = false;
|
||||
|
||||
ngOnInit(): void {
|
||||
this.items = [
|
||||
@@ -196,6 +198,36 @@ export class MetadataViewerComponent implements OnInit, OnChanges {
|
||||
}
|
||||
}
|
||||
|
||||
copyFilePath() {
|
||||
if (this.book?.filePath) {
|
||||
navigator.clipboard.writeText(this.book.filePath).then(() => {
|
||||
this.messageService.add({ severity: 'success', summary: 'Copied', detail: 'File path copied to clipboard.' });
|
||||
}, () => {
|
||||
this.messageService.add({ severity: 'error', summary: 'Error', detail: 'Failed to copy file path.' });
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
getFileExtension(filePath?: string): string | null {
|
||||
if (!filePath) return null;
|
||||
const parts = filePath.split('.');
|
||||
if (parts.length < 2) return null;
|
||||
return parts.pop()?.toUpperCase() || null;
|
||||
}
|
||||
|
||||
getFileTypeColorClass(fileType: string | null | undefined): string {
|
||||
if (!fileType) return 'bg-gray-500 text-white';
|
||||
|
||||
switch (fileType.toLowerCase()) {
|
||||
case 'pdf': return 'bg-red-700 text-white';
|
||||
case 'epub': return 'bg-yellow-600 text-gray-900';
|
||||
case 'cbz': return 'bg-green-700 text-white';
|
||||
case 'cbr': return 'bg-purple-700 text-white';
|
||||
case 'cb7': return 'bg-blue-700 text-white';
|
||||
default: return 'bg-gray-600 text-white';
|
||||
}
|
||||
}
|
||||
|
||||
getStarColor(rating?: number | null): string {
|
||||
if (rating == null) {
|
||||
return 'rgb(203, 213, 225)';
|
||||
|
||||
Reference in New Issue
Block a user