From 14faf0b2f6e7cd7308d3266f9001c16eb54d83f4 Mon Sep 17 00:00:00 2001 From: Aksel <27739622+mellbye@users.noreply.github.com> Date: Thu, 15 Sep 2022 13:35:51 +0200 Subject: [PATCH] Show snapshots on events page (#3763) * Add tabs to show snapshot or thumbnail as part of event details, even if event has a clip available. * Add ability for TextTab to render as disabled. --- web/src/components/Tabs.jsx | 12 +++++++----- web/src/routes/Events.jsx | 33 ++++++++++++++++++++++----------- 2 files changed, 29 insertions(+), 16 deletions(-) diff --git a/web/src/components/Tabs.jsx b/web/src/components/Tabs.jsx index 800375c31..2e14227fb 100644 --- a/web/src/components/Tabs.jsx +++ b/web/src/components/Tabs.jsx @@ -27,12 +27,14 @@ export function Tabs({ children, selectedIndex: selectedIndexProp, onChange, cla ); } -export function TextTab({ selected, text, onClick }) { - const selectedStyle = selected - ? 'text-white bg-blue-500 dark:text-black dark:bg-white' - : 'text-black dark:text-white bg-transparent'; +export function TextTab({ selected, text, onClick, disabled }) { + const selectedStyle = disabled + ? 'text-gray-400 dark:text-gray-600 bg-transparent' + : selected + ? 'text-white bg-blue-500 dark:text-black dark:bg-white' + : 'text-black dark:text-white bg-transparent'; return ( - ); diff --git a/web/src/routes/Events.jsx b/web/src/routes/Events.jsx index b93d661e4..e35925a4b 100644 --- a/web/src/routes/Events.jsx +++ b/web/src/routes/Events.jsx @@ -2,6 +2,7 @@ import { h, Fragment } from 'preact'; import { route } from 'preact-router'; import ActivityIndicator from '../components/ActivityIndicator'; import Heading from '../components/Heading'; +import { Tabs, TextTab } from '../components/Tabs'; import { useApiHost } from '../api'; import useSWR from 'swr'; import useSWRInfinite from 'swr/infinite'; @@ -54,6 +55,7 @@ export default function Events({ path, ...props }) { }); const [uploading, setUploading] = useState([]); const [viewEvent, setViewEvent] = useState(); + const [eventDetailType, setEventDetailType] = useState('clip'); const [downloadEvent, setDownloadEvent] = useState({ id: null, has_clip: false, @@ -235,6 +237,10 @@ export default function Events({ path, ...props }) { } }; + const handleEventDetailTabChange = (index) => { + setEventDetailType(index == 0 ? 'clip' : 'image'); + }; + if (!config) { return ; } @@ -495,9 +501,15 @@ export default function Events({ path, ...props }) { {viewEvent !== event.id ? null : (
- {event.has_clip ? ( - <> - Clip +
+ + + + +
+ +
+ {((eventDetailType == 'clip') && event.has_clip) ? ( {}} /> - - ) : ( -
-
- {event.has_snapshot ? 'Best Image' : 'Thumbnail'} + ) : null } + + {((eventDetailType == 'image') || !event.has_clip) ? ( +
{`${event.label}
-
- )} + ) : null } +
)}