Skip to content

Commit

Permalink
Merge branch 'develop' into Rahul-539
Browse files Browse the repository at this point in the history
  • Loading branch information
ishvindersethi22 authored Jul 3, 2024
2 parents 63eb0c2 + f224de1 commit 7b23c67
Show file tree
Hide file tree
Showing 35 changed files with 2,309 additions and 714 deletions.
1 change: 1 addition & 0 deletions src/config/apiendpoint.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const apiendpoint = {
authUser:"/users/auth/users/",
functions:"/functions/",
Glossary:"/v1/",
transliteration_log: "logs/transliteration-log/",
};

export default apiendpoint;
2 changes: 1 addition & 1 deletion src/redux/actions/CL-Transcription/GetAnnotationsTask.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export default class GetAnnotationsTaskAPI extends API {
constructor(taskId,timeout = 2000) {
super("GET", timeout, false);
this.type = constants.GET_ANNOTATIONS_TASK;
this.endpoint = `${super.apiEndPointAuto()}${ENDPOINTS.getTasks}${taskId}/annotations/?enable_chitralekha_UI=true`;
this.endpoint = `${super.apiEndPointAuto()}${ENDPOINTS.getTasks}${taskId}/annotations/?enable_chitralekha_UI=True`;
}

processResponse(res) {
Expand Down
47 changes: 47 additions & 0 deletions src/redux/actions/api/Annotation/PostTransliterationForLogging.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import API from "../../../api";
import ENDPOINTS from "../../../../config/apiendpoint";
import constants from "../../../constants";

export default class PostTransliterationForLogging extends API {
constructor(source_text, target_text, orginal_romanised_text,edited_romanised_text,target_language, timeout = 2000) {
super("POST", timeout, false);
this.transliterationLog = {
source_english_text: source_text,
indic_translation_text: target_text,
romanised_text: orginal_romanised_text,
edited_romanised_text: edited_romanised_text,
language: target_language,
};
this.type = constants.POST_TRANSLITERATION_LOG;
this.endpoint = `${super.apiEndPointAuto()}${ENDPOINTS.transliteration_log}`;
}

processResponse(res) {
super.processResponse(res);
if (res) {
this.newTransliterationLog = res;
}
}

apiEndPoint() {
return this.endpoint;
}

getBody() {
return this.transliterationLog;
}

getHeaders() {
this.headers = {
headers: {
"Content-Type": "application/json",
"Authorization": `JWT ${localStorage.getItem('shoonya_access_token')}`
},
};
return this.headers;
}

getPayload() {
return this.newTransliterationLog;
}
}
24 changes: 24 additions & 0 deletions src/redux/actions/api/LSFAPI/LSFAPI.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,29 @@ const fetchAnnotation = async (taskID) => {
}
};


const fetchTransliteration = async (sourceText,tgtLng) => {
const url = `https://xlit-api.ai4bharat.org/rt/${encodeURIComponent(tgtLng)}/${encodeURIComponent(sourceText)}`;
const response = await fetch(url, {
method: 'GET',
headers: {
'Content-Type': 'application/json',
},
});

if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}
const data = await response.json();
return {
timestamp: data.at,
error: data.error,
input: data.input,
romanised_transliteration: data.result.join(", "), // Assuming result is always an array; join elements for a single string output
success: data.success
};
};

