feat: add single file download, microphone gain control, and media gallery auto-refresh
CD — Kai-Sa-Cam Deployment / deploy (push) Successful in 10s
CD — Kai-Sa-Cam Deployment / deploy (push) Successful in 10s
This commit is contained in:
+26
-27
@@ -51,7 +51,10 @@ export function App() {
|
||||
|
||||
const handleSnapshot = async () => {
|
||||
try {
|
||||
const res = await fetch("/api/media/snapshots", { method: "POST" });
|
||||
const res = await fetch("/api/media/snapshots", {
|
||||
method: "POST",
|
||||
credentials: "include",
|
||||
});
|
||||
if (!res.ok) throw new Error("Snapshot failed");
|
||||
const data = await res.json();
|
||||
setSnapshots((prev) => [data.filename, ...prev]);
|
||||
@@ -95,33 +98,29 @@ export function App() {
|
||||
</button>
|
||||
</nav>
|
||||
|
||||
<div
|
||||
className={`flex-1 flex flex-col p-4 gap-4 overflow-hidden ${activeTab === "live" ? "" : "hidden"}`}
|
||||
>
|
||||
<VideoPlayer streamUrl="https://stream.esiah.dev/stream.html?src=webcam&mode=mse" />
|
||||
<Controls
|
||||
isRecording={isRecording}
|
||||
recordingTime={recordingTime}
|
||||
isTalking={isTalking}
|
||||
gain={gain}
|
||||
onGainChange={setGain}
|
||||
onRecord={handleRecord}
|
||||
onSnapshot={handleSnapshot}
|
||||
onTalk={handleTalk}
|
||||
disabled={Boolean(recError || talkError)}
|
||||
/>
|
||||
{(recError || talkError) && (
|
||||
<div className="text-red-400 text-sm text-center px-4">
|
||||
{recError || talkError}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<div
|
||||
className={`flex-1 flex flex-col ${activeTab === "media" ? "" : "hidden"}`}
|
||||
>
|
||||
{activeTab === "live" ? (
|
||||
<div className="flex-1 flex flex-col p-4 gap-4 overflow-hidden">
|
||||
<VideoPlayer streamUrl="https://stream.esiah.dev/stream.html?src=webcam&mode=mse" />
|
||||
<Controls
|
||||
isRecording={isRecording}
|
||||
recordingTime={recordingTime}
|
||||
isTalking={isTalking}
|
||||
gain={gain}
|
||||
onGainChange={setGain}
|
||||
onRecord={handleRecord}
|
||||
onSnapshot={handleSnapshot}
|
||||
onTalk={handleTalk}
|
||||
disabled={Boolean(recError || talkError)}
|
||||
/>
|
||||
{(recError || talkError) && (
|
||||
<div className="text-red-400 text-sm text-center px-4">
|
||||
{recError || talkError}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
) : (
|
||||
<MediaGallery />
|
||||
</div>
|
||||
)}
|
||||
</main>
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -16,7 +16,7 @@ export function MediaGallery() {
|
||||
|
||||
const fetchMedia = async () => {
|
||||
try {
|
||||
const res = await fetch("/api/media");
|
||||
const res = await fetch("/api/media", { credentials: "include" });
|
||||
if (!res.ok) throw new Error();
|
||||
const data = await res.json();
|
||||
setMedia(data);
|
||||
@@ -31,7 +31,10 @@ export function MediaGallery() {
|
||||
|
||||
const handleDelete = async (filename: string) => {
|
||||
try {
|
||||
const res = await fetch(`/api/media/${filename}`, { method: "DELETE" });
|
||||
const res = await fetch(`/api/media/${filename}`, {
|
||||
method: "DELETE",
|
||||
credentials: "include",
|
||||
});
|
||||
if (!res.ok) throw new Error();
|
||||
setMedia((prev) => prev.filter((m) => m.filename !== filename));
|
||||
setItemToDelete(null);
|
||||
@@ -42,7 +45,10 @@ export function MediaGallery() {
|
||||
|
||||
const handleExportAll = async () => {
|
||||
try {
|
||||
const res = await fetch("/api/media/export", { method: "POST" });
|
||||
const res = await fetch("/api/media/export", {
|
||||
method: "POST",
|
||||
credentials: "include",
|
||||
});
|
||||
if (!res.ok) throw new Error();
|
||||
const blob = await res.blob();
|
||||
const url = window.URL.createObjectURL(blob);
|
||||
@@ -63,14 +69,22 @@ export function MediaGallery() {
|
||||
<div className="flex-1 flex flex-col p-4 gap-4 overflow-y-auto">
|
||||
<div className="flex justify-between items-center">
|
||||
<span className="text-sm text-zinc-400">{media.length} fichiers</span>
|
||||
{media.length > 0 && (
|
||||
<div className="flex gap-2">
|
||||
<button
|
||||
onClick={handleExportAll}
|
||||
className="px-4 py-2 text-xs glass-button rounded-xl text-zinc-200 hover:text-white"
|
||||
onClick={fetchMedia}
|
||||
className="px-3 py-2 text-xs glass-button rounded-xl text-zinc-200 hover:text-white"
|
||||
>
|
||||
Tout télécharger et vider
|
||||
Actualiser
|
||||
</button>
|
||||
)}
|
||||
{media.length > 0 && (
|
||||
<button
|
||||
onClick={handleExportAll}
|
||||
className="px-4 py-2 text-xs glass-button rounded-xl text-zinc-200 hover:text-white"
|
||||
>
|
||||
Tout télécharger et vider
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
{error && <div className="text-red-400 text-sm text-center">{error}</div>}
|
||||
<div className="grid grid-cols-2 md:grid-cols-4 gap-4">
|
||||
@@ -97,12 +111,21 @@ export function MediaGallery() {
|
||||
<span className="text-xs truncate text-zinc-300">
|
||||
{item.filename}
|
||||
</span>
|
||||
<button
|
||||
onClick={() => setItemToDelete(item.filename)}
|
||||
className="px-2 py-1 text-xs bg-red-500/20 text-red-400 rounded-lg hover:bg-red-500/30 transition-colors"
|
||||
>
|
||||
Supprimer
|
||||
</button>
|
||||
<div className="flex gap-1">
|
||||
<a
|
||||
href={item.url}
|
||||
download={item.filename}
|
||||
className="px-2 py-1 text-xs glass-button rounded-lg text-zinc-300 hover:text-white"
|
||||
>
|
||||
DL
|
||||
</a>
|
||||
<button
|
||||
onClick={() => setItemToDelete(item.filename)}
|
||||
className="px-2 py-1 text-xs bg-red-500/20 text-red-400 rounded-lg hover:bg-red-500/30 transition-colors"
|
||||
>
|
||||
Supprimer
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
|
||||
Reference in New Issue
Block a user