Skip to content
Snippets Groups Projects
Commit 846c64ab authored by Andréas Livet's avatar Andréas Livet
Browse files

Add upload percentage

parent 4b01f857
Branches
Tags
Loading
...@@ -36,6 +36,7 @@ export default function ViewerSidePanel({ ...@@ -36,6 +36,7 @@ export default function ViewerSidePanel({
const documentsRef = useRef(liriaeDocuments); const documentsRef = useRef(liriaeDocuments);
const [isUploading, setIsUploading] = useState(false); const [isUploading, setIsUploading] = useState(false);
const [uploadPercentage, setUploadPercentage] = useState("0");
// We'll need to display an alert message whether the files upload is successful or not // We'll need to display an alert message whether the files upload is successful or not
const { setAlert } = useContext(AlertContext); const { setAlert } = useContext(AlertContext);
const uploadInputRef = useRef<HTMLInputElement>(null); const uploadInputRef = useRef<HTMLInputElement>(null);
...@@ -159,8 +160,8 @@ export default function ViewerSidePanel({ ...@@ -159,8 +160,8 @@ export default function ViewerSidePanel({
setIsUploading(false); setIsUploading(false);
}, },
onProgress: function (bytesUploaded, bytesTotal) { onProgress: function (bytesUploaded, bytesTotal) {
var percentage = ((bytesUploaded / bytesTotal) * 100).toFixed(2); const percentage = ((bytesUploaded / bytesTotal) * 100).toFixed(0);
console.log(bytesUploaded, bytesTotal, percentage + "%"); setUploadPercentage(percentage)
}, },
onSuccess: async function () { onSuccess: async function () {
setIsUploading(false); setIsUploading(false);
...@@ -191,7 +192,6 @@ export default function ViewerSidePanel({ ...@@ -191,7 +192,6 @@ export default function ViewerSidePanel({
// Check if there are any previous uploads to continue. // Check if there are any previous uploads to continue.
const previousUploads = await upload.findPreviousUploads(); const previousUploads = await upload.findPreviousUploads();
console.log("Previous Uploads", previousUploads);
// Found previous uploads so we select the first one. // Found previous uploads so we select the first one.
if (previousUploads.length) { if (previousUploads.length) {
upload.resumeFromPreviousUpload(previousUploads[0]); upload.resumeFromPreviousUpload(previousUploads[0]);
...@@ -348,7 +348,7 @@ export default function ViewerSidePanel({ ...@@ -348,7 +348,7 @@ export default function ViewerSidePanel({
onClick={handleClick} onClick={handleClick}
priority="secondary" priority="secondary"
> >
{isUploading ? "Envoi en cours" : "Ajouter des fichiers"} {isUploading ? `Envoi en cours ${uploadPercentage}%` : "Ajouter des fichiers"}
{isUploading && ( {isUploading && (
<CircularProgress <CircularProgress
size={24} size={24}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment