add: Export button to events UI

This commit is contained in:
PovilasID 2023-07-28 17:37:08 +00:00
parent f8c0f74ab8
commit 3f58c98987
2 changed files with 43 additions and 0 deletions

24
web/src/icons/Export.jsx Normal file
View File

@ -0,0 +1,24 @@
import { h } from 'preact';
import { memo } from 'preact/compat';
export function Export({ className = 'h-6 w-6', stroke = 'currentColor', fill = 'none', onClick = () => {} }) {
return (
<svg
xmlns="http://www.w3.org/2000/svg"
className={className}
fill={fill}
viewBox="0 0 24 24"
stroke={stroke}
onClick={onClick}
>
<path
stroke-linecap="round"
stroke-linejoin="round"
stroke-width="2"
d="M8 7H5a2 2 0 00-2 2v9a2 2 0 002 2h14a2 2 0 002-2V9a2 2 0 00-2-2h-3m-1 4l-3 3m0 0l-3-3m3 3V4"
/>
</svg>
);
}
export default memo(Export);

View File

@ -19,6 +19,7 @@ import { Camera } from '../icons/Camera';
import { Clock } from '../icons/Clock'; import { Clock } from '../icons/Clock';
import { Delete } from '../icons/Delete'; import { Delete } from '../icons/Delete';
import { Download } from '../icons/Download'; import { Download } from '../icons/Download';
import { Export } from '../icons/Export';
import Menu, { MenuItem } from '../components/Menu'; import Menu, { MenuItem } from '../components/Menu';
import CalendarIcon from '../icons/Calendar'; import CalendarIcon from '../icons/Calendar';
import Calendar from '../components/Calendar'; import Calendar from '../components/Calendar';
@ -216,6 +217,17 @@ export default function Events({ path, ...props }) {
setState({ ...state, showDownloadMenu: true }); setState({ ...state, showDownloadMenu: true });
}; };
const onExport = async (e, camera, start_time, end_time) => {
e.stopPropagation();
const response = await axios.post(`export/${camera}/start/${Math.round(start_time)}/end/${Math.round(end_time)}`, {playback : "realtime"});
if (response.status === 200) {
mutate();
}
};
const showSubmitToPlus = (event_id, label, box, e) => { const showSubmitToPlus = (event_id, label, box, e) => {
if (e) { if (e) {
e.stopPropagation(); e.stopPropagation();
@ -663,6 +675,13 @@ export default function Events({ path, ...props }) {
</Fragment> </Fragment>
)} )}
</div> </div>
<div class="sm:flex flex-col justify-end mr-2">
<Export
className="h-6 w-6 cursor-pointer"
stroke="#3b82f6"
onClick={(e) => onExport(e, event.camera, event.start_time, event.end_time)}
/>
</div>
<div class="flex flex-col"> <div class="flex flex-col">
<Delete <Delete
className="h-6 w-6 cursor-pointer" className="h-6 w-6 cursor-pointer"