const postAnnotation = async (
result,
task,
Expand Down Expand Up @@ -273,6 +296,7 @@ export {
patchAnnotation,
deleteAnnotation,
fetchAnnotation,
fetchTransliteration,
postReview,
patchReview,
patchSuperChecker,
Expand Down
27 changes: 18 additions & 9 deletions src/redux/actions/apitransport/apitransport.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,14 +124,23 @@ export default function dispatchAPI(api) {
};
}
return dispatch => {
dispatch(apiStatusAsync(api.dontShowApiLoader() ? false : true, false, "",null, null, true));
axios
.get(api.apiEndPoint(), api.getHeaders())
.then(res => {
success(res, api, dispatch);
})
.catch(err => {
error(err, api, dispatch);
});
if (api.dontShowApiLoader && typeof api.dontShowApiLoader === 'function') {
dispatch(apiStatusAsync(api.dontShowApiLoader() ? false : true, false, "",null, null, true));
}

if (api.apiEndPoint && typeof api.apiEndPoint === 'function' && api.getHeaders && typeof api.getHeaders === 'function') {
axios
.get(api.apiEndPoint(), api.getHeaders())
.then(res => {
if (success && typeof success === 'function') {
success(res, api, dispatch);
}
})
.catch(err => {
if (error && typeof error === 'function') {
error(err, api, dispatch);
}
});
}
};
}
1 change: 1 addition & 0 deletions src/redux/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ const constants = {
SUBTITLES: "SUBTITLES",
PATCH_ANNOTATION:"PATCH_ANNOTATION",
UPDATE_UI_PREFS: "UPDATE_UI_PREFS",
POST_TRANSLITERATION_LOG : "POST_TRANSLITERATION_LOG"

};

