Skip to content

Commit

Permalink
showing feedback for each trining
Browse files Browse the repository at this point in the history
  • Loading branch information
omranlm committed Aug 1, 2023
1 parent 358a468 commit b2ec882
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 10 deletions.
60 changes: 60 additions & 0 deletions frontend/src/components/Layout/AIModels/AIModelEditor/Feedback.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import { IconButton, Tooltip } from "@mui/material";
import React, { useContext } from "react";
import InfoIcon from "@mui/icons-material/Info";
import FeedbackIcon from "@mui/icons-material/Feedback";
import { useQuery } from "react-query";
import axios from "../../../../axios";
import AuthContext from "../../../../Context/AuthContext";
import FindReplaceIcon from "@mui/icons-material/FindReplace";
const Feedback = ({ trainingId }) => {
const { accessToken } = useContext(AuthContext);
const getFeedback = async () => {
try {
const headers = {
"access-token": accessToken,
};
const res = await axios.get(`/feedback/?training=${trainingId}`, null, {
headers,
});

if (res.error) {
} else {
console.log(`/feedback/?training=${trainingId}`, res.data);
return res.data;
}
} catch (e) {
console.log("isError", e);
} finally {
}
};
const { data: feedbackData, isLoading } = useQuery(
"getFeedback" + trainingId,
getFeedback,
{
refetchInterval: 10000,
}
);

return (
<>
{feedbackData &&
feedbackData.features &&
feedbackData.features.length > 0 && (
<Tooltip
title={`Total number of feedback on this training is ${feedbackData.features.length}`}
placement="left"
>
<IconButton aria-label="popup">
<FeedbackIcon size="small" />
</IconButton>
</Tooltip>
)}
{isLoading && (
<IconButton aria-label="popup">
<FindReplaceIcon size="small" />
</IconButton>
)}
</>
);
};
export default Feedback;
27 changes: 17 additions & 10 deletions frontend/src/components/Layout/AIModels/AIModelEditor/Trainings.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import Popup from "./Popup";
import InfoIcon from "@mui/icons-material/Info";

import AuthContext from "../../../../Context/AuthContext";
import Feedback from "./Feedback";

const DEFAULT_FILTER = {
items: [{ columnField: "created_date", id: 8537, operatorValue: "contains" }],
Expand Down Expand Up @@ -151,16 +152,22 @@ const TrainingsList = (props) => {
},
{
field: "popup",
headerName: "Info",
width: 10,
renderCell: (params) => (
<IconButton
onClick={() => handlePopupOpen(params.row)}
aria-label="popup"
>
<InfoIcon size="small" />
</IconButton>
),
headerName: "Info/Feedback",
width: 100,
renderCell: (params) => {
console.log("params in info row", params);
return (
<div>
<IconButton
onClick={() => handlePopupOpen(params.row)}
aria-label="popup"
>
<InfoIcon size="small" />
</IconButton>
<Feedback trainingId={params.row.id}></Feedback>
</div>
);
},
},
{
field: "accuracy",
Expand Down

0 comments on commit b2ec882

Please sign in to comment.