cloudmr-ux 1.2.1 → 1.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.css +15 -15
- package/dist/index.d.ts +110 -96
- package/dist/index.js +785 -781
- package/dist/index.mjs +781 -778
- package/package.json +6 -1
package/dist/index.mjs
CHANGED
|
@@ -213,865 +213,867 @@ var CmrPanel = function(props) {
|
|
|
213
213
|
};
|
|
214
214
|
var Panel_default = CmrPanel;
|
|
215
215
|
|
|
216
|
-
// src/CmrComponents/
|
|
217
|
-
import React5, { useState as useState4 } from "react";
|
|
218
|
-
import { Button as Button3 } from "@mui/material";
|
|
219
|
-
|
|
220
|
-
// src/CmrComponents/upload/UploadWindow.tsx
|
|
216
|
+
// src/CmrComponents/rename/edit.tsx
|
|
221
217
|
import * as React4 from "react";
|
|
222
|
-
import
|
|
218
|
+
import { Typography } from "@mui/material";
|
|
223
219
|
import TextField from "@mui/material/TextField";
|
|
224
220
|
import Dialog from "@mui/material/Dialog";
|
|
225
221
|
import DialogActions from "@mui/material/DialogActions";
|
|
226
222
|
import DialogContent from "@mui/material/DialogContent";
|
|
227
|
-
import DialogContentText from "@mui/material/DialogContentText";
|
|
228
223
|
import DialogTitle from "@mui/material/DialogTitle";
|
|
229
|
-
import
|
|
230
|
-
import Box from "@mui/material/Box";
|
|
231
|
-
import { Alert, Collapse, MenuItem as MenuItem2 } from "@mui/material";
|
|
232
|
-
|
|
233
|
-
// src/CmrComponents/label/Label.tsx
|
|
224
|
+
import { useEffect } from "react";
|
|
234
225
|
import { jsx as jsx8, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
226
|
+
function CmrNameDialog(props) {
|
|
227
|
+
let { originalName, open, setOpen } = props;
|
|
228
|
+
const [helperText, setHelperText] = React4.useState("");
|
|
229
|
+
const [text, setText] = React4.useState(originalName);
|
|
230
|
+
const [error, setError] = React4.useState(false);
|
|
231
|
+
const renamingCallback = props.renamingCallback;
|
|
232
|
+
const handleClose = () => {
|
|
233
|
+
setOpen(false);
|
|
234
|
+
};
|
|
235
|
+
useEffect(() => {
|
|
236
|
+
checkError(originalName);
|
|
237
|
+
}, [originalName]);
|
|
238
|
+
const handleConfirm = async () => {
|
|
239
|
+
if (await renamingCallback(text))
|
|
240
|
+
handleClose();
|
|
241
|
+
};
|
|
242
|
+
const handleTextFieldChange = (e) => {
|
|
243
|
+
setText(e.target.value);
|
|
244
|
+
checkError(e.target.value);
|
|
245
|
+
};
|
|
246
|
+
const checkError = (text2) => {
|
|
247
|
+
const fileNameRegex = /^[a-zA-Z0-9_\-]+\.[a-zA-Z]{1,5}$/;
|
|
248
|
+
let newExtension = text2.split(".").pop();
|
|
249
|
+
let orgExtension = originalName.indexOf(".") >= 0 ? originalName.split(".").pop() : "?";
|
|
250
|
+
if (!fileNameRegex.test(text2)) {
|
|
251
|
+
setError(true);
|
|
252
|
+
if (text2.indexOf(".") < 0) {
|
|
253
|
+
setHelperText("Invalid file name, needs a valid extension.");
|
|
254
|
+
} else {
|
|
255
|
+
setHelperText("Invalid file name, please check.");
|
|
256
|
+
}
|
|
257
|
+
} else if (newExtension !== orgExtension) {
|
|
258
|
+
setHelperText(`You are modifying your file extension from .${orgExtension} to .${newExtension}.`);
|
|
259
|
+
setError(false);
|
|
260
|
+
} else {
|
|
261
|
+
setError(false);
|
|
262
|
+
setHelperText("");
|
|
263
|
+
}
|
|
264
|
+
};
|
|
265
|
+
return /* @__PURE__ */ jsx8("div", { children: /* @__PURE__ */ jsxs4(
|
|
266
|
+
Dialog,
|
|
267
|
+
{
|
|
268
|
+
open,
|
|
269
|
+
onClose: handleClose,
|
|
270
|
+
fullWidth: true,
|
|
271
|
+
maxWidth: "xs",
|
|
272
|
+
children: [
|
|
273
|
+
/* @__PURE__ */ jsx8(DialogTitle, { children: /* @__PURE__ */ jsxs4(Typography, { children: [
|
|
274
|
+
' Rename "',
|
|
275
|
+
originalName,
|
|
276
|
+
'" as:'
|
|
277
|
+
] }) }),
|
|
278
|
+
/* @__PURE__ */ jsx8(DialogContent, { children: /* @__PURE__ */ jsx8(
|
|
279
|
+
TextField,
|
|
280
|
+
{
|
|
281
|
+
autoFocus: true,
|
|
282
|
+
margin: "dense",
|
|
283
|
+
id: "name",
|
|
284
|
+
defaultValue: originalName,
|
|
285
|
+
onFocus: (event) => {
|
|
286
|
+
event.target.select();
|
|
287
|
+
},
|
|
288
|
+
fullWidth: true,
|
|
289
|
+
inputProps: { style: { fontSize: "16px" } },
|
|
290
|
+
variant: "standard",
|
|
291
|
+
onChange: handleTextFieldChange,
|
|
292
|
+
error,
|
|
293
|
+
helperText
|
|
294
|
+
}
|
|
295
|
+
) }),
|
|
296
|
+
/* @__PURE__ */ jsxs4(DialogActions, { children: [
|
|
297
|
+
/* @__PURE__ */ jsx8(CmrButton_default, { variant: "outlined", onClick: handleClose, children: "Cancel" }),
|
|
298
|
+
/* @__PURE__ */ jsx8(CmrButton_default, { variant: "contained", color: "primary", onClick: handleConfirm, children: "Confirm" })
|
|
299
|
+
] })
|
|
300
|
+
]
|
|
301
|
+
}
|
|
302
|
+
) });
|
|
303
|
+
}
|
|
243
304
|
|
|
244
|
-
// src/CmrComponents/
|
|
305
|
+
// src/CmrComponents/dialogue/Confirmation.tsx
|
|
306
|
+
import * as React5 from "react";
|
|
307
|
+
import Dialog2 from "@mui/material/Dialog";
|
|
308
|
+
import DialogActions2 from "@mui/material/DialogActions";
|
|
309
|
+
import DialogContent2 from "@mui/material/DialogContent";
|
|
310
|
+
import DialogContentText from "@mui/material/DialogContentText";
|
|
311
|
+
import DialogTitle2 from "@mui/material/DialogTitle";
|
|
245
312
|
import { jsx as jsx9, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
246
|
-
function
|
|
247
|
-
|
|
313
|
+
function CmrConfirmation({
|
|
314
|
+
name,
|
|
315
|
+
message,
|
|
316
|
+
cancelText = "Cancel",
|
|
317
|
+
color,
|
|
248
318
|
open,
|
|
249
319
|
setOpen,
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
320
|
+
confirmCallback = () => {
|
|
321
|
+
},
|
|
322
|
+
confirmText = "Confirm",
|
|
323
|
+
cancellable = false,
|
|
324
|
+
cancelCallback = () => {
|
|
325
|
+
},
|
|
326
|
+
width
|
|
253
327
|
}) {
|
|
254
|
-
const [
|
|
255
|
-
const
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
const
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
const
|
|
263
|
-
|
|
264
|
-
|
|
328
|
+
const [text, setText] = React5.useState("");
|
|
329
|
+
const handleClose = () => {
|
|
330
|
+
setOpen(false);
|
|
331
|
+
};
|
|
332
|
+
const handleConfirm = () => {
|
|
333
|
+
confirmCallback();
|
|
334
|
+
handleClose();
|
|
335
|
+
};
|
|
336
|
+
const handleCancel = () => {
|
|
337
|
+
cancelCallback();
|
|
338
|
+
handleClose();
|
|
339
|
+
};
|
|
340
|
+
return /* @__PURE__ */ jsxs5(Dialog2, { open, onClose: handleClose, children: [
|
|
341
|
+
/* @__PURE__ */ jsx9(DialogTitle2, { children: name ? name : "Confirmation" }),
|
|
342
|
+
/* @__PURE__ */ jsxs5(DialogContent2, { sx: { width }, children: [
|
|
343
|
+
/* @__PURE__ */ jsx9(DialogContentText, { alignContent: "center", children: message }),
|
|
344
|
+
/* @__PURE__ */ jsxs5(DialogActions2, { className: "mt-4", children: [
|
|
345
|
+
cancellable && /* @__PURE__ */ jsx9(CmrButton_default, { variant: "outlined", color: "inherit", sx: { color: "#333" }, onClick: handleCancel, children: cancelText }),
|
|
346
|
+
/* @__PURE__ */ jsx9(CmrButton_default, { variant: "contained", color, onClick: handleConfirm, children: confirmText })
|
|
347
|
+
] })
|
|
348
|
+
] })
|
|
349
|
+
] });
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
// src/CmrComponents/dialogue/DeletionDialog.tsx
|
|
353
|
+
import * as React6 from "react";
|
|
354
|
+
import TextField2 from "@mui/material/TextField";
|
|
355
|
+
import Dialog3 from "@mui/material/Dialog";
|
|
356
|
+
import DialogActions3 from "@mui/material/DialogActions";
|
|
357
|
+
import DialogContent3 from "@mui/material/DialogContent";
|
|
358
|
+
import DialogContentText2 from "@mui/material/DialogContentText";
|
|
359
|
+
import DialogTitle3 from "@mui/material/DialogTitle";
|
|
360
|
+
import { jsx as jsx10, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
361
|
+
function CmrDeletionDialog(props) {
|
|
362
|
+
const [open, setOpen] = React6.useState(true);
|
|
363
|
+
const [text, setText] = React6.useState("");
|
|
265
364
|
const handleClickOpen = () => {
|
|
266
365
|
setOpen(true);
|
|
267
366
|
};
|
|
268
367
|
const handleClose = () => {
|
|
269
368
|
setOpen(false);
|
|
270
369
|
};
|
|
271
|
-
const getExtension = (fileName) => {
|
|
272
|
-
if (fileName == void 0)
|
|
273
|
-
return;
|
|
274
|
-
return fileName.split(".").pop();
|
|
275
|
-
};
|
|
276
370
|
const handleConfirm = () => {
|
|
277
|
-
if (
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
setWarningText("Must select files to upload!");
|
|
281
|
-
setTimeout(() => setInfoOpen(false), 2500);
|
|
282
|
-
return;
|
|
283
|
-
}
|
|
284
|
-
if (fileAlias.length === 0) {
|
|
285
|
-
setInfoOpen(true);
|
|
286
|
-
setInfoStyle("error");
|
|
287
|
-
setWarningText("File name can't be empty");
|
|
288
|
-
setTimeout(() => setInfoOpen(false), 2500);
|
|
289
|
-
return;
|
|
371
|
+
if (text === props.name) {
|
|
372
|
+
props.deletionCallback();
|
|
373
|
+
setOpen(false);
|
|
290
374
|
}
|
|
291
|
-
setOpen(false);
|
|
292
|
-
upload(uploadedFiles[0], fileAlias, locationSelection).then((response) => {
|
|
293
|
-
console.log(response);
|
|
294
|
-
if (response > 0) {
|
|
295
|
-
setInfoOpen(true);
|
|
296
|
-
if (response === 200) {
|
|
297
|
-
setInfoStyle("success");
|
|
298
|
-
setWarningText("Upload successful");
|
|
299
|
-
setTimeout(() => {
|
|
300
|
-
setInfoOpen(false);
|
|
301
|
-
setOpen(false);
|
|
302
|
-
}, 1e3);
|
|
303
|
-
setUpBtnDisabled(false);
|
|
304
|
-
setUpBtnText("Upload");
|
|
305
|
-
} else if (response === 413) {
|
|
306
|
-
setInfoStyle("error");
|
|
307
|
-
setWarningText("File size limit exceeded");
|
|
308
|
-
setTimeout(() => {
|
|
309
|
-
setInfoOpen(false);
|
|
310
|
-
setUpBtnDisabled(false);
|
|
311
|
-
setUpBtnText("Upload");
|
|
312
|
-
}, 2e3);
|
|
313
|
-
} else if (response === 500) {
|
|
314
|
-
setInfoStyle("error");
|
|
315
|
-
setWarningText("Internal server error");
|
|
316
|
-
setTimeout(() => {
|
|
317
|
-
setInfoOpen(false);
|
|
318
|
-
setUpBtnDisabled(false);
|
|
319
|
-
setUpBtnText("Upload");
|
|
320
|
-
}, 1500);
|
|
321
|
-
setOpen(true);
|
|
322
|
-
} else if (response === 400) {
|
|
323
|
-
setInfoStyle("warning");
|
|
324
|
-
setWarningText("File upload cancelled");
|
|
325
|
-
setTimeout(() => {
|
|
326
|
-
setInfoOpen(false);
|
|
327
|
-
setUpBtnDisabled(false);
|
|
328
|
-
setUpBtnText("Upload");
|
|
329
|
-
}, 1e3);
|
|
330
|
-
setOpen(true);
|
|
331
|
-
} else {
|
|
332
|
-
setInfoStyle("warning");
|
|
333
|
-
setWarningText("Unknown status");
|
|
334
|
-
setTimeout(() => {
|
|
335
|
-
setInfoOpen(false);
|
|
336
|
-
setUpBtnDisabled(false);
|
|
337
|
-
setUpBtnText("Upload");
|
|
338
|
-
}, 2e3);
|
|
339
|
-
setOpen(true);
|
|
340
|
-
}
|
|
341
|
-
}
|
|
342
|
-
}).catch((error) => {
|
|
343
|
-
setUpBtnDisabled(false);
|
|
344
|
-
setUpBtnText("Upload");
|
|
345
|
-
setInfoOpen(true);
|
|
346
|
-
setInfoStyle("error");
|
|
347
|
-
setWarningText("Upload unsuccessful: " + error.message);
|
|
348
|
-
setTimeout(() => setInfoOpen(false), 2500);
|
|
349
|
-
console.error("Error:", error);
|
|
350
|
-
});
|
|
351
|
-
setUpBtnDisabled(true);
|
|
352
|
-
setUpBtnText("Uploading");
|
|
353
375
|
};
|
|
354
|
-
const
|
|
355
|
-
|
|
376
|
+
const handleTextFieldChange = (e) => {
|
|
377
|
+
setText(e.target.value);
|
|
356
378
|
};
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
"GB",
|
|
382
|
-
"TB",
|
|
383
|
-
"PB",
|
|
384
|
-
"EB",
|
|
385
|
-
"ZB",
|
|
386
|
-
"YB"
|
|
387
|
-
];
|
|
388
|
-
let numberOfBytes = file2.size;
|
|
389
|
-
const exponent = Math.min(
|
|
390
|
-
Math.floor(Math.log(numberOfBytes) / Math.log(1024)),
|
|
391
|
-
units.length - 1
|
|
392
|
-
);
|
|
393
|
-
const approx = numberOfBytes / 1024 ** exponent;
|
|
394
|
-
const output = exponent === 0 ? `${numberOfBytes} bytes` : `${approx.toFixed(3)} ${units[exponent]}`;
|
|
395
|
-
setFileSize(output);
|
|
396
|
-
}
|
|
397
|
-
readFile(file);
|
|
398
|
-
}
|
|
399
|
-
let initialized = false;
|
|
400
|
-
let fileInput = (inputRef) => {
|
|
401
|
-
if (initialized)
|
|
402
|
-
return;
|
|
403
|
-
inputRef.addEventListener("dragover", function(e) {
|
|
404
|
-
e.stopPropagation();
|
|
405
|
-
e.preventDefault();
|
|
406
|
-
if (e.dataTransfer.files) {
|
|
407
|
-
let draggedFiles = e.dataTransfer.files;
|
|
408
|
-
if (draggedFiles.length > 1) {
|
|
409
|
-
setUploadBoxWarning("Only one file can be uploaded at a time");
|
|
410
|
-
} else if (fileExtension != void 0 && draggedFiles.length != 0 && getExtension(draggedFiles[0].name) != fileExtension) {
|
|
411
|
-
setUploadBoxWarning(`Only accepting files with extension ${fileExtension}`);
|
|
412
|
-
}
|
|
413
|
-
}
|
|
414
|
-
e.dataTransfer.dropEffect = "copy";
|
|
415
|
-
});
|
|
416
|
-
inputRef.addEventListener("drop", function(e) {
|
|
417
|
-
e.stopPropagation();
|
|
418
|
-
e.preventDefault();
|
|
419
|
-
setUploadBoxWarning(void 0);
|
|
420
|
-
let files = e.dataTransfer.files;
|
|
421
|
-
if (files.length > 1) {
|
|
422
|
-
setInfoOpen(true);
|
|
423
|
-
setInfoStyle("warning");
|
|
424
|
-
setWarningText("Only one file can be uploaded at a time");
|
|
425
|
-
setTimeout(() => setInfoOpen(false), 2500);
|
|
426
|
-
return;
|
|
427
|
-
} else if (fileExtension != void 0 && `.${getExtension(files[0].name)}` != fileExtension) {
|
|
428
|
-
setInfoOpen(true);
|
|
429
|
-
setInfoStyle("warning");
|
|
430
|
-
setWarningText(`Only accepting files with extension ${fileExtension}`);
|
|
431
|
-
setTimeout(() => setInfoOpen(false), 2500);
|
|
432
|
-
return;
|
|
433
|
-
}
|
|
434
|
-
loadFiles(files);
|
|
435
|
-
});
|
|
436
|
-
inputRef.addEventListener("dragleave", () => {
|
|
437
|
-
setUploadBoxWarning(void 0);
|
|
438
|
-
});
|
|
439
|
-
initialized = true;
|
|
440
|
-
};
|
|
441
|
-
const fileInputClick = (e) => {
|
|
442
|
-
const fileElem = document.getElementById("file-window");
|
|
443
|
-
e.preventDefault();
|
|
444
|
-
if (fileElem) {
|
|
445
|
-
fileElem.click();
|
|
446
|
-
}
|
|
447
|
-
};
|
|
448
|
-
const loadSelectedFiles = (e) => {
|
|
449
|
-
e.preventDefault();
|
|
450
|
-
const fileElem = document.getElementById("file-window");
|
|
451
|
-
loadFiles(fileElem.files);
|
|
452
|
-
};
|
|
453
|
-
return /* @__PURE__ */ jsx9("div", { children: /* @__PURE__ */ jsxs5(Dialog, { open, onClose: handleClose, children: [
|
|
454
|
-
/* @__PURE__ */ jsx9(DialogTitle, { children: "File Upload" }),
|
|
455
|
-
/* @__PURE__ */ jsxs5(DialogContent, { children: [
|
|
456
|
-
/* @__PURE__ */ jsx9(DialogContentText, {}),
|
|
457
|
-
/* @__PURE__ */ jsxs5(DialogContent, { dividers: true, children: [
|
|
458
|
-
/* @__PURE__ */ jsx9(
|
|
459
|
-
Box,
|
|
460
|
-
{
|
|
461
|
-
width: 500,
|
|
462
|
-
height: 250,
|
|
463
|
-
style: {
|
|
464
|
-
borderStyle: "dashed",
|
|
465
|
-
borderRadius: "5pt",
|
|
466
|
-
borderColor: uploadBoxWarning == void 0 ? "lightGray" : "#BA3C3C"
|
|
467
|
-
},
|
|
468
|
-
children: /* @__PURE__ */ jsx9(Typography, { component: "div", style: { height: "100%" }, children: /* @__PURE__ */ jsxs5(
|
|
469
|
-
Box,
|
|
470
|
-
{
|
|
471
|
-
style: {
|
|
472
|
-
display: "flex",
|
|
473
|
-
flexDirection: "column",
|
|
474
|
-
justifyContent: "center",
|
|
475
|
-
alignItems: "center",
|
|
476
|
-
height: "100%"
|
|
477
|
-
},
|
|
478
|
-
onClick: fileInputClick,
|
|
479
|
-
ref: fileInput,
|
|
480
|
-
children: [
|
|
481
|
-
/* @__PURE__ */ jsxs5(Typography, { variant: "body1", align: "center", style: { marginTop: "auto" }, children: [
|
|
482
|
-
"Drag & Drop or Click to Upload Your File Here ",
|
|
483
|
-
/* @__PURE__ */ jsx9("sup", { children: "*" })
|
|
484
|
-
] }),
|
|
485
|
-
/* @__PURE__ */ jsx9(Typography, { variant: "body2", align: "center", style: { marginTop: "auto", fontSize: "0.8rem", fontStyle: "italic" }, children: "* Warning: The file you are uploading may contain sensitive information protected under privacy laws. Please ensure all PHI is anonymized before proceeding.Before proceeding. The user is the sole responsible for data anonymization." })
|
|
486
|
-
]
|
|
487
|
-
}
|
|
488
|
-
) })
|
|
489
|
-
}
|
|
490
|
-
),
|
|
491
|
-
/* @__PURE__ */ jsx9(
|
|
492
|
-
"input",
|
|
493
|
-
{
|
|
494
|
-
type: "file",
|
|
495
|
-
id: "file-window",
|
|
496
|
-
multiple: true,
|
|
497
|
-
accept: fileExtension == void 0 ? "*" : fileExtension,
|
|
498
|
-
style: { display: "none" },
|
|
499
|
-
onChange: loadSelectedFiles
|
|
500
|
-
}
|
|
501
|
-
),
|
|
502
|
-
/* @__PURE__ */ jsxs5(Box, { component: "form", sx: { "& .MuiTextField-root": { m: 2, width: "25ch", mb: 0 } }, children: [
|
|
503
|
-
/* @__PURE__ */ jsxs5("div", { children: [
|
|
504
|
-
template.showFileName && /* @__PURE__ */ jsx9(
|
|
505
|
-
TextField,
|
|
506
|
-
{
|
|
507
|
-
required: true,
|
|
508
|
-
style: { marginTop: "30px" },
|
|
509
|
-
label: `File Alias:`,
|
|
510
|
-
value: fileAlias,
|
|
511
|
-
variant: "standard",
|
|
512
|
-
onChange: changeFileName
|
|
513
|
-
}
|
|
514
|
-
),
|
|
515
|
-
fileOriginalName != "" && /* @__PURE__ */ jsx9(Label_default, { style: { marginLeft: "16px", fontSize: "9pt", color: "#267833" }, children: fileOriginalName }),
|
|
516
|
-
template.showDatabase && /* @__PURE__ */ jsx9(
|
|
517
|
-
TextField,
|
|
518
|
-
{
|
|
519
|
-
select: true,
|
|
520
|
-
label: "Database:",
|
|
521
|
-
defaultValue: "s3",
|
|
522
|
-
helperText: "Upstream Storage Location",
|
|
523
|
-
variant: "standard",
|
|
524
|
-
children: [{ value: "s3", label: "S3" }].map((option) => /* @__PURE__ */ jsx9(MenuItem2, { value: option.value, children: option.label }, option.value))
|
|
525
|
-
}
|
|
526
|
-
)
|
|
527
|
-
] }),
|
|
528
|
-
/* @__PURE__ */ jsxs5("div", { children: [
|
|
529
|
-
template.showFileSize && /* @__PURE__ */ jsx9(
|
|
530
|
-
TextField,
|
|
531
|
-
{
|
|
532
|
-
label: "File Size:",
|
|
533
|
-
value: fileSize,
|
|
534
|
-
InputProps: {
|
|
535
|
-
readOnly: true
|
|
536
|
-
},
|
|
537
|
-
variant: "standard"
|
|
538
|
-
}
|
|
539
|
-
),
|
|
540
|
-
/* @__PURE__ */ jsx9(Collapse, { in: infoOpen, children: /* @__PURE__ */ jsx9(Alert, { severity: infoStyle, sx: { m: 1 }, children: warningText }) })
|
|
541
|
-
] })
|
|
542
|
-
] })
|
|
543
|
-
] }),
|
|
544
|
-
/* @__PURE__ */ jsxs5(DialogActions, { children: [
|
|
545
|
-
/* @__PURE__ */ jsx9(
|
|
546
|
-
Button2,
|
|
547
|
-
{
|
|
548
|
-
color: "inherit",
|
|
549
|
-
sx: { color: "#333" },
|
|
550
|
-
disabled: UpBtnDisabled,
|
|
551
|
-
onClick: handleClose,
|
|
552
|
-
children: "Cancel"
|
|
553
|
-
}
|
|
554
|
-
),
|
|
555
|
-
/* @__PURE__ */ jsx9(
|
|
556
|
-
Button2,
|
|
557
|
-
{
|
|
558
|
-
variant: "contained",
|
|
559
|
-
disabled: UpBtnDisabled,
|
|
560
|
-
onClick: handleConfirm,
|
|
561
|
-
children: UpBtnText
|
|
562
|
-
}
|
|
563
|
-
)
|
|
564
|
-
] })
|
|
565
|
-
] })
|
|
566
|
-
] }) });
|
|
567
|
-
}
|
|
568
|
-
|
|
569
|
-
// src/CmrComponents/upload/Upload.tsx
|
|
570
|
-
import axios from "axios";
|
|
571
|
-
import { jsx as jsx10, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
572
|
-
var CmrUpload = (props) => {
|
|
573
|
-
let [open, setOpen] = useState4(false);
|
|
574
|
-
let [uploading, setUploading] = useState4(false);
|
|
575
|
-
let [progress, setProgress] = useState4(0);
|
|
576
|
-
let [uploadedFile, setUploadedFile] = useState4(void 0);
|
|
577
|
-
const upload = async (file, fileAlias, fileDatabase) => {
|
|
578
|
-
setUploading(true);
|
|
579
|
-
const onProgress = (progress2) => {
|
|
580
|
-
let percentage = progress2 * 99;
|
|
581
|
-
props.uploadProgressed && props.uploadProgressed(+percentage.toFixed(2));
|
|
582
|
-
setProgress(+percentage.toFixed(2));
|
|
583
|
-
};
|
|
584
|
-
if (props.uploadStarted)
|
|
585
|
-
props.uploadStarted();
|
|
586
|
-
let status = 0;
|
|
587
|
-
if (props.beforeUpload != void 0 && !await props.beforeUpload(file)) {
|
|
588
|
-
if (props.uploadEnded)
|
|
589
|
-
props.uploadEnded();
|
|
590
|
-
setUploading(false);
|
|
591
|
-
return 200;
|
|
592
|
-
}
|
|
593
|
-
if (props.preprocess) {
|
|
594
|
-
let processed = await props.preprocess(file);
|
|
595
|
-
if (processed == void 0)
|
|
596
|
-
return failUpload();
|
|
597
|
-
if (typeof processed == "number") {
|
|
598
|
-
setUploading(false);
|
|
599
|
-
return processed;
|
|
600
|
-
}
|
|
601
|
-
file = processed;
|
|
602
|
-
}
|
|
603
|
-
if (props.uploadHandler != void 0) {
|
|
604
|
-
status = await props.uploadHandler(file, fileAlias, fileDatabase, onProgress, props.onUploaded);
|
|
605
|
-
setUploadedFile(props.reusable ? void 0 : file.name);
|
|
606
|
-
} else if (props.createPayload) {
|
|
607
|
-
let payload = await props.createPayload(file, fileAlias, fileDatabase);
|
|
608
|
-
if (payload == void 0) {
|
|
609
|
-
return failUpload();
|
|
610
|
-
}
|
|
611
|
-
payload.config.onUploadProgress = (progressEvent) => {
|
|
612
|
-
if (progressEvent.total == void 0)
|
|
613
|
-
return;
|
|
614
|
-
onProgress(progressEvent.loaded / progressEvent.total);
|
|
615
|
-
};
|
|
616
|
-
const res = await axios.post(payload.destination, payload.lambdaFile, payload.config);
|
|
617
|
-
status = res.status;
|
|
618
|
-
if (status === 200) {
|
|
619
|
-
console.log(res.data);
|
|
620
|
-
await axios.put(res.data.upload_url, payload.file, {
|
|
621
|
-
headers: {
|
|
622
|
-
"Content-Type": payload.file.type
|
|
623
|
-
}
|
|
624
|
-
});
|
|
625
|
-
await props.onUploaded(res, payload.file);
|
|
626
|
-
setUploadedFile(props.reusable ? void 0 : payload.file.name);
|
|
627
|
-
}
|
|
628
|
-
} else {
|
|
629
|
-
return failUpload();
|
|
630
|
-
}
|
|
631
|
-
if (props.uploadEnded)
|
|
632
|
-
props.uploadEnded();
|
|
633
|
-
setUploading(false);
|
|
634
|
-
setProgress(0);
|
|
635
|
-
return status;
|
|
636
|
-
};
|
|
637
|
-
function failUpload() {
|
|
638
|
-
setUploading(false);
|
|
639
|
-
setProgress(0);
|
|
640
|
-
if (props.uploadFailed)
|
|
641
|
-
return props.uploadFailed();
|
|
642
|
-
return 0;
|
|
643
|
-
}
|
|
644
|
-
return /* @__PURE__ */ jsxs6(React5.Fragment, { children: [
|
|
645
|
-
!uploading ? /* @__PURE__ */ jsxs6(
|
|
646
|
-
Button3,
|
|
647
|
-
{
|
|
648
|
-
fullWidth: props.fullWidth,
|
|
649
|
-
style: props.style,
|
|
650
|
-
variant: uploadedFile == void 0 ? "contained" : "outlined",
|
|
651
|
-
onClick: () => {
|
|
652
|
-
setOpen(true);
|
|
653
|
-
},
|
|
654
|
-
color: props.color || "primary",
|
|
655
|
-
sx: props.sx,
|
|
656
|
-
children: [
|
|
657
|
-
props.changeNameAfterUpload ? uploadedFile === void 0 ? props.uploadButtonName ? props.uploadButtonName : "Upload" : uploadedFile : props.uploadButtonName ? props.uploadButtonName : "Upload",
|
|
658
|
-
" "
|
|
659
|
-
]
|
|
660
|
-
}
|
|
661
|
-
) : /* @__PURE__ */ jsxs6(Button3, { fullWidth: props.fullWidth, style: props.style, variant: "contained", sx: { overflowWrap: "inherit" }, color: "primary", disabled: true, children: [
|
|
662
|
-
"Uploading ",
|
|
663
|
-
progress,
|
|
664
|
-
"%"
|
|
665
|
-
] }),
|
|
666
|
-
/* @__PURE__ */ jsx10(
|
|
667
|
-
UploadWindow,
|
|
668
|
-
{
|
|
669
|
-
open,
|
|
670
|
-
setOpen,
|
|
671
|
-
upload,
|
|
672
|
-
fileExtension: props.fileExtension,
|
|
673
|
-
template: { showFileName: true, showFileSize: true }
|
|
674
|
-
}
|
|
675
|
-
)
|
|
676
|
-
] });
|
|
677
|
-
};
|
|
678
|
-
CmrUpload.defaultProps = {
|
|
679
|
-
changeNameAfterUpload: true
|
|
680
|
-
};
|
|
681
|
-
var Upload_default = CmrUpload;
|
|
682
|
-
|
|
683
|
-
// src/CmrComponents/rename/edit.tsx
|
|
684
|
-
import * as React6 from "react";
|
|
685
|
-
import { Typography as Typography2 } from "@mui/material";
|
|
686
|
-
import TextField2 from "@mui/material/TextField";
|
|
687
|
-
import Dialog2 from "@mui/material/Dialog";
|
|
688
|
-
import DialogActions2 from "@mui/material/DialogActions";
|
|
689
|
-
import DialogContent2 from "@mui/material/DialogContent";
|
|
690
|
-
import DialogTitle2 from "@mui/material/DialogTitle";
|
|
691
|
-
import { useEffect } from "react";
|
|
692
|
-
import { jsx as jsx11, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
693
|
-
function CmrNameDialog(props) {
|
|
694
|
-
let { originalName, open, setOpen } = props;
|
|
695
|
-
const [helperText, setHelperText] = React6.useState("");
|
|
696
|
-
const [text, setText] = React6.useState(originalName);
|
|
697
|
-
const [error, setError] = React6.useState(false);
|
|
698
|
-
const renamingCallback = props.renamingCallback;
|
|
699
|
-
const handleClose = () => {
|
|
700
|
-
setOpen(false);
|
|
701
|
-
};
|
|
702
|
-
useEffect(() => {
|
|
703
|
-
checkError(originalName);
|
|
704
|
-
}, [originalName]);
|
|
705
|
-
const handleConfirm = async () => {
|
|
706
|
-
if (await renamingCallback(text))
|
|
707
|
-
handleClose();
|
|
708
|
-
};
|
|
709
|
-
const handleTextFieldChange = (e) => {
|
|
710
|
-
setText(e.target.value);
|
|
711
|
-
checkError(e.target.value);
|
|
712
|
-
};
|
|
713
|
-
const checkError = (text2) => {
|
|
714
|
-
const fileNameRegex = /^[a-zA-Z0-9_\-]+\.[a-zA-Z]{1,5}$/;
|
|
715
|
-
let newExtension = text2.split(".").pop();
|
|
716
|
-
let orgExtension = originalName.indexOf(".") >= 0 ? originalName.split(".").pop() : "?";
|
|
717
|
-
if (!fileNameRegex.test(text2)) {
|
|
718
|
-
setError(true);
|
|
719
|
-
if (text2.indexOf(".") < 0) {
|
|
720
|
-
setHelperText("Invalid file name, needs a valid extension.");
|
|
721
|
-
} else {
|
|
722
|
-
setHelperText("Invalid file name, please check.");
|
|
723
|
-
}
|
|
724
|
-
} else if (newExtension !== orgExtension) {
|
|
725
|
-
setHelperText(`You are modifying your file extension from .${orgExtension} to .${newExtension}.`);
|
|
726
|
-
setError(false);
|
|
727
|
-
} else {
|
|
728
|
-
setError(false);
|
|
729
|
-
setHelperText("");
|
|
730
|
-
}
|
|
731
|
-
};
|
|
732
|
-
return /* @__PURE__ */ jsx11("div", { children: /* @__PURE__ */ jsxs7(
|
|
733
|
-
Dialog2,
|
|
734
|
-
{
|
|
735
|
-
open,
|
|
736
|
-
onClose: handleClose,
|
|
737
|
-
fullWidth: true,
|
|
738
|
-
maxWidth: "xs",
|
|
739
|
-
children: [
|
|
740
|
-
/* @__PURE__ */ jsx11(DialogTitle2, { children: /* @__PURE__ */ jsxs7(Typography2, { children: [
|
|
741
|
-
" Rename the File ",
|
|
742
|
-
originalName,
|
|
743
|
-
" as:"
|
|
744
|
-
] }) }),
|
|
745
|
-
/* @__PURE__ */ jsx11(DialogContent2, { children: /* @__PURE__ */ jsx11(
|
|
746
|
-
TextField2,
|
|
747
|
-
{
|
|
748
|
-
autoFocus: true,
|
|
749
|
-
margin: "dense",
|
|
750
|
-
id: "name",
|
|
751
|
-
defaultValue: originalName,
|
|
752
|
-
onFocus: (event) => {
|
|
753
|
-
event.target.select();
|
|
754
|
-
},
|
|
755
|
-
fullWidth: true,
|
|
756
|
-
inputProps: { style: { fontSize: "16px" } },
|
|
757
|
-
variant: "standard",
|
|
758
|
-
onChange: handleTextFieldChange,
|
|
759
|
-
error,
|
|
760
|
-
helperText
|
|
761
|
-
}
|
|
762
|
-
) }),
|
|
763
|
-
/* @__PURE__ */ jsxs7(DialogActions2, { children: [
|
|
764
|
-
/* @__PURE__ */ jsx11(CmrButton_default, { variant: "outlined", onClick: handleClose, children: "Cancel" }),
|
|
765
|
-
/* @__PURE__ */ jsx11(CmrButton_default, { variant: "contained", color: "primary", onClick: handleConfirm, children: "Confirm" })
|
|
766
|
-
] })
|
|
767
|
-
]
|
|
768
|
-
}
|
|
769
|
-
) });
|
|
379
|
+
return /* @__PURE__ */ jsx10("div", { children: /* @__PURE__ */ jsxs6(Dialog3, { open, onClose: handleClose, children: [
|
|
380
|
+
/* @__PURE__ */ jsx10(DialogTitle3, { children: "Confirmation" }),
|
|
381
|
+
/* @__PURE__ */ jsxs6(DialogContent3, { children: [
|
|
382
|
+
/* @__PURE__ */ jsx10(DialogContentText2, { children: "To delete the files, please type your full name below and confirm." }),
|
|
383
|
+
/* @__PURE__ */ jsx10(
|
|
384
|
+
TextField2,
|
|
385
|
+
{
|
|
386
|
+
autoFocus: true,
|
|
387
|
+
margin: "dense",
|
|
388
|
+
id: "name",
|
|
389
|
+
type: "email",
|
|
390
|
+
placeholder: props.name,
|
|
391
|
+
fullWidth: true,
|
|
392
|
+
inputProps: { style: { fontSize: "16pt" } },
|
|
393
|
+
variant: "standard",
|
|
394
|
+
onChange: handleTextFieldChange
|
|
395
|
+
}
|
|
396
|
+
)
|
|
397
|
+
] }),
|
|
398
|
+
/* @__PURE__ */ jsxs6(DialogActions3, { children: [
|
|
399
|
+
/* @__PURE__ */ jsx10("button", { className: "btn btn-secondary", onClick: handleClose, children: "Cancel" }),
|
|
400
|
+
/* @__PURE__ */ jsx10("button", { className: "btn btn-danger", onClick: handleConfirm, children: "Confirm" })
|
|
401
|
+
] })
|
|
402
|
+
] }) });
|
|
770
403
|
}
|
|
771
404
|
|
|
772
|
-
// src/CmrComponents/dialogue/
|
|
405
|
+
// src/CmrComponents/dialogue/EditConfirmation.tsx
|
|
773
406
|
import * as React7 from "react";
|
|
774
|
-
import
|
|
775
|
-
import
|
|
776
|
-
import
|
|
777
|
-
import
|
|
778
|
-
import
|
|
779
|
-
import
|
|
780
|
-
|
|
407
|
+
import TextField3 from "@mui/material/TextField";
|
|
408
|
+
import Dialog4 from "@mui/material/Dialog";
|
|
409
|
+
import DialogActions4 from "@mui/material/DialogActions";
|
|
410
|
+
import DialogContent4 from "@mui/material/DialogContent";
|
|
411
|
+
import DialogContentText3 from "@mui/material/DialogContentText";
|
|
412
|
+
import DialogTitle4 from "@mui/material/DialogTitle";
|
|
413
|
+
import { InputAdornment } from "@mui/material";
|
|
414
|
+
import { useEffect as useEffect2 } from "react";
|
|
415
|
+
import { jsx as jsx11, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
416
|
+
function CmrEditConfirmation({
|
|
781
417
|
name,
|
|
782
418
|
message,
|
|
783
|
-
|
|
419
|
+
defaultText = "",
|
|
784
420
|
color,
|
|
785
421
|
open,
|
|
786
422
|
setOpen,
|
|
787
423
|
confirmCallback = () => {
|
|
788
424
|
},
|
|
789
|
-
confirmText = "Confirm",
|
|
790
425
|
cancellable = false,
|
|
791
426
|
cancelCallback = () => {
|
|
792
427
|
},
|
|
793
|
-
|
|
428
|
+
suffix = ""
|
|
794
429
|
}) {
|
|
795
|
-
const [text, setText] = React7.useState(
|
|
430
|
+
const [text, setText] = React7.useState(defaultText);
|
|
431
|
+
useEffect2(() => {
|
|
432
|
+
if (open)
|
|
433
|
+
setText(defaultText);
|
|
434
|
+
}, [open]);
|
|
796
435
|
const handleClose = () => {
|
|
797
436
|
setOpen(false);
|
|
798
437
|
};
|
|
799
438
|
const handleConfirm = () => {
|
|
800
|
-
confirmCallback();
|
|
439
|
+
confirmCallback(text + suffix);
|
|
801
440
|
handleClose();
|
|
802
441
|
};
|
|
803
442
|
const handleCancel = () => {
|
|
804
|
-
cancelCallback();
|
|
443
|
+
cancelCallback(text + suffix);
|
|
805
444
|
handleClose();
|
|
806
445
|
};
|
|
807
|
-
return /* @__PURE__ */
|
|
808
|
-
/* @__PURE__ */
|
|
809
|
-
/* @__PURE__ */
|
|
810
|
-
/* @__PURE__ */
|
|
811
|
-
/* @__PURE__ */
|
|
812
|
-
|
|
813
|
-
|
|
446
|
+
return /* @__PURE__ */ jsxs7(Dialog4, { maxWidth: "xs", fullWidth: true, open, onClose: handleCancel, children: [
|
|
447
|
+
/* @__PURE__ */ jsx11(DialogTitle4, { children: name ? name : "Confirmation" }),
|
|
448
|
+
/* @__PURE__ */ jsxs7(DialogContent4, { children: [
|
|
449
|
+
/* @__PURE__ */ jsx11(DialogContentText3, { alignContent: "center", children: message }),
|
|
450
|
+
/* @__PURE__ */ jsx11(DialogActions4, { children: /* @__PURE__ */ jsx11(
|
|
451
|
+
TextField3,
|
|
452
|
+
{
|
|
453
|
+
fullWidth: true,
|
|
454
|
+
variant: "standard",
|
|
455
|
+
InputProps: {
|
|
456
|
+
endAdornment: /* @__PURE__ */ jsx11(InputAdornment, { position: "end", sx: { whiteSpace: "nowrap" }, children: suffix })
|
|
457
|
+
},
|
|
458
|
+
defaultValue: text,
|
|
459
|
+
onChange: (e) => setText(e.target.value)
|
|
460
|
+
}
|
|
461
|
+
) }),
|
|
462
|
+
/* @__PURE__ */ jsxs7(DialogActions4, { children: [
|
|
463
|
+
cancellable && /* @__PURE__ */ jsx11(CmrButton_default, { variant: "outlined", color: "inherit", sx: { color: "#333" }, onClick: handleCancel, children: "Cancel" }),
|
|
464
|
+
/* @__PURE__ */ jsx11(CmrButton_default, { variant: "contained", color, onClick: handleConfirm, children: "Confirm" })
|
|
814
465
|
] })
|
|
815
466
|
] })
|
|
816
467
|
] });
|
|
817
468
|
}
|
|
818
469
|
|
|
819
|
-
// src/
|
|
470
|
+
// src/CmrTabs/CmrTabs.tsx
|
|
820
471
|
import * as React8 from "react";
|
|
821
|
-
import
|
|
822
|
-
import
|
|
823
|
-
import
|
|
824
|
-
import
|
|
825
|
-
import
|
|
826
|
-
import
|
|
827
|
-
import { jsx as
|
|
828
|
-
function
|
|
829
|
-
const
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
props.deletionCallback();
|
|
840
|
-
setOpen(false);
|
|
472
|
+
import Tabs from "@mui/material/Tabs";
|
|
473
|
+
import Tab from "@mui/material/Tab";
|
|
474
|
+
import Container from "@mui/material/Container";
|
|
475
|
+
import Typography2 from "@mui/material/Typography";
|
|
476
|
+
import Box from "@mui/material/Box";
|
|
477
|
+
import { cloneElement as cloneElement2 } from "react";
|
|
478
|
+
import { jsx as jsx12, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
479
|
+
function CustomTabPanel(props) {
|
|
480
|
+
const { children, value, index, ...other } = props;
|
|
481
|
+
return /* @__PURE__ */ jsx12(
|
|
482
|
+
"div",
|
|
483
|
+
{
|
|
484
|
+
role: "tabpanel",
|
|
485
|
+
hidden: value !== index,
|
|
486
|
+
id: `simple-tabpanel-${index}`,
|
|
487
|
+
"aria-labelledby": `simple-tab-${index}`,
|
|
488
|
+
...other,
|
|
489
|
+
children: /* @__PURE__ */ jsx12(Box, { sx: { p: 0 }, style: { display: value === index ? void 0 : "none" }, children: /* @__PURE__ */ jsx12(Typography2, { children }) })
|
|
841
490
|
}
|
|
491
|
+
);
|
|
492
|
+
}
|
|
493
|
+
function a11yProps(index) {
|
|
494
|
+
return {
|
|
495
|
+
id: `simple-tab-${index}`,
|
|
496
|
+
"aria-controls": `simple-tabpanel-${index}`
|
|
842
497
|
};
|
|
843
|
-
|
|
844
|
-
|
|
498
|
+
}
|
|
499
|
+
function CmrTabs(props) {
|
|
500
|
+
const [value, setValue] = React8.useState(0);
|
|
501
|
+
const handleChange = (event, newValue) => {
|
|
502
|
+
setValue(newValue);
|
|
503
|
+
if (props.onTabSelected)
|
|
504
|
+
props.onTabSelected(newValue);
|
|
845
505
|
};
|
|
846
|
-
return /* @__PURE__ */
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
506
|
+
return /* @__PURE__ */ jsxs8(
|
|
507
|
+
Container,
|
|
508
|
+
{
|
|
509
|
+
maxWidth: "lg",
|
|
510
|
+
sx: {
|
|
511
|
+
flex: 1,
|
|
512
|
+
display: "flex",
|
|
513
|
+
flexDirection: "column",
|
|
514
|
+
mt: 4
|
|
515
|
+
},
|
|
516
|
+
children: [
|
|
517
|
+
/* @__PURE__ */ jsx12(Box, { sx: { borderBottom: 1, borderColor: "divider", mb: 4 }, children: /* @__PURE__ */ jsx12(
|
|
518
|
+
Tabs,
|
|
519
|
+
{
|
|
520
|
+
value,
|
|
521
|
+
onChange: handleChange,
|
|
522
|
+
"aria-label": "basic tabs example",
|
|
523
|
+
textColor: "inherit",
|
|
524
|
+
TabIndicatorProps: {
|
|
525
|
+
style: {
|
|
526
|
+
backgroundColor: "#580F8B"
|
|
527
|
+
}
|
|
528
|
+
},
|
|
529
|
+
children: props.tabList.map((tab, index) => /* @__PURE__ */ jsx12(Tab, { sx: { color: value == index ? "#580F8B" : void 0 }, style: { fontSize: "14px", textTransform: "uppercase", fontWeight: 400 }, label: tab.text, ...a11yProps(index) }))
|
|
530
|
+
}
|
|
531
|
+
) }),
|
|
532
|
+
props.tabList.map(
|
|
533
|
+
(tab, index) => /* @__PURE__ */ jsx12(CustomTabPanel, { value, index, children: cloneElement2(tab.children, {
|
|
534
|
+
visible: value == index
|
|
535
|
+
}) })
|
|
536
|
+
)
|
|
537
|
+
]
|
|
538
|
+
}
|
|
539
|
+
);
|
|
870
540
|
}
|
|
871
541
|
|
|
872
|
-
// src/CmrComponents/
|
|
542
|
+
// src/CmrComponents/checkbox/Checkbox.tsx
|
|
543
|
+
import { Checkbox as Checkbox2 } from "@mui/material";
|
|
544
|
+
|
|
545
|
+
// src/CmrComponents/label/Label.tsx
|
|
546
|
+
import { jsx as jsx13, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
547
|
+
var CmrLabel = (props) => {
|
|
548
|
+
const { children, required = false } = props;
|
|
549
|
+
return /* @__PURE__ */ jsxs9("label", { className: "cmr-label", style: { fontSize: "16px", ...props.style }, children: [
|
|
550
|
+
children,
|
|
551
|
+
required && /* @__PURE__ */ jsx13("span", { className: "asterik", children: "*" })
|
|
552
|
+
] });
|
|
553
|
+
};
|
|
554
|
+
var Label_default = CmrLabel;
|
|
555
|
+
|
|
556
|
+
// src/CmrComponents/checkbox/Checkbox.tsx
|
|
557
|
+
import { FormControlLabel as FormControlLabel3 } from "@mui/material";
|
|
558
|
+
import { jsx as jsx14 } from "react/jsx-runtime";
|
|
559
|
+
var CmrCheckbox = (props) => {
|
|
560
|
+
const { defaultChecked, onChange, children, ...rest } = props;
|
|
561
|
+
return /* @__PURE__ */ jsx14(
|
|
562
|
+
FormControlLabel3,
|
|
563
|
+
{
|
|
564
|
+
disabled: props.disabled,
|
|
565
|
+
style: props.style,
|
|
566
|
+
className: props.className,
|
|
567
|
+
control: /* @__PURE__ */ jsx14(Checkbox2, { style: props.style, checked: props.checked, defaultChecked, onChange }),
|
|
568
|
+
label: /* @__PURE__ */ jsx14(Label_default, { children: props.children }),
|
|
569
|
+
sx: props.sx,
|
|
570
|
+
labelPlacement: "end"
|
|
571
|
+
}
|
|
572
|
+
);
|
|
573
|
+
};
|
|
574
|
+
var Checkbox_default = CmrCheckbox;
|
|
575
|
+
|
|
576
|
+
// src/CmrComponents/input-number/InputNumber.tsx
|
|
577
|
+
import { InputNumber } from "antd";
|
|
578
|
+
import { jsx as jsx15 } from "react/jsx-runtime";
|
|
579
|
+
var CmrInputNumber = (props) => {
|
|
580
|
+
const { defaultValue, style, max, min, value, onChange, children, ...rest } = props;
|
|
581
|
+
return /* @__PURE__ */ jsx15(InputNumber, { defaultValue, max, style, min, value, onChange, ...rest, children });
|
|
582
|
+
};
|
|
583
|
+
var InputNumber_default = CmrInputNumber;
|
|
584
|
+
|
|
585
|
+
// src/CmrComponents/tooltip/Tooltip.tsx
|
|
586
|
+
import { Tooltip } from "antd";
|
|
587
|
+
import { jsx as jsx16 } from "react/jsx-runtime";
|
|
588
|
+
var CmrTooltip = (props) => {
|
|
589
|
+
const {
|
|
590
|
+
arrowPointAtCenter,
|
|
591
|
+
autoAdjustOverflow,
|
|
592
|
+
color,
|
|
593
|
+
defaultVisible,
|
|
594
|
+
mouseEnterDelay,
|
|
595
|
+
mouseLeaveDelay,
|
|
596
|
+
overlayClassName,
|
|
597
|
+
placement,
|
|
598
|
+
visible,
|
|
599
|
+
...rest
|
|
600
|
+
} = props;
|
|
601
|
+
return /* @__PURE__ */ jsx16(
|
|
602
|
+
Tooltip,
|
|
603
|
+
{
|
|
604
|
+
arrowPointAtCenter,
|
|
605
|
+
autoAdjustOverflow,
|
|
606
|
+
color,
|
|
607
|
+
defaultVisible,
|
|
608
|
+
mouseEnterDelay,
|
|
609
|
+
mouseLeaveDelay,
|
|
610
|
+
overlayClassName,
|
|
611
|
+
placement,
|
|
612
|
+
visible,
|
|
613
|
+
...rest
|
|
614
|
+
}
|
|
615
|
+
);
|
|
616
|
+
};
|
|
617
|
+
var Tooltip_default = CmrTooltip;
|
|
618
|
+
|
|
619
|
+
// src/CmrComponents/select-upload/SelectUpload.tsx
|
|
620
|
+
import React11, { Fragment } from "react";
|
|
621
|
+
|
|
622
|
+
// src/CmrComponents/upload/Upload.tsx
|
|
623
|
+
import React10, { useState as useState9 } from "react";
|
|
624
|
+
import { Button as Button3 } from "@mui/material";
|
|
625
|
+
|
|
626
|
+
// src/CmrComponents/upload/UploadWindow.tsx
|
|
873
627
|
import * as React9 from "react";
|
|
628
|
+
import Button2 from "@mui/material/Button";
|
|
874
629
|
import TextField4 from "@mui/material/TextField";
|
|
875
630
|
import Dialog5 from "@mui/material/Dialog";
|
|
876
631
|
import DialogActions5 from "@mui/material/DialogActions";
|
|
877
632
|
import DialogContent5 from "@mui/material/DialogContent";
|
|
878
|
-
import DialogContentText4 from "@mui/material/DialogContentText";
|
|
879
|
-
import DialogTitle5 from "@mui/material/DialogTitle";
|
|
880
|
-
import
|
|
881
|
-
import
|
|
882
|
-
import {
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
defaultText = "",
|
|
887
|
-
color,
|
|
633
|
+
import DialogContentText4 from "@mui/material/DialogContentText";
|
|
634
|
+
import DialogTitle5 from "@mui/material/DialogTitle";
|
|
635
|
+
import Typography3 from "@mui/material/Typography";
|
|
636
|
+
import Box2 from "@mui/material/Box";
|
|
637
|
+
import { Alert, Collapse, MenuItem as MenuItem2 } from "@mui/material";
|
|
638
|
+
import { jsx as jsx17, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
639
|
+
function CmrUploadWindow({
|
|
640
|
+
upload,
|
|
888
641
|
open,
|
|
889
642
|
setOpen,
|
|
890
|
-
|
|
891
|
-
}
|
|
892
|
-
|
|
893
|
-
cancelCallback = () => {
|
|
894
|
-
},
|
|
895
|
-
suffix = ""
|
|
643
|
+
fileExtension,
|
|
644
|
+
template = { showFileName: true, showDatabase: true, showFileSize: true }
|
|
645
|
+
// default values
|
|
896
646
|
}) {
|
|
897
|
-
const [
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
647
|
+
const [fileOriginalName, setFileOriginalName] = React9.useState("");
|
|
648
|
+
const [fileAlias, setFileAlias] = React9.useState("/");
|
|
649
|
+
const [fileSize, setFileSize] = React9.useState("0 MB");
|
|
650
|
+
const [warningText, setWarningText] = React9.useState("Unknown Status");
|
|
651
|
+
const [infoOpen, setInfoOpen] = React9.useState(false);
|
|
652
|
+
const [locationSelection, setLocationSelection] = React9.useState("s3");
|
|
653
|
+
const [infoStyle, setInfoStyle] = React9.useState("info");
|
|
654
|
+
const [uploadedFiles, setUploaded] = React9.useState([]);
|
|
655
|
+
const [UpBtnDisabled, setUpBtnDisabled] = React9.useState(false);
|
|
656
|
+
const [UpBtnText, setUpBtnText] = React9.useState("Upload");
|
|
657
|
+
const [uploadBoxWarning, setUploadBoxWarning] = React9.useState(void 0);
|
|
658
|
+
const handleClickOpen = () => {
|
|
659
|
+
setOpen(true);
|
|
660
|
+
};
|
|
902
661
|
const handleClose = () => {
|
|
903
662
|
setOpen(false);
|
|
904
663
|
};
|
|
664
|
+
const getExtension = (fileName) => {
|
|
665
|
+
if (fileName == void 0)
|
|
666
|
+
return;
|
|
667
|
+
return fileName.split(".").pop();
|
|
668
|
+
};
|
|
905
669
|
const handleConfirm = () => {
|
|
906
|
-
|
|
907
|
-
|
|
670
|
+
if (uploadedFiles.length === 0) {
|
|
671
|
+
setInfoOpen(true);
|
|
672
|
+
setInfoStyle("error");
|
|
673
|
+
setWarningText("Must select files to upload!");
|
|
674
|
+
setTimeout(() => setInfoOpen(false), 2500);
|
|
675
|
+
return;
|
|
676
|
+
}
|
|
677
|
+
if (fileAlias.length === 0) {
|
|
678
|
+
setInfoOpen(true);
|
|
679
|
+
setInfoStyle("error");
|
|
680
|
+
setWarningText("File name can't be empty");
|
|
681
|
+
setTimeout(() => setInfoOpen(false), 2500);
|
|
682
|
+
return;
|
|
683
|
+
}
|
|
684
|
+
setOpen(false);
|
|
685
|
+
upload(uploadedFiles[0], fileAlias, locationSelection).then((response) => {
|
|
686
|
+
console.log(response);
|
|
687
|
+
if (response > 0) {
|
|
688
|
+
setInfoOpen(true);
|
|
689
|
+
if (response === 200) {
|
|
690
|
+
setInfoStyle("success");
|
|
691
|
+
setWarningText("Upload successful");
|
|
692
|
+
setTimeout(() => {
|
|
693
|
+
setInfoOpen(false);
|
|
694
|
+
setOpen(false);
|
|
695
|
+
}, 1e3);
|
|
696
|
+
setUpBtnDisabled(false);
|
|
697
|
+
setUpBtnText("Upload");
|
|
698
|
+
} else if (response === 413) {
|
|
699
|
+
setInfoStyle("error");
|
|
700
|
+
setWarningText("File size limit exceeded");
|
|
701
|
+
setTimeout(() => {
|
|
702
|
+
setInfoOpen(false);
|
|
703
|
+
setUpBtnDisabled(false);
|
|
704
|
+
setUpBtnText("Upload");
|
|
705
|
+
}, 2e3);
|
|
706
|
+
} else if (response === 500) {
|
|
707
|
+
setInfoStyle("error");
|
|
708
|
+
setWarningText("Internal server error");
|
|
709
|
+
setTimeout(() => {
|
|
710
|
+
setInfoOpen(false);
|
|
711
|
+
setUpBtnDisabled(false);
|
|
712
|
+
setUpBtnText("Upload");
|
|
713
|
+
}, 1500);
|
|
714
|
+
setOpen(true);
|
|
715
|
+
} else if (response === 400) {
|
|
716
|
+
setInfoStyle("warning");
|
|
717
|
+
setWarningText("File upload cancelled");
|
|
718
|
+
setTimeout(() => {
|
|
719
|
+
setInfoOpen(false);
|
|
720
|
+
setUpBtnDisabled(false);
|
|
721
|
+
setUpBtnText("Upload");
|
|
722
|
+
}, 1e3);
|
|
723
|
+
setOpen(true);
|
|
724
|
+
} else {
|
|
725
|
+
setInfoStyle("warning");
|
|
726
|
+
setWarningText("Unknown status");
|
|
727
|
+
setTimeout(() => {
|
|
728
|
+
setInfoOpen(false);
|
|
729
|
+
setUpBtnDisabled(false);
|
|
730
|
+
setUpBtnText("Upload");
|
|
731
|
+
}, 2e3);
|
|
732
|
+
setOpen(true);
|
|
733
|
+
}
|
|
734
|
+
}
|
|
735
|
+
}).catch((error) => {
|
|
736
|
+
setUpBtnDisabled(false);
|
|
737
|
+
setUpBtnText("Upload");
|
|
738
|
+
setInfoOpen(true);
|
|
739
|
+
setInfoStyle("error");
|
|
740
|
+
setWarningText("Upload unsuccessful: " + error.message);
|
|
741
|
+
setTimeout(() => setInfoOpen(false), 2500);
|
|
742
|
+
console.error("Error:", error);
|
|
743
|
+
});
|
|
744
|
+
setUpBtnDisabled(true);
|
|
745
|
+
setUpBtnText("Uploading");
|
|
908
746
|
};
|
|
909
|
-
const
|
|
910
|
-
|
|
911
|
-
handleClose();
|
|
747
|
+
const changeFileName = (e) => {
|
|
748
|
+
setFileAlias(e.target.value);
|
|
912
749
|
};
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
750
|
+
function loadFiles(files) {
|
|
751
|
+
if (files.length == 0) {
|
|
752
|
+
setInfoOpen(true);
|
|
753
|
+
setInfoStyle("warning");
|
|
754
|
+
setWarningText("No file selected");
|
|
755
|
+
setTimeout(() => setInfoOpen(false), 2500);
|
|
756
|
+
return;
|
|
757
|
+
}
|
|
758
|
+
if (files.length > 1) {
|
|
759
|
+
setInfoOpen(true);
|
|
760
|
+
setInfoStyle("warning");
|
|
761
|
+
setWarningText("Only accepts one file at a time");
|
|
762
|
+
setTimeout(() => setInfoOpen(false), 2500);
|
|
763
|
+
return;
|
|
764
|
+
}
|
|
765
|
+
let file = files[0];
|
|
766
|
+
setUploaded([file]);
|
|
767
|
+
function readFile(file2) {
|
|
768
|
+
setFileOriginalName(file2.name);
|
|
769
|
+
setFileAlias(file2.name);
|
|
770
|
+
const units = [
|
|
771
|
+
"B",
|
|
772
|
+
"KB",
|
|
773
|
+
"MB",
|
|
774
|
+
"GB",
|
|
775
|
+
"TB",
|
|
776
|
+
"PB",
|
|
777
|
+
"EB",
|
|
778
|
+
"ZB",
|
|
779
|
+
"YB"
|
|
780
|
+
];
|
|
781
|
+
let numberOfBytes = file2.size;
|
|
782
|
+
const exponent = Math.min(
|
|
783
|
+
Math.floor(Math.log(numberOfBytes) / Math.log(1024)),
|
|
784
|
+
units.length - 1
|
|
785
|
+
);
|
|
786
|
+
const approx = numberOfBytes / 1024 ** exponent;
|
|
787
|
+
const output = exponent === 0 ? `${numberOfBytes} bytes` : `${approx.toFixed(3)} ${units[exponent]}`;
|
|
788
|
+
setFileSize(output);
|
|
789
|
+
}
|
|
790
|
+
readFile(file);
|
|
791
|
+
}
|
|
792
|
+
let initialized = false;
|
|
793
|
+
let fileInput = (inputRef) => {
|
|
794
|
+
if (initialized)
|
|
795
|
+
return;
|
|
796
|
+
inputRef.addEventListener("dragover", function(e) {
|
|
797
|
+
e.stopPropagation();
|
|
798
|
+
e.preventDefault();
|
|
799
|
+
if (e.dataTransfer.files) {
|
|
800
|
+
let draggedFiles = e.dataTransfer.files;
|
|
801
|
+
if (draggedFiles.length > 1) {
|
|
802
|
+
setUploadBoxWarning("Only one file can be uploaded at a time");
|
|
803
|
+
} else if (fileExtension != void 0 && draggedFiles.length != 0 && getExtension(draggedFiles[0].name) != fileExtension) {
|
|
804
|
+
setUploadBoxWarning(`Only accepting files with extension ${fileExtension}`);
|
|
927
805
|
}
|
|
928
|
-
|
|
806
|
+
}
|
|
807
|
+
e.dataTransfer.dropEffect = "copy";
|
|
808
|
+
});
|
|
809
|
+
inputRef.addEventListener("drop", function(e) {
|
|
810
|
+
e.stopPropagation();
|
|
811
|
+
e.preventDefault();
|
|
812
|
+
setUploadBoxWarning(void 0);
|
|
813
|
+
let files = e.dataTransfer.files;
|
|
814
|
+
if (files.length > 1) {
|
|
815
|
+
setInfoOpen(true);
|
|
816
|
+
setInfoStyle("warning");
|
|
817
|
+
setWarningText("Only one file can be uploaded at a time");
|
|
818
|
+
setTimeout(() => setInfoOpen(false), 2500);
|
|
819
|
+
return;
|
|
820
|
+
} else if (fileExtension != void 0 && `.${getExtension(files[0].name)}` != fileExtension) {
|
|
821
|
+
setInfoOpen(true);
|
|
822
|
+
setInfoStyle("warning");
|
|
823
|
+
setWarningText(`Only accepting files with extension ${fileExtension}`);
|
|
824
|
+
setTimeout(() => setInfoOpen(false), 2500);
|
|
825
|
+
return;
|
|
826
|
+
}
|
|
827
|
+
loadFiles(files);
|
|
828
|
+
});
|
|
829
|
+
inputRef.addEventListener("dragleave", () => {
|
|
830
|
+
setUploadBoxWarning(void 0);
|
|
831
|
+
});
|
|
832
|
+
initialized = true;
|
|
833
|
+
};
|
|
834
|
+
const fileInputClick = (e) => {
|
|
835
|
+
const fileElem = document.getElementById("file-window");
|
|
836
|
+
e.preventDefault();
|
|
837
|
+
if (fileElem) {
|
|
838
|
+
fileElem.click();
|
|
839
|
+
}
|
|
840
|
+
};
|
|
841
|
+
const loadSelectedFiles = (e) => {
|
|
842
|
+
e.preventDefault();
|
|
843
|
+
const fileElem = document.getElementById("file-window");
|
|
844
|
+
loadFiles(fileElem.files);
|
|
845
|
+
};
|
|
846
|
+
return /* @__PURE__ */ jsx17("div", { children: /* @__PURE__ */ jsxs10(Dialog5, { open, onClose: handleClose, children: [
|
|
847
|
+
/* @__PURE__ */ jsx17(DialogTitle5, { children: "File Upload" }),
|
|
848
|
+
/* @__PURE__ */ jsxs10(DialogContent5, { children: [
|
|
849
|
+
/* @__PURE__ */ jsx17(DialogContentText4, {}),
|
|
850
|
+
/* @__PURE__ */ jsxs10(DialogContent5, { dividers: true, children: [
|
|
851
|
+
/* @__PURE__ */ jsx17(
|
|
852
|
+
Box2,
|
|
853
|
+
{
|
|
854
|
+
width: 500,
|
|
855
|
+
height: 250,
|
|
856
|
+
style: {
|
|
857
|
+
borderStyle: "dashed",
|
|
858
|
+
borderRadius: "5pt",
|
|
859
|
+
borderColor: uploadBoxWarning == void 0 ? "lightGray" : "#BA3C3C"
|
|
860
|
+
},
|
|
861
|
+
children: /* @__PURE__ */ jsx17(Typography3, { component: "div", style: { height: "100%" }, children: /* @__PURE__ */ jsxs10(
|
|
862
|
+
Box2,
|
|
863
|
+
{
|
|
864
|
+
style: {
|
|
865
|
+
display: "flex",
|
|
866
|
+
flexDirection: "column",
|
|
867
|
+
justifyContent: "center",
|
|
868
|
+
alignItems: "center",
|
|
869
|
+
height: "100%"
|
|
870
|
+
},
|
|
871
|
+
onClick: fileInputClick,
|
|
872
|
+
ref: fileInput,
|
|
873
|
+
children: [
|
|
874
|
+
/* @__PURE__ */ jsxs10(Typography3, { variant: "body1", align: "center", style: { marginTop: "auto" }, children: [
|
|
875
|
+
"Drag & Drop or Click to Upload Your File Here ",
|
|
876
|
+
/* @__PURE__ */ jsx17("sup", { children: "*" })
|
|
877
|
+
] }),
|
|
878
|
+
/* @__PURE__ */ jsx17(Typography3, { variant: "body2", align: "center", style: { marginTop: "auto", fontSize: "0.8rem", fontStyle: "italic" }, children: "* Warning: The file you are uploading may contain sensitive information protected under privacy laws. Please ensure all PHI is anonymized before proceeding.Before proceeding. The user is the sole responsible for data anonymization." })
|
|
879
|
+
]
|
|
880
|
+
}
|
|
881
|
+
) })
|
|
882
|
+
}
|
|
883
|
+
),
|
|
884
|
+
/* @__PURE__ */ jsx17(
|
|
885
|
+
"input",
|
|
886
|
+
{
|
|
887
|
+
type: "file",
|
|
888
|
+
id: "file-window",
|
|
889
|
+
multiple: true,
|
|
890
|
+
accept: fileExtension == void 0 ? "*" : fileExtension,
|
|
891
|
+
style: { display: "none" },
|
|
892
|
+
onChange: loadSelectedFiles
|
|
893
|
+
}
|
|
894
|
+
),
|
|
895
|
+
/* @__PURE__ */ jsxs10(Box2, { component: "form", sx: { "& .MuiTextField-root": { m: 2, width: "25ch", mb: 0 } }, children: [
|
|
896
|
+
/* @__PURE__ */ jsxs10("div", { children: [
|
|
897
|
+
template.showFileName && /* @__PURE__ */ jsx17(
|
|
898
|
+
TextField4,
|
|
899
|
+
{
|
|
900
|
+
required: true,
|
|
901
|
+
style: { marginTop: "30px" },
|
|
902
|
+
label: `File Alias:`,
|
|
903
|
+
value: fileAlias,
|
|
904
|
+
variant: "standard",
|
|
905
|
+
onChange: changeFileName
|
|
906
|
+
}
|
|
907
|
+
),
|
|
908
|
+
fileOriginalName != "" && /* @__PURE__ */ jsx17(Label_default, { style: { marginLeft: "16px", fontSize: "9pt", color: "#267833" }, children: fileOriginalName }),
|
|
909
|
+
template.showDatabase && /* @__PURE__ */ jsx17(
|
|
910
|
+
TextField4,
|
|
911
|
+
{
|
|
912
|
+
select: true,
|
|
913
|
+
label: "Database:",
|
|
914
|
+
defaultValue: "s3",
|
|
915
|
+
helperText: "Upstream Storage Location",
|
|
916
|
+
variant: "standard",
|
|
917
|
+
children: [{ value: "s3", label: "S3" }].map((option) => /* @__PURE__ */ jsx17(MenuItem2, { value: option.value, children: option.label }, option.value))
|
|
918
|
+
}
|
|
919
|
+
)
|
|
920
|
+
] }),
|
|
921
|
+
/* @__PURE__ */ jsxs10("div", { children: [
|
|
922
|
+
template.showFileSize && /* @__PURE__ */ jsx17(
|
|
923
|
+
TextField4,
|
|
924
|
+
{
|
|
925
|
+
label: "File Size:",
|
|
926
|
+
value: fileSize,
|
|
927
|
+
InputProps: {
|
|
928
|
+
readOnly: true
|
|
929
|
+
},
|
|
930
|
+
variant: "standard"
|
|
931
|
+
}
|
|
932
|
+
),
|
|
933
|
+
/* @__PURE__ */ jsx17(Collapse, { in: infoOpen, children: /* @__PURE__ */ jsx17(Alert, { severity: infoStyle, sx: { m: 1 }, children: warningText }) })
|
|
934
|
+
] })
|
|
935
|
+
] })
|
|
936
|
+
] }),
|
|
929
937
|
/* @__PURE__ */ jsxs10(DialogActions5, { children: [
|
|
930
|
-
|
|
931
|
-
|
|
938
|
+
/* @__PURE__ */ jsx17(
|
|
939
|
+
Button2,
|
|
940
|
+
{
|
|
941
|
+
color: "inherit",
|
|
942
|
+
sx: { color: "#333" },
|
|
943
|
+
disabled: UpBtnDisabled,
|
|
944
|
+
onClick: handleClose,
|
|
945
|
+
children: "Cancel"
|
|
946
|
+
}
|
|
947
|
+
),
|
|
948
|
+
/* @__PURE__ */ jsx17(
|
|
949
|
+
Button2,
|
|
950
|
+
{
|
|
951
|
+
variant: "contained",
|
|
952
|
+
disabled: UpBtnDisabled,
|
|
953
|
+
onClick: handleConfirm,
|
|
954
|
+
children: UpBtnText
|
|
955
|
+
}
|
|
956
|
+
)
|
|
932
957
|
] })
|
|
933
958
|
] })
|
|
934
|
-
] });
|
|
959
|
+
] }) });
|
|
935
960
|
}
|
|
936
961
|
|
|
937
|
-
// src/
|
|
938
|
-
import
|
|
939
|
-
import
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
962
|
+
// src/CmrComponents/upload/Upload.tsx
|
|
963
|
+
import axios from "axios";
|
|
964
|
+
import { jsx as jsx18, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
965
|
+
var CmrUpload = (props) => {
|
|
966
|
+
let [open, setOpen] = useState9(false);
|
|
967
|
+
let [uploading, setUploading] = useState9(false);
|
|
968
|
+
let [progress, setProgress] = useState9(0);
|
|
969
|
+
let [uploadedFile, setUploadedFile] = useState9(void 0);
|
|
970
|
+
const upload = async (file, fileAlias, fileDatabase) => {
|
|
971
|
+
setUploading(true);
|
|
972
|
+
const onProgress = (progress2) => {
|
|
973
|
+
let percentage = progress2 * 99;
|
|
974
|
+
props.uploadProgressed && props.uploadProgressed(+percentage.toFixed(2));
|
|
975
|
+
setProgress(+percentage.toFixed(2));
|
|
976
|
+
};
|
|
977
|
+
if (props.uploadStarted)
|
|
978
|
+
props.uploadStarted();
|
|
979
|
+
let status = 0;
|
|
980
|
+
if (props.beforeUpload != void 0 && !await props.beforeUpload(file)) {
|
|
981
|
+
if (props.uploadEnded)
|
|
982
|
+
props.uploadEnded();
|
|
983
|
+
setUploading(false);
|
|
984
|
+
return 200;
|
|
957
985
|
}
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
}
|
|
966
|
-
|
|
967
|
-
const [value, setValue] = React10.useState(0);
|
|
968
|
-
const handleChange = (event, newValue) => {
|
|
969
|
-
setValue(newValue);
|
|
970
|
-
if (props.onTabSelected)
|
|
971
|
-
props.onTabSelected(newValue);
|
|
972
|
-
};
|
|
973
|
-
return /* @__PURE__ */ jsxs11(
|
|
974
|
-
Container,
|
|
975
|
-
{
|
|
976
|
-
maxWidth: "lg",
|
|
977
|
-
sx: {
|
|
978
|
-
flex: 1,
|
|
979
|
-
display: "flex",
|
|
980
|
-
flexDirection: "column",
|
|
981
|
-
mt: 4
|
|
982
|
-
},
|
|
983
|
-
children: [
|
|
984
|
-
/* @__PURE__ */ jsx15(Box3, { sx: { borderBottom: 1, borderColor: "divider", mb: 4 }, children: /* @__PURE__ */ jsx15(
|
|
985
|
-
Tabs,
|
|
986
|
-
{
|
|
987
|
-
value,
|
|
988
|
-
onChange: handleChange,
|
|
989
|
-
"aria-label": "basic tabs example",
|
|
990
|
-
textColor: "inherit",
|
|
991
|
-
TabIndicatorProps: {
|
|
992
|
-
style: {
|
|
993
|
-
backgroundColor: "#580F8B"
|
|
994
|
-
}
|
|
995
|
-
},
|
|
996
|
-
children: props.tabList.map((tab, index) => /* @__PURE__ */ jsx15(Tab, { sx: { color: value == index ? "#580F8B" : void 0 }, style: { fontSize: "14px", textTransform: "uppercase", fontWeight: 400 }, label: tab.text, ...a11yProps(index) }))
|
|
997
|
-
}
|
|
998
|
-
) }),
|
|
999
|
-
props.tabList.map(
|
|
1000
|
-
(tab, index) => /* @__PURE__ */ jsx15(CustomTabPanel, { value, index, children: cloneElement2(tab.children, {
|
|
1001
|
-
visible: value == index
|
|
1002
|
-
}) })
|
|
1003
|
-
)
|
|
1004
|
-
]
|
|
986
|
+
if (props.preprocess) {
|
|
987
|
+
let processed = await props.preprocess(file);
|
|
988
|
+
if (processed == void 0)
|
|
989
|
+
return failUpload();
|
|
990
|
+
if (typeof processed == "number") {
|
|
991
|
+
setUploading(false);
|
|
992
|
+
return processed;
|
|
993
|
+
}
|
|
994
|
+
file = processed;
|
|
1005
995
|
}
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
996
|
+
if (props.uploadHandler != void 0) {
|
|
997
|
+
status = await props.uploadHandler(file, fileAlias, fileDatabase, onProgress, props.onUploaded);
|
|
998
|
+
setUploadedFile(props.reusable ? void 0 : file.name);
|
|
999
|
+
} else if (props.createPayload) {
|
|
1000
|
+
let payload = await props.createPayload(file, fileAlias, fileDatabase);
|
|
1001
|
+
if (payload == void 0) {
|
|
1002
|
+
return failUpload();
|
|
1003
|
+
}
|
|
1004
|
+
payload.config.onUploadProgress = (progressEvent) => {
|
|
1005
|
+
if (progressEvent.total == void 0)
|
|
1006
|
+
return;
|
|
1007
|
+
onProgress(progressEvent.loaded / progressEvent.total);
|
|
1008
|
+
};
|
|
1009
|
+
const res = await axios.post(payload.destination, payload.lambdaFile, payload.config);
|
|
1010
|
+
status = res.status;
|
|
1011
|
+
if (status === 200) {
|
|
1012
|
+
console.log(res.data);
|
|
1013
|
+
await axios.put(res.data.upload_url, payload.file, {
|
|
1014
|
+
headers: {
|
|
1015
|
+
"Content-Type": payload.file.type
|
|
1016
|
+
}
|
|
1017
|
+
});
|
|
1018
|
+
await props.onUploaded(res, payload.file);
|
|
1019
|
+
setUploadedFile(props.reusable ? void 0 : payload.file.name);
|
|
1020
|
+
}
|
|
1021
|
+
} else {
|
|
1022
|
+
return failUpload();
|
|
1025
1023
|
}
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1024
|
+
if (props.uploadEnded)
|
|
1025
|
+
props.uploadEnded();
|
|
1026
|
+
setUploading(false);
|
|
1027
|
+
setProgress(0);
|
|
1028
|
+
return status;
|
|
1029
|
+
};
|
|
1030
|
+
function failUpload() {
|
|
1031
|
+
setUploading(false);
|
|
1032
|
+
setProgress(0);
|
|
1033
|
+
if (props.uploadFailed)
|
|
1034
|
+
return props.uploadFailed();
|
|
1035
|
+
return 0;
|
|
1036
|
+
}
|
|
1037
|
+
return /* @__PURE__ */ jsxs11(React10.Fragment, { children: [
|
|
1038
|
+
!uploading ? /* @__PURE__ */ jsxs11(
|
|
1039
|
+
Button3,
|
|
1040
|
+
{
|
|
1041
|
+
fullWidth: props.fullWidth,
|
|
1042
|
+
style: props.style,
|
|
1043
|
+
variant: uploadedFile == void 0 ? "contained" : "outlined",
|
|
1044
|
+
onClick: () => {
|
|
1045
|
+
setOpen(true);
|
|
1046
|
+
},
|
|
1047
|
+
color: props.color || "primary",
|
|
1048
|
+
sx: props.sx,
|
|
1049
|
+
children: [
|
|
1050
|
+
props.changeNameAfterUpload ? uploadedFile === void 0 ? props.uploadButtonName ? props.uploadButtonName : "Upload" : uploadedFile : props.uploadButtonName ? props.uploadButtonName : "Upload",
|
|
1051
|
+
" "
|
|
1052
|
+
]
|
|
1053
|
+
}
|
|
1054
|
+
) : /* @__PURE__ */ jsxs11(Button3, { fullWidth: props.fullWidth, style: props.style, variant: "contained", sx: { overflowWrap: "inherit" }, color: "primary", disabled: true, children: [
|
|
1055
|
+
"Uploading ",
|
|
1056
|
+
progress,
|
|
1057
|
+
"%"
|
|
1058
|
+
] }),
|
|
1059
|
+
/* @__PURE__ */ jsx18(
|
|
1060
|
+
CmrUploadWindow,
|
|
1061
|
+
{
|
|
1062
|
+
open,
|
|
1063
|
+
setOpen,
|
|
1064
|
+
upload,
|
|
1065
|
+
fileExtension: props.fileExtension,
|
|
1066
|
+
template: { showFileName: true, showFileSize: true }
|
|
1067
|
+
}
|
|
1068
|
+
)
|
|
1069
|
+
] });
|
|
1036
1070
|
};
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
// src/CmrComponents/tooltip/Tooltip.tsx
|
|
1040
|
-
import { Tooltip } from "antd";
|
|
1041
|
-
import { jsx as jsx18 } from "react/jsx-runtime";
|
|
1042
|
-
var CmrTooltip = (props) => {
|
|
1043
|
-
const {
|
|
1044
|
-
arrowPointAtCenter,
|
|
1045
|
-
autoAdjustOverflow,
|
|
1046
|
-
color,
|
|
1047
|
-
defaultVisible,
|
|
1048
|
-
mouseEnterDelay,
|
|
1049
|
-
mouseLeaveDelay,
|
|
1050
|
-
overlayClassName,
|
|
1051
|
-
placement,
|
|
1052
|
-
visible,
|
|
1053
|
-
...rest
|
|
1054
|
-
} = props;
|
|
1055
|
-
return /* @__PURE__ */ jsx18(
|
|
1056
|
-
Tooltip,
|
|
1057
|
-
{
|
|
1058
|
-
arrowPointAtCenter,
|
|
1059
|
-
autoAdjustOverflow,
|
|
1060
|
-
color,
|
|
1061
|
-
defaultVisible,
|
|
1062
|
-
mouseEnterDelay,
|
|
1063
|
-
mouseLeaveDelay,
|
|
1064
|
-
overlayClassName,
|
|
1065
|
-
placement,
|
|
1066
|
-
visible,
|
|
1067
|
-
...rest
|
|
1068
|
-
}
|
|
1069
|
-
);
|
|
1071
|
+
CmrUpload.defaultProps = {
|
|
1072
|
+
changeNameAfterUpload: true
|
|
1070
1073
|
};
|
|
1071
|
-
var
|
|
1074
|
+
var Upload_default = CmrUpload;
|
|
1072
1075
|
|
|
1073
1076
|
// src/CmrComponents/select-upload/SelectUpload.tsx
|
|
1074
|
-
import React11, { Fragment } from "react";
|
|
1075
1077
|
import { Button as Button4, MenuItem as MenuItem3 } from "@mui/material";
|
|
1076
1078
|
import Select2 from "@mui/material/Select";
|
|
1077
1079
|
import Dialog6 from "@mui/material/Dialog";
|
|
@@ -1118,7 +1120,7 @@ var CMRSelectUpload = (props) => {
|
|
|
1118
1120
|
}
|
|
1119
1121
|
) }),
|
|
1120
1122
|
/* @__PURE__ */ jsxs12(Box4, { sx: { pt: 2, justifyContent: "center", display: "flex", padding: "8px" }, children: [
|
|
1121
|
-
/* @__PURE__ */ jsx19(Button4, { fullWidth: true, variant: "outlined",
|
|
1123
|
+
/* @__PURE__ */ jsx19(Button4, { fullWidth: true, variant: "outlined", sx: { marginRight: "8px" }, onClick: handleClose, children: "Cancel" }),
|
|
1122
1124
|
fileIndex !== -1 && !uploading && /* @__PURE__ */ jsx19(Button4, { fullWidth: true, sx: { marginLeft: "8px" }, variant: "contained", onClick: onSet, children: "OK" }),
|
|
1123
1125
|
fileIndex == -1 && /* @__PURE__ */ jsx19(
|
|
1124
1126
|
Upload_default,
|
|
@@ -1226,5 +1228,6 @@ export {
|
|
|
1226
1228
|
CmrSelect_default as CmrSelect,
|
|
1227
1229
|
CmrTable2 as CmrTable,
|
|
1228
1230
|
CmrTabs,
|
|
1229
|
-
Tooltip_default as CmrTooltip
|
|
1231
|
+
Tooltip_default as CmrTooltip,
|
|
1232
|
+
CmrUploadWindow
|
|
1230
1233
|
};
|