mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-11-20 15:06:19 -05:00
Creating EbookRowCells to handle displaying ebook covers in list view.
This commit is contained in:
parent
3ea5b62865
commit
1d4f61c7bd
1 changed files with 32 additions and 1 deletions
|
|
@ -31,7 +31,7 @@ import {
|
|||
PageContainer,
|
||||
Paginator,
|
||||
textEllipsis,
|
||||
useTitle
|
||||
useTitle, CardLink
|
||||
} from "./Common";
|
||||
import {useBrowseFiles, useQuery, useSearchFiles} from "../hooks/customHooks";
|
||||
import {Route, Routes} from "react-router-dom";
|
||||
|
|
@ -326,13 +326,44 @@ function ImageRowCells({file}) {
|
|||
</React.Fragment>)
|
||||
}
|
||||
|
||||
export function EbookRowCells({file}) {
|
||||
const {ebook} = file;
|
||||
|
||||
const downloadUrl = `/download/${encodeURIComponent(file.path)}`;
|
||||
const viewerUrl = file['mimetype'].startsWith('application/epub') ? `/epub.html?url=${downloadUrl}` : null;
|
||||
|
||||
let cover = <CardIcon><FileIcon file={file}/></CardIcon>;
|
||||
if (ebook && ebook.cover_path) {
|
||||
const coverSrc = `/media/${encodeURIComponent(ebook.cover_path)}`;
|
||||
cover = <Image wrapped src={coverSrc} width='50px'/>;
|
||||
}
|
||||
|
||||
// Fragment for SelectableRow
|
||||
return (<React.Fragment>
|
||||
<TableCell>
|
||||
<center>{cover}</center>
|
||||
</TableCell>
|
||||
<TableCell>
|
||||
<CardLink to={viewerUrl || downloadUrl} newTab={true}>
|
||||
{textEllipsis(ebook.title || file.title)}
|
||||
</CardLink>
|
||||
</TableCell>
|
||||
</React.Fragment>)
|
||||
}
|
||||
|
||||
function FileRow({file}) {
|
||||
const isEbookType = file.mimetype && (
|
||||
file.mimetype.startsWith('application/epub') || file.mimetype.startsWith('application/x-mobipocket-ebook')
|
||||
);
|
||||
|
||||
if (file.model === 'video' && 'video' in file) {
|
||||
return <VideoRowCells file={file}/>;
|
||||
} else if (file.model === 'archive' && 'archive' in file) {
|
||||
return <ArchiveRowCells file={file}/>;
|
||||
} else if (file.mimetype && file.mimetype.startsWith('image/')) {
|
||||
return <ImageRowCells file={file}/>;
|
||||
} else if (isEbookType) {
|
||||
return <EbookRowCells key={file['path']} file={file}/>;
|
||||
}
|
||||
const onDownloadFile = async () => window.open(`/media/${file.key}`);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue