Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Frontend changes mar #643

Merged
merged 3 commits into from
Mar 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions uptrain/dashboard/frontend/dashboard/.env
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
NEXT_PUBLIC_BACKEND_URL=http://localhost:4300/

Original file line number Diff line number Diff line change
Expand Up @@ -8,32 +8,32 @@ import Step2 from "./Step2";
import Step3 from "./Step3";


const fetchData = async (uptrainAccessKey, setData) => {
try {
const response = await fetch(
process.env.NEXT_PUBLIC_BACKEND_URL +
`api/public/get_projects_list?num_days=${10000}`,
{
method: "GET",
headers: {
"Content-Type": "application/json",
"uptrain-access-token": `${uptrainAccessKey}`,
},
}
);
// const fetchData = async (uptrainAccessKey, setData) => {
// try {
// const response = await fetch(
// process.env.NEXT_PUBLIC_BACKEND_URL +
// `api/public/get_projects_list?num_days=${10000}`,
// {
// method: "GET",
// headers: {
// "Content-Type": "application/json",
// "uptrain-access-token": `${uptrainAccessKey}`,
// },
// }
// );

if (response.ok) {
const responseData = await response.json();
setData(responseData.data);
} else {
console.error("Failed to submit API Key:", response.statusText);
// Handle error cases
}
} catch (error) {
console.error("Error submitting API Key:", error.message);
// Handle network errors or other exceptions
}
};
// if (response.ok) {
// const responseData = await response.json();
// setData(responseData.data);
// } else {
// console.error("Failed to submit API Key:", response.statusText);
// // Handle error cases
// }
// } catch (error) {
// console.error("Error submitting API Key:", error.message);
// // Handle network errors or other exceptions
// }
// };

const CreateProjectModal = (props) => {
const uptrainAccessKey = useSelector(selectUptrainAccessKey);
Expand All @@ -52,13 +52,13 @@ const CreateProjectModal = (props) => {
const [metadata, setMetadata] = useState({});
const [allProject, setAllProject] = useState();

useEffect(() => {
const fetchDataAsync = async () => {
await fetchData(uptrainAccessKey, setAllProject);
};
// useEffect(() => {
// const fetchDataAsync = async () => {
// await fetchData(uptrainAccessKey, setAllProject);
// };

if (uptrainAccessKey) fetchDataAsync();
}, [uptrainAccessKey]);
// if (uptrainAccessKey) fetchDataAsync();
// }, [uptrainAccessKey]);

const singleMetrics = [
"context_relevance",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,9 @@ import Step3OverModal from "./Step3OverModal";
const Step1 = (props) => {
const [error, setError] = useState();

console.log(error)

const projectName = props.promptProjectName
? props.promptProjectName
: props.projectName;
? props.promptProjectName
: props.projectName;
const fileInputRef = useRef(null);
const [openModal, setOpenModal] = useState(false);

Expand All @@ -29,10 +27,10 @@ const Step1 = (props) => {
return;
}

if (props.allProject.some(obj => obj.project === projectName)) {
setError("Given Project name already exists");
return;
}
// if (props.allProject.some(obj => obj.project === projectName)) {
// setError("Given Project name already exists");
// return;
// }

props.promptProjectName
? props.nextPrompt()
Expand Down Expand Up @@ -63,11 +61,7 @@ const Step1 = (props) => {
className="bg-[#171721] rounded-xl px-6 py-4 text-[#B6B6B9] w-full"
placeholder="Project name"
onChange={(e) => props.setProjectName(e.target.value)}
value={
props.promptProjectName
? props.promptProjectName
: props.projectName
}
value={projectName}
required
disabled={props.promptProjectName}
/>
Expand Down Expand Up @@ -118,7 +112,7 @@ const Step1 = (props) => {
className="rounded-xl px-6 py-4"
required
/>
<p className="text-red-500">{error}</p>
<p className="text-red-500">{error}</p>
<div className="flex justify-end mt-5">
<button
type="Submit"
Expand Down