From 07155b1fa9469ece552b0ba7a3075067de328971 Mon Sep 17 00:00:00 2001 From: Nicolas Mowen Date: Sat, 15 Jul 2023 14:13:53 -0600 Subject: [PATCH] Show / Download Exported recordings UI (#7171) * Start with getting list of exports * List downloadable exports in export page * Fix downloading * use swr instead of effect --- web/src/routes/Export.jsx | 160 ++++++++++++++++++++++++-------------- 1 file changed, 101 insertions(+), 59 deletions(-) diff --git a/web/src/routes/Export.jsx b/web/src/routes/Export.jsx index 5181ae57c..84a0f6009 100644 --- a/web/src/routes/Export.jsx +++ b/web/src/routes/Export.jsx @@ -3,9 +3,13 @@ import { useState } from 'preact/hooks'; import useSWR from 'swr'; import Button from '../components/Button'; import axios from 'axios'; +import { baseUrl } from '../api/baseUrl'; +import { Fragment } from 'preact'; +import ActivityIndicator from '../components/ActivityIndicator'; export default function Export() { const { data: config } = useSWR('config'); + const { data: exports } = useSWR('exports/', (url) => axios({ baseURL: baseUrl, url }).then((res) => res.data)); const [camera, setCamera] = useState('select'); const [playback, setPlayback] = useState('select'); @@ -64,67 +68,105 @@ export default function Export() {
{message.text}
)} -
- - -
+
+
+
+ + +
-
- - From: - - setStartDate(e.target.value)} - /> - setStartTime(e.target.value)} - /> - - To: - - setEndDate(e.target.value)} - /> - setEndTime(e.target.value)} - /> +
+ + From: + + setStartDate(e.target.value)} + /> + setStartTime(e.target.value)} + /> + + To: + + setEndDate(e.target.value)} + /> + setEndTime(e.target.value)} + /> +
+ +
+ + {exports && ( +
+ Exports + +
+ )}
-
); } + +function Exports({ exports }) { + return ( + + {exports.map((item) => ( +
+ {item.name.startsWith('in_progress') ? ( +
+
+ +
+
{item.name.substring(12, item.name.length - 4)}
+
+ ) : ( +
+ + {item.name.substring(0, item.name.length - 4)} + +
+ )} +
+ ))} +
+ ); +}