mirror of
https://github.com/Monadical-SAS/reflector.git
synced 2025-12-20 20:29:06 +00:00
Separate upload file and record pages
This commit is contained in:
@@ -27,8 +27,7 @@ export default function TranscriptDetails(details: TranscriptDetails) {
|
|||||||
|
|
||||||
const transcript = useTranscript(transcriptId);
|
const transcript = useTranscript(transcriptId);
|
||||||
const transcriptStatus = transcript.response?.status;
|
const transcriptStatus = transcript.response?.status;
|
||||||
const waiting =
|
const waiting = statusToRedirect.includes(transcriptStatus || "");
|
||||||
!transcriptStatus || statusToRedirect.includes(transcriptStatus);
|
|
||||||
|
|
||||||
const topics = useTopics(transcriptId);
|
const topics = useTopics(transcriptId);
|
||||||
const waveform = useWaveform(transcriptId, waiting);
|
const waveform = useWaveform(transcriptId, waiting);
|
||||||
|
|||||||
113
www/app/[domain]/transcripts/[transcriptId]/upload/page.tsx
Normal file
113
www/app/[domain]/transcripts/[transcriptId]/upload/page.tsx
Normal file
@@ -0,0 +1,113 @@
|
|||||||
|
"use client";
|
||||||
|
import { useEffect, useState } from "react";
|
||||||
|
import useTranscript from "../../useTranscript";
|
||||||
|
import { useWebSockets } from "../../useWebSockets";
|
||||||
|
import "../../../../styles/button.css";
|
||||||
|
import { lockWakeState, releaseWakeState } from "../../../../lib/wakeLock";
|
||||||
|
import { useRouter } from "next/navigation";
|
||||||
|
import useMp3 from "../../useMp3";
|
||||||
|
import { Center, VStack, Text, Heading, Button } from "@chakra-ui/react";
|
||||||
|
import FileUploadButton from "../../fileUploadButton";
|
||||||
|
|
||||||
|
type TranscriptUpload = {
|
||||||
|
params: {
|
||||||
|
transcriptId: string;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
const TranscriptUpload = (details: TranscriptUpload) => {
|
||||||
|
const transcript = useTranscript(details.params.transcriptId);
|
||||||
|
const [transcriptStarted, setTranscriptStarted] = useState(false);
|
||||||
|
|
||||||
|
const webSockets = useWebSockets(details.params.transcriptId);
|
||||||
|
|
||||||
|
let mp3 = useMp3(details.params.transcriptId, true);
|
||||||
|
|
||||||
|
const router = useRouter();
|
||||||
|
|
||||||
|
const [status, setStatus] = useState(
|
||||||
|
webSockets.status.value || transcript.response?.status || "idle",
|
||||||
|
);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (!transcriptStarted && webSockets.transcriptTextLive.length !== 0)
|
||||||
|
setTranscriptStarted(true);
|
||||||
|
}, [webSockets.transcriptTextLive]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
//TODO HANDLE ERROR STATUS BETTER
|
||||||
|
const newStatus =
|
||||||
|
webSockets.status.value || transcript.response?.status || "idle";
|
||||||
|
setStatus(newStatus);
|
||||||
|
if (newStatus && (newStatus == "ended" || newStatus == "error")) {
|
||||||
|
console.log(newStatus, "redirecting");
|
||||||
|
|
||||||
|
const newUrl = "/transcripts/" + details.params.transcriptId;
|
||||||
|
router.replace(newUrl);
|
||||||
|
}
|
||||||
|
}, [webSockets.status.value, transcript.response?.status]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (webSockets.waveform && webSockets.waveform) mp3.getNow();
|
||||||
|
}, [webSockets.waveform, webSockets.duration]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
lockWakeState();
|
||||||
|
return () => {
|
||||||
|
releaseWakeState();
|
||||||
|
};
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<VStack
|
||||||
|
align={"left"}
|
||||||
|
w="full"
|
||||||
|
h="full"
|
||||||
|
mb={4}
|
||||||
|
background="gray.bg"
|
||||||
|
border={"2px solid"}
|
||||||
|
borderColor={"gray.bg"}
|
||||||
|
borderRadius={8}
|
||||||
|
p="4"
|
||||||
|
>
|
||||||
|
<Heading size={"lg"}>Upload meeting</Heading>
|
||||||
|
<Center h={"full"} w="full">
|
||||||
|
<VStack spacing={10}>
|
||||||
|
{status && status == "idle" && (
|
||||||
|
<>
|
||||||
|
<Text>
|
||||||
|
Please select the file, supported formats: .mp3, m4a, .wav,
|
||||||
|
.mp4, .mov or .webm
|
||||||
|
</Text>
|
||||||
|
<FileUploadButton transcriptId={details.params.transcriptId} />
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
{status && status == "uploaded" && (
|
||||||
|
<Text>File is uploaded, processing...</Text>
|
||||||
|
)}
|
||||||
|
{(status == "recording" || status == "processing") && (
|
||||||
|
<>
|
||||||
|
<Heading size={"lg"}>Processing your recording...</Heading>
|
||||||
|
<Text>
|
||||||
|
You can safely return to the library while your file is being
|
||||||
|
processed.
|
||||||
|
</Text>
|
||||||
|
<Button
|
||||||
|
colorScheme="blue"
|
||||||
|
onClick={() => {
|
||||||
|
router.push("/browse");
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Browse
|
||||||
|
</Button>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
</VStack>
|
||||||
|
</Center>
|
||||||
|
</VStack>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default TranscriptUpload;
|
||||||
@@ -1,16 +1,15 @@
|
|||||||
import React from "react";
|
import React, { useState } from "react";
|
||||||
import useApi from "../../lib/useApi";
|
import useApi from "../../lib/useApi";
|
||||||
import { Button } from "@chakra-ui/react";
|
import { Button, CircularProgress } from "@chakra-ui/react";
|
||||||
|
|
||||||
type FileUploadButton = {
|
type FileUploadButton = {
|
||||||
transcriptId: string;
|
transcriptId: string;
|
||||||
disabled?: boolean;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export default function FileUploadButton(props: FileUploadButton) {
|
export default function FileUploadButton(props: FileUploadButton) {
|
||||||
const fileInputRef = React.useRef<HTMLInputElement>(null);
|
const fileInputRef = React.useRef<HTMLInputElement>(null);
|
||||||
const api = useApi();
|
const api = useApi();
|
||||||
|
const [progress, setProgress] = useState(0);
|
||||||
const triggerFileUpload = () => {
|
const triggerFileUpload = () => {
|
||||||
fileInputRef.current?.click();
|
fileInputRef.current?.click();
|
||||||
};
|
};
|
||||||
@@ -27,6 +26,12 @@ export default function FileUploadButton(props: FileUploadButton) {
|
|||||||
// Add other properties if required by the type definition
|
// Add other properties if required by the type definition
|
||||||
};
|
};
|
||||||
|
|
||||||
|
api?.httpRequest.config.interceptors.request.use((request) => {
|
||||||
|
request.onUploadProgress = (progressEvent) => {
|
||||||
|
setProgress((progressEvent.progress || 0) * 100);
|
||||||
|
};
|
||||||
|
return request;
|
||||||
|
});
|
||||||
api?.v1TranscriptRecordUpload({
|
api?.v1TranscriptRecordUpload({
|
||||||
transcriptId: props.transcriptId,
|
transcriptId: props.transcriptId,
|
||||||
formData: uploadData,
|
formData: uploadData,
|
||||||
@@ -40,9 +45,16 @@ export default function FileUploadButton(props: FileUploadButton) {
|
|||||||
onClick={triggerFileUpload}
|
onClick={triggerFileUpload}
|
||||||
colorScheme="blue"
|
colorScheme="blue"
|
||||||
mr={2}
|
mr={2}
|
||||||
isDisabled={props.disabled}
|
isDisabled={progress > 0}
|
||||||
>
|
>
|
||||||
Upload File
|
{progress > 0 && progress < 100 ? (
|
||||||
|
<>
|
||||||
|
Uploading...
|
||||||
|
<CircularProgress size="20px" value={progress} />
|
||||||
|
</>
|
||||||
|
) : (
|
||||||
|
<>Select File</>
|
||||||
|
)}
|
||||||
</Button>
|
</Button>
|
||||||
|
|
||||||
<input
|
<input
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import SelectSearch from "react-select-search";
|
|||||||
import { supportedLatinLanguages } from "../../../supportedLanguages";
|
import { supportedLatinLanguages } from "../../../supportedLanguages";
|
||||||
import { useFiefIsAuthenticated } from "@fief/fief/nextjs/react";
|
import { useFiefIsAuthenticated } from "@fief/fief/nextjs/react";
|
||||||
import { featureEnabled } from "../../domainContext";
|
import { featureEnabled } from "../../domainContext";
|
||||||
|
import { Button, Text } from "@chakra-ui/react";
|
||||||
const TranscriptCreate = () => {
|
const TranscriptCreate = () => {
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const isAuthenticated = useFiefIsAuthenticated();
|
const isAuthenticated = useFiefIsAuthenticated();
|
||||||
@@ -30,21 +30,29 @@ const TranscriptCreate = () => {
|
|||||||
|
|
||||||
const createTranscript = useCreateTranscript();
|
const createTranscript = useCreateTranscript();
|
||||||
|
|
||||||
const [loadingSend, setLoadingSend] = useState(false);
|
const [loadingRecord, setLoadingRecord] = useState(false);
|
||||||
|
const [loadingUpload, setLoadingUpload] = useState(false);
|
||||||
|
|
||||||
const send = () => {
|
const send = () => {
|
||||||
if (loadingSend || createTranscript.loading || permissionDenied) return;
|
if (loadingRecord || createTranscript.loading || permissionDenied) return;
|
||||||
setLoadingSend(true);
|
setLoadingRecord(true);
|
||||||
|
createTranscript.create({ name, target_language: targetLanguage });
|
||||||
|
};
|
||||||
|
|
||||||
|
const uploadFile = () => {
|
||||||
|
if (loadingUpload || createTranscript.loading || permissionDenied) return;
|
||||||
|
setLoadingUpload(true);
|
||||||
createTranscript.create({ name, target_language: targetLanguage });
|
createTranscript.create({ name, target_language: targetLanguage });
|
||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
const action = loadingRecord ? "record" : "upload";
|
||||||
createTranscript.transcript &&
|
createTranscript.transcript &&
|
||||||
router.push(`/transcripts/${createTranscript.transcript.id}/record`);
|
router.push(`/transcripts/${createTranscript.transcript.id}/${action}`);
|
||||||
}, [createTranscript.transcript]);
|
}, [createTranscript.transcript]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (createTranscript.error) setLoadingSend(false);
|
if (createTranscript.error) setLoadingRecord(false);
|
||||||
}, [createTranscript.error]);
|
}, [createTranscript.error]);
|
||||||
|
|
||||||
const { loading, permissionOk, permissionDenied, requestPermission } =
|
const { loading, permissionOk, permissionDenied, requestPermission } =
|
||||||
@@ -55,10 +63,7 @@ const TranscriptCreate = () => {
|
|||||||
<div className="lg:grid lg:grid-cols-2 lg:grid-rows-1 lg:gap-4 lg:h-full h-auto flex flex-col">
|
<div className="lg:grid lg:grid-cols-2 lg:grid-rows-1 lg:gap-4 lg:h-full h-auto flex flex-col">
|
||||||
<section className="flex flex-col w-full lg:h-full items-center justify-evenly p-4 md:px-6 md:py-8">
|
<section className="flex flex-col w-full lg:h-full items-center justify-evenly p-4 md:px-6 md:py-8">
|
||||||
<div className="flex flex-col max-w-xl items-center justify-center">
|
<div className="flex flex-col max-w-xl items-center justify-center">
|
||||||
<h1 className="text-2xl font-bold mb-2">
|
<h1 className="text-2xl font-bold mb-2">Welcome to Reflector</h1>
|
||||||
Welcome to reflector.media
|
|
||||||
</h1>
|
|
||||||
<button>Test upload</button>
|
|
||||||
<p>
|
<p>
|
||||||
Reflector is a transcription and summarization pipeline that
|
Reflector is a transcription and summarization pipeline that
|
||||||
transforms audio into knowledge.
|
transforms audio into knowledge.
|
||||||
@@ -101,7 +106,6 @@ const TranscriptCreate = () => {
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</label>
|
</label>
|
||||||
|
|
||||||
<label className="mb-3">
|
<label className="mb-3">
|
||||||
<p>Do you want to enable live translation?</p>
|
<p>Do you want to enable live translation?</p>
|
||||||
<SelectSearch
|
<SelectSearch
|
||||||
@@ -112,7 +116,6 @@ const TranscriptCreate = () => {
|
|||||||
placeholder="Choose your language"
|
placeholder="Choose your language"
|
||||||
/>
|
/>
|
||||||
</label>
|
</label>
|
||||||
|
|
||||||
{loading ? (
|
{loading ? (
|
||||||
<p className="">Checking permissions...</p>
|
<p className="">Checking permissions...</p>
|
||||||
) : permissionOk ? (
|
) : permissionOk ? (
|
||||||
@@ -131,13 +134,23 @@ const TranscriptCreate = () => {
|
|||||||
Request Microphone Permission
|
Request Microphone Permission
|
||||||
</button>
|
</button>
|
||||||
)}
|
)}
|
||||||
<button
|
<Button
|
||||||
className="mt-4 bg-blue-400 hover:bg-blue-500 focus-visible:bg-blue-500 text-white font-bold py-2 px-4 rounded"
|
colorScheme="blue"
|
||||||
onClick={send}
|
onClick={send}
|
||||||
disabled={!permissionOk || loadingSend}
|
isDisabled={!permissionOk || loadingRecord || loadingUpload}
|
||||||
>
|
>
|
||||||
{loadingSend ? "Loading..." : "Confirm"}
|
{loadingRecord ? "Loading..." : "Record Meeting"}
|
||||||
</button>
|
</Button>
|
||||||
|
<Text align="center" m="2">
|
||||||
|
OR
|
||||||
|
</Text>
|
||||||
|
<Button
|
||||||
|
colorScheme="blue"
|
||||||
|
onClick={uploadFile}
|
||||||
|
isDisabled={!permissionOk || loadingRecord || loadingUpload}
|
||||||
|
>
|
||||||
|
{loadingUpload ? "Loading..." : "Upload File"}
|
||||||
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</section>
|
</section>
|
||||||
|
|||||||
@@ -266,10 +266,6 @@ export default function Recorder(props: RecorderProps) {
|
|||||||
mr={2}
|
mr={2}
|
||||||
onClick={handleRecClick}
|
onClick={handleRecClick}
|
||||||
/>
|
/>
|
||||||
<FileUploadButton
|
|
||||||
transcriptId={props.transcriptId}
|
|
||||||
disabled={isRecording}
|
|
||||||
></FileUploadButton>
|
|
||||||
{!isRecording && (window as any).chrome && (
|
{!isRecording && (window as any).chrome && (
|
||||||
<IconButton
|
<IconButton
|
||||||
aria-label={"Record Tab"}
|
aria-label={"Record Tab"}
|
||||||
|
|||||||
Reference in New Issue
Block a user