disconnected UI

This commit is contained in:
Jose B
2023-08-08 15:51:12 -05:00
parent 033bbaa347
commit 06569000c4
3 changed files with 25 additions and 6 deletions

View File

@@ -1,18 +1,16 @@
import { Mulberry32 } from "../utils.js";
import React, { useState, useEffect } from "react"; import React, { useState, useEffect } from "react";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { import {
faChevronRight, faChevronRight,
faChevronDown, faChevronDown,
faLinkSlash,
} from "@fortawesome/free-solid-svg-icons"; } from "@fortawesome/free-solid-svg-icons";
export function Dashboard({ export function Dashboard({
isRecording,
onRecord,
transcriptionText, transcriptionText,
finalSummary, finalSummary,
topics, topics,
stream, disconnected,
}) { }) {
const [openIndex, setOpenIndex] = useState(null); const [openIndex, setOpenIndex] = useState(null);
const [autoscrollEnabled, setAutoscrollEnabled] = useState(true); const [autoscrollEnabled, setAutoscrollEnabled] = useState(true);
@@ -98,6 +96,15 @@ export function Dashboard({
)} )}
</div> </div>
{disconnected && (
<div className="absolute top-0 left-0 w-full h-full bg-black opacity-50 flex justify-center items-center">
<div className="text-white text-2xl">
<FontAwesomeIcon icon={faLinkSlash} className="mr-2" />
Disconnected
</div>
</div>
)}
<footer className="h-[7svh] w-full bg-gray-800 text-white text-center py-4 text-2xl"> <footer className="h-[7svh] w-full bg-gray-800 text-white text-center py-4 text-2xl">
&nbsp;{transcriptionText}&nbsp; &nbsp;{transcriptionText}&nbsp;
</footer> </footer>

View File

@@ -186,7 +186,7 @@ export default function Recorder(props) {
</a> </a>
</div> </div>
<div ref={waveformRef} className="w-full shadow-xl rounded-2xl"></div> <div ref={waveformRef} className="w-full shadow-xl rounded-2xl"></div>
<div className="absolute bottom-0 right-1 text-xs text-black"> <div className="absolute bottom-0 right-2 text-xs text-black">
{isRecording && ( {isRecording && (
<div className="inline-block bg-red-500 rounded-full w-2 h-2 my-auto mr-1 animate-ping"></div> <div className="inline-block bg-red-500 rounded-full w-2 h-2 my-auto mr-1 animate-ping"></div>
)} )}

View File

@@ -1,5 +1,5 @@
"use client"; "use client";
import React, { useState } from "react"; import React, { useEffect, useState } from "react";
import Recorder from "./components/record.js"; import Recorder from "./components/record.js";
import { Dashboard } from "./components/dashboard.js"; import { Dashboard } from "./components/dashboard.js";
import useWebRTC from "./components/webrtc.js"; import useWebRTC from "./components/webrtc.js";
@@ -7,6 +7,17 @@ import "../public/button.css";
const App = () => { const App = () => {
const [stream, setStream] = useState(null); const [stream, setStream] = useState(null);
const [disconnected, setDisconnected] = useState(false);
useEffect(() => {
if (process.env.NEXT_PUBLIC_ENV === "development") {
document.onkeyup = (e) => {
if (e.key === "d") {
setDisconnected((prev) => !prev);
}
};
}
}, []);
// This is where you'd send the stream and receive the data from the server. // This is where you'd send the stream and receive the data from the server.
// transcription, summary, etc // transcription, summary, etc
@@ -28,6 +39,7 @@ const App = () => {
finalSummary={serverData.finalSummary} finalSummary={serverData.finalSummary}
topics={serverData.topics ?? []} topics={serverData.topics ?? []}
stream={stream} stream={stream}
disconnected={disconnected}
/> />
</div> </div>
); );