Skip to content

Commit

Permalink
Merge branch 'develop2' into newsletter
Browse files Browse the repository at this point in the history
  • Loading branch information
AlpanaMajhi committed Nov 14, 2023
2 parents 90124e7 + ba768bf commit 0f12b5c
Show file tree
Hide file tree
Showing 5 changed files with 111 additions and 37 deletions.
49 changes: 48 additions & 1 deletion src/containers/Organization/Project/TaskList.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ const TaskList = () => {
const [searchedCol, setSearchedCol] = useState({});
const [searchedColumn, setSearchedColumn] = useState({});
const [columnDisplay, setColumnDisplay] = useState(false);
const [reOpenTaskId, setReOpenTaskId]= useState(null);

//Data from Redux
const { total_count: totalCount, tasks_list: taskList } = useSelector(
Expand All @@ -176,6 +177,51 @@ const TaskList = () => {
(state) => state.getPreviewData?.data
);

const reopenActionColumn = {
name: "Action",
label: "Actions",
options: {
filter: false,
sort: false,
align: "center",
setCellHeaderProps: () => ({
className: tableClasses.cellHeaderProps,
}),
customBodyRender: (_value, tableMeta) => {
const { tableData: data, rowIndex } = tableMeta;
const selectedTask = data[rowIndex];

return (
<Tooltip
placement="top"
title='Warning! VoiceOver cannot be recovered once deleted'
sx={{
color:'red',
display: "flex",
justifyContent: "flex-end",
alignItems: "center",
}}
>
<Button
color={'error'}
sx={{whiteSpace:'nowrap',display:'inline'}}
onClick={()=>{
{
console.log(tableMeta.rowData[0]);
console.log(setTableDialogColumn)
const reopenObj = new ReopenTaskAPI(reOpenTaskId,true);
dispatch(APITransport(reopenObj));
}
}
}>
Reopen
</Button>
</Tooltip>
);
},
},
};

useEffect(() => {
const { progress, success, apiType, data } = apiStatus;
if (!progress) {
Expand Down Expand Up @@ -250,7 +296,7 @@ const TaskList = () => {
if (apiType === "REOPEN_TASK" && data.response) {
dispatch(setSnackBar({ open: false }));
handleDialogOpen("tableDialog");
setTableDialogColumn(reopenTableColumns);
setTableDialogColumn([...reopenTableColumns,reopenActionColumn]);
setTableDialogMessage(data.message);
setTableDialogResponse(data.response);
}
Expand Down Expand Up @@ -669,6 +715,7 @@ const TaskList = () => {
case "Reopen":
const reopenObj = new ReopenTaskAPI(id);
dispatch(APITransport(reopenObj));
setReOpenTaskId(id)
break;

default:
Expand Down
4 changes: 3 additions & 1 deletion src/containers/Organization/Video/RightPanel.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,9 @@ const RightPanel = ({ currentIndex, setCurrentIndex }) => {

if (!progress && success && apiType === "SAVE_TRANSCRIPT") {
if (!autoSave) {
dispatch(setSnackBar({ open: false }));
setTimeout(() => {
dispatch(setSnackBar({ open: false }));
}, 1000);
}

if (complete) {
Expand Down
4 changes: 4 additions & 0 deletions src/containers/Organization/Video/components/Metronome.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ const findIndex = (subs, startTime) => {

export default React.memo(
function Component({ render, playing }) {
const taskDetails = useSelector((state) => state.getTaskDetails.data);
const classes = VideoLandingStyle();
const dispatch = useDispatch();

Expand All @@ -52,6 +53,7 @@ export default React.memo(
const onMouseDown = useCallback(
(event) => {
if (event.button !== 0) return;
if (taskDetails.task_type.includes("VOICEOVER")){return}
const clickTime = getEventTime(event);
setIsDroging(true);
setDrogStartTime(clickTime);
Expand All @@ -61,6 +63,7 @@ export default React.memo(

const onMouseMove = useCallback(
(event) => {
if (taskDetails.task_type.includes("VOICEOVER")){return}
if (isDroging) {
if (playing) player.pause();
setDrogEndTime(getEventTime(event));
Expand All @@ -70,6 +73,7 @@ export default React.memo(
);

const onDocumentMouseUp = useCallback(() => {
if (taskDetails.task_type.includes("VOICEOVER")){return}
if (isDroging) {
if (
drogStartTime > 0 &&
Expand Down
86 changes: 53 additions & 33 deletions src/containers/Organization/Video/components/SubtitleBoxes.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import React, {
} from "react";
import isEqual from "lodash/isEqual";
import DT from "duration-time-conversion";
import { useParams } from "react-router-dom";
import { useDispatch, useSelector } from "react-redux";
import {
copySubs,
Expand All @@ -34,7 +33,6 @@ import C from "redux/constants";
import {
APITransport,
FetchTranscriptPayloadAPI,
SaveTranscriptAPI,
setSubtitles,
} from "redux/actions";

Expand All @@ -48,6 +46,8 @@ function magnetically(time, closeTime) {

let lastTarget = null;
let lastSub = null;
let previousTarget = null;
let nextTarget = null;
let lastType = "";
let lastX = 0;
let lastIndex = -1;
Expand All @@ -57,7 +57,6 @@ let isDroging = false;

export default memo(
function ({ render, currentTime }) {
const { taskId } = useParams();
const classes = VideoLandingStyle();
const dispatch = useDispatch();

Expand Down Expand Up @@ -103,20 +102,6 @@ export default memo(
// eslint-disable-next-line
}, [subtitles, currentIndex, isPlaying(player)]);

const saveTranscript = async (taskType, subs = subtitles) => {
const reqBody = {
task_id: taskId,
offset: currentPage,
limit: limit,
payload: {
payload: subs,
},
};

const obj = new SaveTranscriptAPI(reqBody, taskType);
dispatch(APITransport(obj));
};

const removeSub = useCallback(
(sub) => {
const index = hasSub(sub);
Expand All @@ -137,25 +122,32 @@ export default memo(
[limit, currentPage]
);

const updateSub = (sub, obj) => {
const index = hasSub(sub);
const copySub = [...subtitles];
const updateSub = useCallback(
(sub, obj) => {
const index = hasSub(sub);
const copySub = [...subtitles];

if (index < 0) return;
if (index <= 0) return;
if (taskDetails.task_type.includes("VOICEOVER")){return}

Object.assign(sub, obj);
Object.assign(sub, obj);

copySub[index] = sub;
dispatch(setSubtitles(copySub, C.SUBTITLES));
};
copySub[index] = sub;
dispatch(setSubtitles(copySub, C.SUBTITLES));
},
// eslint-disable-next-line
[subtitles]
);

const onMouseDown = (sub, event, type) => {
lastSub = sub;
const onMouseDown = (index, event, type) => {
previousTarget = $subsRef.current.children[index - 1];
lastSub = subtitles[index];
nextTarget = $subsRef.current.children[index + 1];
if (event.button !== 0) return;
isDroging = true;
lastType = type;
lastX = event.pageX;
lastIndex = subtitles.indexOf(sub);
lastIndex = index;
lastTarget = $subsRef.current.children[lastIndex];
lastWidth = parseFloat(lastTarget.style.width);
};
Expand Down Expand Up @@ -189,7 +181,14 @@ export default memo(
lastSub.endTime + timeDiff,
next ? next.startTime : null
);

const nextCardStartTime = endTime;
const previousCardEndTime = startTime;

const width = (endTime - startTime) * 10 * gridGap;
const nextCardWidth = (next.endTime - nextCardStartTime) * 10 * gridGap;
const previousCardWidth =
(previousCardEndTime - previou?.startTime?previou.startTime:0) * 10 * gridGap;

if (lastType === "left") {
if (startTime >= 0 && lastSub.endTime - startTime >= 0.2) {
Expand All @@ -199,6 +198,12 @@ export default memo(
updateSub(lastSub, { start_time });
}

if(index > 0 && startTime < DT.t2d(previou.end_time) && startTime !== DT.t2d(previou.end_time)) {
updateSub(lastSub, { start_time });
updateSub(previou, { end_time: start_time });
previousTarget.style.width = `${previousCardWidth}px`;
}

if (index === 0) {
updateSub(lastSub, { start_time });
}
Expand All @@ -209,11 +214,26 @@ export default memo(
if (endTime >= 0 && endTime - lastSub.startTime >= 0.2) {
const end_time = DT.d2t(endTime);

if (index >= 0 && index !== subtitles.length - 1 && endTime <= DT.t2d(next.start_time)) {
if (
index >= 0 &&
index !== subtitles.length - 1 &&
endTime <= DT.t2d(next.start_time)
) {
updateSub(lastSub, { end_time });
}

if (
index >= 0 &&
index !== subtitles.length - 1 &&
endTime > DT.t2d(next.start_time) &&
endTime !== DT.t2d(next.start_time)
) {
updateSub(lastSub, { end_time });
updateSub(next, { start_time: end_time });
nextTarget.style.width = `${nextCardWidth}px`;
}

if(index === subtitles.length - 1 && endTime < lastSub.endTime) {
if (index === subtitles.length - 1 && endTime < lastSub.endTime) {
updateSub(lastSub, { end_time });
}
} else {
Expand Down Expand Up @@ -372,13 +392,13 @@ export default memo(
left: 0,
width: 10,
}}
onMouseDown={(event) => onMouseDown(sub, event, "left")}
onMouseDown={(event) => onMouseDown(key, event, "left")}
></div>

<div
className={classes.subText}
title={sub.text}
onMouseDown={(event) => onMouseDown(sub, event)}
onMouseDown={(event) => onMouseDown(key, event)}
>
<p className={classes.subTextP}>
{taskDetails.task_type.includes("TRANSCRIPTION") ||
Expand All @@ -394,7 +414,7 @@ export default memo(
right: 0,
width: 10,
}}
onMouseDown={(event) => onMouseDown(sub, event, "right")}
onMouseDown={(event) => onMouseDown(key, event, "right")}
></div>
<div className={classes.subDuration}>{sub.duration}</div>
</ContextMenuTrigger>
Expand Down
5 changes: 3 additions & 2 deletions src/redux/actions/api/Project/ReopenTask.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@ import ENDPOINTS from "../../../../config/apiendpoint";
import C from "../../../constants";

export default class ReopenTaskAPI extends API {
constructor(id, timeout = 2000) {
constructor(id, delete_voiceover_and_reopen=false, timeout = 2000) {
super("POST", timeout, false);
this.type = C.REOPEN_TASK;
this.delete_and_reopen=delete_voiceover_and_reopen;
this.id = id;

this.endpoint = `${super.apiEndPointAuto()}${
ENDPOINTS.task
}${id}/reopen_translation_task/`;
}${id}/reopen_translation_task/?delete_voiceover_and_reopen=${delete_voiceover_and_reopen}`;
}

processResponse(res) {
Expand Down

0 comments on commit 0f12b5c

Please sign in to comment.