Skip to content

Commit

Permalink
ui bug bash fixes (TransformerOptimus#839)
Browse files Browse the repository at this point in the history
  • Loading branch information
jedan2506 authored Jul 21, 2023
1 parent 9156985 commit 540509d
Showing 1 changed file with 18 additions and 18 deletions.
36 changes: 18 additions & 18 deletions gui/pages/Content/Agents/ResourceManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,26 @@ export default function ResourceManager({agentId, runs}) {
const [isDragging, setIsDragging] = useState(false);
const fileInputRef = useRef(null);

const handleFileInputChange = (event) => {
const files = event.target.files;
function handleFile(files) {
if (files.length > 0) {
const fileData = {
"file": files[0],
"name": files[0].name,
"size": files[0].size,
"type": files[0].type,
};
uploadResource(fileData);
const sizeInMB = files[0].size / (1024*1024);
if (sizeInMB > 5) {
toast.error('File size should not exceed 5MB', {autoClose: 1800});
} else {
const fileData = {
"file": files[0],
"name": files[0].name,
"size": files[0].size,
"type": files[0].type,
};
uploadResource(fileData);
}
}
};
const handleFileInputChange = (event) => {
const files = event.target.files;
handleFile(files);
};

const handleDropAreaClick = () => {
fileInputRef.current.click();
Expand All @@ -48,15 +56,7 @@ export default function ResourceManager({agentId, runs}) {
event.preventDefault();
setIsDragging(false);
const files = event.dataTransfer.files;
if (files.length > 0) {
const fileData = {
"file": files[0],
"name": files[0].name,
"size": files[0].size,
"type": files[0].type,
};
uploadResource(fileData);
}
handleFile(files);
};

useEffect(() => {
Expand Down

0 comments on commit 540509d

Please sign in to comment.