Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
a3dc77f
Fixed path routes for group view and artefact editor
JunHammy Aug 11, 2025
a10d02e
Added DialogMain, PendingBatchCard, DialogNewBatchCard Component
ZyuT0h Aug 11, 2025
3aa6174
Added fetch metadata request for artefact editor
JunHammy Aug 11, 2025
2253ecd
Modified PBC to have artefactCount instead of status
ZyuT0h Aug 12, 2025
2b2a80b
Added Custom FileUpload Button and Show File List
ZyuT0h Aug 12, 2025
ee52930
Added rough layout for artefact editor
JunHammy Aug 12, 2025
55eed68
Fixed metadataDisplay to set metadata based on response.data.raw.data…
JunHammy Aug 12, 2025
bcfcee1
Custom FileItem Component to show error/sucess status of file(s)
ZyuT0h Aug 12, 2025
8dba01e
Added back arrow and chevrons for artefact editor
JunHammy Aug 12, 2025
a09a706
Added image rendering for AE
JunHammy Aug 12, 2025
7c5f36c
Fixed sizing and layout in AE
JunHammy Aug 12, 2025
512c63e
added editorCard
JunHammy Aug 12, 2025
f046b57
Added title and button for editCard
JunHammy Aug 12, 2025
8b2d040
Shifted addInfo in metadatadisplay to be before the figure headshot
JunHammy Aug 12, 2025
4122d91
Fixed batch number and Added Responsiveness
ZyuT0h Aug 12, 2025
aa43d21
Added metadata toggle
JunHammy Aug 12, 2025
662a762
Merge pull request #28 from ArchAIve-Project/prakhar
Prakhar896 Aug 12, 2025
fd57f37
Added rendering of name and mm transcription using text area
JunHammy Aug 12, 2025
24e157d
Added displaying of all transcriptions
JunHammy Aug 12, 2025
b734750
Modified to change state instead of nested dialog
ZyuT0h Aug 12, 2025
c6e5b16
Added UploadExisting State, force user to clear before adding new fil…
ZyuT0h Aug 12, 2025
934d084
Modified from showing BatchID to BatchNumber
ZyuT0h Aug 12, 2025
8b80ffa
Added artefact editor action bar
JunHammy Aug 13, 2025
48d1358
Change icon size
JunHammy Aug 13, 2025
27ed57f
Added edit button
JunHammy Aug 13, 2025
2b67068
Added icon to edit button
JunHammy Aug 13, 2025
682cff0
Added feedback toasts and edit button for editor card
JunHammy Aug 13, 2025
0fab603
Cleaned up codes
ZyuT0h Aug 13, 2025
b9f42ea
changed informatin toast
JunHammy Aug 13, 2025
c8ac5c9
Added Done Button to be visible only after file successfully uploaded…
ZyuT0h Aug 13, 2025
3017382
Implemented better and cleaner layout for HF editor card
JunHammy Aug 13, 2025
0f9242b
Modified to auto update changes of batches
ZyuT0h Aug 13, 2025
4f00109
Added remove figure function
JunHammy Aug 13, 2025
f64b261
Added dialog to confirm delete of HF for artefact figure association
JunHammy Aug 13, 2025
e588914
Added highlighted text
JunHammy Aug 13, 2025
b80bd3e
Removed debug console logs
JunHammy Aug 13, 2025
03a52dc
Modified DialogUploadFile instead of batchid shows the batchcard
ZyuT0h Aug 13, 2025
c4f589d
Minor fixes to the Artefact Editor
JunHammy Aug 13, 2025
ceb4215
Added isLoading, loadingText to show loading msg while uploading
ZyuT0h Aug 13, 2025
afe19b1
Deleted DialogUpload, Changed name for DialogMain to UploadArtefact
ZyuT0h Aug 13, 2025
712adb4
Change function name from DialogName to UploadArtefact
ZyuT0h Aug 13, 2025
b832e0a
Fixed variable names and removed field.root tags
JunHammy Aug 13, 2025
dfd5446
Change import from DialogMain to UploadArtefact
ZyuT0h Aug 13, 2025
ff45a8e
Changed validation for artefact editor action bar
JunHammy Aug 13, 2025
fd85709
Removed debug console log
JunHammy Aug 13, 2025
eeb9cf4
Merge branch 'main' into junhan
Prakhar896 Aug 13, 2025
963dad3
Merge pull request #29 from ArchAIve-Project/junhan
Prakhar896 Aug 13, 2025
2260577
Change File & Function Name, added toastwizard
ZyuT0h Aug 13, 2025
b89adc8
Remove redundant filtering and filter while fetching the batch
ZyuT0h Aug 13, 2025
2144243
Removed Done Button
ZyuT0h Aug 13, 2025
c8fc006
Merge pull request #30 from ArchAIve-Project/zhengyu
Prakhar896 Aug 13, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions src/components/Catalogue/metadataDisplay.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ function MetadataDisplay({ currentItem, isOpen }) {
}

