diff --git a/src/redux/actions/api/LSFAPI/LSFAPI.js b/src/redux/actions/api/LSFAPI/LSFAPI.js index fd967c4da..6ce637037 100644 --- a/src/redux/actions/api/LSFAPI/LSFAPI.js +++ b/src/redux/actions/api/LSFAPI/LSFAPI.js @@ -118,7 +118,7 @@ const patchAnnotation = async ( }); return res; } catch (err) { - return err; + return { err, status: 400 }; } }; @@ -133,7 +133,7 @@ const patchReview = async ( autoSave=false ) => { try { - await axiosInstance.patch(`/annotation/${annotationID}/`, { + const res = await axiosInstance.patch(`/annotation/${annotationID}/`, { lead_time: (new Date() - load_time) / 1000 + Number(lead_time ?? 0), annotation_status: review_status, result: result, @@ -150,13 +150,14 @@ const patchReview = async ( }), ...(autoSave && { auto_save: true }), }); + return res; // if (review_status === "to_be_revised") { // await axiosInstance.patch(`/annotation/${parentAnnotation}/`, { // annotation_status: review_status, // }); // } } catch (err) { - return err; + return { err, status: 400 }; } }; @@ -173,7 +174,7 @@ const patchSuperChecker = async ( ) => { console.log(superchecknotes,"superchecknotes") try { - await axiosInstance.patch(`/annotation/${annotationID}/`, { + const res = await axiosInstance.patch(`/annotation/${annotationID}/`, { lead_time: (new Date() - load_time) / 1000 + Number(lead_time ?? 0), annotation_status: review_status, result: result, @@ -181,9 +182,9 @@ const patchSuperChecker = async ( supercheck_notes: superchecknotes, ...(autoSave && { auto_save: true }), }); - + return res; } catch (err) { - return err; + return { err, status: 400 }; } }; diff --git a/src/ui/pages/component/CL-Transcription/SuperCheckerStageButtons.jsx b/src/ui/pages/component/CL-Transcription/SuperCheckerStageButtons.jsx index cd8db2306..724528e84 100644 --- a/src/ui/pages/component/CL-Transcription/SuperCheckerStageButtons.jsx +++ b/src/ui/pages/component/CL-Transcription/SuperCheckerStageButtons.jsx @@ -62,6 +62,8 @@ const SuperCheckerStageButtons = ({ disableSkip, anchorEl, setAnchorEl, + filterMessage, + disableBtns, // taskData, }) => { // const classes = AudioTranscriptionLandingStyle(); @@ -127,7 +129,7 @@ const SuperCheckerStageButtons = ({ - + {!disableBtns && {taskData?.super_check_user === user?.id && ( + + )} + + + {taskData?.super_check_user === user?.id && ( + + + + )} + + + {taskData?.super_check_user === user?.id && ( + + + + )} + + handleSuperCheckerClick( - "skipped", + "validated", SuperChecker.id, SuperChecker.lead_time, + SuperChecker.parent_annotation ) } - style={{ - minWidth: "120px", - border: "1px solid gray", - color: "#d00", - pt: 2, - pb: 2, - }} - // className="lsf-button" + disableRipple > - Skip - - - )} - - - {taskData?.super_check_user === user?.id && ( - - - - )} - - - {taskData?.super_check_user === user?.id && ( - - - - )} - - - handleSuperCheckerClick( - "validated", - SuperChecker.id, - SuperChecker.lead_time, - SuperChecker.parent_annotation - ) - } - disableRipple - > - Validated No Changes - - - handleSuperCheckerClick( - "validated_with_changes", - SuperChecker.id, - SuperChecker.lead_time, - SuperChecker.parent_annotation - ) - } - disableRipple - > - Validated with Changes - - - + Validated with Changes + + + + } + {filterMessage && ( + + {filterMessage} + + )} ); }; diff --git a/src/ui/pages/component/common/Tooltip.jsx b/src/ui/pages/component/common/Tooltip.jsx index 65c3dd2ad..7ff6267e2 100644 --- a/src/ui/pages/component/common/Tooltip.jsx +++ b/src/ui/pages/component/common/Tooltip.jsx @@ -11,6 +11,7 @@ const LightTooltip = styled(({ className, ...props }) => ( color: 'rgba(0, 0, 0, 0.87)', boxShadow: theme.shadows[1], fontSize: 11, + maxWidth: 400, }, })); diff --git a/src/ui/pages/container/CL-Transcription/AllAudioTranscriptionLandingPage.jsx b/src/ui/pages/container/CL-Transcription/AllAudioTranscriptionLandingPage.jsx index c785ebbc7..2844c25a4 100644 --- a/src/ui/pages/container/CL-Transcription/AllAudioTranscriptionLandingPage.jsx +++ b/src/ui/pages/container/CL-Transcription/AllAudioTranscriptionLandingPage.jsx @@ -38,6 +38,7 @@ import GetTaskDetailsAPI from "../../../../redux/actions/api/Tasks/GetTaskDetail import ArrowDropDownIcon from "@mui/icons-material/ArrowDropDown"; import ArrowRightIcon from "@mui/icons-material/ArrowRight"; import ArrowBackIcon from "@mui/icons-material/ArrowBack"; +import UserMappedByRole from '../../../../utils/UserMappedByRole/UserMappedByRole'; import getTaskAssignedUsers from '../../../../utils/getTaskAssignedUsers'; import LightTooltip from "../../component/common/Tooltip"; @@ -81,7 +82,8 @@ const AllAudioTranscriptionLandingPage = () => { const taskDetails = useSelector((state) => state.getTaskDetails?.data); const getNextTask = useSelector((state) => state.getnextProject?.data); const [advancedWaveformSettings, setAdvancedWaveformSettings] = useState(false); - const [assignedUsers, setAssignedUsers] = useState(null); + const [assignedUsers, setAssignedUsers] = useState([]); + const [selectedUserId, setSelectedUserId] = useState(-2); const handleCollapseClick = () => { !showNotes && setShowStdTranscript(false); @@ -148,12 +150,22 @@ const AllAudioTranscriptionLandingPage = () => { getTaskData(taskId); }, []); + useEffect(() => { + if (selectedUserId && [4, 5, 6].includes(user?.role)) { + const userAnnotations = AnnotationsTaskDetails?.filter((item) => item.completed_by === selectedUserId); + userAnnotations.length && setAnnotations(userAnnotations); + } + }, [selectedUserId]); + useEffect(() => { const showAssignedUsers = async () => { - getTaskAssignedUsers(taskDetails).then(res => setAssignedUsers(res)); + getTaskAssignedUsers(taskDetails).then(res => { + setAssignedUsers(res); + setSelectedUserId(res[0]?.id); + }); } - taskDetails?.id && showAssignedUsers(); - }, [taskDetails]); + AnnotationsTaskDetails && taskDetails?.id && user?.id && showAssignedUsers(); + }, [taskDetails, user, AnnotationsTaskDetails]); const getProjectDetails = () => { const projectObj = new GetProjectDetailsAPI(projectId); @@ -163,7 +175,7 @@ const AllAudioTranscriptionLandingPage = () => { useEffect(() => { if (AnnotationsTaskDetails?.length > 0) { setLoading(false); - setAnnotations(AnnotationsTaskDetails); + setAnnotations(AnnotationsTaskDetails?.filter((item) => item.annotation_type === 1)); } }, [AnnotationsTaskDetails]); @@ -400,7 +412,24 @@ const AllAudioTranscriptionLandingPage = () => { Task #{taskDetails?.id} + {assignedUsers.map((u, idx) => u && + + )} + + : ""} > diff --git a/src/ui/pages/container/CL-Transcription/AudioTranscriptionLandingPage.jsx b/src/ui/pages/container/CL-Transcription/AudioTranscriptionLandingPage.jsx index 924524dec..3200efae7 100644 --- a/src/ui/pages/container/CL-Transcription/AudioTranscriptionLandingPage.jsx +++ b/src/ui/pages/container/CL-Transcription/AudioTranscriptionLandingPage.jsx @@ -45,6 +45,7 @@ import AnnotationStageButtons from "../../component/CL-Transcription/AnnotationS import ArrowDropDownIcon from "@mui/icons-material/ArrowDropDown"; import ArrowRightIcon from "@mui/icons-material/ArrowRight"; import ArrowBackIcon from "@mui/icons-material/ArrowBack"; +import UserMappedByRole from '../../../../utils/UserMappedByRole/UserMappedByRole'; import getTaskAssignedUsers from '../../../../utils/getTaskAssignedUsers'; import LightTooltip from "../../component/common/Tooltip"; @@ -110,6 +111,7 @@ const AudioTranscriptionLandingPage = () => { const [assignedUsers, setAssignedUsers] = useState(null); const [autoSave, setAutoSave] = useState(true); const [autoSaveTrigger, setAutoSaveTrigger] = useState(false); + const [selectedUserId, setSelectedUserId] = useState(-1); // useEffect(() => { // let intervalId; @@ -296,7 +298,7 @@ const AudioTranscriptionLandingPage = () => { const handleAutosave = async () => { setAutoSaveTrigger(false); - if(!autoSave) return; + if(!autoSave || disableUpdateButton) return; const reqBody = { task_id: taskId, auto_save: true, @@ -336,22 +338,22 @@ const AudioTranscriptionLandingPage = () => { }, [autoSaveTrigger, autoSave, handleAutosave, user, result, taskId, annotations, taskDetails, stdTranscription, stdTranscriptionSettings]); useEffect(() => { - if(!autoSave) return; + if(!autoSave || disableUpdateButton) return; - const handleUpdateTimeSpent = (time = 60) => { + /* const handleUpdateTimeSpent = (time = 60) => { // const apiObj = new UpdateTimeSpentPerTask(taskId, time); // dispatch(APITransport(apiObj)); - }; + }; */ saveIntervalRef.current = setInterval(() => setAutoSaveTrigger(true), 60 * 1000); - timeSpentIntervalRef.current = setInterval( + /* timeSpentIntervalRef.current = setInterval( handleUpdateTimeSpent, 60 * 1000 - ); + ); */ const handleBeforeUnload = (event) => { setAutoSaveTrigger(true); - handleUpdateTimeSpent(ref.current); + // handleUpdateTimeSpent(ref.current); event.preventDefault(); event.returnValue = ""; ref.current = 0; @@ -374,9 +376,9 @@ const AudioTranscriptionLandingPage = () => { const interval = setInterval(checkInactivity, 1000); if(!isActive){ - handleUpdateTimeSpent(ref.current); + // handleUpdateTimeSpent(ref.current); clearInterval(saveIntervalRef.current); - clearInterval(timeSpentIntervalRef.current); + // clearInterval(timeSpentIntervalRef.current); ref.current = 0; } @@ -384,16 +386,16 @@ const AudioTranscriptionLandingPage = () => { if (!document.hidden) { // Tab is active, restart the autosave interval saveIntervalRef.current = setInterval(() => setAutoSaveTrigger(true), 60 * 1000); - timeSpentIntervalRef.current = setInterval( + /* timeSpentIntervalRef.current = setInterval( handleUpdateTimeSpent, 60 * 1000 - ); + ); */ } else { setAutoSaveTrigger(true); - handleUpdateTimeSpent(ref.current); + // handleUpdateTimeSpent(ref.current); // Tab is inactive, clear the autosave interval clearInterval(saveIntervalRef.current); - clearInterval(timeSpentIntervalRef.current); + // clearInterval(timeSpentIntervalRef.current); ref.current = 0; } }; @@ -406,13 +408,13 @@ const AudioTranscriptionLandingPage = () => { document.removeEventListener('keydown', handleInteraction); clearInterval(interval); clearInterval(saveIntervalRef.current); - clearInterval(timeSpentIntervalRef.current); + // clearInterval(timeSpentIntervalRef.current); window.removeEventListener("beforeunload", handleBeforeUnload); document.removeEventListener("visibilitychange", handleVisibilityChange); }; // eslint-disable-next-line - }, [autoSave, user, taskId, annotations, taskDetails, isActive]); + }, [autoSave, user, taskId, annotations, taskDetails, isActive, disableUpdateButton]); // useEffect(() => { // const apiObj = new FetchTaskDetailsAPI(taskId); @@ -495,9 +497,31 @@ const AudioTranscriptionLandingPage = () => { getTaskData(taskId); }, []); + useEffect(() => { + if (selectedUserId === -1) return; + if (selectedUserId === user?.id) { + setFilterMessage(""); + setDisableBtns(false); + setdisableSkipButton(false); + setDisableUpdateButton(false); + getAnnotationsTaskData(taskId); + return; + } + const userAnnotations = AnnotationsTaskDetails?.filter((item) => item.completed_by === selectedUserId); + if(userAnnotations.length) { + setDisableBtns(true); + setdisableSkipButton(true); + setDisableUpdateButton(true); + setFilterMessage(`This is the ${["Annotator", "Reviewer", "Super Checker"][userAnnotations[0].annotation_type - 1]}'s Annotation in read only mode`); + setAnnotations(userAnnotations); + } + }, [selectedUserId, user, taskId]); + useEffect(() => { const showAssignedUsers = async () => { - getTaskAssignedUsers(taskDetails).then(res => setAssignedUsers(res)); + getTaskAssignedUsers(taskDetails).then(res => { + setAssignedUsers(res); + }); } taskDetails?.id && showAssignedUsers(); }, [taskDetails]); @@ -862,9 +886,30 @@ useEffect(() => { Task #{taskDetails?.id} + {assignedUsers.map((u, idx) => u && + + )} + + : ""} > - + { const classes = AudioTranscriptionLandingStyle(); @@ -111,9 +112,10 @@ const ReviewAudioTranscriptionLandingPage = () => { const reviewNotesRef = useRef(null); const superCheckerNotesRef = useRef(null); const [advancedWaveformSettings, setAdvancedWaveformSettings] = useState(false); - const [assignedUsers, setAssignedUsers] = useState(null); + const [assignedUsers, setAssignedUsers] = useState(null); const [autoSave, setAutoSave] = useState(true); const [autoSaveTrigger, setAutoSaveTrigger] = useState(false); + const [selectedUserId, setSelectedUserId] = useState(-1); // useEffect(() => { // let intervalId; @@ -311,7 +313,7 @@ const ReviewAudioTranscriptionLandingPage = () => { const handleAutosave = async () => { setAutoSaveTrigger(false); - if(!autoSave) return; + if(!autoSave || disableButton) return; const currentAnnotation = AnnotationsTaskDetails?.find((a) => a.completed_by === user.id && a.annotation_type === 2); if(!currentAnnotation) return; const reqBody = { @@ -353,22 +355,22 @@ const ReviewAudioTranscriptionLandingPage = () => { }, [autoSaveTrigger, autoSave, handleAutosave, user, result, taskId, annotations, taskDetails, stdTranscription, stdTranscriptionSettings]); useEffect(() => { - if(!autoSave) return; + if(!autoSave || disableBtns) return; - const handleUpdateTimeSpent = (time = 60) => { - // const apiObj = new UpdateTimeSpentPerTask(taskId, time); - // dispatch(APITransport(apiObj)); - }; + /* const handleUpdateTimeSpent = (time = 60) => { + const apiObj = new UpdateTimeSpentPerTask(taskId, time); + dispatch(APITransport(apiObj)); + }; */ saveIntervalRef.current = setInterval(() => setAutoSaveTrigger(true), 60 * 1000); - timeSpentIntervalRef.current = setInterval( + /* timeSpentIntervalRef.current = setInterval( handleUpdateTimeSpent, 60 * 1000 - ); + ); */ const handleBeforeUnload = (event) => { setAutoSaveTrigger(true); - handleUpdateTimeSpent(ref.current); + ///handleUpdateTimeSpent(ref.current); event.preventDefault(); event.returnValue = ""; ref.current = 0; @@ -391,7 +393,7 @@ const ReviewAudioTranscriptionLandingPage = () => { const interval = setInterval(checkInactivity, 1000); if(!isActive){ - handleUpdateTimeSpent(ref.current); + //handleUpdateTimeSpent(ref.current); clearInterval(saveIntervalRef.current); clearInterval(timeSpentIntervalRef.current); ref.current = 0; @@ -401,16 +403,16 @@ const ReviewAudioTranscriptionLandingPage = () => { if (!document.hidden) { // Tab is active, restart the autosave interval saveIntervalRef.current = setInterval(() => setAutoSaveTrigger(true), 60 * 1000); - timeSpentIntervalRef.current = setInterval( + /* timeSpentIntervalRef.current = setInterval( handleUpdateTimeSpent, 60 * 1000 - ); + ); */ } else { setAutoSaveTrigger(true); - handleUpdateTimeSpent(ref.current); + // handleUpdateTimeSpent(ref.current); // Tab is inactive, clear the autosave interval clearInterval(saveIntervalRef.current); - clearInterval(timeSpentIntervalRef.current); + // clearInterval(timeSpentIntervalRef.current); ref.current = 0; } }; @@ -422,13 +424,13 @@ const ReviewAudioTranscriptionLandingPage = () => { document.removeEventListener('keydown', handleInteraction); clearInterval(interval); clearInterval(saveIntervalRef.current); - clearInterval(timeSpentIntervalRef.current); + // clearInterval(timeSpentIntervalRef.current); window.removeEventListener("beforeunload", handleBeforeUnload); document.removeEventListener("visibilitychange", handleVisibilityChange); }; // eslint-disable-next-line - }, [autoSave, user, taskId, annotations, taskDetails, isActive]); + }, [autoSave, user, taskId, annotations, taskDetails, isActive, disableButton]); // useEffect(() => { // const apiObj = new FetchTaskDetailsAPI(taskId); @@ -519,9 +521,29 @@ const ReviewAudioTranscriptionLandingPage = () => { dispatch(APITransport(projectObj)); }; + useEffect(() => { + if(selectedUserId === -1) return; + if(selectedUserId === user?.id) { + setFilterMessage(""); + setDisableBtns(false); + setDisableButton(false); + getAnnotationsTaskData(taskId); + return; + } + const userAnnotations = AnnotationsTaskDetails?.filter((item) => item.completed_by === selectedUserId); + if(userAnnotations.length) { + setDisableButton(true); + setDisableBtns(true); + setFilterMessage(`This is the ${["Annotator", "Reviewer", "Super Checker"][userAnnotations[0].annotation_type - 1]}'s Annotation in read only mode`); + setAnnotations(userAnnotations); + } + }, [selectedUserId, user, taskId]); + useEffect(() => { const showAssignedUsers = async () => { - getTaskAssignedUsers(taskDetails).then(res => setAssignedUsers(res)); + getTaskAssignedUsers(taskDetails).then(res => { + setAssignedUsers(res); + }); } taskDetails?.id && showAssignedUsers(); }, [taskDetails]); @@ -1058,9 +1080,32 @@ useEffect(() => { Task #{taskDetails?.id} + {assignedUsers.map((u, idx) => u && + + )} + + : ""} > - + { const classes = AudioTranscriptionLandingStyle(); const dispatch = useDispatch(); const navigate = useNavigate(); - let location = useLocation(); const { projectId, taskId } = useParams(); const [loading, setLoading] = useState(false); const [playing, setPlaying] = useState(false); const [currentTime, setCurrentTime] = useState(0); const [currentIndex, setCurrentIndex] = useState(-1); - const [annotationtext,setannotationtext] = useState(''); const [currentSubs, setCurrentSubs] = useState(); const [loadtime, setloadtime] = useState(new Date()); const [textBox, settextBox] = useState(""); @@ -93,7 +85,6 @@ const SuperCheckerAudioTranscriptionLandingPage = () => { const [speakerBox, setSpeakerBox] = useState(""); let labellingMode = localStorage.getItem("labellingMode"); - // const subs = useSelector((state) => state.commonReducer.subtitles); const result = useSelector((state) => state.commonReducer.subtitles); const AnnotationsTaskDetails = useSelector( @@ -112,34 +103,10 @@ const SuperCheckerAudioTranscriptionLandingPage = () => { const [assignedUsers, setAssignedUsers] = useState(null); const [autoSave, setAutoSave] = useState(true); const [autoSaveTrigger, setAutoSaveTrigger] = useState(false); - - // useEffect(() => { - // let intervalId; - - // const updateTimer = () => { - // ref.current = ref.current + 1; - // }; - - // intervalId = setInterval(updateTimer, 1000); - - // setInterval(() => { - // clearInterval(intervalId); - // ref.current = 0; - - // intervalId = setInterval(updateTimer, 1000); - // }, 60 * 1000); - - // return () => { - // const apiObj = new UpdateTimeSpentPerTask(taskId, ref.current); - // dispatch(APITransport(apiObj)); - // clearInterval(intervalId); - // ref.current = 0; - // }; - // }, []); + const [selectedUserId, setSelectedUserId] = useState(-1); const filterAnnotations = (annotations, user) => { let disableSkip = false; - let disableAutoSave = false; let filteredAnnotations = annotations; let userAnnotation = annotations.find((annotation) => { return ( @@ -167,22 +134,22 @@ const SuperCheckerAudioTranscriptionLandingPage = () => { filteredAnnotations = annotations.filter( (value) => value.annotation_type === 2 ); - if(filteredAnnotations[0].annotation_status === "rejected") + if (filteredAnnotations[0].annotation_status === "rejected") setAutoSave(false); } } else if ([4, 5, 6].includes(user.role)) { filteredAnnotations = annotations.filter((a) => a.annotation_type === 3); + setAutoSave(false); disableSkip = true; } setAnnotations(filteredAnnotations); setdisableSkip(disableSkip); - return [filteredAnnotations, disableSkip, disableAutoSave]; + // return [filteredAnnotations, disableSkip]; }; useEffect(() => { filterAnnotations(AnnotationsTaskDetails, userData); }, [AnnotationsTaskDetails, userData]); - //console.log(disableSkip); const handleCollapseClick = () => { !showNotes && setShowStdTranscript(false); @@ -190,7 +157,7 @@ const SuperCheckerAudioTranscriptionLandingPage = () => { }; - useEffect(() => { + useEffect(() => { const hasEmptyText = result?.some((element) => element.text?.trim() === ""); const hasEmptySpeaker = result?.some( (element) => element.speaker_id?.trim() === "" @@ -233,9 +200,9 @@ const SuperCheckerAudioTranscriptionLandingPage = () => { // eslint-disable-next-line react-hooks/exhaustive-deps const handleAutosave = async () => { setAutoSaveTrigger(false); - if(!autoSave) return; + if (!autoSave) return; const currentAnnotation = AnnotationsTaskDetails?.find((a) => a.completed_by === userData.id && a.annotation_type === 3); - if(!currentAnnotation) return; + if (!currentAnnotation) return; const reqBody = { task_id: taskId, auto_save: true, @@ -277,20 +244,10 @@ const SuperCheckerAudioTranscriptionLandingPage = () => { useEffect(() => { if(!autoSave) return; - const handleUpdateTimeSpent = (time = 60) => { - // const apiObj = new UpdateTimeSpentPerTask(taskId, time); - // dispatch(APITransport(apiObj)); - }; - saveIntervalRef.current = setInterval(() => setAutoSaveTrigger(true), 60 * 1000); - timeSpentIntervalRef.current = setInterval( - handleUpdateTimeSpent, - 60 * 1000 - ); const handleBeforeUnload = (event) => { setAutoSaveTrigger(true); - handleUpdateTimeSpent(ref.current); event.preventDefault(); event.returnValue = ""; ref.current = 0; @@ -312,31 +269,23 @@ const SuperCheckerAudioTranscriptionLandingPage = () => { document.addEventListener('keydown', handleInteraction); const interval = setInterval(checkInactivity, 1000); - if(!isActive){ - handleUpdateTimeSpent(ref.current); + if (!isActive) { clearInterval(saveIntervalRef.current); - clearInterval(timeSpentIntervalRef.current); ref.current = 0; } - + const handleVisibilityChange = () => { if (!document.hidden) { // Tab is active, restart the autosave interval saveIntervalRef.current = setInterval(() => setAutoSaveTrigger(true), 60 * 1000); - timeSpentIntervalRef.current = setInterval( - handleUpdateTimeSpent, - 60 * 1000 - ); } else { setAutoSaveTrigger(true); - handleUpdateTimeSpent(ref.current); // Tab is inactive, clear the autosave interval - clearInterval(saveIntervalRef.current); - clearInterval(timeSpentIntervalRef.current); + clearInterval(saveIntervalRef.current) ref.current = 0; } }; - + window.addEventListener("beforeunload", handleBeforeUnload); document.addEventListener("visibilitychange", handleVisibilityChange); @@ -345,7 +294,6 @@ const SuperCheckerAudioTranscriptionLandingPage = () => { document.removeEventListener('keydown', handleInteraction); clearInterval(interval); clearInterval(saveIntervalRef.current); - clearInterval(timeSpentIntervalRef.current); window.removeEventListener("beforeunload", handleBeforeUnload); document.removeEventListener("visibilitychange", handleVisibilityChange); }; @@ -395,17 +343,6 @@ const SuperCheckerAudioTranscriptionLandingPage = () => { dispatch(setSubtitles(sub, C.SUBTITLES)); setStdTranscription(standardisedTranscription); - // const newSub = cloneDeep(sub); - - // dispatch(setCurrentPage(transcriptPayload?.current)); - // dispatch(setNextPage(transcriptPayload?.next)); // dispatch(setPreviousPage(transcriptPayload?.previous)); - // dispatch(setTotalPages(transcriptPayload?.count)); - // dispatch(setSubtitlesForCheck(newSub)); - // dispatch(setCompletedCount(transcriptPayload?.completed_count)); - // dispatch(setRangeStart(transcriptPayload?.start)); - // dispatch(setRangeEnd(transcriptPayload?.end)); - - // eslint-disable-next-line }, [annotations]); useMemo(() => { @@ -429,19 +366,36 @@ const SuperCheckerAudioTranscriptionLandingPage = () => { getAnnotationsTaskData(taskId); getProjectDetails(); getTaskData(taskId); - console.log( - localStorage.getItem("Stage") === "review", - "StageStageStageStage" - ); }, []); + const getProjectDetails = () => { const projectObj = new GetProjectDetailsAPI(projectId); dispatch(APITransport(projectObj)); }; + useEffect(() => { + if (selectedUserId === -1) return; + if (selectedUserId === userData?.id) { + setFilterMessage(""); + setDisableBtns(false); + setAutoSave(true); + getAnnotationsTaskData(taskId); + return; + } + const userAnnotations = AnnotationsTaskDetails?.filter((item) => item.completed_by === selectedUserId); + if (userAnnotations.length) { + setAutoSave(false); + setDisableBtns(true); + setFilterMessage(`This is the ${["Annotator", "Reviewer", "Super Checker"][userAnnotations[0].annotation_type - 1]}'s Annotation in read only mode`); + setAnnotations(userAnnotations); + } + }, [selectedUserId, userData, taskId]); + useEffect(() => { const showAssignedUsers = async () => { - getTaskAssignedUsers(taskDetails).then(res => setAssignedUsers(res)); + getTaskAssignedUsers(taskDetails).then(res => { + setAssignedUsers(res); + }); } taskDetails?.id && showAssignedUsers(); }, [taskDetails]); @@ -452,25 +406,12 @@ const SuperCheckerAudioTranscriptionLandingPage = () => { } }, [AnnotationsTaskDetails]); - /* useEffect(() => { - if(Object.keys(userData).includes("prefer_cl_ui") && !(userData.prefer_cl_ui) && ProjectDetails?.project_type.includes("AudioTranscription")) { - const changeUI = async() => { - handleAutosave().then(navigate(`/projects/${projectId}/SuperChecker/${taskId}`)) - }; - changeUI(); - } - }, [userData]); */ - const tasksComplete = (id) => { if (id) { - // resetNotes(); - // navigate(`/projects/${projectId}/task/${id}`, {replace: true}); navigate( `/projects/${projectId}/SuperCheckerAudioTranscriptionLandingPage/${id}` ); } else { - // navigate(-1); - // resetNotes(); setSnackbarInfo({ open: true, message: "No more tasks to label", @@ -528,7 +469,6 @@ const SuperCheckerAudioTranscriptionLandingPage = () => { id, lead_time, parentannotation, - reviewNotesValue, ) => { setLoading(true); setAutoSave(false); @@ -549,7 +489,7 @@ const SuperCheckerAudioTranscriptionLandingPage = () => { ["draft", "skipped", "rejected"].includes(value) || (["validated", "validated_with_changes"].includes(value) && L1Check && L2Check) ) { - if(value === "rejected") PatchAPIdata["result"] = []; + if (value === "rejected") PatchAPIdata["result"] = []; const TaskObj = new PatchAnnotationAPI(id, PatchAPIdata); const res = await fetch(TaskObj.apiEndPoint(), { method: "PATCH", @@ -562,10 +502,10 @@ const SuperCheckerAudioTranscriptionLandingPage = () => { onNextAnnotation(resp.task); } setSnackbarInfo({ - open: true, - message: resp?.message, - variant: "success", - }); + open: true, + message: resp?.message, + variant: "success", + }); } else { setAutoSave(true); setSnackbarInfo({ @@ -582,7 +522,7 @@ const SuperCheckerAudioTranscriptionLandingPage = () => { message: "Please Enter All The Transcripts", variant: "error", }); - } else if(speakerBox) { + } else if (speakerBox) { setSnackbarInfo({ open: true, message: "Please Select The Speaker", @@ -725,7 +665,6 @@ const SuperCheckerAudioTranscriptionLandingPage = () => { }; const modules = { toolbar: [ - [{ size: [] }], ['bold', 'italic', 'underline', 'strike'], [{ 'color': [] }], @@ -892,22 +831,47 @@ useEffect(() => { onClick={() => { localStorage.removeItem("labelAll"); navigate(`/projects/${projectId}`); - //window.location.replace(`/#/projects/${projectId}`); - //window.location.reload(); }} > Back to Project Task #{taskDetails?.id} + {/* */} + {assignedUsers.map((u, idx) => u && + + )} + + : ""} > - + { disableSkip={disableSkip} anchorEl={anchorEl} setAnchorEl={setAnchorEl} + filterMessage={filterMessage} + disableBtns={disableBtns} /> { setDuration(e.target.value); player.currentTime += 0.01; player.currentTime -= 0.01; - }}/> + }} /> @@ -961,7 +927,7 @@ useEffect(() => { valueLabelDisplay="auto" onChange={(e) => { player.playbackRate = e.target.value; - }}/> + }} /> @@ -976,8 +942,8 @@ useEffect(() => { > Notes {reviewtext.trim().length === 0 ? "" : "*"} - - + + {stdTranscriptionSettings.enable && @@ -996,50 +962,13 @@ useEffect(() => { }
- {/* - {translate("alert.notes")} - */} - {/* setNotesValue(event.target.value)} - inputRef={reviewNotesRef} - rows={1} - maxRows={3} - inputProps={{ - style: { fontSize: "1rem" }, - readOnly: true, - }} - style={{ width: "99%", marginTop: "1%" }} - // ref={quillRef} - /> - - setNotesValue(event.target.value)} - inputRef={superCheckerNotesRef} - InputLabelProps={{ - shrink: true, - }} - rows={1} - maxRows={3} - inputProps={{ - style: { fontSize: "1rem" }, - }} - style={{ width: "99%", marginTop: "1%" }} - /> */} { overflow: "auto", height: "max-content" }} - > - - + > +
+ diff --git a/src/ui/pages/container/Label-Studio/AllTaskLSF.jsx b/src/ui/pages/container/Label-Studio/AllTaskLSF.jsx index 6c069c3c5..0bd65bfbd 100644 --- a/src/ui/pages/container/Label-Studio/AllTaskLSF.jsx +++ b/src/ui/pages/container/Label-Studio/AllTaskLSF.jsx @@ -8,9 +8,10 @@ import ArrowRightIcon from '@mui/icons-material/ArrowRight'; import CustomizedSnackbars from "../../component/common/Snackbar"; import generateLabelConfig from '../../../../utils/LabelConfig/ConversationTranslation'; import conversationVerificationLabelConfig from "../../../../utils/LabelConfig/ConversationVerification" -import LightTooltip from "../../component/common/Tooltip"; import InfoOutlinedIcon from "@mui/icons-material/InfoOutlined"; +import UserMappedByRole from '../../../../utils/UserMappedByRole/UserMappedByRole'; import getTaskAssignedUsers from '../../../../utils/getTaskAssignedUsers'; +import LightTooltip from "../../component/common/Tooltip"; import { getProjectsandTasks, @@ -44,6 +45,7 @@ const LabelStudioWrapper = ({annotationNotesRef, loader, showLoader, hideLoader, const lsfRef = useRef(); const navigate = useNavigate(); const [labelConfig, setLabelConfig] = useState(); + const [projectType, setProjectType] = useState(); const [snackbar, setSnackbarInfo] = useState({ open: false, message: "", @@ -53,6 +55,8 @@ const LabelStudioWrapper = ({annotationNotesRef, loader, showLoader, hideLoader, const { projectId, taskId } = useParams(); const userData = useSelector(state=>state.fetchLoggedInUserData.data) const [assignedUsers, setAssignedUsers] = useState(null); + const [selectedUserId, setSelectedUserId] = useState(null); + const [annotations, setAnnotations] = useState([]); let loaded = useRef(); console.log("projectId, taskId", projectId, taskId); @@ -78,9 +82,30 @@ const LabelStudioWrapper = ({annotationNotesRef, loader, showLoader, hideLoader, })) }, []) + useEffect(() => { + if(!selectedUserId) return; + const userAnnotations = annotations?.filter((item) => item.completed_by === selectedUserId); + if(userAnnotations.length) { + LSFRoot( + rootRef, + lsfRef, + userData, + projectId, + taskData, + labelConfig, + userAnnotations, + [], + annotationNotesRef + ); + } + }, [selectedUserId]); + useEffect(() => { const showAssignedUsers = async () => { - getTaskAssignedUsers(taskData).then(res => setAssignedUsers(res)); + getTaskAssignedUsers(taskData).then(res => { + setAssignedUsers(res); + setSelectedUserId(res[0]?.id); + }); } taskData?.id && showAssignedUsers(); }, [taskData]); @@ -343,6 +368,8 @@ const LabelStudioWrapper = ({annotationNotesRef, loader, showLoader, hideLoader, console.log("[labelConfig, taskData, annotations, predictions]", [labelConfig, taskData, annotations, predictions]); let tempLabelConfig = labelConfig.project_type === "ConversationTranslation" || labelConfig.project_type === "ConversationTranslationEditing" ? generateLabelConfig(taskData.data) : labelConfig.project_type === "ConversationVerification" ? conversationVerificationLabelConfig(taskData.data) : labelConfig.label_config; setLabelConfig(tempLabelConfig); + setProjectType(labelConfig.project_type); + setAnnotations(annotations); setTaskData(taskData); LSFRoot( rootRef, @@ -415,7 +442,25 @@ const LabelStudioWrapper = ({annotationNotesRef, loader, showLoader, hideLoader, } */} - + + {assignedUsers.map((u, idx) => u && + + )} + + : ""} + > + )} + + : ""} + > - + + {assignedUsers.map((u, idx) => u && + + )} + + : ""} + > + + - + + {assignedUsers.map((u, idx) => u && + + )} + + : ""} + > + +
Wave:   {setWave(!wave)}}> {setWaveColor(e.target.value)}}> Background:   {setBackgroundColor(e.target.value)}}> Padding:   {setPaddingColor(e.target.value)}}>