Send to zulip

This commit is contained in:
Koper
2023-11-20 21:39:33 +07:00
parent 82f50817f8
commit ba40d28152
3609 changed files with 2311843 additions and 7 deletions

View File

@@ -13,6 +13,7 @@ import FinalSummary from "../finalSummary";
import ShareLink from "../shareLink";
import QRCode from "react-qr-code";
import TranscriptTitle from "../transcriptTitle";
import ShareModal from "./shareModal";
type TranscriptDetails = {
params: {
@@ -30,6 +31,7 @@ export default function TranscriptDetails(details: TranscriptDetails) {
const waveform = useWaveform(protectedPath, transcriptId);
const useActiveTopic = useState<Topic | null>(null);
const mp3 = useMp3(protectedPath, transcriptId);
const [showModal, setShowModal] = useState(false);
if (transcript?.error /** || topics?.error || waveform?.error **/) {
return (
@@ -53,6 +55,13 @@ export default function TranscriptDetails(details: TranscriptDetails) {
<Modal title="Loading" text={"Loading transcript..."} />
) : (
<>
<ShareModal
show={showModal}
setShow={(v) => setShowModal(v)}
title={transcript?.response?.title}
summary={transcript?.response?.longSummary}
url={window.location.href}
/>
<div className="flex flex-col">
{transcript?.response?.title && (
<TranscriptTitle
@@ -81,6 +90,13 @@ export default function TranscriptDetails(details: TranscriptDetails) {
/>
<div className="w-full h-full grid grid-rows-layout-one grid-cols-1 gap-2 lg:gap-4">
<section className=" bg-blue-400/20 rounded-lg md:rounded-xl p-2 md:px-4 h-full">
<button
className="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded"
onClick={() => setShowModal(true)}
>
Open Modal
</button>
{transcript?.response?.longSummary && (
<FinalSummary
protectedPath={protectedPath}

View File

@@ -0,0 +1,114 @@
import React, { useState, useEffect } from "react";
import SelectSearch from "react-select-search";
type ShareModal = {
show: boolean;
setShow: (show: boolean) => void;
title: string;
url: string;
summary: string;
};
const ShareModal = (props: ShareModal) => {
const [stream, setStream] = useState(null);
const [topic, setTopic] = useState(null);
const [includeTranscript, setIncludeTranscript] = useState(false);
const [includeSummary, setIncludeSummary] = useState(false);
const [includeTopics, setIncludeTopics] = useState(false);
const [isLoading, setIsLoading] = useState(true);
const [streams, setStreams] = useState({});
useEffect(() => {
fetch("/streams.json")
.then((response) => {
if (!response.ok) {
throw new Error("Network response was not ok");
}
return response.json();
})
.then((data) => {
console.log("Stream data:", data);
setStreams(data);
setIsLoading(false);
// data now contains the JavaScript object decoded from JSON
})
.catch((error) => {
console.error("There was a problem with your fetch operation:", error);
});
}, []);
const handleSendToZulip = () => {
const message = `### Reflector Recording\n\n**[${props.title}](${props.url})**\n\n${props.summary}`;
alert("Send to zulip");
};
if (props.show && isLoading) {
return <div>Loading...</div>;
}
return (
<div>
{props.show && (
<div className="fixed inset-0 bg-gray-600 bg-opacity-50 overflow-y-auto h-full w-full">
<div className="relative top-20 mx-auto p-5 border w-96 shadow-lg rounded-md bg-white">
<div className="mt-3 text-center">
{/*
<Select
options={streamOptions}
onChange={setStream}
placeholder="Select Stream"
/>
<Select
options={topicOptions}
onChange={setTopic}
placeholder="Select Topic"
className="mt-4"
/> */}
<div className="flex flex-col mt-4">
<label>
<input
type="checkbox"
checked={includeTranscript}
onChange={(e) => setIncludeTranscript(e.target.checked)}
/>
Include Transcript
</label>
<label>
<input
type="checkbox"
checked={includeSummary}
onChange={(e) => setIncludeSummary(e.target.checked)}
/>
Include Summary
</label>
<label>
<input
type="checkbox"
checked={includeTopics}
onChange={(e) => setIncludeTopics(e.target.checked)}
/>
Include Topics
</label>
</div>
<button
className="bg-green-500 hover:bg-green-700 text-white font-bold py-2 px-4 rounded mt-4"
onClick={handleSendToZulip}
>
Send to Zulip
</button>
<button
className="bg-red-500 hover:bg-red-700 text-white font-bold py-2 px-4 rounded mt-4"
onClick={() => props.setShow(false)}
>
Close
</button>
</div>
</div>
</div>
)}
</div>
);
};
export default ShareModal;

View File

@@ -3,9 +3,9 @@ import { isDevelopment } from "./utils";
const localConfig = {
features: {
requireLogin: true,
requireLogin: false,
privacy: true,
browse: true,
browse: false,
},
api_url: "http://127.0.0.1:1250",
websocket_url: "ws://127.0.0.1:1250",