Skip to content

Commit

Permalink
Merge pull request #990 from AI4Bharat/develop
Browse files Browse the repository at this point in the history
Shoonya v2.6.2 Patch
  • Loading branch information
ishvindersethi22 authored Apr 1, 2024
2 parents 17f559e + de7e54c commit 9162f80
Show file tree
Hide file tree
Showing 8 changed files with 405 additions and 16 deletions.
12 changes: 10 additions & 2 deletions src/redux/actions/api/LSFAPI/LSFAPI.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,9 @@ const patchReview = async (
result,
parentAnnotation,
reviewnotes,
autoSave=false
autoSave=false,
languages,
ocr_domain
) => {
try {
await axiosInstance.patch(`/annotation/${annotationID}/`, {
Expand All @@ -156,6 +158,8 @@ const patchReview = async (
parent_annotation: parentAnnotation,
review_notes: reviewnotes,
}),
...(languages && {languages: languages.current}),
...(ocr_domain && {ocr_domain: ocr_domain.current}),
...(autoSave && { auto_save: true }),
});
// if (review_status === "to_be_revised") {
Expand All @@ -178,7 +182,9 @@ const patchSuperChecker = async (
result,
parentAnnotation,
superchecknotes,
autoSave=false
autoSave=false,
languages,
ocr_domain
) => {
console.log(superchecknotes,"superchecknotes")
try {
Expand All @@ -189,6 +195,8 @@ const patchSuperChecker = async (
result: result,
parent_annotation: parentAnnotation,
supercheck_notes: superchecknotes,
...(languages && {languages: languages.current}),
...(ocr_domain && {ocr_domain: ocr_domain.current}),
...(autoSave && { auto_save: true }),
});

Expand Down
11 changes: 9 additions & 2 deletions src/ui/pages/component/common/DataitemsTable.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,15 @@ const DataitemsTable = () => {
const [searchAnchor, setSearchAnchor] = useState(null);
const searchOpen = Boolean(searchAnchor);
const [searchedCol, setSearchedCol] = useState();
localStorage.setItem("DataitemsList", JSON.stringify(columns));
localStorage.setItem("Dataitem", JSON.stringify(dataitemsList));

useEffect(()=>{
try{
localStorage.setItem("DataitemsList", JSON.stringify(columns));
localStorage.setItem("Dataitem", JSON.stringify(dataitemsList));
}catch{
console.log("Local storage set item quota exceeded")
}
}, [columns, dataitemsList]);

const getDataitems = () => {
const dataObj = new GetDataitemsById(
Expand Down
6 changes: 3 additions & 3 deletions src/ui/pages/component/common/Header.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -1038,12 +1038,13 @@ console.log(unseenNotifications,'uuu');
: 'primary'
: "primary"} />
</div>
<div style={{ display: 'flex', flexDirection: 'column', width: '100%' ,cursor:"pointer"}}>
<Link style={{ color: "rgba(0, 0, 0, 0.87)", display: 'flex', flexDirection: 'column', width: '100%' ,cursor:"pointer",textDecoration:"none" }} to={notification.on_click}>
<div style={{ display: 'flex', flexDirection: 'row', width: '100%' }}>
<Typography variant="subtitle2">{`ID: ${notification?.title?.split('-')[0]}`}</Typography>
<Typography style={{ paddingLeft: "10px" }} variant="subtitle2">{`TITLE: ${notification?.notification_type}`}</Typography>
<Typography style={{ padding: "5px 5px 0px 5px" }} variant="caption" color="action">{`${formatDistanceToNow(new Date(notification?.created_at), { addSuffix: true })}`}</Typography>
</div>

<div style={{ display: 'flex', flexDirection: 'row', justifyContent: "space-between" }}>
<Typography style={{ justifyContent: "flex-start", width: '100%' }} variant="body2">{notification?.title?.split('-')[1]}</Typography>
{notification?.seen_json==null || !notification?.seen_json[loggedInUserData.id] ?
Expand All @@ -1053,8 +1054,7 @@ console.log(unseenNotifications,'uuu');
</div>
<Typography variant="caption" color="action">{`Sent on: ${format(new Date(notification?.created_at), 'MMM d, yyyy')}`}</Typography>
{index !== Notification?.length - 1 && <Divider />}
</div>

</Link>
</div>
))}
</>
Expand Down
6 changes: 6 additions & 0 deletions src/ui/pages/container/Admin/TaskDetails.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { snakeToTitleCase } from '../../../../utils/utils.js';
import GetTaskAnnotationsAPI from '../../../../redux/actions/api/Tasks/GetTaskAnnotations.js';
import FetchUserByIdAPI from "../../../../redux/actions/api/UserManagement/FetchUserById";
import {CircularProgress} from '@mui/material';
import { Link } from 'react-router-dom';

function TaskDetails() {
const [taskId, setTaskId] = useState('');
Expand Down Expand Up @@ -231,6 +232,11 @@ function TaskDetails() {
valueRenderer={(raw) => <span>{typeof raw === "string" && raw.match(/^"(.*)"$/) ? raw.slice(1, -1) : raw}</span>}
theme={theme}
/>
{taskDetails &&(
<Link to ={`/projects/${taskDetails.project_id}`}>
<Button variant="contained">Project Page</Button>
</Link>
)}
</TabPanel>
<TabPanel value={tabValue} index={1}>
<JSONTree
Expand Down
119 changes: 118 additions & 1 deletion src/ui/pages/container/Label-Studio/AllTaskLSF.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,21 @@ const LabelStudioWrapper = ({annotationNotesRef, loader, showLoader, hideLoader,
message: "",
variant: "success",
});
const ocrDomain = useRef();
const [ocrD, setOcrD] = useState("");
const selectedLanguages = useRef([]);
const [selectedL, setSelectedL] = useState([]);
const [predictions, setPredictions] = useState([]);
const [taskData, setTaskData] = useState(undefined);
const { projectId, taskId } = useParams();
const userData = useSelector(state=>state.fetchLoggedInUserData.data)
const [assignedUsers, setAssignedUsers] = useState(null);
let loaded = useRef();

useEffect(() => {
setPredictions(taskData?.data?.ocr_prediction_json);
}, [taskData]);

console.log("projectId, taskId", projectId, taskId);
// debugger

Expand Down Expand Up @@ -325,7 +334,11 @@ useEffect(() => {
load_time,
annotations[i].lead_time,
annotation_status.current,
annotationNotesRef.current.value
annotationNotesRef.current.value,
{},
false,
selectedLanguages,
ocrDomain
).then(() => {
if (localStorage.getItem("labelAll"))
getNextProject(projectId, taskData.id).then((res) => {
Expand Down Expand Up @@ -443,6 +456,31 @@ useEffect(() => {
);
};

const handleSelectChange = (event) => {
selectedLanguages.current = Array.from(event.target.selectedOptions, (option) => option.value);
setSelectedL(Array.from(event.target.selectedOptions, (option) => option.value));
};

useEffect(() => {
if(taskData){
if(Array.isArray(taskData?.data?.language)){
taskData?.data?.language?.map((lang)=>{
selectedLanguages.current?.push(lang);
const newLanguages = [...selectedL, ...taskData?.data?.language];
setSelectedL(newLanguages);
});
}
if(typeof taskData?.data?.language === 'string' && taskData?.data?.ocr_domain !== ""){
setSelectedL([taskData?.data?.language]);
selectedLanguages.current?.push(taskData?.data?.language);
}
if(typeof taskData?.data?.ocr_domain === 'string' && taskData?.data?.ocr_domain !== ""){
ocrDomain.current = taskData?.data?.ocr_domain;
setOcrD(taskData?.data?.ocr_domain);
}
}
}, [taskData]);

return (
<div>
{!loader && <div style={{ display: "flex", justifyContent: "space-between" }} className="lsf-controls">
Expand Down Expand Up @@ -508,6 +546,85 @@ useEffect(() => {
>
<div className="label-studio-root" ref={rootRef}></div>
</Box>
{!loader && ProjectDetails?.project_type?.includes("OCRSegmentCategorization") &&
<>
<div style={{borderStyle:"solid", borderWidth:"1px", borderColor:"#E0E0E0", paddingBottom:"1%", display:"flex", justifyContent:"space-around"}}>
<div style={{paddingLeft:"1%", fontSize:"medium", paddingTop:"1%", display:"flex"}}><div style={{margin:"auto"}}>Languages :&nbsp;</div>
<select multiple onChange={handleSelectChange} value={selectedL}>
<option value="English">English</option>
<option value="Hindi">Hindi</option>
<option value="Marathi">Marathi</option>
<option value="Tamil">Tamil</option>
<option value="Telugu">Telugu</option>
<option value="Kannada">Kannada</option>
<option value="Gujarati">Gujarati</option>
<option value="Punjabi">Punjabi</option>
<option value="Bengali">Bengali</option>
<option value="Malayalam">Malayalam</option>
<option value="Assamese">Assamese</option>
<option value="Bodo">Bodo</option>
<option value="Dogri">Dogri</option>
<option value="Kashmiri">Kashmiri</option>
<option value="Maithili">Maithili</option>
<option value="Manipuri">Manipuri</option>
<option value="Nepali">Nepali</option>
<option value="Odia">Odia</option>
<option value="Sindhi">Sindhi</option>
<option value="Sinhala">Sinhala</option>
<option value="Urdu">Urdu</option>
<option value="Santali">Santali</option>
<option value="Sanskrit">Sanskrit</option>
<option value="Goan Konkani">Goan Konkani</option>
</select>
</div>
<div style={{paddingLeft:"1%", fontSize:"medium", paddingTop:"1%", display:"flex"}}><div style={{margin:"auto"}}>Domain :&nbsp;</div>
<select style={{margin:"auto"}} onChange={(e) => {setOcrD(e.target.value); ocrDomain.current = e.target.value;}} value={ocrD}>
<option disabled selected></option>
<option value="BO">Books</option>
<option value="FO">Forms</option>
<option value="OT">Others</option>
<option value="TB">Textbooks</option>
<option value="NV">Novels</option>
<option value="NP">Newspapers</option>
<option value="MG">Magazines</option>
<option value="RP">Research_Papers</option>
<option value="FM">Form</option>
<option value="BR">Brochure_Posters_Leaflets</option>
<option value="AR">Acts_Rules</option>
<option value="PB">Publication</option>
<option value="NT">Notice</option>
<option value="SY">Syllabus</option>
<option value="QP">Question_Papers</option>
<option value="MN">Manual</option>
</select>
</div>
</div>
<div style={{borderStyle:"solid", borderWidth:"1px", borderColor:"#E0E0E0", paddingBottom:"1%"}}>
<div style={{paddingLeft:"1%", fontSize:"medium", paddingTop:"1%", paddingBottom:"1%"}}>Predictions</div>
{predictions?.length > 0 ?
(() => {
try {
return JSON.parse(predictions)?.map((pred, index) => (
<div style={{paddingLeft:"2%", display:"flex", paddingRight:"2%", paddingBottom:"1%"}}>
<div style={{padding:"1%", margin:"auto", color:"#9E9E9E"}}>{index}</div>
<textarea readOnly style={{width:"100%", borderColor:"#E0E0E0"}} value={pred.text}/>
</div>
));
} catch (error) {
console.error("Error parsing predictions:", error);
return predictions?.map((pred, index) => (
<div style={{paddingLeft:"2%", display:"flex", paddingRight:"2%", paddingBottom:"1%"}}>
<div style={{padding:"1%", margin:"auto", color:"#9E9E9E"}}>{index}</div>
<textarea readOnly style={{width:"100%", borderColor:"#E0E0E0"}} value={pred.text}/>
</div>
));
}
})()
:
<div style={{textAlign:"center"}}>No Predictions Present</div>}
</div>
</>
}

{loader}
{renderSnackBar()}
Expand Down
23 changes: 20 additions & 3 deletions src/ui/pages/container/Label-Studio/LSF.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -1118,9 +1118,26 @@ const LabelStudioWrapper = ({
<div style={{borderStyle:"solid", borderWidth:"1px", borderColor:"#E0E0E0", paddingBottom:"1%"}}>
<div style={{paddingLeft:"1%", fontSize:"medium", paddingTop:"1%", paddingBottom:"1%"}}>Predictions</div>
{predictions?.length > 0 ?
predictions?.map((pred, index) => (
<div style={{paddingLeft:"2%", display:"flex", paddingRight:"2%", paddingBottom:"1%"}}><div style={{padding:"1%", margin:"auto", color:"#9E9E9E"}}>{index}</div><textarea readOnly style={{width:"100%", borderColor:"#E0E0E0"}} value={pred.text}/></div>
)) : <div style={{textAlign:"center"}}>No Predictions Present</div>}
(() => {
try {
return JSON.parse(predictions)?.map((pred, index) => (
<div style={{paddingLeft:"2%", display:"flex", paddingRight:"2%", paddingBottom:"1%"}}>
<div style={{padding:"1%", margin:"auto", color:"#9E9E9E"}}>{index}</div>
<textarea readOnly style={{width:"100%", borderColor:"#E0E0E0"}} value={pred.text}/>
</div>
));
} catch (error) {
console.error("Error parsing predictions:", error);
return predictions?.map((pred, index) => (
<div style={{paddingLeft:"2%", display:"flex", paddingRight:"2%", paddingBottom:"1%"}}>
<div style={{padding:"1%", margin:"auto", color:"#9E9E9E"}}>{index}</div>
<textarea readOnly style={{width:"100%", borderColor:"#E0E0E0"}} value={pred.text}/>
</div>
));
}
})()
:
<div style={{textAlign:"center"}}>No Predictions Present</div>}
</div>
</>
}
Expand Down
Loading

0 comments on commit 9162f80

Please sign in to comment.