Expand Down
2 changes: 1 addition & 1 deletion src/ui/Layout.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ const Layout= (props) => {
return (
<ThemeProvider theme={themeDefault}>
<div
className={location.pathname.includes("AudioTranscriptionLandingPage") || projectType==="StandardizedTranscriptionEditing" ? classes.Audioroot : classes.root}
className={location.pathname.includes("AudioTranscriptionLandingPage") ? classes.Audioroot : classes.root}
>
<Suspense fallback={<div>Loading....</div>}>
<Header
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import CheckIcon from "@mui/icons-material/Check";
import UndoIcon from "@mui/icons-material/Undo";
import RedoIcon from "@mui/icons-material/Redo";
import SplitscreenIcon from "@mui/icons-material/Splitscreen";
import MergeIcon from "@mui/icons-material/MergeType";
// import { FindAndReplace } from "common";
import InfoOutlinedIcon from "@mui/icons-material/InfoOutlined";
// import FormatLineSpacingIcon from "@mui/icons-material/FormatLineSpacingIcon";
Expand Down Expand Up @@ -66,6 +67,8 @@ const SettingsButtonComponent = ({
pauseOnType,
setPauseOnType,
annotationId,
showMerge,
onMergeClickL3,
}) => {
const classes = AudioTranscriptionLandingStyle();
// const dispatch = useDispatch();
Expand Down Expand Up @@ -100,6 +103,27 @@ const SettingsButtonComponent = ({
</Tooltip>
)}

{showMerge && (
<Tooltip title="Merge L2 Transcription" placement="bottom">
<IconButton
sx={{
backgroundColor: "#2C2799",
borderRadius: "50%",
color: "#fff",
marginX: "5px",
marginRight: "5px",
"&.Mui-disabled": { backgroundColor: "lightgray" },
"&:hover": {
backgroundColor: "#271e4f",
},
}}
onClick={onMergeClickL3}
// disabled={!showPopOver}
>
<MergeIcon />
</IconButton>
</Tooltip>
)}
<Tooltip title="Settings" placement="bottom">
<IconButton
className={classes.rightPanelBtnGrp}
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 @@ -435,7 +435,7 @@ const TaskTable = (props) => {
props.type === "review" &&
row.push(
<Link
to={ProjectDetails?.project_type?.includes("Acoustic")
to={ProjectDetails?.project_type?.includes("Acoustic") || ProjectDetails?.project_type?.includes("StandardizedTranscriptionEditing")
? `ReviewAudioTranscriptionLandingPage/${el.id}` : `review/${el.id}`} className={classes.link}>
<CustomButton
disabled={ ProjectDetails.is_archived}
Expand Down
4 changes: 2 additions & 2 deletions src/ui/pages/component/Tabs/AdvancedOperation.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -646,7 +646,7 @@ const AdvancedOperation = (props) => {
onChange={handleReviewToggle}
/>
</Grid> */}
<Grid item xs={12} sm={12} md={12} lg={12} xl={12}
{userRole.Admin === loggedInUserData?.role ?<Grid item xs={12} sm={12} md={12} lg={12} xl={12}
sx={{ ml: 2 }}
>
<FormControl size="small" className={classes.formControl}>
Expand All @@ -668,7 +668,7 @@ const AdvancedOperation = (props) => {
))}
</Select>
</FormControl>
</Grid>
</Grid>:null}

{((userRole.WorkspaceManager === loggedInUserData?.role ||
userRole.OrganizationOwner === loggedInUserData?.role ||
Expand Down
6 changes: 5 additions & 1 deletion src/ui/pages/component/Tabs/DatasetProjectsTable.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import Search from "../../component/common/Search";
import { Grid, Stack, ThemeProvider } from "@mui/material";
import tableTheme from "../../../theme/tableTheme";
import { width } from "@mui/system";
import userRole from "../../../../utils/UserMappedByRole/Roles";

const columns = [
{
Expand Down Expand Up @@ -179,6 +180,9 @@ export default function DatasetProjectsTable({ datasetId }) {
});
}
};
const loggedInUserData = useSelector(
(state) => state.fetchLoggedInUserData.data
);
const renderSnackBar = () => {
return (
<CustomizedSnackbars
Expand All @@ -203,7 +207,7 @@ export default function DatasetProjectsTable({ datasetId }) {
>
<CustomButton sx={{ borderRadius: 2 }} label="View" />
</Link>
<CustomButton sx={{ borderRadius: 2, height: 37 }} onClick={() => getExportProjectButton(project)} label="Export" />
{userRole.Admin === loggedInUserData?.role ?<CustomButton sx={{ borderRadius: 2, height: 37 }} onClick={() => getExportProjectButton(project)} label="Export" />:null}
<CustomButton sx={{ borderRadius: 2 }} onClick={() => getPullNewDataAPI(project)} label="Pull New Data Items" />
</Stack>
),
Expand Down
14 changes: 14 additions & 0 deletions src/ui/pages/component/common/Header.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ const Header = () => {
const [selectedNotificationId, setSelectedNotificationId] = useState(null);
const [showTransliterationModel, setShowTransliterationModel] =
useState(false);

const ProjectDetails = useSelector((state) => state.getProjectDetails.data);

const [snackbar, setSnackbarInfo] = useState({
open: false,
message: "",
Expand Down Expand Up @@ -758,6 +761,17 @@ console.log(unseenNotifications,'uuu');
// onclick: () => {},
// },
];

if (ProjectDetails?.project_type?.includes("ContextualTranslationEditing")) {
appSettings.splice(1, 0, {
name: "Romanised Transliteration",
onclick: () => {
handleCloseSettingsMenu();
localStorage.setItem("showRomanisedTransliterationModel", "true" );
},
});
}

const helpMenu = [
{
name: "Help",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ import ArrowRightIcon from "@mui/icons-material/ArrowRight";
import ArrowBackIcon from "@mui/icons-material/ArrowBack";
import getTaskAssignedUsers from '../../../../utils/getTaskAssignedUsers';
import LightTooltip from "../../component/common/Tooltip";
import configs from '../../../../config/config';
import StandarisedisedTranscriptionEditing from './StandardizedTranscription';

const AllAudioTranscriptionLandingPage = () => {
Expand Down Expand Up @@ -85,6 +86,7 @@ const AllAudioTranscriptionLandingPage = () => {
const [advancedWaveformSettings, setAdvancedWaveformSettings] = useState(false);
const [assignedUsers, setAssignedUsers] = useState(null);
const [waveSurfer, setWaveSurfer] = useState(true);
const [audioURL, setAudioURL] = useState("");

const handleCollapseClick = () => {
!showNotes && setShowStdTranscript(false);
Expand Down Expand Up @@ -114,11 +116,32 @@ const AllAudioTranscriptionLandingPage = () => {
});
} else {
setTaskData(resp);
if (resp?.data?.audio_duration < 700){
if (resp?.data?.audio_duration < 1000){
setWaveSurfer(false);
}else{
setWaveSurfer(true);
}
const fetchAudioData = await fetch(String(resp?.data?.audio_url).replace("https://asr-transcription.objectstore.e2enetworks.net/", `${configs.BASE_URL_AUTO}/task/get_audio_file/?audio_url=`), {
method: "GET",
headers: ProjectObj.getHeaders().headers
})
if (!fetchAudioData.ok){
setAudioURL(resp?.data?.audio_url)
}else{
try {
var base64data = await fetchAudioData.json();
var binaryData = atob(base64data);
var buffer = new ArrayBuffer(binaryData.length);
var view = new Uint8Array(buffer);
for (var i = 0; i < binaryData.length; i++) {
view[i] = binaryData.charCodeAt(i);
}
var blob = new Blob([view], { type: 'audio/mpeg' });
setAudioURL(URL.createObjectURL(blob));
} catch {
setAudioURL(resp?.data?.audio_url)
}
}
}
setLoading(false);
};
Expand Down Expand Up @@ -473,11 +496,14 @@ const AllAudioTranscriptionLandingPage = () => {
</Tooltip>
</Grid>
</Grid>
{audioURL &&
<AudioPanel
setCurrentTime={setCurrentTime}
setPlaying={setPlaying}
taskData={taskData}
audioUrl={audioURL}
/>
}
<Grid container spacing={1} sx={{ pt: 1, pl: 2, pr : 3}} justifyContent="flex-end">
<Stack spacing={2} direction="row" sx={{ mb: 1 }} alignItems="center" justifyContent="flex-end" width="fit-content">
<Typography fontSize={14} fontWeight={"medium"} color="#555">
Expand Down Expand Up @@ -728,7 +754,7 @@ const AllAudioTranscriptionLandingPage = () => {
position="fixed"
bottom={1}
>
{waveSurfer ? <Timeline2 key={taskDetails?.data?.audio_url} details={taskDetails} waveformSettings={waveSurferWaveformSettings}/> : <Timeline currentTime={currentTime} playing={playing} taskID={taskData?.id} waveformSettings={waveformSettings} />}
{audioURL && (waveSurfer ? <Timeline2 key={taskDetails?.data?.audio_url} details={taskDetails} waveformSettings={waveSurferWaveformSettings}/> : <Timeline currentTime={currentTime} playing={playing} taskID={taskData?.id} waveformSettings={waveformSettings} />)}
</Grid>
</>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const AnnotationTranscription = () => {
return (
<div style={{ margin: 0, padding: 0 }}>
{ProjectDetails?.project_type === "StandardizedTranscriptionEditing" ? (
<AudioTranscriptionLandingPage />
<AudioTranscriptionLandingPage project_type={ProjectDetails?.project_type} />
) : (
<LSF />
)}
Expand Down
5 changes: 3 additions & 2 deletions src/ui/pages/container/CL-Transcription/AudioPanel.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ import APITransport from "../../../../redux/actions/apitransport/apitransport";
const AudioPanel = memo( ({
setCurrentTime,
setPlaying,
taskData
taskData,
audioUrl
}) => {
const classes = AudioTranscriptionLandingStyle();
const dispatch = useDispatch();
Expand Down Expand Up @@ -67,7 +68,7 @@ const AudioPanel = memo( ({
id ="audio-panel"
controls
controlsList="nodownload"
src={TaskDetails?.data?.audio_url}
src={audioUrl}
preload="metadata"
type="audio"
// style={{
Expand Down
Loading

0 comments on commit 7b23c67

Please sign in to comment.