feat: 💄 improve preview styling, allow document select in preview panel
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/promote/production Build is passing

This commit is contained in:
RaviAnand Mohabir 2025-04-08 16:23:15 +02:00
parent fa3d55cd1b
commit 0e1bde62b7
2 changed files with 25 additions and 18 deletions

View File

@ -1,4 +1,4 @@
.pdfPreview { .pdfThumbnail {
width: 100%; width: 100%;
height: 100%; height: 100%;
} }

View File

@ -2,6 +2,7 @@ import {
ActionIcon, ActionIcon,
AppShell, AppShell,
Autocomplete, Autocomplete,
Box,
Burger, Burger,
Button, Button,
Group, Group,
@ -131,20 +132,18 @@ function Organizrr() {
const handleFileDrop = (files: FileWithPath[]) => { const handleFileDrop = (files: FileWithPath[]) => {
if (files.length < 1) return; if (files.length < 1) return;
if (engine.current) { files.forEach((f) => {
files.forEach((f) => { const id = Math.random().toString(36).replace("0.", "doc_");
if (!engine.current) return; const fileId = Math.random().toString(36).replace("0.", "file_");
const id = Math.random().toString(36).replace("0.", "doc_"); form.insertListItem("documents", { id, file: f });
const fileId = Math.random().toString(36).replace("0.", "file_"); form.insertListItem("files", {
id: fileId,
form.insertListItem("documents", { id, file: f }); documents: [{ id }],
form.insertListItem("files", { suffix: "",
id: fileId, });
documents: [{ id }],
suffix: "",
});
if (engine.current) {
const messages: ChatCompletionMessageParam[] = [ const messages: ChatCompletionMessageParam[] = [
systemMessage, systemMessage,
{ role: "user", content: "The file name is: " + f.name }, { role: "user", content: "The file name is: " + f.name },
@ -185,8 +184,8 @@ function Organizrr() {
setGeneratingFilenames((fns) => fns.filter((fn) => fn !== fileId)); setGeneratingFilenames((fns) => fns.filter((fn) => fn !== fileId));
}); });
}); }
} });
setActiveFile(form.getValues().files.length - 1); setActiveFile(form.getValues().files.length - 1);
setActiveDocumentId( setActiveDocumentId(
@ -461,7 +460,7 @@ function Organizrr() {
(_d) => _d.id === d.id (_d) => _d.id === d.id
)?.file )?.file
} }
className={classNames.pdfPreview} className={classNames.pdfThumbnail}
> >
<Page pageNumber={1} scale={0.5} /> <Page pageNumber={1} scale={0.5} />
</Document> </Document>
@ -525,11 +524,19 @@ function Organizrr() {
<Group style={{ alignSelf: "start" }}> <Group style={{ alignSelf: "start" }}>
<IconEye /> <Title order={3}>Preview</Title> <IconEye /> <Title order={3}>Preview</Title>
</Group> </Group>
<Select
label="Select file"
data={form.values.documents.map(({ id, file }) => ({
value: id,
label: file.name,
}))}
value={activeDocumentId}
onChange={setActiveDocumentId}
/>
{activeDocument && {activeDocument &&
activeDocument.file.name.toLowerCase().endsWith(".pdf") && ( activeDocument.file.name.toLowerCase().endsWith(".pdf") && (
<> <>
<Text>{activeDocument.file.name}</Text> <ScrollArea maw="100%">
<ScrollArea w="100%">
<Document <Document
file={activeDocument.file} file={activeDocument.file}
onLoadSuccess={onDocumentLoadSuccess} onLoadSuccess={onDocumentLoadSuccess}