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

restrict max task pull per user #132

Merged
merged 1 commit into from
Jul 2, 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
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ const ModelInteractionEvaluation = ({ currentInteraction, setCurrentInteraction
useEffect(() => {
setSelectedQuestions(questions.slice(0, 3)); // Change this to your default questions
}, []);
console.log(interactions[0]);
useEffect(() => {
if (forms && interactions) {
let defaultFormIndex = interactions[0]?.prompt_output_pair_id;
Expand All @@ -109,7 +110,7 @@ const ModelInteractionEvaluation = ({ currentInteraction, setCurrentInteraction
setCurrentInteraction((prev) => {
return {
prompt: interactions[0]?.prompt,
output: typeof(interactions[0]?.output)==="string"?interactions[0]?.output:interactions[0]?.value,
output: typeof(interactions[0]?.output)==="string"?interactions[0]?.output:interactions[0]?.output[0]?.value,
prompt_output_pair_id: interactions[0]?.prompt_output_pair_id,
rating: currentForm[0]?.form_output_json?.rating,
additional_note: currentForm[0]?.form_output_json?.additional_note,
Expand All @@ -129,7 +130,7 @@ const ModelInteractionEvaluation = ({ currentInteraction, setCurrentInteraction
});
}
}, [forms, interactions]);

console.log(currentInteraction);
const handleOptionChange = (index, answer) => {
const newAnswers = currentInteraction.questions_response
? [...currentInteraction.questions_response]
Expand Down Expand Up @@ -167,10 +168,12 @@ const ModelInteractionEvaluation = ({ currentInteraction, setCurrentInteraction
)[0];
const currFormResponse = forms.filter(
(form) => form.prompt_output_pair_id == e.target.id,
);
)[0];
const outputValues = currInteractionPair?.output.map(item => item.value) || [];
setCurrentInteraction((prev) => ({
prompt: currInteractionPair.prompt,
output: currInteractionPair.output,
...prev,
prompt: currInteractionPair?.prompt,
output: outputValues,
prompt_output_pair_id: currInteractionPair.prompt_output_pair_id,
rating: currFormResponse?.form_output_json?.rating,
additional_note: currFormResponse?.form_output_json?.additional_note,
Expand Down Expand Up @@ -342,9 +345,11 @@ const ModelInteractionEvaluation = ({ currentInteraction, setCurrentInteraction
width: "100%",
overflow: "hidden",
textOverflow: "ellipsis",
whiteSpace: "nowrap",
maxWidth: "100px"
whiteSpace: expanded[index] ? "wrap": "nowrap",
maxWidth: "200px",
maxHeight: "3rem",
}}

className={classes.promptTile}
>
{pair.prompt}
Expand All @@ -356,12 +361,13 @@ const ModelInteractionEvaluation = ({ currentInteraction, setCurrentInteraction
width: "100%",
overflow: "hidden",
textOverflow: "ellipsis",
whiteSpace: "nowrap",
maxWidth: "100px"
whiteSpace: expanded[index] ? "wrap": "nowrap",
maxWidth: "200px",
maxHeight: "3rem",
}}
className={classes.answerTile}
>
{typeof(pair.output)==="string"?pair?.output:pair?.output?.value}
{typeof(pair.output)==="string"?pair?.output:pair?.output[0]?.value}
</Box>
<Box sx={{ display: 'flex', alignItems: 'center', marginTop: '1rem' }}>
<Button
Expand Down
64 changes: 59 additions & 5 deletions src/components/Project/BasicSettings.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ import CustomizedSnackbars from "../common/Snackbar";
import Spinner from "../common/Spinner";
import {fetchLanguages} from "@/Lib/Features/fetchLanguages";
import GetSaveButtonAPI from "@/app/actions/api/Projects/getSaveButtonAPI";

import getWorkspaceDetails from "@/Lib/Features/getWorkspaceDetails";
import { FetchLoggedInUserData } from "@/Lib/Features/getLoggedInData";


const BasicSettings = (props) => {
Expand All @@ -36,7 +37,21 @@ const BasicSettings = (props) => {
const classes = DatasetStyle();
const dispatch = useDispatch();
const apiLoading = useSelector(state => state.apiStatus.loading);

const loggedInUserData = useSelector(state => state.getLoggedInData?.data); //retrieved the id of the current signedin user
const workspaceManagers = useSelector(state=>(state.getWorkspaceDetails.data.managers));

const isManager = workspaceManagers?.some(manager => manager.id === loggedInUserData.id);


console.log(loggedInUserData.id);
const getLoggedInUserData = () => {
dispatch(FetchLoggedInUserData("me"));
};

useEffect(() => {
getLoggedInUserData();
}, []);


useEffect(() => {
// if (ProjectDetails.project_type === "MonolingualTranslation" ||ProjectDetails.project_type === "SemanticTextualSimilarity" || ProjectDetails.project_type === "TranslationEditing" || ProjectDetails.project_type === "ContextualTranslationEditing"|| ProjectDetails.project_type==="SingleSpeakerAudioTranscriptionEditing") {
Expand All @@ -54,13 +69,13 @@ const BasicSettings = (props) => {
description: ProjectDetails.description,
max_pending_tasks_per_user: ProjectDetails.max_pending_tasks_per_user,
tasks_pull_count_per_batch: ProjectDetails.tasks_pull_count_per_batch,
max_tasks_per_user: ProjectDetails.max_tasks_per_user,
});
setTargetLanguage(ProjectDetails?.tgt_language)
setSourceLanguage(ProjectDetails?.src_language)
}, [ProjectDetails]);

const LanguageChoices = useSelector((state) => state.getLanguages.data.language);

const getLanguageChoices = () => {
dispatch(fetchLanguages());
};
Expand Down Expand Up @@ -95,7 +110,9 @@ const BasicSettings = (props) => {
annotation_reviewers: ProjectDetails.annotation_reviewers,
max_pending_tasks_per_user: newDetails.max_pending_tasks_per_user,
tasks_pull_count_per_batch: newDetails.tasks_pull_count_per_batch,
max_tasks_per_user: newDetails.max_tasks_per_user,
}
console.log(sendData);
const projectObj = new GetSaveButtonAPI(id, sendData);
const res = await fetch(projectObj.apiEndPoint(), {
method: "PUT",
Expand Down Expand Up @@ -157,7 +174,6 @@ const BasicSettings = (props) => {
/>
);
};

return (
<ThemeProvider theme={themeDefault}>

Expand Down Expand Up @@ -418,6 +434,44 @@ const BasicSettings = (props) => {
onChange={handleProjectName} />
</Grid>
</Grid>

<Grid
container
direction='row'
sx={{
alignItems: "center",
mt: 2
}}
>
<Grid
items
xs={12}
sm={12}
md={12}
lg={2}
xl={2}
>
<Typography variant="body2" fontWeight='700' label="Required">
Max Tasks Per User
</Typography>
</Grid>
<Grid
item
xs={12}
md={12}
lg={9}
xl={9}
sm={12}
>
<OutlinedTextField
fullWidth
name="max_tasks_per_user"
InputProps={{ step: 1, min: 0, max: 99999, type: 'number', style: { fontSize: "14px", width: "500px" }, readOnly: !isManager }}

value={newDetails?.max_tasks_per_user}
onChange={handleProjectName} />
</Grid>
</Grid>
</>
<Grid
container
Expand Down
Loading