mirror of
https://github.com/Monadical-SAS/reflector.git
synced 2025-12-20 20:29:06 +00:00
Add transcript source kind
This commit is contained in:
@@ -49,8 +49,11 @@ import Pagination from "./pagination";
|
||||
import { formatTimeMs } from "../../lib/time";
|
||||
import useApi from "../../lib/useApi";
|
||||
import { useError } from "../../(errors)/errorContext";
|
||||
import { SourceKind } from "../../api";
|
||||
|
||||
export default function TranscriptBrowser() {
|
||||
const [selectedSourceKind, setSelectedSourceKind] =
|
||||
useState<SourceKind | null>(null);
|
||||
const [selectedRoomId, setSelectedRoomId] = useState("");
|
||||
const [rooms, setRooms] = useState<Room[]>([]);
|
||||
const [page, setPage] = useState(1);
|
||||
@@ -58,6 +61,7 @@ export default function TranscriptBrowser() {
|
||||
const [searchInputValue, setSearchInputValue] = useState("");
|
||||
const { loading, response, refetch } = useTranscriptList(
|
||||
page,
|
||||
selectedSourceKind,
|
||||
selectedRoomId,
|
||||
searchTerm,
|
||||
);
|
||||
@@ -86,7 +90,11 @@ export default function TranscriptBrowser() {
|
||||
.catch((err) => setError(err, "There was an error fetching the rooms"));
|
||||
}, [api]);
|
||||
|
||||
const handleFilterTranscripts = (roomId: string) => {
|
||||
const handleFilterTranscripts = (
|
||||
sourceKind: SourceKind | null,
|
||||
roomId: string,
|
||||
) => {
|
||||
setSelectedSourceKind(sourceKind);
|
||||
setSelectedRoomId(roomId);
|
||||
setPage(1);
|
||||
};
|
||||
@@ -187,10 +195,10 @@ export default function TranscriptBrowser() {
|
||||
<Link
|
||||
as={NextLink}
|
||||
href="#"
|
||||
onClick={() => handleFilterTranscripts("")}
|
||||
color={selectedRoomId === "" ? "blue.500" : "gray.600"}
|
||||
onClick={() => handleFilterTranscripts(null, "")}
|
||||
color={selectedSourceKind === null ? "blue.500" : "gray.600"}
|
||||
_hover={{ color: "blue.300" }}
|
||||
fontWeight={selectedRoomId === "" ? "bold" : "normal"}
|
||||
fontWeight={selectedSourceKind === null ? "bold" : "normal"}
|
||||
>
|
||||
All Transcripts
|
||||
</Link>
|
||||
@@ -208,10 +216,20 @@ export default function TranscriptBrowser() {
|
||||
key={room.id}
|
||||
as={NextLink}
|
||||
href="#"
|
||||
onClick={() => handleFilterTranscripts(room.id)}
|
||||
color={selectedRoomId === room.id ? "blue.500" : "gray.600"}
|
||||
onClick={() => handleFilterTranscripts("room", room.id)}
|
||||
color={
|
||||
selectedSourceKind === "room" &&
|
||||
selectedRoomId === room.id
|
||||
? "blue.500"
|
||||
: "gray.600"
|
||||
}
|
||||
_hover={{ color: "blue.300" }}
|
||||
fontWeight={selectedRoomId === room.id ? "bold" : "normal"}
|
||||
fontWeight={
|
||||
selectedSourceKind === "room" &&
|
||||
selectedRoomId === room.id
|
||||
? "bold"
|
||||
: "normal"
|
||||
}
|
||||
ml={4}
|
||||
>
|
||||
{room.name}
|
||||
@@ -219,6 +237,28 @@ export default function TranscriptBrowser() {
|
||||
))}
|
||||
</>
|
||||
)}
|
||||
|
||||
<Divider />
|
||||
<Link
|
||||
as={NextLink}
|
||||
href="#"
|
||||
onClick={() => handleFilterTranscripts("live", "")}
|
||||
color={selectedSourceKind === "live" ? "blue.500" : "gray.600"}
|
||||
_hover={{ color: "blue.300" }}
|
||||
fontWeight={selectedSourceKind === "live" ? "bold" : "normal"}
|
||||
>
|
||||
Live Transcripts
|
||||
</Link>
|
||||
<Link
|
||||
as={NextLink}
|
||||
href="#"
|
||||
onClick={() => handleFilterTranscripts("file", "")}
|
||||
color={selectedSourceKind === "file" ? "blue.500" : "gray.600"}
|
||||
_hover={{ color: "blue.300" }}
|
||||
fontWeight={selectedSourceKind === "file" ? "bold" : "normal"}
|
||||
>
|
||||
Uploaded Files
|
||||
</Link>
|
||||
</Stack>
|
||||
</Box>
|
||||
|
||||
@@ -241,7 +281,7 @@ export default function TranscriptBrowser() {
|
||||
<Th pl={12} width="400px">
|
||||
Transcription Title
|
||||
</Th>
|
||||
<Th width="150px">Room</Th>
|
||||
<Th width="150px">Source</Th>
|
||||
<Th width="200px">Date</Th>
|
||||
<Th width="100px">Duration</Th>
|
||||
<Th width="50px"></Th>
|
||||
@@ -296,7 +336,11 @@ export default function TranscriptBrowser() {
|
||||
</Link>
|
||||
</Flex>
|
||||
</Td>
|
||||
<Td>{item.room_name}</Td>
|
||||
<Td>
|
||||
{item.source_kind === "room"
|
||||
? item.room_name
|
||||
: item.source_kind}
|
||||
</Td>
|
||||
<Td>
|
||||
{new Date(item.created_at).toLocaleString("en-US", {
|
||||
year: "numeric",
|
||||
@@ -376,7 +420,12 @@ export default function TranscriptBrowser() {
|
||||
<Text fontWeight="bold">
|
||||
{item.title || "Unnamed Transcript"}
|
||||
</Text>
|
||||
<Text>Room: {item.room_name}</Text>
|
||||
<Text>
|
||||
Source:{" "}
|
||||
{item.source_kind === "room"
|
||||
? item.room_name
|
||||
: item.source_kind}
|
||||
</Text>
|
||||
<Text>
|
||||
Date: {new Date(item.created_at).toLocaleString()}
|
||||
</Text>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { useEffect, useState } from "react";
|
||||
import { useError } from "../../(errors)/errorContext";
|
||||
import useApi from "../../lib/useApi";
|
||||
import { Page_GetTranscript_ } from "../../api";
|
||||
import { Page_GetTranscript_, SourceKind } from "../../api";
|
||||
|
||||
type TranscriptList = {
|
||||
response: Page_GetTranscript_ | null;
|
||||
@@ -12,6 +12,7 @@ type TranscriptList = {
|
||||
|
||||
const useTranscriptList = (
|
||||
page: number,
|
||||
sourceKind: SourceKind | null,
|
||||
roomId: string | null,
|
||||
searchTerm: string | null,
|
||||
): TranscriptList => {
|
||||
@@ -31,7 +32,12 @@ const useTranscriptList = (
|
||||
if (!api) return;
|
||||
setLoading(true);
|
||||
api
|
||||
.v1TranscriptsList({ page, roomId, searchTerm })
|
||||
.v1TranscriptsList({
|
||||
page,
|
||||
sourceKind,
|
||||
roomId,
|
||||
searchTerm,
|
||||
})
|
||||
.then((response) => {
|
||||
setResponse(response);
|
||||
setLoading(false);
|
||||
|
||||
@@ -285,6 +285,9 @@ export const $GetTranscript = {
|
||||
],
|
||||
title: "Room Name",
|
||||
},
|
||||
source_kind: {
|
||||
$ref: "#/components/schemas/SourceKind",
|
||||
},
|
||||
},
|
||||
type: "object",
|
||||
required: [
|
||||
@@ -305,6 +308,7 @@ export const $GetTranscript = {
|
||||
"meeting_id",
|
||||
"room_id",
|
||||
"room_name",
|
||||
"source_kind",
|
||||
],
|
||||
title: "GetTranscript",
|
||||
} as const;
|
||||
@@ -766,6 +770,12 @@ export const $RtcOffer = {
|
||||
title: "RtcOffer",
|
||||
} as const;
|
||||
|
||||
export const $SourceKind = {
|
||||
type: "string",
|
||||
enum: ["room", "live", "file"],
|
||||
title: "SourceKind",
|
||||
} as const;
|
||||
|
||||
export const $SpeakerAssignment = {
|
||||
properties: {
|
||||
speaker: {
|
||||
|
||||
@@ -201,6 +201,7 @@ export class DefaultService {
|
||||
* @param data The data for the request.
|
||||
* @param data.roomId
|
||||
* @param data.searchTerm
|
||||
* @param data.sourceKind
|
||||
* @param data.page Page number
|
||||
* @param data.size Page size
|
||||
* @returns Page_GetTranscript_ Successful Response
|
||||
@@ -215,6 +216,7 @@ export class DefaultService {
|
||||
query: {
|
||||
room_id: data.roomId,
|
||||
search_term: data.searchTerm,
|
||||
source_kind: data.sourceKind,
|
||||
page: data.page,
|
||||
size: data.size,
|
||||
},
|
||||
|
||||
@@ -54,6 +54,7 @@ export type GetTranscript = {
|
||||
meeting_id: string | null;
|
||||
room_id: string | null;
|
||||
room_name: string | null;
|
||||
source_kind: SourceKind;
|
||||
};
|
||||
|
||||
export type GetTranscriptSegmentTopic = {
|
||||
@@ -149,6 +150,8 @@ export type RtcOffer = {
|
||||
type: string;
|
||||
};
|
||||
|
||||
export type SourceKind = "room" | "live" | "file";
|
||||
|
||||
export type SpeakerAssignment = {
|
||||
speaker?: number | null;
|
||||
participant?: string | null;
|
||||
@@ -282,6 +285,7 @@ export type V1TranscriptsListData = {
|
||||
* Page size
|
||||
*/
|
||||
size?: number;
|
||||
sourceKind?: SourceKind | null;
|
||||
};
|
||||
|
||||
export type V1TranscriptsListResponse = Page_GetTranscript_;
|
||||
|
||||
Reference in New Issue
Block a user