@sparkstudio/storage-ui 1.0.26 → 1.0.27
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.cjs +108 -71
- package/dist/index.d.cts +8 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +108 -71
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1066,25 +1066,71 @@ var ContainerUploadPanel = ({
|
|
|
1066
1066
|
// src/components/SingleFileProcessUploader.tsx
|
|
1067
1067
|
var import_react8 = require("react");
|
|
1068
1068
|
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
1069
|
-
var SingleFileProcessUploader = ({
|
|
1069
|
+
var SingleFileProcessUploader = ({
|
|
1070
|
+
getPresignedUrl,
|
|
1071
|
+
onUploadComplete,
|
|
1072
|
+
onUploadFailed,
|
|
1073
|
+
accept,
|
|
1074
|
+
disabled,
|
|
1075
|
+
uploadOnDrop = false
|
|
1076
|
+
}) => {
|
|
1070
1077
|
const [selectedFile, setSelectedFile] = (0, import_react8.useState)(null);
|
|
1071
1078
|
const [isDragging, setIsDragging] = (0, import_react8.useState)(false);
|
|
1072
1079
|
const [progress, setProgress] = (0, import_react8.useState)(null);
|
|
1073
1080
|
const [status, setStatus] = (0, import_react8.useState)("idle");
|
|
1074
|
-
const [errorMessage, setErrorMessage] = (0, import_react8.useState)(null);
|
|
1075
1081
|
const fileInputRef = (0, import_react8.useRef)(null);
|
|
1076
|
-
|
|
1077
|
-
if (
|
|
1078
|
-
|
|
1082
|
+
function getErrorMessage(err) {
|
|
1083
|
+
if (err instanceof Error) return err.message;
|
|
1084
|
+
if (typeof err === "string") return err;
|
|
1085
|
+
return "Unknown error during upload.";
|
|
1086
|
+
}
|
|
1087
|
+
const isUploading = status === "uploading";
|
|
1088
|
+
const resetUiForNewFile = (0, import_react8.useCallback)((file) => {
|
|
1079
1089
|
setSelectedFile(file);
|
|
1080
1090
|
setStatus("idle");
|
|
1081
1091
|
setProgress(null);
|
|
1082
|
-
setErrorMessage(null);
|
|
1083
1092
|
}, []);
|
|
1084
|
-
const handleBrowseClick = () => {
|
|
1093
|
+
const handleBrowseClick = (0, import_react8.useCallback)(() => {
|
|
1085
1094
|
if (disabled) return;
|
|
1095
|
+
if (isUploading) return;
|
|
1086
1096
|
fileInputRef.current?.click();
|
|
1087
|
-
};
|
|
1097
|
+
}, [disabled, isUploading]);
|
|
1098
|
+
const startUpload = (0, import_react8.useCallback)(
|
|
1099
|
+
async (file) => {
|
|
1100
|
+
if (disabled) return;
|
|
1101
|
+
if (isUploading) return;
|
|
1102
|
+
try {
|
|
1103
|
+
setStatus("uploading");
|
|
1104
|
+
setProgress(0);
|
|
1105
|
+
const presignedUrl = await getPresignedUrl(file);
|
|
1106
|
+
await UploadFileToS3(
|
|
1107
|
+
file,
|
|
1108
|
+
presignedUrl?.PresignedUrl ?? "",
|
|
1109
|
+
(p) => setProgress(p)
|
|
1110
|
+
);
|
|
1111
|
+
setStatus("success");
|
|
1112
|
+
onUploadComplete?.(file, presignedUrl);
|
|
1113
|
+
} catch (err) {
|
|
1114
|
+
const message = getErrorMessage(err);
|
|
1115
|
+
console.error("Upload failed:", message);
|
|
1116
|
+
setStatus("error");
|
|
1117
|
+
onUploadFailed?.({ file, message, error: err });
|
|
1118
|
+
}
|
|
1119
|
+
},
|
|
1120
|
+
[disabled, getPresignedUrl, isUploading, onUploadComplete, onUploadFailed]
|
|
1121
|
+
);
|
|
1122
|
+
const handleFilesSelected = (0, import_react8.useCallback)(
|
|
1123
|
+
(files) => {
|
|
1124
|
+
if (!files || files.length === 0) return;
|
|
1125
|
+
if (disabled) return;
|
|
1126
|
+
const file = files[0];
|
|
1127
|
+
resetUiForNewFile(file);
|
|
1128
|
+
if (uploadOnDrop) {
|
|
1129
|
+
void startUpload(file);
|
|
1130
|
+
}
|
|
1131
|
+
},
|
|
1132
|
+
[disabled, resetUiForNewFile, startUpload, uploadOnDrop]
|
|
1133
|
+
);
|
|
1088
1134
|
const handleInputChange = (e) => {
|
|
1089
1135
|
handleFilesSelected(e.target.files);
|
|
1090
1136
|
e.target.value = "";
|
|
@@ -1102,36 +1148,12 @@ var SingleFileProcessUploader = ({ getPresignedUrl, onUploadComplete, accept, di
|
|
|
1102
1148
|
e.preventDefault();
|
|
1103
1149
|
if (disabled) return;
|
|
1104
1150
|
setIsDragging(false);
|
|
1105
|
-
|
|
1106
|
-
handleFilesSelected(files);
|
|
1151
|
+
handleFilesSelected(e.dataTransfer.files);
|
|
1107
1152
|
};
|
|
1108
1153
|
const handleProcessClick = async () => {
|
|
1109
1154
|
if (!selectedFile || disabled) return;
|
|
1110
|
-
|
|
1111
|
-
setStatus("uploading");
|
|
1112
|
-
setProgress(0);
|
|
1113
|
-
setErrorMessage(null);
|
|
1114
|
-
const presignedUrl = await getPresignedUrl(selectedFile);
|
|
1115
|
-
await UploadFileToS3(
|
|
1116
|
-
selectedFile,
|
|
1117
|
-
presignedUrl?.PresignedUrl ?? "",
|
|
1118
|
-
(p) => setProgress(p)
|
|
1119
|
-
);
|
|
1120
|
-
setStatus("success");
|
|
1121
|
-
onUploadComplete?.(selectedFile, presignedUrl);
|
|
1122
|
-
} catch (err) {
|
|
1123
|
-
const message = getErrorMessage(err);
|
|
1124
|
-
console.error("Upload failed:", message);
|
|
1125
|
-
setStatus("error");
|
|
1126
|
-
setErrorMessage(message);
|
|
1127
|
-
}
|
|
1155
|
+
await startUpload(selectedFile);
|
|
1128
1156
|
};
|
|
1129
|
-
function getErrorMessage(err) {
|
|
1130
|
-
if (err instanceof Error) return err.message;
|
|
1131
|
-
if (typeof err === "string") return err;
|
|
1132
|
-
return "Unknown error during upload.";
|
|
1133
|
-
}
|
|
1134
|
-
const isUploading = status === "uploading";
|
|
1135
1157
|
const dropzoneClasses = [
|
|
1136
1158
|
"border",
|
|
1137
1159
|
"border-2",
|
|
@@ -1140,10 +1162,33 @@ var SingleFileProcessUploader = ({ getPresignedUrl, onUploadComplete, accept, di
|
|
|
1140
1162
|
"text-center",
|
|
1141
1163
|
"user-select-none",
|
|
1142
1164
|
disabled ? "opacity-50" : "cursor-pointer",
|
|
1143
|
-
isDragging ? "bg-body-secondary border-dashed border-2 border-secondary" : "bg-body-trasparent border-
|
|
1165
|
+
isDragging ? "bg-body-secondary border-dashed border-2 border-secondary" : "bg-body-trasparent border-dashed border-2"
|
|
1144
1166
|
].join(" ");
|
|
1145
1167
|
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "d-flex flex-column gap-2", children: [
|
|
1146
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
|
|
1168
|
+
isUploading ? /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "small", children: [
|
|
1169
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "d-flex justify-content-between mb-1", children: [
|
|
1170
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("span", { children: [
|
|
1171
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "spinner-border spinner-border-sm text-primary" }),
|
|
1172
|
+
" ",
|
|
1173
|
+
"Uploading..."
|
|
1174
|
+
] }),
|
|
1175
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("span", { children: [
|
|
1176
|
+
progress ?? 0,
|
|
1177
|
+
"%"
|
|
1178
|
+
] })
|
|
1179
|
+
] }),
|
|
1180
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "progress", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1181
|
+
"div",
|
|
1182
|
+
{
|
|
1183
|
+
className: "progress-bar progress-bar-striped progress-bar-animated",
|
|
1184
|
+
role: "progressbar",
|
|
1185
|
+
"aria-valuemin": 0,
|
|
1186
|
+
"aria-valuemax": 100,
|
|
1187
|
+
"aria-valuenow": progress ?? 0,
|
|
1188
|
+
style: { width: `${progress ?? 0}%` }
|
|
1189
|
+
}
|
|
1190
|
+
) })
|
|
1191
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
|
|
1147
1192
|
"div",
|
|
1148
1193
|
{
|
|
1149
1194
|
className: dropzoneClasses,
|
|
@@ -1162,52 +1207,43 @@ var SingleFileProcessUploader = ({ getPresignedUrl, onUploadComplete, accept, di
|
|
|
1162
1207
|
accept,
|
|
1163
1208
|
className: "d-none",
|
|
1164
1209
|
onChange: handleInputChange,
|
|
1165
|
-
disabled
|
|
1210
|
+
disabled: disabled || isUploading
|
|
1166
1211
|
}
|
|
1167
1212
|
),
|
|
1168
1213
|
selectedFile ? /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "small", children: [
|
|
1214
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1215
|
+
"button",
|
|
1216
|
+
{
|
|
1217
|
+
type: "button",
|
|
1218
|
+
className: "btn btn-primary align-self-start",
|
|
1219
|
+
disabled: disabled || isUploading,
|
|
1220
|
+
children: "Browse file\u2026"
|
|
1221
|
+
}
|
|
1222
|
+
),
|
|
1169
1223
|
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { children: [
|
|
1170
1224
|
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("strong", { children: "Selected file:" }),
|
|
1171
1225
|
" ",
|
|
1172
1226
|
selectedFile.name
|
|
1173
1227
|
] }),
|
|
1174
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "text-muted", children: "Click here to change file or drag a new one." })
|
|
1228
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "text-muted", children: "Click here to change file or drag a new one." }),
|
|
1229
|
+
uploadOnDrop && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "text-muted", children: "Upload starts automatically." })
|
|
1175
1230
|
] }) : /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "small", children: [
|
|
1231
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1232
|
+
"button",
|
|
1233
|
+
{
|
|
1234
|
+
type: "button",
|
|
1235
|
+
className: "btn btn-primary align-self-start",
|
|
1236
|
+
disabled: disabled || isUploading,
|
|
1237
|
+
children: "Browse file\u2026"
|
|
1238
|
+
}
|
|
1239
|
+
),
|
|
1176
1240
|
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { children: "Drag & drop a file here" }),
|
|
1177
1241
|
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "text-muted", children: "or click to browse" })
|
|
1178
1242
|
] })
|
|
1179
1243
|
]
|
|
1180
1244
|
}
|
|
1181
1245
|
),
|
|
1182
|
-
|
|
1183
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "d-flex justify-content-between mb-1", children: [
|
|
1184
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("span", { children: [
|
|
1185
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "spinner-border spinner-border-sm text-primary" }),
|
|
1186
|
-
" Uploading..."
|
|
1187
|
-
] }),
|
|
1188
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("span", { children: [
|
|
1189
|
-
progress ?? 0,
|
|
1190
|
-
"%"
|
|
1191
|
-
] })
|
|
1192
|
-
] }),
|
|
1193
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "progress", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1194
|
-
"div",
|
|
1195
|
-
{
|
|
1196
|
-
className: "progress-bar progress-bar-striped progress-bar-animated",
|
|
1197
|
-
role: "progressbar",
|
|
1198
|
-
"aria-valuemin": 0,
|
|
1199
|
-
"aria-valuemax": 100,
|
|
1200
|
-
"aria-valuenow": progress ?? 0,
|
|
1201
|
-
style: { width: `${progress ?? 0}%` }
|
|
1202
|
-
}
|
|
1203
|
-
) })
|
|
1204
|
-
] }),
|
|
1205
|
-
status === "success" && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "small text-success", children: "Upload complete \u2705" }),
|
|
1206
|
-
status === "error" && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "small text-danger", children: [
|
|
1207
|
-
"Upload failed: ",
|
|
1208
|
-
errorMessage
|
|
1209
|
-
] }),
|
|
1210
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1246
|
+
!uploadOnDrop && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1211
1247
|
"button",
|
|
1212
1248
|
{
|
|
1213
1249
|
type: "button",
|
|
@@ -1238,8 +1274,8 @@ function HomeContent() {
|
|
|
1238
1274
|
const { user } = (0, import_authentication_ui.useUser)();
|
|
1239
1275
|
async function getPresignedUrlFromApi(file) {
|
|
1240
1276
|
const res = new SparkStudioStorageSDK(
|
|
1241
|
-
|
|
1242
|
-
"https://localhost:5001"
|
|
1277
|
+
"https://iq0gmcn0pd.execute-api.us-east-2.amazonaws.com/Prod"
|
|
1278
|
+
//"https://localhost:5001"
|
|
1243
1279
|
);
|
|
1244
1280
|
const contentType = file.type || "application/octet-stream";
|
|
1245
1281
|
const result = await res.s3.GetTemporaryPreSignedUrl(new TemporaryFileDTO({ Name: file.name, ContentType: contentType }));
|
|
@@ -1251,6 +1287,7 @@ function HomeContent() {
|
|
|
1251
1287
|
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
1252
1288
|
SingleFileProcessUploader,
|
|
1253
1289
|
{
|
|
1290
|
+
uploadOnDrop: true,
|
|
1254
1291
|
accept: "*/*",
|
|
1255
1292
|
getPresignedUrl: getPresignedUrlFromApi,
|
|
1256
1293
|
onUploadComplete: (file, s3Url) => {
|
|
@@ -1261,8 +1298,8 @@ function HomeContent() {
|
|
|
1261
1298
|
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
1262
1299
|
ContainerUploadPanel,
|
|
1263
1300
|
{
|
|
1264
|
-
containerApiBaseUrl: "https://
|
|
1265
|
-
storageApiBaseUrl: "https://
|
|
1301
|
+
containerApiBaseUrl: "https://lf9zyufpuk.execute-api.us-east-2.amazonaws.com/Prod",
|
|
1302
|
+
storageApiBaseUrl: "https://iq0gmcn0pd.execute-api.us-east-2.amazonaws.com/Prod"
|
|
1266
1303
|
}
|
|
1267
1304
|
)
|
|
1268
1305
|
] })
|
package/dist/index.d.cts
CHANGED
|
@@ -134,8 +134,16 @@ declare const DesktopFileIcon: React__default.FC<DesktopFileIconProps>;
|
|
|
134
134
|
interface SingleFileProcessUploaderProps {
|
|
135
135
|
getPresignedUrl: (file: File) => Promise<AWSPresignedUrlDTO>;
|
|
136
136
|
onUploadComplete?: (file: File, s3Url: AWSPresignedUrlDTO) => void;
|
|
137
|
+
/** NEW: send errors outward instead of rendering them */
|
|
138
|
+
onUploadFailed?: (args: {
|
|
139
|
+
file: File;
|
|
140
|
+
message: string;
|
|
141
|
+
error: unknown;
|
|
142
|
+
}) => void;
|
|
137
143
|
accept?: string;
|
|
138
144
|
disabled?: boolean;
|
|
145
|
+
/** if true, auto-start upload immediately after drop/select */
|
|
146
|
+
uploadOnDrop?: boolean;
|
|
139
147
|
}
|
|
140
148
|
declare const SingleFileProcessUploader: React__default.FC<SingleFileProcessUploaderProps>;
|
|
141
149
|
|
package/dist/index.d.ts
CHANGED
|
@@ -134,8 +134,16 @@ declare const DesktopFileIcon: React__default.FC<DesktopFileIconProps>;
|
|
|
134
134
|
interface SingleFileProcessUploaderProps {
|
|
135
135
|
getPresignedUrl: (file: File) => Promise<AWSPresignedUrlDTO>;
|
|
136
136
|
onUploadComplete?: (file: File, s3Url: AWSPresignedUrlDTO) => void;
|
|
137
|
+
/** NEW: send errors outward instead of rendering them */
|
|
138
|
+
onUploadFailed?: (args: {
|
|
139
|
+
file: File;
|
|
140
|
+
message: string;
|
|
141
|
+
error: unknown;
|
|
142
|
+
}) => void;
|
|
137
143
|
accept?: string;
|
|
138
144
|
disabled?: boolean;
|
|
145
|
+
/** if true, auto-start upload immediately after drop/select */
|
|
146
|
+
uploadOnDrop?: boolean;
|
|
139
147
|
}
|
|
140
148
|
declare const SingleFileProcessUploader: React__default.FC<SingleFileProcessUploaderProps>;
|
|
141
149
|
|
package/dist/index.js
CHANGED
|
@@ -1033,25 +1033,71 @@ var ContainerUploadPanel = ({
|
|
|
1033
1033
|
// src/components/SingleFileProcessUploader.tsx
|
|
1034
1034
|
import { useCallback as useCallback2, useRef as useRef2, useState as useState5 } from "react";
|
|
1035
1035
|
import { jsx as jsx6, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
1036
|
-
var SingleFileProcessUploader = ({
|
|
1036
|
+
var SingleFileProcessUploader = ({
|
|
1037
|
+
getPresignedUrl,
|
|
1038
|
+
onUploadComplete,
|
|
1039
|
+
onUploadFailed,
|
|
1040
|
+
accept,
|
|
1041
|
+
disabled,
|
|
1042
|
+
uploadOnDrop = false
|
|
1043
|
+
}) => {
|
|
1037
1044
|
const [selectedFile, setSelectedFile] = useState5(null);
|
|
1038
1045
|
const [isDragging, setIsDragging] = useState5(false);
|
|
1039
1046
|
const [progress, setProgress] = useState5(null);
|
|
1040
1047
|
const [status, setStatus] = useState5("idle");
|
|
1041
|
-
const [errorMessage, setErrorMessage] = useState5(null);
|
|
1042
1048
|
const fileInputRef = useRef2(null);
|
|
1043
|
-
|
|
1044
|
-
if (
|
|
1045
|
-
|
|
1049
|
+
function getErrorMessage(err) {
|
|
1050
|
+
if (err instanceof Error) return err.message;
|
|
1051
|
+
if (typeof err === "string") return err;
|
|
1052
|
+
return "Unknown error during upload.";
|
|
1053
|
+
}
|
|
1054
|
+
const isUploading = status === "uploading";
|
|
1055
|
+
const resetUiForNewFile = useCallback2((file) => {
|
|
1046
1056
|
setSelectedFile(file);
|
|
1047
1057
|
setStatus("idle");
|
|
1048
1058
|
setProgress(null);
|
|
1049
|
-
setErrorMessage(null);
|
|
1050
1059
|
}, []);
|
|
1051
|
-
const handleBrowseClick = () => {
|
|
1060
|
+
const handleBrowseClick = useCallback2(() => {
|
|
1052
1061
|
if (disabled) return;
|
|
1062
|
+
if (isUploading) return;
|
|
1053
1063
|
fileInputRef.current?.click();
|
|
1054
|
-
};
|
|
1064
|
+
}, [disabled, isUploading]);
|
|
1065
|
+
const startUpload = useCallback2(
|
|
1066
|
+
async (file) => {
|
|
1067
|
+
if (disabled) return;
|
|
1068
|
+
if (isUploading) return;
|
|
1069
|
+
try {
|
|
1070
|
+
setStatus("uploading");
|
|
1071
|
+
setProgress(0);
|
|
1072
|
+
const presignedUrl = await getPresignedUrl(file);
|
|
1073
|
+
await UploadFileToS3(
|
|
1074
|
+
file,
|
|
1075
|
+
presignedUrl?.PresignedUrl ?? "",
|
|
1076
|
+
(p) => setProgress(p)
|
|
1077
|
+
);
|
|
1078
|
+
setStatus("success");
|
|
1079
|
+
onUploadComplete?.(file, presignedUrl);
|
|
1080
|
+
} catch (err) {
|
|
1081
|
+
const message = getErrorMessage(err);
|
|
1082
|
+
console.error("Upload failed:", message);
|
|
1083
|
+
setStatus("error");
|
|
1084
|
+
onUploadFailed?.({ file, message, error: err });
|
|
1085
|
+
}
|
|
1086
|
+
},
|
|
1087
|
+
[disabled, getPresignedUrl, isUploading, onUploadComplete, onUploadFailed]
|
|
1088
|
+
);
|
|
1089
|
+
const handleFilesSelected = useCallback2(
|
|
1090
|
+
(files) => {
|
|
1091
|
+
if (!files || files.length === 0) return;
|
|
1092
|
+
if (disabled) return;
|
|
1093
|
+
const file = files[0];
|
|
1094
|
+
resetUiForNewFile(file);
|
|
1095
|
+
if (uploadOnDrop) {
|
|
1096
|
+
void startUpload(file);
|
|
1097
|
+
}
|
|
1098
|
+
},
|
|
1099
|
+
[disabled, resetUiForNewFile, startUpload, uploadOnDrop]
|
|
1100
|
+
);
|
|
1055
1101
|
const handleInputChange = (e) => {
|
|
1056
1102
|
handleFilesSelected(e.target.files);
|
|
1057
1103
|
e.target.value = "";
|
|
@@ -1069,36 +1115,12 @@ var SingleFileProcessUploader = ({ getPresignedUrl, onUploadComplete, accept, di
|
|
|
1069
1115
|
e.preventDefault();
|
|
1070
1116
|
if (disabled) return;
|
|
1071
1117
|
setIsDragging(false);
|
|
1072
|
-
|
|
1073
|
-
handleFilesSelected(files);
|
|
1118
|
+
handleFilesSelected(e.dataTransfer.files);
|
|
1074
1119
|
};
|
|
1075
1120
|
const handleProcessClick = async () => {
|
|
1076
1121
|
if (!selectedFile || disabled) return;
|
|
1077
|
-
|
|
1078
|
-
setStatus("uploading");
|
|
1079
|
-
setProgress(0);
|
|
1080
|
-
setErrorMessage(null);
|
|
1081
|
-
const presignedUrl = await getPresignedUrl(selectedFile);
|
|
1082
|
-
await UploadFileToS3(
|
|
1083
|
-
selectedFile,
|
|
1084
|
-
presignedUrl?.PresignedUrl ?? "",
|
|
1085
|
-
(p) => setProgress(p)
|
|
1086
|
-
);
|
|
1087
|
-
setStatus("success");
|
|
1088
|
-
onUploadComplete?.(selectedFile, presignedUrl);
|
|
1089
|
-
} catch (err) {
|
|
1090
|
-
const message = getErrorMessage(err);
|
|
1091
|
-
console.error("Upload failed:", message);
|
|
1092
|
-
setStatus("error");
|
|
1093
|
-
setErrorMessage(message);
|
|
1094
|
-
}
|
|
1122
|
+
await startUpload(selectedFile);
|
|
1095
1123
|
};
|
|
1096
|
-
function getErrorMessage(err) {
|
|
1097
|
-
if (err instanceof Error) return err.message;
|
|
1098
|
-
if (typeof err === "string") return err;
|
|
1099
|
-
return "Unknown error during upload.";
|
|
1100
|
-
}
|
|
1101
|
-
const isUploading = status === "uploading";
|
|
1102
1124
|
const dropzoneClasses = [
|
|
1103
1125
|
"border",
|
|
1104
1126
|
"border-2",
|
|
@@ -1107,10 +1129,33 @@ var SingleFileProcessUploader = ({ getPresignedUrl, onUploadComplete, accept, di
|
|
|
1107
1129
|
"text-center",
|
|
1108
1130
|
"user-select-none",
|
|
1109
1131
|
disabled ? "opacity-50" : "cursor-pointer",
|
|
1110
|
-
isDragging ? "bg-body-secondary border-dashed border-2 border-secondary" : "bg-body-trasparent border-
|
|
1132
|
+
isDragging ? "bg-body-secondary border-dashed border-2 border-secondary" : "bg-body-trasparent border-dashed border-2"
|
|
1111
1133
|
].join(" ");
|
|
1112
1134
|
return /* @__PURE__ */ jsxs4("div", { className: "d-flex flex-column gap-2", children: [
|
|
1113
|
-
/* @__PURE__ */ jsxs4(
|
|
1135
|
+
isUploading ? /* @__PURE__ */ jsxs4("div", { className: "small", children: [
|
|
1136
|
+
/* @__PURE__ */ jsxs4("div", { className: "d-flex justify-content-between mb-1", children: [
|
|
1137
|
+
/* @__PURE__ */ jsxs4("span", { children: [
|
|
1138
|
+
/* @__PURE__ */ jsx6("div", { className: "spinner-border spinner-border-sm text-primary" }),
|
|
1139
|
+
" ",
|
|
1140
|
+
"Uploading..."
|
|
1141
|
+
] }),
|
|
1142
|
+
/* @__PURE__ */ jsxs4("span", { children: [
|
|
1143
|
+
progress ?? 0,
|
|
1144
|
+
"%"
|
|
1145
|
+
] })
|
|
1146
|
+
] }),
|
|
1147
|
+
/* @__PURE__ */ jsx6("div", { className: "progress", children: /* @__PURE__ */ jsx6(
|
|
1148
|
+
"div",
|
|
1149
|
+
{
|
|
1150
|
+
className: "progress-bar progress-bar-striped progress-bar-animated",
|
|
1151
|
+
role: "progressbar",
|
|
1152
|
+
"aria-valuemin": 0,
|
|
1153
|
+
"aria-valuemax": 100,
|
|
1154
|
+
"aria-valuenow": progress ?? 0,
|
|
1155
|
+
style: { width: `${progress ?? 0}%` }
|
|
1156
|
+
}
|
|
1157
|
+
) })
|
|
1158
|
+
] }) : /* @__PURE__ */ jsxs4(
|
|
1114
1159
|
"div",
|
|
1115
1160
|
{
|
|
1116
1161
|
className: dropzoneClasses,
|
|
@@ -1129,52 +1174,43 @@ var SingleFileProcessUploader = ({ getPresignedUrl, onUploadComplete, accept, di
|
|
|
1129
1174
|
accept,
|
|
1130
1175
|
className: "d-none",
|
|
1131
1176
|
onChange: handleInputChange,
|
|
1132
|
-
disabled
|
|
1177
|
+
disabled: disabled || isUploading
|
|
1133
1178
|
}
|
|
1134
1179
|
),
|
|
1135
1180
|
selectedFile ? /* @__PURE__ */ jsxs4("div", { className: "small", children: [
|
|
1181
|
+
/* @__PURE__ */ jsx6(
|
|
1182
|
+
"button",
|
|
1183
|
+
{
|
|
1184
|
+
type: "button",
|
|
1185
|
+
className: "btn btn-primary align-self-start",
|
|
1186
|
+
disabled: disabled || isUploading,
|
|
1187
|
+
children: "Browse file\u2026"
|
|
1188
|
+
}
|
|
1189
|
+
),
|
|
1136
1190
|
/* @__PURE__ */ jsxs4("div", { children: [
|
|
1137
1191
|
/* @__PURE__ */ jsx6("strong", { children: "Selected file:" }),
|
|
1138
1192
|
" ",
|
|
1139
1193
|
selectedFile.name
|
|
1140
1194
|
] }),
|
|
1141
|
-
/* @__PURE__ */ jsx6("div", { className: "text-muted", children: "Click here to change file or drag a new one." })
|
|
1195
|
+
/* @__PURE__ */ jsx6("div", { className: "text-muted", children: "Click here to change file or drag a new one." }),
|
|
1196
|
+
uploadOnDrop && /* @__PURE__ */ jsx6("div", { className: "text-muted", children: "Upload starts automatically." })
|
|
1142
1197
|
] }) : /* @__PURE__ */ jsxs4("div", { className: "small", children: [
|
|
1198
|
+
/* @__PURE__ */ jsx6(
|
|
1199
|
+
"button",
|
|
1200
|
+
{
|
|
1201
|
+
type: "button",
|
|
1202
|
+
className: "btn btn-primary align-self-start",
|
|
1203
|
+
disabled: disabled || isUploading,
|
|
1204
|
+
children: "Browse file\u2026"
|
|
1205
|
+
}
|
|
1206
|
+
),
|
|
1143
1207
|
/* @__PURE__ */ jsx6("div", { children: "Drag & drop a file here" }),
|
|
1144
1208
|
/* @__PURE__ */ jsx6("div", { className: "text-muted", children: "or click to browse" })
|
|
1145
1209
|
] })
|
|
1146
1210
|
]
|
|
1147
1211
|
}
|
|
1148
1212
|
),
|
|
1149
|
-
|
|
1150
|
-
/* @__PURE__ */ jsxs4("div", { className: "d-flex justify-content-between mb-1", children: [
|
|
1151
|
-
/* @__PURE__ */ jsxs4("span", { children: [
|
|
1152
|
-
/* @__PURE__ */ jsx6("div", { className: "spinner-border spinner-border-sm text-primary" }),
|
|
1153
|
-
" Uploading..."
|
|
1154
|
-
] }),
|
|
1155
|
-
/* @__PURE__ */ jsxs4("span", { children: [
|
|
1156
|
-
progress ?? 0,
|
|
1157
|
-
"%"
|
|
1158
|
-
] })
|
|
1159
|
-
] }),
|
|
1160
|
-
/* @__PURE__ */ jsx6("div", { className: "progress", children: /* @__PURE__ */ jsx6(
|
|
1161
|
-
"div",
|
|
1162
|
-
{
|
|
1163
|
-
className: "progress-bar progress-bar-striped progress-bar-animated",
|
|
1164
|
-
role: "progressbar",
|
|
1165
|
-
"aria-valuemin": 0,
|
|
1166
|
-
"aria-valuemax": 100,
|
|
1167
|
-
"aria-valuenow": progress ?? 0,
|
|
1168
|
-
style: { width: `${progress ?? 0}%` }
|
|
1169
|
-
}
|
|
1170
|
-
) })
|
|
1171
|
-
] }),
|
|
1172
|
-
status === "success" && /* @__PURE__ */ jsx6("div", { className: "small text-success", children: "Upload complete \u2705" }),
|
|
1173
|
-
status === "error" && /* @__PURE__ */ jsxs4("div", { className: "small text-danger", children: [
|
|
1174
|
-
"Upload failed: ",
|
|
1175
|
-
errorMessage
|
|
1176
|
-
] }),
|
|
1177
|
-
/* @__PURE__ */ jsx6(
|
|
1213
|
+
!uploadOnDrop && /* @__PURE__ */ jsx6(
|
|
1178
1214
|
"button",
|
|
1179
1215
|
{
|
|
1180
1216
|
type: "button",
|
|
@@ -1210,8 +1246,8 @@ function HomeContent() {
|
|
|
1210
1246
|
const { user } = useUser();
|
|
1211
1247
|
async function getPresignedUrlFromApi(file) {
|
|
1212
1248
|
const res = new SparkStudioStorageSDK(
|
|
1213
|
-
|
|
1214
|
-
"https://localhost:5001"
|
|
1249
|
+
"https://iq0gmcn0pd.execute-api.us-east-2.amazonaws.com/Prod"
|
|
1250
|
+
//"https://localhost:5001"
|
|
1215
1251
|
);
|
|
1216
1252
|
const contentType = file.type || "application/octet-stream";
|
|
1217
1253
|
const result = await res.s3.GetTemporaryPreSignedUrl(new TemporaryFileDTO({ Name: file.name, ContentType: contentType }));
|
|
@@ -1223,6 +1259,7 @@ function HomeContent() {
|
|
|
1223
1259
|
/* @__PURE__ */ jsx7(
|
|
1224
1260
|
SingleFileProcessUploader,
|
|
1225
1261
|
{
|
|
1262
|
+
uploadOnDrop: true,
|
|
1226
1263
|
accept: "*/*",
|
|
1227
1264
|
getPresignedUrl: getPresignedUrlFromApi,
|
|
1228
1265
|
onUploadComplete: (file, s3Url) => {
|
|
@@ -1233,8 +1270,8 @@ function HomeContent() {
|
|
|
1233
1270
|
/* @__PURE__ */ jsx7(
|
|
1234
1271
|
ContainerUploadPanel,
|
|
1235
1272
|
{
|
|
1236
|
-
containerApiBaseUrl: "https://
|
|
1237
|
-
storageApiBaseUrl: "https://
|
|
1273
|
+
containerApiBaseUrl: "https://lf9zyufpuk.execute-api.us-east-2.amazonaws.com/Prod",
|
|
1274
|
+
storageApiBaseUrl: "https://iq0gmcn0pd.execute-api.us-east-2.amazonaws.com/Prod"
|
|
1238
1275
|
}
|
|
1239
1276
|
)
|
|
1240
1277
|
] })
|