@sparkstudio/storage-ui 1.0.26 → 1.0.28
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 +95 -71
- package/dist/index.d.cts +8 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +95 -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,20 @@ 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.
|
|
1168
|
+
isUploading ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "small", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "progress", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1169
|
+
"div",
|
|
1170
|
+
{
|
|
1171
|
+
className: "progress-bar progress-bar-striped progress-bar-animated",
|
|
1172
|
+
role: "progressbar",
|
|
1173
|
+
"aria-valuemin": 0,
|
|
1174
|
+
"aria-valuemax": 100,
|
|
1175
|
+
"aria-valuenow": progress ?? 0,
|
|
1176
|
+
style: { width: `${progress ?? 0}%` }
|
|
1177
|
+
}
|
|
1178
|
+
) }) }) : /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
|
|
1147
1179
|
"div",
|
|
1148
1180
|
{
|
|
1149
1181
|
className: dropzoneClasses,
|
|
@@ -1162,52 +1194,43 @@ var SingleFileProcessUploader = ({ getPresignedUrl, onUploadComplete, accept, di
|
|
|
1162
1194
|
accept,
|
|
1163
1195
|
className: "d-none",
|
|
1164
1196
|
onChange: handleInputChange,
|
|
1165
|
-
disabled
|
|
1197
|
+
disabled: disabled || isUploading
|
|
1166
1198
|
}
|
|
1167
1199
|
),
|
|
1168
1200
|
selectedFile ? /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "small", children: [
|
|
1201
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1202
|
+
"button",
|
|
1203
|
+
{
|
|
1204
|
+
type: "button",
|
|
1205
|
+
className: "btn btn-primary align-self-start",
|
|
1206
|
+
disabled: disabled || isUploading,
|
|
1207
|
+
children: "Browse file\u2026"
|
|
1208
|
+
}
|
|
1209
|
+
),
|
|
1169
1210
|
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { children: [
|
|
1170
1211
|
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("strong", { children: "Selected file:" }),
|
|
1171
1212
|
" ",
|
|
1172
1213
|
selectedFile.name
|
|
1173
1214
|
] }),
|
|
1174
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "text-muted", children: "Click here to change file or drag a new one." })
|
|
1215
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "text-muted", children: "Click here to change file or drag a new one." }),
|
|
1216
|
+
uploadOnDrop && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "text-muted", children: "Upload starts automatically." })
|
|
1175
1217
|
] }) : /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "small", children: [
|
|
1218
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1219
|
+
"button",
|
|
1220
|
+
{
|
|
1221
|
+
type: "button",
|
|
1222
|
+
className: "btn btn-primary align-self-start",
|
|
1223
|
+
disabled: disabled || isUploading,
|
|
1224
|
+
children: "Browse file\u2026"
|
|
1225
|
+
}
|
|
1226
|
+
),
|
|
1176
1227
|
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { children: "Drag & drop a file here" }),
|
|
1177
1228
|
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "text-muted", children: "or click to browse" })
|
|
1178
1229
|
] })
|
|
1179
1230
|
]
|
|
1180
1231
|
}
|
|
1181
1232
|
),
|
|
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)(
|
|
1233
|
+
!uploadOnDrop && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1211
1234
|
"button",
|
|
1212
1235
|
{
|
|
1213
1236
|
type: "button",
|
|
@@ -1238,8 +1261,8 @@ function HomeContent() {
|
|
|
1238
1261
|
const { user } = (0, import_authentication_ui.useUser)();
|
|
1239
1262
|
async function getPresignedUrlFromApi(file) {
|
|
1240
1263
|
const res = new SparkStudioStorageSDK(
|
|
1241
|
-
|
|
1242
|
-
"https://localhost:5001"
|
|
1264
|
+
"https://iq0gmcn0pd.execute-api.us-east-2.amazonaws.com/Prod"
|
|
1265
|
+
//"https://localhost:5001"
|
|
1243
1266
|
);
|
|
1244
1267
|
const contentType = file.type || "application/octet-stream";
|
|
1245
1268
|
const result = await res.s3.GetTemporaryPreSignedUrl(new TemporaryFileDTO({ Name: file.name, ContentType: contentType }));
|
|
@@ -1251,6 +1274,7 @@ function HomeContent() {
|
|
|
1251
1274
|
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
1252
1275
|
SingleFileProcessUploader,
|
|
1253
1276
|
{
|
|
1277
|
+
uploadOnDrop: true,
|
|
1254
1278
|
accept: "*/*",
|
|
1255
1279
|
getPresignedUrl: getPresignedUrlFromApi,
|
|
1256
1280
|
onUploadComplete: (file, s3Url) => {
|
|
@@ -1261,8 +1285,8 @@ function HomeContent() {
|
|
|
1261
1285
|
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
1262
1286
|
ContainerUploadPanel,
|
|
1263
1287
|
{
|
|
1264
|
-
containerApiBaseUrl: "https://
|
|
1265
|
-
storageApiBaseUrl: "https://
|
|
1288
|
+
containerApiBaseUrl: "https://lf9zyufpuk.execute-api.us-east-2.amazonaws.com/Prod",
|
|
1289
|
+
storageApiBaseUrl: "https://iq0gmcn0pd.execute-api.us-east-2.amazonaws.com/Prod"
|
|
1266
1290
|
}
|
|
1267
1291
|
)
|
|
1268
1292
|
] })
|
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,20 @@ 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__ */
|
|
1135
|
+
isUploading ? /* @__PURE__ */ jsx6("div", { className: "small", children: /* @__PURE__ */ jsx6("div", { className: "progress", children: /* @__PURE__ */ jsx6(
|
|
1136
|
+
"div",
|
|
1137
|
+
{
|
|
1138
|
+
className: "progress-bar progress-bar-striped progress-bar-animated",
|
|
1139
|
+
role: "progressbar",
|
|
1140
|
+
"aria-valuemin": 0,
|
|
1141
|
+
"aria-valuemax": 100,
|
|
1142
|
+
"aria-valuenow": progress ?? 0,
|
|
1143
|
+
style: { width: `${progress ?? 0}%` }
|
|
1144
|
+
}
|
|
1145
|
+
) }) }) : /* @__PURE__ */ jsxs4(
|
|
1114
1146
|
"div",
|
|
1115
1147
|
{
|
|
1116
1148
|
className: dropzoneClasses,
|
|
@@ -1129,52 +1161,43 @@ var SingleFileProcessUploader = ({ getPresignedUrl, onUploadComplete, accept, di
|
|
|
1129
1161
|
accept,
|
|
1130
1162
|
className: "d-none",
|
|
1131
1163
|
onChange: handleInputChange,
|
|
1132
|
-
disabled
|
|
1164
|
+
disabled: disabled || isUploading
|
|
1133
1165
|
}
|
|
1134
1166
|
),
|
|
1135
1167
|
selectedFile ? /* @__PURE__ */ jsxs4("div", { className: "small", children: [
|
|
1168
|
+
/* @__PURE__ */ jsx6(
|
|
1169
|
+
"button",
|
|
1170
|
+
{
|
|
1171
|
+
type: "button",
|
|
1172
|
+
className: "btn btn-primary align-self-start",
|
|
1173
|
+
disabled: disabled || isUploading,
|
|
1174
|
+
children: "Browse file\u2026"
|
|
1175
|
+
}
|
|
1176
|
+
),
|
|
1136
1177
|
/* @__PURE__ */ jsxs4("div", { children: [
|
|
1137
1178
|
/* @__PURE__ */ jsx6("strong", { children: "Selected file:" }),
|
|
1138
1179
|
" ",
|
|
1139
1180
|
selectedFile.name
|
|
1140
1181
|
] }),
|
|
1141
|
-
/* @__PURE__ */ jsx6("div", { className: "text-muted", children: "Click here to change file or drag a new one." })
|
|
1182
|
+
/* @__PURE__ */ jsx6("div", { className: "text-muted", children: "Click here to change file or drag a new one." }),
|
|
1183
|
+
uploadOnDrop && /* @__PURE__ */ jsx6("div", { className: "text-muted", children: "Upload starts automatically." })
|
|
1142
1184
|
] }) : /* @__PURE__ */ jsxs4("div", { className: "small", children: [
|
|
1185
|
+
/* @__PURE__ */ jsx6(
|
|
1186
|
+
"button",
|
|
1187
|
+
{
|
|
1188
|
+
type: "button",
|
|
1189
|
+
className: "btn btn-primary align-self-start",
|
|
1190
|
+
disabled: disabled || isUploading,
|
|
1191
|
+
children: "Browse file\u2026"
|
|
1192
|
+
}
|
|
1193
|
+
),
|
|
1143
1194
|
/* @__PURE__ */ jsx6("div", { children: "Drag & drop a file here" }),
|
|
1144
1195
|
/* @__PURE__ */ jsx6("div", { className: "text-muted", children: "or click to browse" })
|
|
1145
1196
|
] })
|
|
1146
1197
|
]
|
|
1147
1198
|
}
|
|
1148
1199
|
),
|
|
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(
|
|
1200
|
+
!uploadOnDrop && /* @__PURE__ */ jsx6(
|
|
1178
1201
|
"button",
|
|
1179
1202
|
{
|
|
1180
1203
|
type: "button",
|
|
@@ -1210,8 +1233,8 @@ function HomeContent() {
|
|
|
1210
1233
|
const { user } = useUser();
|
|
1211
1234
|
async function getPresignedUrlFromApi(file) {
|
|
1212
1235
|
const res = new SparkStudioStorageSDK(
|
|
1213
|
-
|
|
1214
|
-
"https://localhost:5001"
|
|
1236
|
+
"https://iq0gmcn0pd.execute-api.us-east-2.amazonaws.com/Prod"
|
|
1237
|
+
//"https://localhost:5001"
|
|
1215
1238
|
);
|
|
1216
1239
|
const contentType = file.type || "application/octet-stream";
|
|
1217
1240
|
const result = await res.s3.GetTemporaryPreSignedUrl(new TemporaryFileDTO({ Name: file.name, ContentType: contentType }));
|
|
@@ -1223,6 +1246,7 @@ function HomeContent() {
|
|
|
1223
1246
|
/* @__PURE__ */ jsx7(
|
|
1224
1247
|
SingleFileProcessUploader,
|
|
1225
1248
|
{
|
|
1249
|
+
uploadOnDrop: true,
|
|
1226
1250
|
accept: "*/*",
|
|
1227
1251
|
getPresignedUrl: getPresignedUrlFromApi,
|
|
1228
1252
|
onUploadComplete: (file, s3Url) => {
|
|
@@ -1233,8 +1257,8 @@ function HomeContent() {
|
|
|
1233
1257
|
/* @__PURE__ */ jsx7(
|
|
1234
1258
|
ContainerUploadPanel,
|
|
1235
1259
|
{
|
|
1236
|
-
containerApiBaseUrl: "https://
|
|
1237
|
-
storageApiBaseUrl: "https://
|
|
1260
|
+
containerApiBaseUrl: "https://lf9zyufpuk.execute-api.us-east-2.amazonaws.com/Prod",
|
|
1261
|
+
storageApiBaseUrl: "https://iq0gmcn0pd.execute-api.us-east-2.amazonaws.com/Prod"
|
|
1238
1262
|
}
|
|
1239
1263
|
)
|
|
1240
1264
|
] })
|