Skip to content

Commit

Permalink
Merge pull request #686 from AI4Bharat/frontEnd
Browse files Browse the repository at this point in the history
Front end
  • Loading branch information
ishvindersethi22 authored Sep 6, 2023
2 parents c5706ee + fa50f1f commit 9e63085
Show file tree
Hide file tree
Showing 7 changed files with 64 additions and 63 deletions.
7 changes: 5 additions & 2 deletions src/ui/Layout.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ const Layout= (props) => {
const handleClose = () => {
setPopup(false);
};
const loggedInUserData = useSelector(
(state) => state?.fetchLoggedInUserData?.data
);

// const renderError = () => {
// if (apiStatus.unauthrized) {
Expand Down Expand Up @@ -89,7 +92,7 @@ const Layout= (props) => {
return (
<ThemeProvider theme={themeDefault}>
<div
className={ localStorage.getItem("enableChitrlekhaTranscription") === "true" && (localStorage.getItem("enableChitrlekhaUI") === "true")?classes.Audioroot:classes.root}
className={ loggedInUserData?.prefer_cl_ui=== true && (localStorage.getItem("enableChitrlekhaUI") === "true")?classes.Audioroot:classes.root}
>
<Suspense fallback={<div>Loading....</div>}>
<Header
Expand All @@ -99,7 +102,7 @@ const Layout= (props) => {
/>
</Suspense>
<div
className={localStorage.getItem("enableChitrlekhaTranscription") === "true" && (localStorage.getItem("enableChitrlekhaUI") === "true") ?classes.Audiocontainer:classes.container}
className={ loggedInUserData?.prefer_cl_ui=== true && (localStorage.getItem("enableChitrlekhaUI") === "true") ?classes.Audiocontainer:classes.container}
>
{/* {renderSpinner()}
{renderError()} */}
Expand Down
4 changes: 2 additions & 2 deletions src/ui/pages/component/Project/SuperCheckerTasks.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ const SuperCheckerTasks = (props) => {
]);

useEffect(() => {
if((localStorage.getItem("enableChitrlekhaTranscription") === "true" && ProjectDetails?.project_type === "AudioTranscriptionEditing"||ProjectDetails?.project_type === "AudioTranscription" )){
if((userDetails?.prefer_cl_ui && ProjectDetails?.project_type?.includes("AudioTranscription")) || ProjectDetails?.project_type?.includes("AudioTranscriptionEditing") || ProjectDetails?.project_type?.includes("Acoustic")){
if (labellingStarted && Object?.keys(NextTask)?.length > 0) {
navigate(
`/projects/${id}/SuperCheckerAudioTranscriptionLandingPage/${
Expand Down Expand Up @@ -234,7 +234,7 @@ const SuperCheckerTasks = (props) => {
<CustomButton
disabled={ProjectDetails.is_archived}
onClick={() => { console.log("task id === ", el.id); localStorage.removeItem("labelAll")
if(localStorage.getItem("enableChitrlekhaTranscription") === "true" && ProjectDetails?.project_type === "AudioTranscriptionEditing"||ProjectDetails?.project_type === "AudioTranscription" ){
if((userDetails?.prefer_cl_ui && ProjectDetails?.project_type?.includes("AudioTranscription")) || ProjectDetails?.project_type?.includes("AudioTranscriptionEditing") || ProjectDetails?.project_type?.includes("Acoustic") ){
navigate(`SuperCheckerAudioTranscriptionLandingPage/${el.id}`)
}
else{
Expand Down
2 changes: 1 addition & 1 deletion src/ui/pages/component/Project/TaskTable.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ const TaskTable = (props) => {
onClick={() => {
console.log("task id === ", el.id);
localStorage.removeItem("labelAll");
if ((userDetails?.prefer_cl_ui && ProjectDetails?.project_type?.includes("AudioTranscription")) || ProjectDetails?.project_type?.includes("Acoustic")) {
if ((userDetails?.prefer_cl_ui && ProjectDetails?.project_type?.includes("AudioTranscription")) || ProjectDetails?.project_type?.includes("AudioTranscriptionEditing") || ProjectDetails?.project_type?.includes("Acoustic")) {
navigate(`ReviewAudioTranscriptionLandingPage/${el.id}`)
}
else{
Expand Down
51 changes: 36 additions & 15 deletions src/ui/pages/component/common/Header.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import Modal from "./Modal";
import Transliteration from "../../container/Transliteration/Transliteration";
import CustomizedSnackbars from "../common/Snackbar";
import userRole from "../../../../utils/UserMappedByRole/Roles";
import UpdateUIPrefsAPI from "../../../../redux/actions/api/UserManagement/UpdateUIPrefs";

const Header = () => {
const [anchorElUser, setAnchorElUser] = useState(null);
Expand All @@ -46,6 +47,11 @@ const Header = () => {
message: "",
variant: "success",
});
const[checkClUI,setCheckClUI]=useState(null)

const loggedInUserData = useSelector(
(state) => state?.fetchLoggedInUserData?.data
);

const theme = useTheme();
const isMobile = useMediaQuery(theme.breakpoints.down("md"));
Expand All @@ -54,20 +60,26 @@ const Header = () => {
let navigate = useNavigate();
const classes = headerStyle();

const loggedInUserData = useSelector(
(state) => state.fetchLoggedInUserData.data
);


const getLoggedInUserData = () => {
const loggedInUserObj = new FetchLoggedInUserDataAPI("me");
dispatch(APITransport(loggedInUserObj));
dispatch(APITransport(loggedInUserObj));
};



useEffect(() => {
getLoggedInUserData();
console.log("loggedInUserData", loggedInUserData);

}, []);

useEffect(()=>{
if(loggedInUserData?.prefer_cl_ui !== undefined){
setCheckClUI(loggedInUserData?.prefer_cl_ui)
}
},[loggedInUserData])

// const settings = ['Profile', 'Account', 'Dashboard', 'Logout'];
const onLogoutClick = () => {
handleCloseUserMenu();
Expand Down Expand Up @@ -128,12 +140,23 @@ const Header = () => {
}
};

const handleTranscriptionFlowChange = (event) => {
if (event.target.checked) {
localStorage.setItem("enableChitrlekhaTranscription", true);
} else {
localStorage.setItem("enableChitrlekhaTranscription", false);
}
const handleTranscriptionFlowChange = async(event) => {
const obj = new UpdateUIPrefsAPI(event.target.checked);
// dispatch(APITransport(loggedInUserObj));
const res = await fetch(obj.apiEndPoint(), {
method: "POST",
body: JSON.stringify(obj.getBody()),
headers: obj.getHeaders().headers,
});
const resp = await res.json();
if (res.ok) {
getLoggedInUserData();
setSnackbarInfo({
open: true,
message:resp.message,
variant: "success",
});
}
};

const handleTagsChange = (event) => {
Expand Down Expand Up @@ -594,9 +617,7 @@ const Header = () => {
control: (
<Checkbox
onChange={handleTranscriptionFlowChange}
defaultChecked={
localStorage.getItem("enableChitrlekhaTranscription") === "true"
}
checked={checkClUI}
/>
),
},
Expand Down Expand Up @@ -638,7 +659,7 @@ const Header = () => {
<Grid container direction="row">
<Box
className={
localStorage.getItem("enableChitrlekhaTranscription") === "true" &&
loggedInUserData?.prefer_cl_ui=== true &&
localStorage.getItem("enableChitrlekhaUI") === "true"
? classes.AudioparentContainers
: classes.parentContainer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ const AudioTranscriptionLandingPage = () => {
const saveIntervalRef = useRef(null);
const timeSpentIntervalRef = useRef(null);
const user = useSelector((state) => state.fetchLoggedInUserData.data);
const taskDetails = useSelector((state) => state.getTaskDetails?.data);


// useEffect(() => {
// let intervalId;
Expand Down Expand Up @@ -264,7 +266,6 @@ const AudioTranscriptionLandingPage = () => {
setLoading(false);
};


useEffect(() => {
const handleAutosave = async (id) => {
const reqBody = {
Expand All @@ -275,7 +276,7 @@ const AudioTranscriptionLandingPage = () => {
(new Date() - loadtime) / 1000 + Number(AnnotationsTaskDetails[0]?.lead_time?.lead_time ?? 0),
result,
};

if(result.length > 0 && taskDetails?.annotation_users?.some((users) => users === user.id)){
const obj = new SaveTranscriptAPI(AnnotationsTaskDetails[0]?.id,reqBody);
// dispatch(APITransport(obj));
const res = await fetch(obj.apiEndPoint(), {
Expand All @@ -291,6 +292,7 @@ const AudioTranscriptionLandingPage = () => {
variant: "error",
});
}
}
};
const handleUpdateTimeSpent = (time = 60) => {
// const apiObj = new UpdateTimeSpentPerTask(taskId, time);
Expand Down Expand Up @@ -513,24 +515,15 @@ const AudioTranscriptionLandingPage = () => {
if (localStorage.getItem("labelAll") || value === "skipped" ) {
onNextAnnotation(resp.task);
}

if (value === "labeled") {
setSnackbarInfo({
open: true,
message: "Task successfully submitted",
message: resp?.message,
variant: "success",
});
} else if (value === "draft") {
setSnackbarInfo({
open: true,
message: "Task saved as draft",
variant: "success",
});
}
} else {
setSnackbarInfo({
open: true,
message: "Error in saving annotation",
message: resp?.message,
variant: "error",
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ const ReviewAudioTranscriptionLandingPage = () => {
(state) => state.getAnnotationsTask.data
);
const ProjectDetails = useSelector((state) => state.getProjectDetails?.data);
const TaskDetails = useSelector((state) => state.getTaskDetails?.data);
const taskDetails = useSelector((state) => state.getTaskDetails?.data);
const user = useSelector((state) => state.fetchLoggedInUserData.data);
const player = useSelector((state) => state.commonReducer.player);
const ref = useRef(0);
Expand Down Expand Up @@ -300,6 +300,7 @@ const ReviewAudioTranscriptionLandingPage = () => {
// limit: limit,
result,
};
if(result.length > 0 && taskDetails?.annotation_users?.some((users) => users === user.id)){

const obj = new SaveTranscriptAPI(AnnotationsTaskDetails[1]?.id, reqBody);
// dispatch(APITransport(obj));
Expand All @@ -315,7 +316,7 @@ const ReviewAudioTranscriptionLandingPage = () => {
message: "Error in autosaving annotation",
variant: "error",
});
}
}}
};
const handleUpdateTimeSpent = (time = 60) => {
// const apiObj = new UpdateTimeSpentPerTask(taskId, time);
Expand Down Expand Up @@ -561,27 +562,17 @@ const ReviewAudioTranscriptionLandingPage = () => {
onNextAnnotation(resp.task);
}

if (
value === "accepted" ||
value === "accepted_with_minor_changes" ||
value === "accepted_with_major_changes"
) {
setSnackbarInfo({
open: true,
message: "Task successfully submitted",
variant: "success",
});
} else if (value === "draft") {

setSnackbarInfo({
open: true,
message: "Task saved as draft",
message: resp?.message,
variant: "success",
});
}

} else {
setSnackbarInfo({
open: true,
message: "Error in saving annotation",
message: resp?.message,
variant: "error",
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ const SuperCheckerAudioTranscriptionLandingPage = () => {
(state) => state.getAnnotationsTask.data
);
const ProjectDetails = useSelector((state) => state.getProjectDetails?.data);
const TaskDetails = useSelector((state) => state.getTaskDetails?.data);
const taskDetails = useSelector((state) => state.getTaskDetails?.data);
const player = useSelector((state) => state.commonReducer.player);
const userData = useSelector((state) => state.fetchLoggedInUserData.data);
const ref = useRef(0);
Expand Down Expand Up @@ -208,6 +208,7 @@ const SuperCheckerAudioTranscriptionLandingPage = () => {
(new Date() - loadtime) / 1000 + Number(AnnotationsTaskDetails[2]?.lead_time?.lead_time ?? 0),
result,
};
if(result.length > 0 && taskDetails?.annotation_users?.some((users) => users === userData.id)){

const obj = new SaveTranscriptAPI(AnnotationsTaskDetails[2]?.id, reqBody);
// dispatch(APITransport(obj));
Expand All @@ -224,7 +225,7 @@ const SuperCheckerAudioTranscriptionLandingPage = () => {
variant: "error",
});
}

}
};
const handleUpdateTimeSpent = (time = 60) => {
// const apiObj = new UpdateTimeSpentPerTask(taskId, time);
Expand Down Expand Up @@ -473,24 +474,16 @@ const SuperCheckerAudioTranscriptionLandingPage = () => {
if (localStorage.getItem("labelAll") || value === "skipped") {
onNextAnnotation(resp.task);
}

if (value === "validated" || value === "validated_with_changes") {
setSnackbarInfo({
open: true,
message: "Task successfully submitted",
variant: "success",
});
} else if (value === "draft") {
setSnackbarInfo({
setSnackbarInfo({
open: true,
message: "Task saved as draft",
message: resp?.message,
variant: "success",
});
}

} else {
setSnackbarInfo({
open: true,
message: "Error in saving annotation",
message: resp?.message,
variant: "error",
});
}
Expand Down

0 comments on commit 9e63085

Please sign in to comment.