// Success case
setMetadata(response.data.raw.data);
setMetadata(response.data.raw.data.metadata);
} else {
throw new Error("Unexpected response format");
}
Expand Down Expand Up @@ -245,6 +245,14 @@ function MetadataDisplay({ currentItem, isOpen }) {
<Text fontWeight="bold" mb={1}>Caption:</Text>
<Text mb={6}>{metadata.caption || "N/A"}</Text>

{/* Additional figure metadata, if present */}
{metadata.addInfo && (
<>
<Text fontWeight="bold" mb={1}>Additional Info:</Text>
<Text>{metadata.addInfo}</Text>
</>
)}

{/* Figure headshots (if available) */}
{Array.isArray(metadata.figureIDs) && metadata.figureIDs.length > 0 ? (
<Flex wrap="wrap" gap={4} mb={4}>
Expand Down Expand Up @@ -277,14 +285,6 @@ function MetadataDisplay({ currentItem, isOpen }) {
) : (
<Text mb={2}>N/A</Text>
)}

{/* Additional figure metadata, if present */}
{metadata.addInfo && (
<>
<Text fontWeight="bold" mb={1}>Additional Info:</Text>
<Text>{metadata.addInfo}</Text>
</>
)}
</>
)}
</Box>
Expand Down
2 changes: 1 addition & 1 deletion src/components/Catalogue/transcriptionToggle.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ const TranscriptionToggle = ({ value, onChange }) => {
p="1"
rounded="lg"
boxShadow="sm"
gap="00"
gap="0"
>
<SegmentGroup.Indicator bg="primaryColour" rounded="lg" />
<SegmentGroup.Items items={items} />
Expand Down
224 changes: 224 additions & 0 deletions src/components/DataImport/ArtefactUploadView.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,224 @@
import { Button, Flex, Box, Text } from "@chakra-ui/react";
import { useEffect, useRef, useState } from "react";
import { HiUpload } from "react-icons/hi";
import server from "../../networking";
import ToastWizard from "../toastWizard";
import FileItem from "./FileItem";
import { IoArrowBackCircleSharp } from "react-icons/io5";
import PendingBatchCard from "./PendingBatchCard";
import hp1 from "../../assets/hp1.png";

function ArtefactUploadView({ batch, setBatchID, onClose, fetchBatches, onBackToPending }) {
const batchID = batch?.id;
const fileInputRef = useRef(null);
const [isSubmitting, setIsSubmitting] = useState(false);
const [selectedFiles, setSelectedFiles] = useState([]);
const [fileStatuses, setFileStatuses] = useState({});

const handleButtonClick = () => {
fileInputRef.current?.click();
};

const handleFileChange = (event) => {
const files = Array.from(event.target.files);
if (files.length > 0) {
setSelectedFiles((prev) => [...prev, ...files]);
// Clear statuses for newly added files
const newStatuses = { ...fileStatuses };
files.forEach((file) => {
delete newStatuses[file.name];
});
setFileStatuses(newStatuses);
}
};

const removeFile = (fileToRemove) => {
setSelectedFiles((prev) => prev.filter((file) => file !== fileToRemove));
setFileStatuses((prev) => {
const updated = { ...prev };
delete updated[fileToRemove.name];
return updated;
});
};

const clearAll = () => {
setSelectedFiles([]);
setFileStatuses({});
};

const hasPreviousStatus = selectedFiles.some(file => fileStatuses[file.name]);

const isDisabled =
selectedFiles.length === 0 ||
isSubmitting ||
hasPreviousStatus;

const handleUpload = async () => {
if (selectedFiles.length === 0 || isSubmitting) {
ToastWizard.standard("warning", "No Files Selected", "Please choose at least one file before uploading.");
return;
}

const formData = new FormData();
selectedFiles.forEach((file) => {
formData.append("file", file);
});

if (batchID) {
formData.append("batchID", batchID);
}

setIsSubmitting(true);

try {
const res = await server.post("/dataImport/upload", formData, {
headers: { "Content-Type": "multipart/form-data" },
transformRequest: formData => formData
});

const data = res.data;
const updates = data.raw?.updates || {};
const returnedBatchID = data.raw?.batchID;

if (returnedBatchID) {
setBatchID(returnedBatchID);
}
setFileStatuses(updates);
fetchBatches();

ToastWizard.standard(
"success",
"Upload Complete",
`Uploaded files to Batch ${returnedBatchID || '<Unknown ID>'}. Ready for processing.`
);
} catch (err) {
console.log(`Non-success response in file upload to batch ${batchID || 'New Batch'}`, err)
const updates = err?.response?.data?.raw?.updates;
if (updates) {
setFileStatuses(updates);
} else {
// If no detailed errors, mark all files as failed
const fallbackStatus = {};
selectedFiles.forEach((file) => {
fallbackStatus[file.name] = "ERROR: Failed to upload.";
});
setFileStatuses(fallbackStatus);
}

ToastWizard.standard("error", "Upload Failed", "Some or all files failed to upload.");
} finally {
setIsSubmitting(false);
}
};

useEffect(() => {
return () => {
clearAll();
}
}, []);

return (
<>
<Flex mb={{ base: 4, md: 6 }}>
<Box>
<Button
variant="ghost"
size={{ base: "sm", md: "md" }}
onClick={() => {
clearAll();
setBatchID(null);
onBackToPending();
}}
>
<IoArrowBackCircleSharp />
</Button>

</Box>
<Box ml={{ base: 5, md: 4 }}>
<PendingBatchCard
batchName={batch?.name || "New Batch"}
artefactCount={batch?.artefactCount || 0}
timestamp={batch?.created || new Date().toLocaleString()}
thumbnail={batch?.thumbnail || hp1}
/>
</Box>
</Flex >
<input
type="file"
accept=".png,.jpg,jpeg"
multiple
ref={fileInputRef}
onChange={handleFileChange}
style={{ display: "none" }}
/>

<Button
leftIcon={<HiUpload />}
variant="outline"
width={{ base: "400px", md: "full" }}
justifyContent="start"
mb={4}
onClick={handleButtonClick}
>
Choose Files
</Button>

{
selectedFiles.length > 0 && (
<Box mb={4}>
<Flex justify="space-between" align="center" mb={2}>
<Text fontSize="sm" fontWeight="medium">
{selectedFiles.length} file(s) selected
</Text>
<Button size="xs" variant="ghost" colorScheme="red" onClick={clearAll}>
Remove All
</Button>
</Flex>

<Box
borderWidth="1px"
borderRadius="md"
p={2}
maxHeight="200px"
overflowY="auto"
bg="gray.50"
>
{selectedFiles.map((file, index) => (
<FileItem
key={index}
file={file}
statusMsg={fileStatuses[file.name]}
onRemove={removeFile}
/>
))}
</Box>
</Box>
)
}

{
hasPreviousStatus && (
<Text fontSize="sm" color="orange.500" mt={2}>
Click "Remove All" to upload new files.
</Text>
)
}

<Flex direction="row" justify="flex-end" gap={3} mt={4}>
<Box pl={{ base: 0, md: 4 }} pr={{ base: 0, md: 4 }} display="flex" gap={2} flexWrap="wrap">
<Button
variant="ArchPrimary"
disabled={isDisabled}
onClick={handleUpload}
loading={isSubmitting}
loadingText={batchID ? `Uploading ${selectedFiles.length} file(s)...` : `Creating batch...`}
>
{batchID ? 'Upload to Existing Batch' : 'Create New Batch and Upload'} ({selectedFiles.length})
</Button>
</Box>
</Flex >
</>
);
}

export default ArtefactUploadView;
Loading