diff --git a/app/components/dashboard.js b/app/components/dashboard.js
index 425c63ea..5830c930 100644
--- a/app/components/dashboard.js
+++ b/app/components/dashboard.js
@@ -1,104 +1,17 @@
import { Mulberry32 } from "../utils.js";
import React, { useState, useEffect } from "react";
-export function Dashboard(props) {
+export function Dashboard({
+ isRecording,
+ onRecord,
+ transcriptionText,
+ finalSummary,
+ topics,
+ stream,
+}) {
const [openIndex, setOpenIndex] = useState(null);
const [liveTranscript, setLiveTranscript] = useState("");
- const fakeTranscripts = [
- "This is the first transcript. We are discussing the current situation of our company. We are currently leading the market with a significant margin, and our future outlook is also very promising...",
- "Here is the second transcript. We are now moving to our next topic, which is the progress in our ongoing projects. Most of them are on schedule and the quality of work is up to our standard...",
- "This is the third transcript. It's about the financial status of our company. We are doing quite well financially. The revenue for this quarter is higher than expected...",
- // add more fake transcripts as needed
- ];
-
- useEffect(() => {
- // Randomly select a fake transcript
- const selectedTranscript =
- fakeTranscripts[Math.floor(Math.random() * fakeTranscripts.length)];
- // Split the selected transcript into characters
- const characters = Array.from(selectedTranscript);
-
- let counter = 0;
- let liveTranscriptCopy = "";
- let intervalId = setInterval(() => {
- if (counter < characters.length) {
- liveTranscriptCopy += characters[counter];
- setLiveTranscript(liveTranscriptCopy);
- counter++;
- } else {
- clearInterval(intervalId);
- }
- }, 50); // delay of 100ms
-
- // Cleanup function to clear the interval when the component unmounts
- return () => clearInterval(intervalId);
- }, []);
-
- const generateDecibelData = (x) => {
- let data = [];
- let random = Mulberry32(123456789 + x);
- for (let i = 0; i < 50; i++) {
- data.push(Math.floor(random() * 30) + 10); // generate random values between 10 and 40
- }
- return data;
- };
- const generateDecibelGraph = (decibelData) => {
- return decibelData.map((decibel, i) => (
-
diff --git a/app/components/webrtc.js b/app/components/webrtc.js
index f13e8356..927b8a95 100644
--- a/app/components/webrtc.js
+++ b/app/components/webrtc.js
@@ -3,16 +3,19 @@ import Peer from "simple-peer";
const WebRTC_SERVER_URL = "http://127.0.0.1:1250/offer";
-const useWebRTC = (stream) => {
- const [data, setData] = useState(null);
+const useWebRTC = (stream, setIsRecording) => {
+ const [data, setData] = useState({
+ peer: null,
+ });
useEffect(() => {
+ if (!stream) {
+ return;
+ }
+
let peer = new Peer({ initiator: true, stream: stream });
peer.on("signal", (data) => {
- // This is where you'd send the signal data to the server.
- // The server would then send it back to other peers who would then
- // use `peer.signal()` method to continue the connection negotiation.
if ("sdp" in data) {
fetch(WebRTC_SERVER_URL, {
body: JSON.stringify({
@@ -24,13 +27,9 @@ const useWebRTC = (stream) => {
},
method: "POST",
})
- .then(function (response) {
- return response.json();
- })
- .then(function (answer) {
- return peer.signal(answer);
- })
- .catch(function (e) {
+ .then((response) => response.json())
+ .then((answer) => peer.signal(answer))
+ .catch((e) => {
alert(e);
});
}
@@ -38,20 +37,45 @@ const useWebRTC = (stream) => {
peer.on("connect", () => {
console.log("WebRTC connected");
+ setData(prevData => ({ ...prevData, peer: peer }));
});
peer.on("data", (data) => {
- // Received data from the server.
- console.log(data.toString());
const serverData = JSON.parse(data.toString());
- setData(serverData);
+ console.log(serverData);
+
+ switch (serverData.cmd) {
+ case "SHOW_TRANSCRIPTION":
+ setData((prevData) => ({
+ ...prevData,
+ text: serverData.text,
+ }));
+ break;
+ case "UPDATE_TOPICS":
+ setData((prevData) => ({
+ ...prevData,
+ topics: serverData.topics,
+ }));
+ break;
+ case "DISPLAY_FINAL_SUMMARY":
+ setData((prevData) => ({
+ ...prevData,
+ finalSummary: {
+ duration: serverData.duration,
+ summary: serverData.summary,
+ },
+ }));
+ setIsRecording(false);
+ break;
+ default:
+ console.error(`Unknown command ${serverData.cmd}`);
+ }
});
- // Clean up
return () => {
peer.destroy();
};
- }, [stream]);
+ }, [stream, setIsRecording]);
return data;
};
diff --git a/app/globals.css b/app/globals.scss
similarity index 64%
rename from app/globals.css
rename to app/globals.scss
index a4532f27..b16c3c87 100644
--- a/app/globals.css
+++ b/app/globals.scss
@@ -8,16 +8,7 @@
--background-end-rgb: 255, 255, 255;
}
-@media (prefers-color-scheme: dark) {
- :root {
- --foreground-rgb: 255, 255, 255;
- --background-start-rgb: 32, 32, 32;
- --background-end-rgb: 32, 32, 32;
- }
-}
-
body {
- color: rgb(var(--foreground-rgb));
background: linear-gradient(
to bottom,
transparent,
@@ -28,8 +19,7 @@ body {
font-family: "Roboto", sans-serif;
}
-.temp-transcription
-{
+.temp-transcription {
background: beige;
border-radius: 5px;
}
diff --git a/app/layout.js b/app/layout.js
index df1a0ac7..0e91a9e4 100644
--- a/app/layout.js
+++ b/app/layout.js
@@ -1,4 +1,4 @@
-import "./globals.css";
+import "./globals.scss";
import { Roboto } from "next/font/google";
import Head from "next/head";
diff --git a/package-lock.json b/package-lock.json
index cb583783..e2b473d8 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -14,6 +14,7 @@
"postcss": "8.4.25",
"react": "^18.2.0",
"react-dom": "^18.2.0",
+ "sass": "^1.63.6",
"simple-peer": "^9.11.1",
"supports-color": "^9.4.0",
"tailwindcss": "^3.3.2"
@@ -724,6 +725,11 @@
}
]
},
+ "node_modules/immutable": {
+ "version": "4.3.1",
+ "resolved": "https://registry.npmjs.org/immutable/-/immutable-4.3.1.tgz",
+ "integrity": "sha512-lj9cnmB/kVS0QHsJnYKD1uo3o39nrbKxszjnqS9Fr6NB7bZzW45U6WSGBPKXDL/CvDKqDNPA4r3DoDQ8GTxo2A=="
+ },
"node_modules/inflight": {
"version": "1.0.6",
"resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz",
@@ -1337,6 +1343,22 @@
}
]
},
+ "node_modules/sass": {
+ "version": "1.63.6",
+ "resolved": "https://registry.npmjs.org/sass/-/sass-1.63.6.tgz",
+ "integrity": "sha512-MJuxGMHzaOW7ipp+1KdELtqKbfAWbH7OLIdoSMnVe3EXPMTmxTmlaZDCTsgIpPCs3w99lLo9/zDKkOrJuT5byw==",
+ "dependencies": {
+ "chokidar": ">=3.0.0 <4.0.0",
+ "immutable": "^4.0.0",
+ "source-map-js": ">=0.6.2 <2.0.0"
+ },
+ "bin": {
+ "sass": "sass.js"
+ },
+ "engines": {
+ "node": ">=14.0.0"
+ }
+ },
"node_modules/scheduler": {
"version": "0.23.0",
"resolved": "https://registry.npmjs.org/scheduler/-/scheduler-0.23.0.tgz",
diff --git a/package.json b/package.json
index 40c90b86..5bbde722 100644
--- a/package.json
+++ b/package.json
@@ -15,6 +15,7 @@
"postcss": "8.4.25",
"react": "^18.2.0",
"react-dom": "^18.2.0",
+ "sass": "^1.63.6",
"react-dropdown": "^1.11.0",
"simple-peer": "^9.11.1",
"supports-color": "^9.4.0",
diff --git a/yarn.lock b/yarn.lock
index 28c3e776..4ade487a 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -217,7 +217,7 @@ caniuse-lite@^1.0.30001406, caniuse-lite@^1.0.30001464, caniuse-lite@^1.0.300015
resolved "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001515.tgz"
integrity sha512-eEFDwUOZbE24sb+Ecsx3+OvNETqjWIdabMy52oOkIgcUtAsQifjUG9q4U9dgTHJM2mfk4uEPxc0+xuFdJ629QA==
-chokidar@^3.5.3:
+chokidar@^3.5.3, "chokidar@>=3.0.0 <4.0.0":
version "3.5.3"
resolved "https://registry.npmjs.org/chokidar/-/chokidar-3.5.3.tgz"
integrity sha512-Dr3sfKRP6oTcjf2JmUmFJfeVMvXBdegxB0iVQ5eb2V10uFJUCAS8OByZdVAyVb8xXNz3GjjTgj9kLWsZTqE6kw==
@@ -387,6 +387,11 @@ ieee754@^1.2.1:
resolved "https://registry.npmjs.org/ieee754/-/ieee754-1.2.1.tgz"
integrity sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==
+immutable@^4.0.0:
+ version "4.3.1"
+ resolved "https://registry.npmjs.org/immutable/-/immutable-4.3.1.tgz"
+ integrity sha512-lj9cnmB/kVS0QHsJnYKD1uo3o39nrbKxszjnqS9Fr6NB7bZzW45U6WSGBPKXDL/CvDKqDNPA4r3DoDQ8GTxo2A==
+
inflight@^1.0.4:
version "1.0.6"
resolved "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz"
@@ -733,6 +738,15 @@ safe-buffer@^5.1.0, safe-buffer@~5.2.0:
resolved "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz"
integrity sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==
+sass@^1.3.0, sass@^1.63.6:
+ version "1.63.6"
+ resolved "https://registry.npmjs.org/sass/-/sass-1.63.6.tgz"
+ integrity sha512-MJuxGMHzaOW7ipp+1KdELtqKbfAWbH7OLIdoSMnVe3EXPMTmxTmlaZDCTsgIpPCs3w99lLo9/zDKkOrJuT5byw==
+ dependencies:
+ chokidar ">=3.0.0 <4.0.0"
+ immutable "^4.0.0"
+ source-map-js ">=0.6.2 <2.0.0"
+
scheduler@^0.23.0:
version "0.23.0"
resolved "https://registry.npmjs.org/scheduler/-/scheduler-0.23.0.tgz"
@@ -753,7 +767,7 @@ simple-peer@^9.11.1:
randombytes "^2.1.0"
readable-stream "^3.6.0"
-source-map-js@^1.0.2:
+source-map-js@^1.0.2, "source-map-js@>=0.6.2 <2.0.0":
version "1.0.2"
resolved "https://registry.npmjs.org/source-map-js/-/source-map-js-1.0.2.tgz"
integrity sha512-R0XvVJ9WusLiqTCEiGCmICCMplcCkIwwR11mOSD9CR5u+IXYdiseeEuXCVAjS54zqwkLcPNnmU4OeJ6tUrWhDw==