Skip to content

Commit

Permalink
Merge pull request #85 from Jai0212/Navnoor-14-bootstrap-modal-upload…
Browse files Browse the repository at this point in the history
…-instructions

Bootstrap Modal for Model Upload Instructions
  • Loading branch information
Jai0212 authored Nov 22, 2024
2 parents 4591520 + ea304a9 commit 101004c
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ input[type="file"] {

/* Style for the Download Graph button */
.file-import-container button:nth-child(3) {
background-color: #0088cc;
background-color: #45a049;
color: #fafafa;
}

Expand Down
76 changes: 74 additions & 2 deletions frontend/src/pages/DashboardPage/ControlButtons/ControlButtons.jsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import React, { useRef, useState, useEffect } from "react";
import "bootstrap/dist/css/bootstrap.min.css"; // Import Bootstrap CSS
import "./ControlButtons.css";

const ControlButtons = ({ onDownload }) => {
const VITE_BACKEND_URL = import.meta.env.VITE_BACKEND_URL;

const [currUser, setCurrUser] = useState("");
const [showModal, setShowModal] = useState(false); // Modal visibility state

const fileInputRef1 = useRef(null); // For model import
const fileInputRef2 = useRef(null); // For dataset import
Expand Down Expand Up @@ -36,7 +38,6 @@ const ControlButtons = ({ onDownload }) => {
timer: 5000,
timerProgressBar: true,
}).then(() => {

window.location.href = "/";
});
}
Expand All @@ -57,7 +58,7 @@ const ControlButtons = ({ onDownload }) => {
}, []);

const handleImportModels = () => {
fileInputRef1.current.click();
setShowModal(true); // Open the modal when button is clicked
};

const handleImportDataset = () => {
Expand Down Expand Up @@ -142,18 +143,23 @@ const ControlButtons = ({ onDownload }) => {
}
};

const closeModal = () => {
setShowModal(false); // Close the modal
};

return (
<div className="file-import-container">
<input
type="file"
ref={fileInputRef1}
onChange={handleModelFileChange}
style={{ display: 'none' }} // Hide the file input
/>
<input
type="file"
ref={fileInputRef2}
onChange={handleDatasetFileChange}
style={{ display: 'none' }} // Hide the file input
/>
<button
className="upload-model-button"
Expand All @@ -175,6 +181,72 @@ const ControlButtons = ({ onDownload }) => {
>
Download Graph
</button>

{/* Bootstrap Modal for model upload instructions */}
{showModal && (
<div className="modal show" style={{ display: "block" }}>
<div className="modal-dialog">
<div className="modal-content">
<div className="modal-header">
<h5 className="modal-title">Model Upload Instructions</h5>
<button
type="button"
className="close"
style={{
backgroundColor: "#45a049",
borderColor: "#45a049",
fontSize: "0.875rem", // Smaller font size
padding: "0.25rem 0.5rem", // Smaller padding
borderRadius: "0.2rem" // Optional: round corners slightly
}}
onClick={closeModal}
>
&times;
</button>
</div>
<div className="modal-body">
<p><strong>File format:</strong> The file must be in <code>.pkl</code> format.</p>
<p><strong>File size:</strong> The file size must be less than 1 MB.</p>
</div>
<div className="modal-footer">
<button
type="button"
className="btn btn-primary"
style={{
backgroundColor: "#45a049",
borderColor: "#45a049",
fontSize: "0.875rem", // Smaller font size
padding: "0.25rem 0.5rem", // Smaller padding
borderRadius: "0.2rem" // Optional: round corners slightly
}}
onClick={() => {
fileInputRef1.current.click(); // Trigger file input inside modal
closeModal(); // Close the modal after triggering file input
}}
>
Upload Model
</button>
<button
type="button"
className="btn btn-secondary"
style={{
backgroundColor: "#45a049",
borderColor: "#45a049",
fontSize: "0.875rem", // Smaller font size
padding: "0.25rem 0.5rem", // Smaller padding
borderRadius: "0.2rem" // Optional: round corners slightly
}}
onClick={closeModal}
>
Close
</button>
</div>
</div>
</div>
</div>
)}


</div>
);
};
Expand Down
4 changes: 0 additions & 4 deletions frontend/src/pages/DashboardPage/Dashboard/Dashboard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -569,10 +569,6 @@ const Dashboard = () => {
return maxInitialElement;
};

// const handleSliderChange = (event) => {
// setSliderValue(parseFloat(event.target.value));
// console.log("Slider Value:", event.target.value); // For debugging
// };
const handleSliderValueChange = (value) => {
console.log('Slider Value:', value); // Handle the slider value update
};
Expand Down

0 comments on commit 101004c

Please sign in to comment.