Initial push to new VMS-frontend repository
This commit is contained in:
parent
9fc7a44c69
commit
ba9a32720e
@ -1,4 +1,4 @@
|
|||||||
FRIGATE_PROXY=http://localhost:4000
|
FRIGATE_PROXY=http://frigate-proxy:4000
|
||||||
OPENID_SERVER=https://your.server.com:443/realms/your-realm
|
OPENID_SERVER=https://keycloak:8443
|
||||||
REALM=frigate-realm
|
CLIENT_ID=frontend-client
|
||||||
CLIENT_ID=frontend-client
|
REALM=frigate-realm
|
||||||
@ -16,7 +16,7 @@ const AppBody = () => {
|
|||||||
{ link: routesPath.SETTINGS_PATH, label: t('header.settings'), admin: true },
|
{ link: routesPath.SETTINGS_PATH, label: t('header.settings'), admin: true },
|
||||||
{ link: routesPath.RECORDINGS_PATH, label: t('header.recordings') },
|
{ link: routesPath.RECORDINGS_PATH, label: t('header.recordings') },
|
||||||
{ link: routesPath.EVENTS_PATH, label: t('header.events') },
|
{ link: routesPath.EVENTS_PATH, label: t('header.events') },
|
||||||
{ link: routesPath.HOSTS_PATH, label: t('header.hostsConfig'), admin: true },
|
{ link: routesPath.HOSTS_PATH, label: t('header.sitesConfig'), admin: true },
|
||||||
{ link: routesPath.ACCESS_PATH, label: t('header.acessSettings'), admin: true },
|
{ link: routesPath.ACCESS_PATH, label: t('header.acessSettings'), admin: true },
|
||||||
]
|
]
|
||||||
|
|
||||||
@ -53,7 +53,7 @@ const AppBody = () => {
|
|||||||
|
|
||||||
aside={
|
aside={
|
||||||
!pathsWithRightSidebar.includes(location.pathname) ? <></> :
|
!pathsWithRightSidebar.includes(location.pathname) ? <></> :
|
||||||
<RightSideBar onChangeHidden={handleRightSidebarChange}/>
|
<RightSideBar onChangeHidden={handleRightSidebarChange} />
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
<AppRouter />
|
<AppRouter />
|
||||||
|
|||||||
@ -18,6 +18,12 @@ const en = {
|
|||||||
selectStartTime: 'Select start time:',
|
selectStartTime: 'Select start time:',
|
||||||
selectEndTime: 'Select end time:',
|
selectEndTime: 'Select end time:',
|
||||||
startTimeBiggerThanEnd: 'Start time bigger than end time',
|
startTimeBiggerThanEnd: 'Start time bigger than end time',
|
||||||
|
confidenceThreshold: 'Confidence Threshold',
|
||||||
|
objectTypeFilter: 'Object Type',
|
||||||
|
selectObjectType: 'Select object types...',
|
||||||
|
eventTypeFilter: 'Event Type',
|
||||||
|
allEvents: 'All Events',
|
||||||
|
aiDetectionOnly: 'AI Detection',
|
||||||
},
|
},
|
||||||
frigateConfigPage: {
|
frigateConfigPage: {
|
||||||
copyConfig: 'Copy Config',
|
copyConfig: 'Copy Config',
|
||||||
@ -70,10 +76,10 @@ const en = {
|
|||||||
memory: 'Memory %'
|
memory: 'Memory %'
|
||||||
},
|
},
|
||||||
hostMenu: {
|
hostMenu: {
|
||||||
editConfig: 'Редакт. конфиг.',
|
editConfig: 'Edit config',
|
||||||
restart: 'Перезагрузка',
|
restart: 'Restart',
|
||||||
system: 'Система',
|
system: 'System',
|
||||||
storage: 'Хранилище',
|
storage: 'Storage',
|
||||||
},
|
},
|
||||||
|
|
||||||
header: {
|
header: {
|
||||||
@ -81,18 +87,25 @@ const en = {
|
|||||||
settings: 'Settings',
|
settings: 'Settings',
|
||||||
recordings: 'Recordings',
|
recordings: 'Recordings',
|
||||||
events: 'Events',
|
events: 'Events',
|
||||||
hostsConfig: 'Frigate servers',
|
sitesConfig: 'Sites',
|
||||||
acessSettings: 'Access settings',
|
acessSettings: 'Access settings',
|
||||||
},
|
|
||||||
frigateHostTableTitles: {
|
|
||||||
host: 'Хост',
|
|
||||||
name: 'Имя хоста',
|
|
||||||
url: 'Адрес',
|
|
||||||
enabled: 'Включен',
|
|
||||||
},
|
},
|
||||||
frigateHostTablePlaceholders: {
|
siteTableTitles: {
|
||||||
host: 'http://host.docker.internal:5000 or http://192.168.1.1:5000',
|
siteName: 'Site Name',
|
||||||
name: 'YourFrigateHostName',
|
location: 'Physical Location',
|
||||||
|
url: 'Frigate URL',
|
||||||
|
enabled: 'Enabled',
|
||||||
|
},
|
||||||
|
siteTablePlaceholders: {
|
||||||
|
url: 'http://host.docker.internal:5000 or http://192.168.1.1:5000',
|
||||||
|
name: 'Warehouse North',
|
||||||
|
location: 'Building A, Floor 2',
|
||||||
|
},
|
||||||
|
siteStatus: {
|
||||||
|
online: 'Online',
|
||||||
|
degraded: 'Degraded',
|
||||||
|
offline: 'Offline',
|
||||||
|
camerasOnline: '{{online}}/{{total}} cameras online',
|
||||||
},
|
},
|
||||||
player: {
|
player: {
|
||||||
startVideo: 'Enable Video',
|
startVideo: 'Enable Video',
|
||||||
@ -114,7 +127,7 @@ const en = {
|
|||||||
version: 'Version',
|
version: 'Version',
|
||||||
uptime: 'Uptime',
|
uptime: 'Uptime',
|
||||||
pleaseSelectRole: 'Please select Role',
|
pleaseSelectRole: 'Please select Role',
|
||||||
pleaseSelectHost: 'Please select Host',
|
pleaseSelectSite: 'Please select Site',
|
||||||
pleaseSelectCamera: 'Please select Camera',
|
pleaseSelectCamera: 'Please select Camera',
|
||||||
pleaseSelectDate: 'Please select Date',
|
pleaseSelectDate: 'Please select Date',
|
||||||
nothingHere: 'Nothing here',
|
nothingHere: 'Nothing here',
|
||||||
@ -131,7 +144,7 @@ const en = {
|
|||||||
events: 'Events',
|
events: 'Events',
|
||||||
notHaveEvents: 'No events',
|
notHaveEvents: 'No events',
|
||||||
notHaveEventsAtThatPeriod: 'Not have events at that period',
|
notHaveEventsAtThatPeriod: 'Not have events at that period',
|
||||||
selectHost: 'Select host',
|
selectSite: 'Select site',
|
||||||
selectCamera: 'Select Camera',
|
selectCamera: 'Select Camera',
|
||||||
selectRange: 'Select period',
|
selectRange: 'Select period',
|
||||||
changeTheme: "Change theme",
|
changeTheme: "Change theme",
|
||||||
|
|||||||
@ -11,11 +11,17 @@ const ru = {
|
|||||||
width: 'Ширина',
|
width: 'Ширина',
|
||||||
height: 'Высота',
|
height: 'Высота',
|
||||||
points: 'Точки',
|
points: 'Точки',
|
||||||
},
|
},
|
||||||
eventsPage: {
|
eventsPage: {
|
||||||
selectStartTime: 'Выбери время начала:',
|
selectStartTime: 'Выбери время начала:',
|
||||||
selectEndTime: 'Выбери время окончания:',
|
selectEndTime: 'Выбери время окончания:',
|
||||||
startTimeBiggerThanEnd: 'Время начала больше времени окончания',
|
startTimeBiggerThanEnd: 'Время начала больше времени окончания',
|
||||||
|
confidenceThreshold: 'Порог уверенности',
|
||||||
|
objectTypeFilter: 'Тип объекта',
|
||||||
|
selectObjectType: 'Выберите типы объектов...',
|
||||||
|
eventTypeFilter: 'Тип события',
|
||||||
|
allEvents: 'Все события',
|
||||||
|
aiDetectionOnly: 'AI обнаружение',
|
||||||
},
|
},
|
||||||
frigateConfigPage: {
|
frigateConfigPage: {
|
||||||
copyConfig: 'Копировать Конфиг.',
|
copyConfig: 'Копировать Конфиг.',
|
||||||
@ -78,18 +84,25 @@ const ru = {
|
|||||||
settings: 'Настройки',
|
settings: 'Настройки',
|
||||||
recordings: 'Записи',
|
recordings: 'Записи',
|
||||||
events: 'События',
|
events: 'События',
|
||||||
hostsConfig: 'Серверы Frigate',
|
sitesConfig: 'Объекты',
|
||||||
acessSettings: 'Настройка доступа',
|
acessSettings: 'Настройка доступа',
|
||||||
},
|
},
|
||||||
frigateHostTableTitles: {
|
siteTableTitles: {
|
||||||
host: 'Хост',
|
siteName: 'Название объекта',
|
||||||
name: 'Имя хоста',
|
location: 'Физ. расположение',
|
||||||
url: 'Адрес',
|
url: 'Frigate URL',
|
||||||
enabled: 'Включен',
|
enabled: 'Включен',
|
||||||
},
|
},
|
||||||
frigateHostTablePlaceholders: {
|
siteTablePlaceholders: {
|
||||||
host: 'http://host.docker.internal:5000 or http://192.168.1.1:5000',
|
url: 'http://host.docker.internal:5000 or http://192.168.1.1:5000',
|
||||||
name: 'YourFrigateHostName',
|
name: 'Склад Северный',
|
||||||
|
location: 'Здание А, Этаж 2',
|
||||||
|
},
|
||||||
|
siteStatus: {
|
||||||
|
online: 'В сети',
|
||||||
|
degraded: 'Частично',
|
||||||
|
offline: 'Не в сети',
|
||||||
|
camerasOnline: '{{online}}/{{total}} камер в сети',
|
||||||
},
|
},
|
||||||
player: {
|
player: {
|
||||||
startVideo: 'Вкл. Видео',
|
startVideo: 'Вкл. Видео',
|
||||||
@ -111,7 +124,7 @@ const ru = {
|
|||||||
version: 'Версия',
|
version: 'Версия',
|
||||||
uptime: 'Время работы',
|
uptime: 'Время работы',
|
||||||
pleaseSelectRole: 'Пожалуйста выберите роль',
|
pleaseSelectRole: 'Пожалуйста выберите роль',
|
||||||
pleaseSelectHost: 'Пожалуйста выберите хост',
|
pleaseSelectSite: 'Пожалуйста выберите объект',
|
||||||
pleaseSelectCamera: 'Пожалуйста выберите камеру',
|
pleaseSelectCamera: 'Пожалуйста выберите камеру',
|
||||||
pleaseSelectDate: 'Пожалуйста выберите дату',
|
pleaseSelectDate: 'Пожалуйста выберите дату',
|
||||||
nothingHere: 'Ничего нет',
|
nothingHere: 'Ничего нет',
|
||||||
@ -128,7 +141,7 @@ const ru = {
|
|||||||
events: 'События',
|
events: 'События',
|
||||||
notHaveEvents: 'Событий нет',
|
notHaveEvents: 'Событий нет',
|
||||||
notHaveEventsAtThatPeriod: 'Нет событий за этот период',
|
notHaveEventsAtThatPeriod: 'Нет событий за этот период',
|
||||||
selectHost: 'Выбери хост',
|
selectSite: 'Выбери объект',
|
||||||
selectCamera: 'Выбери камеру',
|
selectCamera: 'Выбери камеру',
|
||||||
selectRange: 'Выбери период',
|
selectRange: 'Выбери период',
|
||||||
changeTheme: "Изменить тему",
|
changeTheme: "Изменить тему",
|
||||||
|
|||||||
@ -1,15 +1,16 @@
|
|||||||
import { Button, Center, Flex, Text } from '@mantine/core';
|
import { Button, Center, Flex, Text, Divider, Paper, Title } from '@mantine/core';
|
||||||
import { notifications } from '@mantine/notifications';
|
import { notifications } from '@mantine/notifications';
|
||||||
import { IconAlertCircle, IconCircleCheck } from '@tabler/icons-react';
|
import { IconAlertCircle, IconCircleCheck } from '@tabler/icons-react';
|
||||||
import { useMutation, useQuery } from '@tanstack/react-query';
|
import { useMutation, useQuery } from '@tanstack/react-query';
|
||||||
import { observer } from 'mobx-react-lite';
|
import { observer } from 'mobx-react-lite';
|
||||||
import { useState } from 'react';
|
import { useState, useEffect } from 'react';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { useParams } from 'react-router-dom';
|
import { useParams } from 'react-router-dom';
|
||||||
import { useAdminRole } from '../hooks/useAdminRole';
|
import { useAdminRole } from '../hooks/useAdminRole';
|
||||||
import { frigateApi, frigateQueryKeys, mapHostToHostname, proxyApi } from '../services/frigate.proxy/frigate.api';
|
import { frigateApi, frigateQueryKeys, mapHostToHostname, proxyApi } from '../services/frigate.proxy/frigate.api';
|
||||||
import MaskSelect, { MaskItem, MaskType } from '../shared/components/filters/MaskSelect';
|
import MaskSelect, { MaskItem, MaskType } from '../shared/components/filters/MaskSelect';
|
||||||
import OverlayCogwheelLoader from '../shared/components/loaders/OverlayCogwheelLoader';
|
import OverlayCogwheelLoader from '../shared/components/loaders/OverlayCogwheelLoader';
|
||||||
|
import RetentionSettings from '../shared/components/RetentionSettings';
|
||||||
import { Point, extractMaskNumber } from '../shared/utils/maskPoint';
|
import { Point, extractMaskNumber } from '../shared/utils/maskPoint';
|
||||||
import CameraMaskDrawer from '../widgets/CameraMaskDrawer';
|
import CameraMaskDrawer from '../widgets/CameraMaskDrawer';
|
||||||
import CameraPageHeader from '../widgets/header/CameraPageHeader';
|
import CameraPageHeader from '../widgets/header/CameraPageHeader';
|
||||||
@ -22,6 +23,7 @@ const EditCameraPage = () => {
|
|||||||
if (!cameraId) throw Error(t('editCameraPage.cameraIdNotExist'))
|
if (!cameraId) throw Error(t('editCameraPage.cameraIdNotExist'))
|
||||||
const [selectedMask, setSelectedMask] = useState<MaskItem>()
|
const [selectedMask, setSelectedMask] = useState<MaskItem>()
|
||||||
const [points, setPoints] = useState<Point[]>()
|
const [points, setPoints] = useState<Point[]>()
|
||||||
|
const [retentionDays, setRetentionDays] = useState<number>(0)
|
||||||
|
|
||||||
const { data: camera, isPending, isError, refetch } = useQuery({
|
const { data: camera, isPending, isError, refetch } = useQuery({
|
||||||
queryKey: [frigateQueryKeys.getCameraWHost, cameraId],
|
queryKey: [frigateQueryKeys.getCameraWHost, cameraId],
|
||||||
@ -143,9 +145,45 @@ const EditCameraPage = () => {
|
|||||||
setPoints([])
|
setPoints([])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Initialize retention days from camera config
|
||||||
|
useEffect(() => {
|
||||||
|
if (camera?.config?.record?.retain?.days !== undefined) {
|
||||||
|
setRetentionDays(camera.config.record.retain.days)
|
||||||
|
}
|
||||||
|
}, [camera])
|
||||||
|
|
||||||
|
const handleRetentionChange = (days: number) => {
|
||||||
|
setRetentionDays(days)
|
||||||
|
// Note: Actual config update requires modifying the Frigate YAML config
|
||||||
|
// This could be integrated with a save button that calls proxyApi.postHostConfig
|
||||||
|
notifications.show({
|
||||||
|
id: 'retention-changed',
|
||||||
|
withCloseButton: true,
|
||||||
|
autoClose: 3000,
|
||||||
|
title: t('settings.retentionUpdated'),
|
||||||
|
message: t('settings.retentionUpdatedMessage', { days }),
|
||||||
|
color: 'blue',
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Flex w='100%' h='100%' direction='column'>
|
<Flex w='100%' h='100%' direction='column'>
|
||||||
<CameraPageHeader camera={camera} configButton/>
|
<CameraPageHeader camera={camera} configButton />
|
||||||
|
|
||||||
|
{/* Retention Settings Section */}
|
||||||
|
<Paper shadow="xs" p="md" mb="lg" mx="md" withBorder>
|
||||||
|
<Title order={4} mb="sm">{t('settings.recordingRetention')}</Title>
|
||||||
|
<RetentionSettings
|
||||||
|
currentDays={retentionDays}
|
||||||
|
onChange={handleRetentionChange}
|
||||||
|
/>
|
||||||
|
<Text size="xs" color="dimmed" mt="xs">
|
||||||
|
{t('settings.retentionNote')}
|
||||||
|
</Text>
|
||||||
|
</Paper>
|
||||||
|
|
||||||
|
<Divider my="md" label={t('editCameraPage.maskSettings')} labelPosition="center" />
|
||||||
|
|
||||||
{!camera.config ? null :
|
{!camera.config ? null :
|
||||||
<Flex w='100%' justify='center' mb='1rem'>
|
<Flex w='100%' justify='center' mb='1rem'>
|
||||||
<MaskSelect
|
<MaskSelect
|
||||||
|
|||||||
@ -18,6 +18,9 @@ export const eventsQueryParams = {
|
|||||||
endDate: 'endDate',
|
endDate: 'endDate',
|
||||||
startTime: 'startTime',
|
startTime: 'startTime',
|
||||||
endTime: 'endTime',
|
endTime: 'endTime',
|
||||||
|
minScore: 'minScore',
|
||||||
|
labels: 'labels',
|
||||||
|
eventType: 'eventType',
|
||||||
}
|
}
|
||||||
|
|
||||||
const EventsPage = () => {
|
const EventsPage = () => {
|
||||||
@ -34,14 +37,17 @@ const EventsPage = () => {
|
|||||||
const paramEndDate = searchParams.get(eventsQueryParams.endDate) || undefined
|
const paramEndDate = searchParams.get(eventsQueryParams.endDate) || undefined
|
||||||
const paramStartTime = searchParams.get(eventsQueryParams.startTime) || undefined
|
const paramStartTime = searchParams.get(eventsQueryParams.startTime) || undefined
|
||||||
const paramEndTime = searchParams.get(eventsQueryParams.endTime) || undefined
|
const paramEndTime = searchParams.get(eventsQueryParams.endTime) || undefined
|
||||||
eventsStore.loadFiltersFromPage(paramHostId, paramCameraId, paramStartDate, paramEndDate, paramStartTime, paramEndTime)
|
const paramMinScore = searchParams.get(eventsQueryParams.minScore) || undefined
|
||||||
|
const paramLabels = searchParams.get(eventsQueryParams.labels) || undefined
|
||||||
|
const paramEventType = searchParams.get(eventsQueryParams.eventType) || undefined
|
||||||
|
eventsStore.loadFiltersFromPage(paramHostId, paramCameraId, paramStartDate, paramEndDate, paramStartTime, paramEndTime, paramMinScore, paramLabels, paramEventType)
|
||||||
return () => setRightChildren(null)
|
return () => setRightChildren(null)
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
const { eventsStore } = useContext(Context)
|
const { eventsStore } = useContext(Context)
|
||||||
|
|
||||||
|
|
||||||
const { hostId, cameraId, period, startTime, endTime } = eventsStore.filters
|
const { hostId, cameraId, period, startTime, endTime, minScore, labels, eventType } = eventsStore.filters
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|
||||||
@ -73,6 +79,9 @@ const EventsPage = () => {
|
|||||||
period={[period[0], period[1]]}
|
period={[period[0], period[1]]}
|
||||||
startTime={startTime}
|
startTime={startTime}
|
||||||
endTime={endTime}
|
endTime={endTime}
|
||||||
|
minScore={minScore}
|
||||||
|
labels={labels}
|
||||||
|
eventType={eventType}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
import { Flex, Grid } from '@mantine/core';
|
import { Flex, Accordion } from '@mantine/core';
|
||||||
import { IconSearch } from '@tabler/icons-react';
|
import { IconSearch } from '@tabler/icons-react';
|
||||||
import { useInfiniteQuery } from '@tanstack/react-query';
|
import { useInfiniteQuery, useQuery } from '@tanstack/react-query';
|
||||||
import { observer } from 'mobx-react-lite';
|
import { observer } from 'mobx-react-lite';
|
||||||
import { ChangeEvent, useContext, useEffect, useRef, useState } from 'react';
|
import { ChangeEvent, useContext, useEffect, useRef, useState } from 'react';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
@ -10,15 +10,15 @@ import { Context } from '..';
|
|||||||
import { useDebounce } from '../hooks/useDebounce';
|
import { useDebounce } from '../hooks/useDebounce';
|
||||||
import { useRealmUser } from '../hooks/useRealmUser';
|
import { useRealmUser } from '../hooks/useRealmUser';
|
||||||
import { frigateApi, frigateQueryKeys } from '../services/frigate.proxy/frigate.api';
|
import { frigateApi, frigateQueryKeys } from '../services/frigate.proxy/frigate.api';
|
||||||
import { GetCameraWHostWConfig } from '../services/frigate.proxy/frigate.schema';
|
import { GetCameraWHostWConfig, GetFrigateHost } from '../services/frigate.proxy/frigate.schema';
|
||||||
import ClearableTextInput from '../shared/components/inputs/ClearableTextInput';
|
import ClearableTextInput from '../shared/components/inputs/ClearableTextInput';
|
||||||
import CenteredCogwheelLoader from '../shared/components/loaders/CenteredCogwheelLoader';
|
import CenteredCogwheelLoader from '../shared/components/loaders/CenteredCogwheelLoader';
|
||||||
import CogwheelLoader from '../shared/components/loaders/CogwheelLoader';
|
import CogwheelLoader from '../shared/components/loaders/CogwheelLoader';
|
||||||
import { isProduction } from '../shared/env.const';
|
import { isProduction } from '../shared/env.const';
|
||||||
import CameraCard from '../widgets/card/CameraCard';
|
|
||||||
import MainFiltersRightSide from '../widgets/sidebars/MainFiltersRightSide';
|
import MainFiltersRightSide from '../widgets/sidebars/MainFiltersRightSide';
|
||||||
import { SideBarContext } from '../widgets/sidebars/SideBarContext';
|
import { SideBarContext } from '../widgets/sidebars/SideBarContext';
|
||||||
import RetryErrorPage from './RetryErrorPage';
|
import RetryErrorPage from './RetryErrorPage';
|
||||||
|
import SiteGroup from '../shared/components/SiteGroup';
|
||||||
|
|
||||||
export const mainPageParams = {
|
export const mainPageParams = {
|
||||||
hostId: 'hostId',
|
hostId: 'hostId',
|
||||||
@ -43,6 +43,11 @@ const MainPage = () => {
|
|||||||
|
|
||||||
const pageSize = 20;
|
const pageSize = 20;
|
||||||
|
|
||||||
|
const { data: sitesData } = useQuery({
|
||||||
|
queryKey: [frigateQueryKeys.getFrigateHosts],
|
||||||
|
queryFn: frigateApi.getHosts
|
||||||
|
})
|
||||||
|
|
||||||
const {
|
const {
|
||||||
data,
|
data,
|
||||||
isLoading,
|
isLoading,
|
||||||
@ -55,7 +60,6 @@ const MainPage = () => {
|
|||||||
} = useInfiniteQuery<GetCameraWHostWConfig[]>({
|
} = useInfiniteQuery<GetCameraWHostWConfig[]>({
|
||||||
queryKey: [frigateQueryKeys.getCamerasWHost, selectedHostId, searchQuery, selectedTags],
|
queryKey: [frigateQueryKeys.getCamerasWHost, selectedHostId, searchQuery, selectedTags],
|
||||||
queryFn: ({ pageParam = 0 }) =>
|
queryFn: ({ pageParam = 0 }) =>
|
||||||
// Pass pagination parameters to the backend
|
|
||||||
frigateApi.getCamerasWHost({
|
frigateApi.getCamerasWHost({
|
||||||
name: searchQuery,
|
name: searchQuery,
|
||||||
frigateHostId: selectedHostId,
|
frigateHostId: selectedHostId,
|
||||||
@ -64,16 +68,13 @@ const MainPage = () => {
|
|||||||
limit: pageSize,
|
limit: pageSize,
|
||||||
}),
|
}),
|
||||||
getNextPageParam: (lastPage, pages) => {
|
getNextPageParam: (lastPage, pages) => {
|
||||||
// If last page size is less than pageSize, no more pages
|
|
||||||
if (lastPage.length < pageSize) return undefined;
|
if (lastPage.length < pageSize) return undefined;
|
||||||
// Next page offset is pages.length * pageSize
|
|
||||||
return pages.length * pageSize;
|
return pages.length * pageSize;
|
||||||
},
|
},
|
||||||
initialPageParam: 0,
|
initialPageParam: 0,
|
||||||
});
|
});
|
||||||
|
|
||||||
const cameras: GetCameraWHostWConfig[] = data?.pages.flat() || [];
|
const cameras: GetCameraWHostWConfig[] = data?.pages.flat() || [];
|
||||||
// const cameras: GetCameraWHostWConfig[] = [];
|
|
||||||
|
|
||||||
const [visibleCount, setVisibleCount] = useState(pageSize)
|
const [visibleCount, setVisibleCount] = useState(pageSize)
|
||||||
|
|
||||||
@ -84,11 +85,10 @@ const MainPage = () => {
|
|||||||
} else if (hasNextPage && !isFetchingNextPage) {
|
} else if (hasNextPage && !isFetchingNextPage) {
|
||||||
loadTriggered.current = true;
|
loadTriggered.current = true;
|
||||||
fetchNextPage().then(() => {
|
fetchNextPage().then(() => {
|
||||||
// Add a small delay before resetting the flag
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
loadTriggered.current = false;
|
loadTriggered.current = false;
|
||||||
}, 300); // delay in milliseconds; adjust as needed
|
}, 300);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, [inView, cameras, visibleCount, hasNextPage, isFetchingNextPage, isFetching, fetchNextPage])
|
}, [inView, cameras, visibleCount, hasNextPage, isFetchingNextPage, isFetching, fetchNextPage])
|
||||||
@ -114,7 +114,6 @@ const MainPage = () => {
|
|||||||
return () => setRightChildren(null);
|
return () => setRightChildren(null);
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
|
||||||
const debouncedHandleSearchQuery = useDebounce((value: string) => {
|
const debouncedHandleSearchQuery = useDebounce((value: string) => {
|
||||||
mainStore.setSearchQuery(value, navigate);
|
mainStore.setSearchQuery(value, navigate);
|
||||||
}, 600);
|
}, 600);
|
||||||
@ -125,14 +124,29 @@ const MainPage = () => {
|
|||||||
|
|
||||||
if (isLoading) return <CenteredCogwheelLoader />;
|
if (isLoading) return <CenteredCogwheelLoader />;
|
||||||
if (isError) return <RetryErrorPage onRetry={refetch} />
|
if (isError) return <RetryErrorPage onRetry={refetch} />
|
||||||
if (!isProduction) console.log('MainPage rendered')
|
|
||||||
|
|
||||||
|
const enabledSites = sitesData?.filter(s => s.enabled) || []
|
||||||
|
|
||||||
|
// Group cameras by site
|
||||||
|
const visibleCameras = cameras.slice(0, visibleCount)
|
||||||
|
const groupedCameras: Record<string, GetCameraWHostWConfig[]> = {}
|
||||||
|
|
||||||
|
visibleCameras.forEach(camera => {
|
||||||
|
const siteId = camera.frigateHost?.id
|
||||||
|
if (siteId) {
|
||||||
|
if (!groupedCameras[siteId]) groupedCameras[siteId] = []
|
||||||
|
groupedCameras[siteId].push(camera)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
// Determine initial expanded items (all sites with cameras)
|
||||||
|
const initialExpanded = enabledSites
|
||||||
|
.filter(site => groupedCameras[site.id]?.length > 0)
|
||||||
|
.map(site => site.id)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Flex direction='column' h='100%' w='100%' >
|
<Flex direction='column' h='100%' w='100%' >
|
||||||
<Flex w='100%'
|
<Flex w='100%' justify='center'>
|
||||||
justify='center'
|
|
||||||
>
|
|
||||||
<ClearableTextInput
|
<ClearableTextInput
|
||||||
clearable
|
clearable
|
||||||
maw={400}
|
maw={400}
|
||||||
@ -143,14 +157,31 @@ const MainPage = () => {
|
|||||||
onChange={onInputChange}
|
onChange={onInputChange}
|
||||||
/>
|
/>
|
||||||
</Flex>
|
</Flex>
|
||||||
<Flex justify='center' h='100%' direction='column' w='100%' >
|
<Flex justify='center' h='100%' direction='column' w='100%' mt="md">
|
||||||
<Grid mt='sm' justify="center" mb='sm' align='stretch'>
|
<Accordion multiple defaultValue={initialExpanded} variant="separated">
|
||||||
{cameras.slice(0, visibleCount).map(camera => (
|
{enabledSites.map(site => {
|
||||||
<CameraCard key={camera.id} camera={camera} />
|
const siteCameras = groupedCameras[site.id] || []
|
||||||
))}
|
const onlineCount = siteCameras.filter(c => c.state !== false).length
|
||||||
</Grid>
|
|
||||||
{ isFetching && !isFetchingNextPage ? <CogwheelLoader /> : null}
|
// If we are filtering by host, only show that host
|
||||||
{/* trigger point. Rerender twice when enabled */}
|
if (selectedHostId && site.id !== selectedHostId) return null
|
||||||
|
|
||||||
|
// If we are searching and this site has no matching cameras, skip it?
|
||||||
|
// User requirement says "Map through the list of Sites", so maybe show even if empty?
|
||||||
|
// Usually, it's better to show if it has cameras or if no search is active.
|
||||||
|
if (searchQuery && siteCameras.length === 0) return null
|
||||||
|
|
||||||
|
return (
|
||||||
|
<SiteGroup
|
||||||
|
key={site.id}
|
||||||
|
site={site}
|
||||||
|
cameras={siteCameras}
|
||||||
|
onlineCount={onlineCount}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
})}
|
||||||
|
</Accordion>
|
||||||
|
{isFetching && !isFetchingNextPage ? <CogwheelLoader /> : null}
|
||||||
<div ref={ref} style={{ height: '50px' }} />
|
<div ref={ref} style={{ height: '50px' }} />
|
||||||
</Flex>
|
</Flex>
|
||||||
</Flex>
|
</Flex>
|
||||||
|
|||||||
@ -6,6 +6,7 @@ import NotFound from './404';
|
|||||||
|
|
||||||
export const playRecordPageQuery = {
|
export const playRecordPageQuery = {
|
||||||
link: 'link',
|
link: 'link',
|
||||||
|
startTime: 'startTime',
|
||||||
}
|
}
|
||||||
|
|
||||||
const PlayRecordPage = () => {
|
const PlayRecordPage = () => {
|
||||||
@ -13,11 +14,15 @@ const PlayRecordPage = () => {
|
|||||||
const location = useLocation()
|
const location = useLocation()
|
||||||
const queryParams = new URLSearchParams(location.search)
|
const queryParams = new URLSearchParams(location.search)
|
||||||
const paramLink = queryParams.get(playRecordPageQuery.link)
|
const paramLink = queryParams.get(playRecordPageQuery.link)
|
||||||
|
const paramStartTime = queryParams.get(playRecordPageQuery.startTime)
|
||||||
|
|
||||||
|
// Parse startTime as Unix timestamp (seconds) and convert to video-relative offset if needed
|
||||||
|
const initialSeekTime = paramStartTime ? parseFloat(paramStartTime) : undefined
|
||||||
|
|
||||||
if (!paramLink) return (<NotFound />)
|
if (!paramLink) return (<NotFound />)
|
||||||
return (
|
return (
|
||||||
<Flex w='100%' h='100%' justify='center' align='center' direction='column'>
|
<Flex w='100%' h='100%' justify='center' align='center' direction='column'>
|
||||||
<VideoPlayer videoUrl={paramLink} />
|
<VideoPlayer videoUrl={paramLink} initialSeekTime={initialSeekTime} />
|
||||||
</Flex>
|
</Flex>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@ -28,6 +28,7 @@ export const getFrigateHostSchema = z.object({
|
|||||||
updateAt: z.string(),
|
updateAt: z.string(),
|
||||||
name: z.string(),
|
name: z.string(),
|
||||||
host: z.string(),
|
host: z.string(),
|
||||||
|
location: z.string().optional(),
|
||||||
enabled: z.boolean(),
|
enabled: z.boolean(),
|
||||||
state: z.boolean().nullable().optional()
|
state: z.boolean().nullable().optional()
|
||||||
});
|
});
|
||||||
|
|||||||
79
src/shared/components/RetentionSettings.tsx
Normal file
79
src/shared/components/RetentionSettings.tsx
Normal file
@ -0,0 +1,79 @@
|
|||||||
|
import { NumberInput, Text, Alert, Stack, Flex } from '@mantine/core';
|
||||||
|
import { IconAlertTriangle } from '@tabler/icons-react';
|
||||||
|
import { useTranslation } from 'react-i18next';
|
||||||
|
|
||||||
|
interface RetentionSettingsProps {
|
||||||
|
/** Current retention days from camera config */
|
||||||
|
currentDays: number;
|
||||||
|
/** Callback when retention days change */
|
||||||
|
onChange: (days: number) => void;
|
||||||
|
/** Whether the input is disabled */
|
||||||
|
disabled?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Component for configuring camera recording retention period.
|
||||||
|
* Displays a numeric input for days with optional storage warning.
|
||||||
|
*/
|
||||||
|
const RetentionSettings = ({
|
||||||
|
currentDays,
|
||||||
|
onChange,
|
||||||
|
disabled = false,
|
||||||
|
}: RetentionSettingsProps) => {
|
||||||
|
const { t } = useTranslation();
|
||||||
|
|
||||||
|
const handleChange = (value: number | string) => {
|
||||||
|
const numValue = typeof value === 'string' ? parseInt(value, 10) : value;
|
||||||
|
if (!isNaN(numValue) && numValue >= 0) {
|
||||||
|
onChange(numValue);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Stack spacing="xs">
|
||||||
|
<NumberInput
|
||||||
|
label={t('settings.retentionPeriod')}
|
||||||
|
description={t('settings.retentionDescription')}
|
||||||
|
value={currentDays}
|
||||||
|
onChange={handleChange}
|
||||||
|
min={0}
|
||||||
|
max={365}
|
||||||
|
step={1}
|
||||||
|
disabled={disabled}
|
||||||
|
styles={{
|
||||||
|
input: {
|
||||||
|
fontWeight: 500,
|
||||||
|
},
|
||||||
|
}}
|
||||||
|
rightSection={
|
||||||
|
<Text size="sm" color="dimmed" mr="md">
|
||||||
|
{t('settings.days')}
|
||||||
|
</Text>
|
||||||
|
}
|
||||||
|
rightSectionWidth={60}
|
||||||
|
/>
|
||||||
|
{currentDays > 30 && (
|
||||||
|
<Alert
|
||||||
|
icon={<IconAlertTriangle size={16} />}
|
||||||
|
color="yellow"
|
||||||
|
variant="light"
|
||||||
|
title={t('settings.storageWarningTitle')}
|
||||||
|
>
|
||||||
|
{t('settings.storageWarning')}
|
||||||
|
</Alert>
|
||||||
|
)}
|
||||||
|
{currentDays === 0 && (
|
||||||
|
<Alert
|
||||||
|
icon={<IconAlertTriangle size={16} />}
|
||||||
|
color="red"
|
||||||
|
variant="light"
|
||||||
|
title={t('settings.noRetentionTitle')}
|
||||||
|
>
|
||||||
|
{t('settings.noRetentionWarning')}
|
||||||
|
</Alert>
|
||||||
|
)}
|
||||||
|
</Stack>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default RetentionSettings;
|
||||||
54
src/shared/components/SiteGroup.tsx
Normal file
54
src/shared/components/SiteGroup.tsx
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
import { Accordion, Flex, Grid, Text, Group } from '@mantine/core';
|
||||||
|
import { useTranslation } from 'react-i18next';
|
||||||
|
import { GetCameraWHostWConfig, GetFrigateHost } from '../../services/frigate.proxy/frigate.schema';
|
||||||
|
import CameraCard from '../../widgets/card/CameraCard';
|
||||||
|
import SiteStatusBadge from './SiteStatusBadge';
|
||||||
|
|
||||||
|
interface SiteGroupProps {
|
||||||
|
site: GetFrigateHost;
|
||||||
|
cameras: GetCameraWHostWConfig[];
|
||||||
|
onlineCount: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
const SiteGroup = ({ site, cameras, onlineCount }: SiteGroupProps) => {
|
||||||
|
const { t } = useTranslation();
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Accordion.Item value={site.id} sx={{ border: 'none' }}>
|
||||||
|
<Accordion.Control>
|
||||||
|
<Group position="apart">
|
||||||
|
<Flex direction="column">
|
||||||
|
<Text weight={700} size="lg">
|
||||||
|
{site.name}
|
||||||
|
</Text>
|
||||||
|
{site.location && (
|
||||||
|
<Text size="xs" color="dimmed">
|
||||||
|
{site.location}
|
||||||
|
</Text>
|
||||||
|
)}
|
||||||
|
</Flex>
|
||||||
|
<SiteStatusBadge
|
||||||
|
onlineCameras={onlineCount}
|
||||||
|
totalCameras={cameras.length}
|
||||||
|
isReachable={site.state !== false} // Assume true if null/undefined unless explicitly false
|
||||||
|
/>
|
||||||
|
</Group>
|
||||||
|
</Accordion.Control>
|
||||||
|
<Accordion.Panel>
|
||||||
|
{cameras.length === 0 ? (
|
||||||
|
<Text color="dimmed" align="center" py="md">
|
||||||
|
{t('camersDoesNotExist')}
|
||||||
|
</Text>
|
||||||
|
) : (
|
||||||
|
<Grid gutter="md">
|
||||||
|
{cameras.map((camera) => (
|
||||||
|
<CameraCard key={camera.id} camera={camera} />
|
||||||
|
))}
|
||||||
|
</Grid>
|
||||||
|
)}
|
||||||
|
</Accordion.Panel>
|
||||||
|
</Accordion.Item>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default SiteGroup;
|
||||||
40
src/shared/components/SiteStatusBadge.tsx
Normal file
40
src/shared/components/SiteStatusBadge.tsx
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
import { Badge, Tooltip } from '@mantine/core';
|
||||||
|
import { useTranslation } from 'react-i18next';
|
||||||
|
|
||||||
|
interface SiteStatusBadgeProps {
|
||||||
|
onlineCameras: number;
|
||||||
|
totalCameras: number;
|
||||||
|
isReachable: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
const SiteStatusBadge = ({ onlineCameras, totalCameras, isReachable }: SiteStatusBadgeProps) => {
|
||||||
|
const { t } = useTranslation();
|
||||||
|
|
||||||
|
if (!isReachable) {
|
||||||
|
return (
|
||||||
|
<Badge color="red" variant="filled">
|
||||||
|
{t('siteStatus.offline')}
|
||||||
|
</Badge>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (onlineCameras < totalCameras) {
|
||||||
|
return (
|
||||||
|
<Tooltip label={t('siteStatus.camerasOnline', { online: onlineCameras, total: totalCameras })}>
|
||||||
|
<Badge color="yellow" variant="filled">
|
||||||
|
{t('siteStatus.degraded')} ({onlineCameras}/{totalCameras})
|
||||||
|
</Badge>
|
||||||
|
</Tooltip>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Tooltip label={t('siteStatus.camerasOnline', { online: onlineCameras, total: totalCameras })}>
|
||||||
|
<Badge color="green" variant="filled">
|
||||||
|
{t('siteStatus.online')} ({onlineCameras}/{totalCameras})
|
||||||
|
</Badge>
|
||||||
|
</Tooltip>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default SiteStatusBadge;
|
||||||
@ -24,6 +24,9 @@ interface EventsAccordionProps {
|
|||||||
hour?: string,
|
hour?: string,
|
||||||
camera: GetCameraWHostWConfig
|
camera: GetCameraWHostWConfig
|
||||||
host: GetFrigateHost
|
host: GetFrigateHost
|
||||||
|
minScore?: number
|
||||||
|
labels?: string[]
|
||||||
|
eventType?: 'all' | 'motion' | 'ai_detection'
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -39,6 +42,9 @@ const EventsAccordion = ({
|
|||||||
hour,
|
hour,
|
||||||
camera,
|
camera,
|
||||||
host,
|
host,
|
||||||
|
minScore,
|
||||||
|
labels,
|
||||||
|
eventType,
|
||||||
}: EventsAccordionProps) => {
|
}: EventsAccordionProps) => {
|
||||||
const { recordingsStore: recStore } = useContext(Context)
|
const { recordingsStore: recStore } = useContext(Context)
|
||||||
const [openedItem, setOpenedItem] = useState<string>()
|
const [openedItem, setOpenedItem] = useState<string>()
|
||||||
@ -52,8 +58,8 @@ const EventsAccordion = ({
|
|||||||
const isRequiredParams = (host && camera) || !(day && hour) || !(startTime && endTime)
|
const isRequiredParams = (host && camera) || !(day && hour) || !(startTime && endTime)
|
||||||
|
|
||||||
const { data, isPending, isError, refetch } = useQuery({
|
const { data, isPending, isError, refetch } = useQuery({
|
||||||
queryKey: [frigateQueryKeys.getEvents, host, camera, day, hour, startTime, endTime],
|
queryKey: [frigateQueryKeys.getEvents, host, camera, day, hour, startTime, endTime, minScore, labels, eventType],
|
||||||
queryFn: ({signal}) => {
|
queryFn: ({ signal }) => {
|
||||||
if (!isRequiredParams) return null
|
if (!isRequiredParams) return null
|
||||||
let queryStartTime: number
|
let queryStartTime: number
|
||||||
let queryEndTime: number
|
let queryEndTime: number
|
||||||
@ -71,6 +77,8 @@ const EventsAccordion = ({
|
|||||||
before: queryEndTime,
|
before: queryEndTime,
|
||||||
hasClip: true,
|
hasClip: true,
|
||||||
includeThumnails: false,
|
includeThumnails: false,
|
||||||
|
minScore: minScore,
|
||||||
|
labels: labels,
|
||||||
})
|
})
|
||||||
if (parsed.success) {
|
if (parsed.success) {
|
||||||
return proxyApi.getEvents(
|
return proxyApi.getEvents(
|
||||||
@ -114,6 +122,11 @@ const EventsAccordion = ({
|
|||||||
</Flex>
|
</Flex>
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Client-side filtering for event type (Frigate API doesn't support this filter)
|
||||||
|
const filteredData = eventType === 'ai_detection'
|
||||||
|
? data.filter(event => event.data?.type === 'object')
|
||||||
|
: data;
|
||||||
|
|
||||||
const handleOpenPlayer = (value: string | undefined) => {
|
const handleOpenPlayer = (value: string | undefined) => {
|
||||||
if (value !== recStore.playedItem) {
|
if (value !== recStore.playedItem) {
|
||||||
setOpenedItem(value)
|
setOpenedItem(value)
|
||||||
@ -141,7 +154,7 @@ const EventsAccordion = ({
|
|||||||
value={openedItem}
|
value={openedItem}
|
||||||
onChange={handleOpenItem}
|
onChange={handleOpenItem}
|
||||||
>
|
>
|
||||||
{data.map(event => (
|
{filteredData.map(event => (
|
||||||
<EventsAccordionItem
|
<EventsAccordionItem
|
||||||
key={event.id}
|
key={event.id}
|
||||||
event={event}
|
event={event}
|
||||||
|
|||||||
@ -13,6 +13,7 @@ import { proxyApi } from '../../../services/frigate.proxy/frigate.api';
|
|||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import BlobImage from '../images/BlobImage';
|
import BlobImage from '../images/BlobImage';
|
||||||
import OnScreenImage from '../images/OnScreenImage';
|
import OnScreenImage from '../images/OnScreenImage';
|
||||||
|
import BoundingBoxOverlay from '../images/BoundingBoxOverlay';
|
||||||
|
|
||||||
|
|
||||||
interface EventsAccordionItemProps {
|
interface EventsAccordionItemProps {
|
||||||
@ -81,12 +82,18 @@ const EventsAccordionItem = ({
|
|||||||
<Accordion.Control key={event.id + 'Control'}>
|
<Accordion.Control key={event.id + 'Control'}>
|
||||||
<Flex justify='space-between'>
|
<Flex justify='space-between'>
|
||||||
{!hostName ? <></> :
|
{!hostName ? <></> :
|
||||||
<OnScreenImage
|
<BoundingBoxOverlay
|
||||||
maw={200}
|
box={event.data?.box}
|
||||||
mr='1rem'
|
label={event.label}
|
||||||
fit="contain"
|
score={event.data?.score}
|
||||||
withPlaceholder
|
>
|
||||||
src={proxyApi.eventThumbnailUrl(hostName, event.id)} />
|
<OnScreenImage
|
||||||
|
maw={200}
|
||||||
|
mr='1rem'
|
||||||
|
fit="contain"
|
||||||
|
withPlaceholder
|
||||||
|
src={proxyApi.eventThumbnailUrl(hostName, event.id)} />
|
||||||
|
</BoundingBoxOverlay>
|
||||||
}
|
}
|
||||||
{eventLabel(event)}
|
{eventLabel(event)}
|
||||||
<Group>
|
<Group>
|
||||||
|
|||||||
32
src/shared/components/filters/EventTypeFilter.tsx
Normal file
32
src/shared/components/filters/EventTypeFilter.tsx
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
import { SegmentedControl, Stack, Text } from '@mantine/core';
|
||||||
|
import { useTranslation } from 'react-i18next';
|
||||||
|
|
||||||
|
type EventType = 'all' | 'motion' | 'ai_detection';
|
||||||
|
|
||||||
|
interface EventTypeFilterProps {
|
||||||
|
value?: EventType;
|
||||||
|
onChange: (eventType: EventType) => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
const EventTypeFilter = ({ value = 'all', onChange }: EventTypeFilterProps) => {
|
||||||
|
const { t } = useTranslation();
|
||||||
|
|
||||||
|
const options = [
|
||||||
|
{ value: 'all', label: t('eventsPage.allEvents') },
|
||||||
|
{ value: 'ai_detection', label: t('eventsPage.aiDetectionOnly') },
|
||||||
|
];
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Stack mt="md" gap="xs">
|
||||||
|
<Text size="sm" fw={500}>{t('eventsPage.eventTypeFilter')}</Text>
|
||||||
|
<SegmentedControl
|
||||||
|
value={value}
|
||||||
|
onChange={(val) => onChange(val as EventType)}
|
||||||
|
data={options}
|
||||||
|
fullWidth
|
||||||
|
/>
|
||||||
|
</Stack>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default EventTypeFilter;
|
||||||
48
src/shared/components/filters/ObjectTypeFilter.tsx
Normal file
48
src/shared/components/filters/ObjectTypeFilter.tsx
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
import { MultiSelect, Stack, Text } from '@mantine/core';
|
||||||
|
import { useTranslation } from 'react-i18next';
|
||||||
|
|
||||||
|
// Common Frigate AI labels
|
||||||
|
const OBJECT_TYPE_OPTIONS = [
|
||||||
|
{ value: 'person', label: 'Person' },
|
||||||
|
{ value: 'car', label: 'Car' },
|
||||||
|
{ value: 'motorcycle', label: 'Motorcycle' },
|
||||||
|
{ value: 'bicycle', label: 'Bicycle' },
|
||||||
|
{ value: 'bus', label: 'Bus' },
|
||||||
|
{ value: 'truck', label: 'Truck' },
|
||||||
|
{ value: 'dog', label: 'Dog' },
|
||||||
|
{ value: 'cat', label: 'Cat' },
|
||||||
|
{ value: 'bird', label: 'Bird' },
|
||||||
|
{ value: 'horse', label: 'Horse' },
|
||||||
|
{ value: 'face', label: 'Face' },
|
||||||
|
{ value: 'license_plate', label: 'License Plate' },
|
||||||
|
{ value: 'package', label: 'Package' },
|
||||||
|
];
|
||||||
|
|
||||||
|
interface ObjectTypeFilterProps {
|
||||||
|
value?: string[];
|
||||||
|
onChange: (labels: string[] | undefined) => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
const ObjectTypeFilter = ({ value, onChange }: ObjectTypeFilterProps) => {
|
||||||
|
const { t } = useTranslation();
|
||||||
|
|
||||||
|
const handleChange = (selected: string[]) => {
|
||||||
|
onChange(selected.length > 0 ? selected : undefined);
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Stack mt="md" gap="xs">
|
||||||
|
<Text size="sm" fw={500}>{t('eventsPage.objectTypeFilter')}</Text>
|
||||||
|
<MultiSelect
|
||||||
|
data={OBJECT_TYPE_OPTIONS}
|
||||||
|
value={value || []}
|
||||||
|
onChange={handleChange}
|
||||||
|
placeholder={t('eventsPage.selectObjectType')}
|
||||||
|
searchable
|
||||||
|
clearable
|
||||||
|
/>
|
||||||
|
</Stack>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default ObjectTypeFilter;
|
||||||
@ -5,7 +5,7 @@ import { frigateApi, frigateQueryKeys } from '../../../services/frigate.proxy/fr
|
|||||||
import RetryError from '../RetryError';
|
import RetryError from '../RetryError';
|
||||||
import OneSelectFilter, { OneSelectItem } from './OneSelectFilter';
|
import OneSelectFilter, { OneSelectItem } from './OneSelectFilter';
|
||||||
|
|
||||||
interface HostSelectProps extends MantineStyleSystemProps {
|
interface SiteSelectProps extends MantineStyleSystemProps {
|
||||||
label?: string
|
label?: string
|
||||||
valueId?: string
|
valueId?: string
|
||||||
defaultId?: string
|
defaultId?: string
|
||||||
@ -15,7 +15,7 @@ interface HostSelectProps extends MantineStyleSystemProps {
|
|||||||
onSuccess?: () => void
|
onSuccess?: () => void
|
||||||
}
|
}
|
||||||
|
|
||||||
const HostSelect = ({
|
const SiteSelect = ({
|
||||||
label,
|
label,
|
||||||
valueId,
|
valueId,
|
||||||
defaultId,
|
defaultId,
|
||||||
@ -24,8 +24,8 @@ const HostSelect = ({
|
|||||||
onChange,
|
onChange,
|
||||||
onSuccess,
|
onSuccess,
|
||||||
...styleProps
|
...styleProps
|
||||||
}: HostSelectProps) => {
|
}: SiteSelectProps) => {
|
||||||
const { data: hosts, isError, isPending, isSuccess, refetch } = useQuery({
|
const { data: sites, isError, isPending, isSuccess, refetch } = useQuery({
|
||||||
queryKey: [frigateQueryKeys.getFrigateHosts],
|
queryKey: [frigateQueryKeys.getFrigateHosts],
|
||||||
queryFn: frigateApi.getHosts
|
queryFn: frigateApi.getHosts
|
||||||
})
|
})
|
||||||
@ -37,11 +37,11 @@ const HostSelect = ({
|
|||||||
if (isPending) return <Center><Loader /></Center>
|
if (isPending) return <Center><Loader /></Center>
|
||||||
if (isError) return <RetryError onRetry={refetch} />
|
if (isError) return <RetryError onRetry={refetch} />
|
||||||
|
|
||||||
if (!hosts || hosts.length < 1) return null
|
if (!sites || sites.length < 1) return null
|
||||||
|
|
||||||
const hostItems: OneSelectItem[] = hosts
|
const siteItems: OneSelectItem[] = sites
|
||||||
.filter(host => host.enabled)
|
.filter(site => site.enabled)
|
||||||
.map(host => ({ value: host.id, label: host.name }))
|
.map(site => ({ value: site.id, label: site.name }))
|
||||||
|
|
||||||
const handleSelect = (value: string) => {
|
const handleSelect = (value: string) => {
|
||||||
if (onChange) onChange(value)
|
if (onChange) onChange(value)
|
||||||
@ -49,17 +49,17 @@ const HostSelect = ({
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<OneSelectFilter
|
<OneSelectFilter
|
||||||
id='frigate-hosts'
|
id='frigate-sites'
|
||||||
label={label}
|
label={label}
|
||||||
placeholder={placeholder}
|
placeholder={placeholder}
|
||||||
spaceBetween={spaceBetween ? spaceBetween : '1rem'}
|
spaceBetween={spaceBetween ? spaceBetween : '1rem'}
|
||||||
value={valueId || ''}
|
value={valueId || ''}
|
||||||
defaultValue={defaultId || ''}
|
defaultValue={defaultId || ''}
|
||||||
data={hostItems}
|
data={siteItems}
|
||||||
onChange={handleSelect}
|
onChange={handleSelect}
|
||||||
{...styleProps}
|
{...styleProps}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default HostSelect;
|
export default SiteSelect;
|
||||||
122
src/shared/components/images/BoundingBoxOverlay.tsx
Normal file
122
src/shared/components/images/BoundingBoxOverlay.tsx
Normal file
@ -0,0 +1,122 @@
|
|||||||
|
import React, { useState, useEffect, useRef } from 'react';
|
||||||
|
import { Box } from '@mantine/core';
|
||||||
|
|
||||||
|
interface BoundingBoxOverlayProps {
|
||||||
|
/** Bounding box coordinates [y_min, x_min, y_max, x_max] normalized 0-1 from Frigate */
|
||||||
|
box?: number[];
|
||||||
|
/** The label to display on the bounding box */
|
||||||
|
label?: string;
|
||||||
|
/** Confidence score (0-1) to display */
|
||||||
|
score?: number;
|
||||||
|
/** Color for the bounding box */
|
||||||
|
color?: string;
|
||||||
|
/** Children elements (e.g., the image) */
|
||||||
|
children: React.ReactNode;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Overlay component that renders a bounding box on top of its children.
|
||||||
|
* Frigate provides normalized coordinates [y_min, x_min, y_max, x_max] in range 0-1.
|
||||||
|
*/
|
||||||
|
const BoundingBoxOverlay = ({
|
||||||
|
box,
|
||||||
|
label,
|
||||||
|
score,
|
||||||
|
color = '#00ff00',
|
||||||
|
children,
|
||||||
|
}: BoundingBoxOverlayProps) => {
|
||||||
|
const containerRef = useRef<HTMLDivElement>(null);
|
||||||
|
const [dimensions, setDimensions] = useState({ width: 0, height: 0 });
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const updateDimensions = () => {
|
||||||
|
if (containerRef.current) {
|
||||||
|
const rect = containerRef.current.getBoundingClientRect();
|
||||||
|
setDimensions({ width: rect.width, height: rect.height });
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
updateDimensions();
|
||||||
|
window.addEventListener('resize', updateDimensions);
|
||||||
|
|
||||||
|
// Also observe for image loading
|
||||||
|
const observer = new ResizeObserver(updateDimensions);
|
||||||
|
if (containerRef.current) {
|
||||||
|
observer.observe(containerRef.current);
|
||||||
|
}
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
window.removeEventListener('resize', updateDimensions);
|
||||||
|
observer.disconnect();
|
||||||
|
};
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
// Convert Frigate box format [y_min, x_min, y_max, x_max] to pixel coordinates
|
||||||
|
const getBoxStyle = () => {
|
||||||
|
if (!box || box.length < 4 || dimensions.width === 0) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
const [yMin, xMin, yMax, xMax] = box;
|
||||||
|
|
||||||
|
const left = xMin * dimensions.width;
|
||||||
|
const top = yMin * dimensions.height;
|
||||||
|
const width = (xMax - xMin) * dimensions.width;
|
||||||
|
const height = (yMax - yMin) * dimensions.height;
|
||||||
|
|
||||||
|
return {
|
||||||
|
left: `${left}px`,
|
||||||
|
top: `${top}px`,
|
||||||
|
width: `${width}px`,
|
||||||
|
height: `${height}px`,
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
const boxStyle = getBoxStyle();
|
||||||
|
const displayLabel = label ? `${label}${score ? ` ${(score * 100).toFixed(0)}%` : ''}` : '';
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Box
|
||||||
|
ref={containerRef}
|
||||||
|
style={{ position: 'relative', display: 'inline-block' }}
|
||||||
|
>
|
||||||
|
{children}
|
||||||
|
{boxStyle && (
|
||||||
|
<>
|
||||||
|
<div
|
||||||
|
style={{
|
||||||
|
position: 'absolute',
|
||||||
|
...boxStyle,
|
||||||
|
border: `2px solid ${color}`,
|
||||||
|
borderRadius: '2px',
|
||||||
|
pointerEvents: 'none',
|
||||||
|
boxSizing: 'border-box',
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
{displayLabel && (
|
||||||
|
<div
|
||||||
|
style={{
|
||||||
|
position: 'absolute',
|
||||||
|
left: boxStyle.left,
|
||||||
|
top: boxStyle.top,
|
||||||
|
transform: 'translateY(-100%)',
|
||||||
|
backgroundColor: color,
|
||||||
|
color: '#000',
|
||||||
|
padding: '2px 6px',
|
||||||
|
fontSize: '11px',
|
||||||
|
fontWeight: 600,
|
||||||
|
borderRadius: '2px 2px 0 0',
|
||||||
|
whiteSpace: 'nowrap',
|
||||||
|
pointerEvents: 'none',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{displayLabel}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
</Box>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default BoundingBoxOverlay;
|
||||||
60
src/shared/components/players/PlaybackSpeedControls.tsx
Normal file
60
src/shared/components/players/PlaybackSpeedControls.tsx
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
import { Button, Group, Text } from '@mantine/core';
|
||||||
|
import { IconPlayerPlay } from '@tabler/icons-react';
|
||||||
|
import { useTranslation } from 'react-i18next';
|
||||||
|
import videojs from 'video.js';
|
||||||
|
|
||||||
|
interface PlaybackSpeedControlsProps {
|
||||||
|
playerRef: React.MutableRefObject<ReturnType<typeof videojs> | null>;
|
||||||
|
currentSpeed: number;
|
||||||
|
onSpeedChange: (speed: number) => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
const PLAYBACK_SPEEDS = [0.5, 1, 2, 4, 8, 16];
|
||||||
|
|
||||||
|
const PlaybackSpeedControls = ({
|
||||||
|
playerRef,
|
||||||
|
currentSpeed,
|
||||||
|
onSpeedChange,
|
||||||
|
}: PlaybackSpeedControlsProps) => {
|
||||||
|
const { t } = useTranslation();
|
||||||
|
const isFirefox = typeof navigator !== 'undefined' && navigator.userAgent.toLowerCase().includes('firefox');
|
||||||
|
|
||||||
|
const availableSpeeds = isFirefox
|
||||||
|
? PLAYBACK_SPEEDS.filter(speed => speed <= 8)
|
||||||
|
: PLAYBACK_SPEEDS;
|
||||||
|
|
||||||
|
const handleSpeedClick = (speed: number) => {
|
||||||
|
if (playerRef.current) {
|
||||||
|
playerRef.current.playbackRate(speed);
|
||||||
|
onSpeedChange(speed);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Group spacing="xs" mt="sm" mb="sm">
|
||||||
|
<Text size="sm" fw={500} mr="xs">
|
||||||
|
<IconPlayerPlay size={14} style={{ verticalAlign: 'middle', marginRight: 4 }} />
|
||||||
|
{t('player.speed')}:
|
||||||
|
</Text>
|
||||||
|
{availableSpeeds.map((speed) => (
|
||||||
|
<Button
|
||||||
|
key={speed}
|
||||||
|
size="xs"
|
||||||
|
variant={currentSpeed === speed ? 'filled' : 'outline'}
|
||||||
|
onClick={() => handleSpeedClick(speed)}
|
||||||
|
styles={{
|
||||||
|
root: {
|
||||||
|
minWidth: '48px',
|
||||||
|
fontWeight: currentSpeed === speed ? 700 : 400,
|
||||||
|
transition: 'all 0.2s ease',
|
||||||
|
},
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{speed}x
|
||||||
|
</Button>
|
||||||
|
))}
|
||||||
|
</Group>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default PlaybackSpeedControls;
|
||||||
@ -1,19 +1,23 @@
|
|||||||
import React, { useRef, useEffect } from 'react';
|
import React, { useRef, useEffect, useState } from 'react';
|
||||||
import videojs from 'video.js';
|
import videojs from 'video.js';
|
||||||
import Player from 'video.js/dist/types/player';
|
import Player from 'video.js/dist/types/player';
|
||||||
import 'video.js/dist/video-js.css'
|
import 'video.js/dist/video-js.css'
|
||||||
import { isProduction } from '../../env.const';
|
import { isProduction } from '../../env.const';
|
||||||
import { useKeycloak } from '@react-keycloak/web';
|
import { useKeycloak } from '@react-keycloak/web';
|
||||||
|
import PlaybackSpeedControls from './PlaybackSpeedControls';
|
||||||
|
|
||||||
interface VideoPlayerProps {
|
interface VideoPlayerProps {
|
||||||
videoUrl: string
|
videoUrl: string;
|
||||||
|
showSpeedControls?: boolean;
|
||||||
|
initialSeekTime?: number; // Unix timestamp or seconds offset to seek to on load
|
||||||
}
|
}
|
||||||
|
|
||||||
const VideoPlayer = ({ videoUrl }: VideoPlayerProps) => {
|
const VideoPlayer = ({ videoUrl, showSpeedControls = true, initialSeekTime }: VideoPlayerProps) => {
|
||||||
const { keycloak } = useKeycloak()
|
const { keycloak } = useKeycloak()
|
||||||
const executed = useRef(false)
|
const executed = useRef(false)
|
||||||
const videoRef = useRef<HTMLVideoElement>(null);
|
const videoRef = useRef<HTMLVideoElement>(null);
|
||||||
const playerRef = useRef<Player | null>(null);
|
const playerRef = useRef<Player | null>(null);
|
||||||
|
const [currentSpeed, setCurrentSpeed] = useState(1);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!executed.current) {
|
if (!executed.current) {
|
||||||
@ -56,6 +60,11 @@ const VideoPlayer = ({ videoUrl }: VideoPlayerProps) => {
|
|||||||
if (!isProduction) console.log('mount new player')
|
if (!isProduction) console.log('mount new player')
|
||||||
playerRef.current = videojs(videoRef.current, { ...defaultOptions }, () => {
|
playerRef.current = videojs(videoRef.current, { ...defaultOptions }, () => {
|
||||||
if (!isProduction) console.log('player is ready')
|
if (!isProduction) console.log('player is ready')
|
||||||
|
// Seek to initial time if specified (relative to video start)
|
||||||
|
if (initialSeekTime !== undefined && playerRef.current) {
|
||||||
|
playerRef.current.currentTime(initialSeekTime);
|
||||||
|
if (!isProduction) console.log('Seeking to initial time:', initialSeekTime)
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (!isProduction) console.log('VideoPlayer rendered')
|
if (!isProduction) console.log('VideoPlayer rendered')
|
||||||
@ -78,10 +87,24 @@ const VideoPlayer = ({ videoUrl }: VideoPlayerProps) => {
|
|||||||
}
|
}
|
||||||
}, [videoUrl]);
|
}, [videoUrl]);
|
||||||
|
|
||||||
|
const handleSpeedChange = (speed: number) => {
|
||||||
|
setCurrentSpeed(speed);
|
||||||
|
if (!isProduction) console.log('Playback speed changed to:', speed);
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div data-vjs-player>
|
<div>
|
||||||
{/* Setting an empty data-setup is required to override the default values and allow video to be fit the size of its parent */}
|
<div data-vjs-player>
|
||||||
<video ref={videoRef} className="small-player video-js vjs-default-skin" data-setup="{}" controls playsInline />
|
{/* Setting an empty data-setup is required to override the default values and allow video to be fit the size of its parent */}
|
||||||
|
<video ref={videoRef} className="small-player video-js vjs-default-skin" data-setup="{}" controls playsInline />
|
||||||
|
</div>
|
||||||
|
{showSpeedControls && (
|
||||||
|
<PlaybackSpeedControls
|
||||||
|
playerRef={playerRef as React.MutableRefObject<ReturnType<typeof videojs> | null>}
|
||||||
|
currentSpeed={currentSpeed}
|
||||||
|
onSpeedChange={handleSpeedChange}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@ -8,6 +8,9 @@ interface Filters {
|
|||||||
period?: [Date | null, Date | null]
|
period?: [Date | null, Date | null]
|
||||||
startTime?: string
|
startTime?: string
|
||||||
endTime?: string
|
endTime?: string
|
||||||
|
minScore?: number
|
||||||
|
labels?: string[]
|
||||||
|
eventType?: 'all' | 'motion' | 'ai_detection'
|
||||||
}
|
}
|
||||||
|
|
||||||
export class EventsStore {
|
export class EventsStore {
|
||||||
@ -23,7 +26,10 @@ export class EventsStore {
|
|||||||
paramStartDate: string | undefined,
|
paramStartDate: string | undefined,
|
||||||
paramEndDate: string | undefined,
|
paramEndDate: string | undefined,
|
||||||
paramStartTime: string | undefined,
|
paramStartTime: string | undefined,
|
||||||
paramEndTime: string | undefined) {
|
paramEndTime: string | undefined,
|
||||||
|
paramMinScore: string | undefined,
|
||||||
|
paramLabels: string | undefined,
|
||||||
|
paramEventType: string | undefined) {
|
||||||
this.filters.hostId = paramHostId
|
this.filters.hostId = paramHostId
|
||||||
this.filters.cameraId = paramCameraId
|
this.filters.cameraId = paramCameraId
|
||||||
if (paramStartDate && paramEndDate) {
|
if (paramStartDate && paramEndDate) {
|
||||||
@ -31,6 +37,20 @@ export class EventsStore {
|
|||||||
}
|
}
|
||||||
this.filters.startTime = paramStartTime
|
this.filters.startTime = paramStartTime
|
||||||
this.filters.endTime = paramEndTime
|
this.filters.endTime = paramEndTime
|
||||||
|
if (paramMinScore) {
|
||||||
|
const score = parseFloat(paramMinScore)
|
||||||
|
if (!isNaN(score) && score >= 0 && score <= 1) {
|
||||||
|
this.filters.minScore = score
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (paramLabels) {
|
||||||
|
this.filters.labels = paramLabels.split(',')
|
||||||
|
}
|
||||||
|
if (paramEventType === 'motion' || paramEventType === 'ai_detection') {
|
||||||
|
this.filters.eventType = paramEventType
|
||||||
|
} else {
|
||||||
|
this.filters.eventType = 'all'
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
setHostId(hostId: string, navigate: (path: string, options?: NavigateOptions) => void) {
|
setHostId(hostId: string, navigate: (path: string, options?: NavigateOptions) => void) {
|
||||||
@ -58,6 +78,21 @@ export class EventsStore {
|
|||||||
this.updateURL(navigate)
|
this.updateURL(navigate)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setMinScore(minScore: number | undefined, navigate: (path: string, options?: NavigateOptions) => void) {
|
||||||
|
this.filters.minScore = minScore
|
||||||
|
this.updateURL(navigate)
|
||||||
|
}
|
||||||
|
|
||||||
|
setLabels(labels: string[] | undefined, navigate: (path: string, options?: NavigateOptions) => void) {
|
||||||
|
this.filters.labels = labels
|
||||||
|
this.updateURL(navigate)
|
||||||
|
}
|
||||||
|
|
||||||
|
setEventType(eventType: 'all' | 'motion' | 'ai_detection', navigate: (path: string, options?: NavigateOptions) => void) {
|
||||||
|
this.filters.eventType = eventType
|
||||||
|
this.updateURL(navigate)
|
||||||
|
}
|
||||||
|
|
||||||
updateURL(navigate: (path: string, options?: NavigateOptions) => void) {
|
updateURL(navigate: (path: string, options?: NavigateOptions) => void) {
|
||||||
const params = new URLSearchParams();
|
const params = new URLSearchParams();
|
||||||
if (this.filters.hostId) params.set(eventsQueryParams.hostId, this.filters.hostId);
|
if (this.filters.hostId) params.set(eventsQueryParams.hostId, this.filters.hostId);
|
||||||
@ -74,6 +109,15 @@ export class EventsStore {
|
|||||||
|
|
||||||
if (this.filters.startTime) params.set(eventsQueryParams.startTime, this.filters.startTime)
|
if (this.filters.startTime) params.set(eventsQueryParams.startTime, this.filters.startTime)
|
||||||
if (this.filters.endTime) params.set(eventsQueryParams.endTime, this.filters.endTime)
|
if (this.filters.endTime) params.set(eventsQueryParams.endTime, this.filters.endTime)
|
||||||
|
if (this.filters.minScore !== undefined && this.filters.minScore > 0) {
|
||||||
|
params.set(eventsQueryParams.minScore, this.filters.minScore.toString())
|
||||||
|
}
|
||||||
|
if (this.filters.labels && this.filters.labels.length > 0) {
|
||||||
|
params.set(eventsQueryParams.labels, this.filters.labels.join(','))
|
||||||
|
}
|
||||||
|
if (this.filters.eventType && this.filters.eventType !== 'all') {
|
||||||
|
params.set(eventsQueryParams.eventType, this.filters.eventType)
|
||||||
|
}
|
||||||
|
|
||||||
navigate(`?${params.toString()}`, { replace: true });
|
navigate(`?${params.toString()}`, { replace: true });
|
||||||
}
|
}
|
||||||
|
|||||||
@ -13,6 +13,9 @@ interface EventsBodyProps {
|
|||||||
period: [Date, Date],
|
period: [Date, Date],
|
||||||
startTime?: string,
|
startTime?: string,
|
||||||
endTime?: string,
|
endTime?: string,
|
||||||
|
minScore?: number,
|
||||||
|
labels?: string[],
|
||||||
|
eventType?: 'all' | 'motion' | 'ai_detection',
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -22,6 +25,9 @@ const EventsBody: FC<EventsBodyProps> = ({
|
|||||||
period,
|
period,
|
||||||
startTime,
|
startTime,
|
||||||
endTime,
|
endTime,
|
||||||
|
minScore,
|
||||||
|
labels,
|
||||||
|
eventType,
|
||||||
}) => {
|
}) => {
|
||||||
|
|
||||||
const startTimeUnix = dayTimeToUnixTime(period[0], startTime ? startTime : '00:00')
|
const startTimeUnix = dayTimeToUnixTime(period[0], startTime ? startTime : '00:00')
|
||||||
@ -46,6 +52,9 @@ const EventsBody: FC<EventsBodyProps> = ({
|
|||||||
host={data.host}
|
host={data.host}
|
||||||
startTime={startTimeUnix}
|
startTime={startTimeUnix}
|
||||||
endTime={endTimeUnix}
|
endTime={endTimeUnix}
|
||||||
|
minScore={minScore}
|
||||||
|
labels={labels}
|
||||||
|
eventType={eventType}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
};
|
};
|
||||||
|
|||||||
@ -48,9 +48,10 @@ const FrigateHostsTable = ({ data, showAddButton = false, saveCallback, changedC
|
|||||||
}
|
}
|
||||||
|
|
||||||
const headTitle = [
|
const headTitle = [
|
||||||
{ propertyName: 'name', title: t('frigateHostTableTitles.host') },
|
{ propertyName: 'name', title: t('siteTableTitles.siteName') },
|
||||||
{ propertyName: 'host', title: t('frigateHostTableTitles.url') },
|
{ propertyName: 'location', title: t('siteTableTitles.location') },
|
||||||
{ propertyName: 'enabled', title: t('frigateHostTableTitles.enabled') },
|
{ propertyName: 'host', title: t('siteTableTitles.url') },
|
||||||
|
{ propertyName: 'enabled', title: t('siteTableTitles.enabled') },
|
||||||
{ title: '', sorting: false },
|
{ title: '', sorting: false },
|
||||||
]
|
]
|
||||||
|
|
||||||
@ -100,6 +101,7 @@ const FrigateHostsTable = ({ data, showAddButton = false, saveCallback, changedC
|
|||||||
updateAt: '',
|
updateAt: '',
|
||||||
host: '',
|
host: '',
|
||||||
name: '',
|
name: '',
|
||||||
|
location: '',
|
||||||
enabled: true
|
enabled: true
|
||||||
}
|
}
|
||||||
setTableData([...tableData, newHost])
|
setTableData([...tableData, newHost])
|
||||||
@ -110,20 +112,28 @@ const FrigateHostsTable = ({ data, showAddButton = false, saveCallback, changedC
|
|||||||
<tr key={item.id}>
|
<tr key={item.id}>
|
||||||
<TextInputCell
|
<TextInputCell
|
||||||
text={item.name}
|
text={item.name}
|
||||||
width='40%'
|
width='25%'
|
||||||
id={item.id}
|
id={item.id}
|
||||||
propertyName='name'
|
propertyName='name'
|
||||||
onChange={handleTextChange}
|
onChange={handleTextChange}
|
||||||
placeholder={t('frigateHostTablePlaceholders.name')}
|
placeholder={t('siteTablePlaceholders.name')}
|
||||||
|
/>
|
||||||
|
<TextInputCell
|
||||||
|
text={item.location || ''}
|
||||||
|
width='25%'
|
||||||
|
id={item.id}
|
||||||
|
propertyName='location'
|
||||||
|
onChange={handleTextChange}
|
||||||
|
placeholder={t('siteTablePlaceholders.location')}
|
||||||
/>
|
/>
|
||||||
<TextInputCell
|
<TextInputCell
|
||||||
text={item.host}
|
text={item.host}
|
||||||
width='40%'
|
width='30%'
|
||||||
id={item.id}
|
id={item.id}
|
||||||
propertyName='host'
|
propertyName='host'
|
||||||
onChange={handleTextChange}
|
onChange={handleTextChange}
|
||||||
placeholder={t('frigateHostTablePlaceholders.host')}
|
placeholder={t('siteTablePlaceholders.url')}
|
||||||
/>
|
/>
|
||||||
<SwitchCell value={item.enabled} width='5%' id={item.id} propertyName='enabled' toggle={handleSwitchChange} />
|
<SwitchCell value={item.enabled} width='5%' id={item.id} propertyName='enabled' toggle={handleSwitchChange} />
|
||||||
<StateCell id={item.id} width='5%' />
|
<StateCell id={item.id} width='5%' />
|
||||||
<td align='right' style={{ width: '10%', padding: '0', }}>
|
<td align='right' style={{ width: '10%', padding: '0', }}>
|
||||||
|
|||||||
@ -1,12 +1,15 @@
|
|||||||
|
import { Slider, Text, Stack } from '@mantine/core';
|
||||||
import { observer } from 'mobx-react-lite';
|
import { observer } from 'mobx-react-lite';
|
||||||
import { useContext, useState } from 'react';
|
import { useContext } from 'react';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { useNavigate } from 'react-router-dom';
|
import { useNavigate } from 'react-router-dom';
|
||||||
import { Context } from '../..';
|
import { Context } from '../..';
|
||||||
import CameraSelect from '../../shared/components/filters/CameraSelect';
|
import CameraSelect from '../../shared/components/filters/CameraSelect';
|
||||||
import DateRangeSelect from '../../shared/components/filters/DateRangeSelect';
|
import DateRangeSelect from '../../shared/components/filters/DateRangeSelect';
|
||||||
import HostSelect from '../../shared/components/filters/HostSelect';
|
import SiteSelect from '../../shared/components/filters/SiteSelect';
|
||||||
import TimePicker from '../../shared/components/filters/TimePicker';
|
import TimePicker from '../../shared/components/filters/TimePicker';
|
||||||
|
import ObjectTypeFilter from '../../shared/components/filters/ObjectTypeFilter';
|
||||||
|
import EventTypeFilter from '../../shared/components/filters/EventTypeFilter';
|
||||||
import { isProduction } from '../../shared/env.const';
|
import { isProduction } from '../../shared/env.const';
|
||||||
|
|
||||||
|
|
||||||
@ -42,6 +45,21 @@ const EventsRightFilters = () => {
|
|||||||
if (!isProduction) console.log('Selected end time: ', value)
|
if (!isProduction) console.log('Selected end time: ', value)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const handleMinScoreChange = (value: number) => {
|
||||||
|
eventsStore.setMinScore(value > 0 ? value : undefined, navigate)
|
||||||
|
if (!isProduction) console.log('Selected min score: ', value)
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleLabelsChange = (labels: string[] | undefined) => {
|
||||||
|
eventsStore.setLabels(labels, navigate)
|
||||||
|
if (!isProduction) console.log('Selected labels: ', labels)
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleEventTypeChange = (eventType: 'all' | 'motion' | 'ai_detection') => {
|
||||||
|
eventsStore.setEventType(eventType, navigate)
|
||||||
|
if (!isProduction) console.log('Selected event type: ', eventType)
|
||||||
|
}
|
||||||
|
|
||||||
const validatedStartTime = () => {
|
const validatedStartTime = () => {
|
||||||
if (eventsStore.filters.startTime && eventsStore.filters.endTime) {
|
if (eventsStore.filters.startTime && eventsStore.filters.endTime) {
|
||||||
if (eventsStore.filters.startTime > eventsStore.filters.endTime) {
|
if (eventsStore.filters.startTime > eventsStore.filters.endTime) {
|
||||||
@ -53,8 +71,8 @@ const EventsRightFilters = () => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<HostSelect
|
<SiteSelect
|
||||||
label={t('selectHost')}
|
label={t('selectSite')}
|
||||||
valueId={eventsStore.filters.hostId}
|
valueId={eventsStore.filters.hostId}
|
||||||
onChange={handleHostSelect}
|
onChange={handleHostSelect}
|
||||||
/>
|
/>
|
||||||
@ -86,6 +104,33 @@ const EventsRightFilters = () => {
|
|||||||
label={t('eventsPage.selectEndTime')}
|
label={t('eventsPage.selectEndTime')}
|
||||||
onChange={handleSelectEndTime}
|
onChange={handleSelectEndTime}
|
||||||
/>
|
/>
|
||||||
|
<Stack mt="md" gap="xs">
|
||||||
|
<Text size="sm" fw={500}>{t('eventsPage.confidenceThreshold')}</Text>
|
||||||
|
<Slider
|
||||||
|
min={0}
|
||||||
|
max={1}
|
||||||
|
step={0.05}
|
||||||
|
value={eventsStore.filters.minScore ?? 0}
|
||||||
|
onChange={handleMinScoreChange}
|
||||||
|
marks={[
|
||||||
|
{ value: 0, label: '0%' },
|
||||||
|
{ value: 0.5, label: '50%' },
|
||||||
|
{ value: 1, label: '100%' }
|
||||||
|
]}
|
||||||
|
label={(value) => `${(value * 100).toFixed(0)}%`}
|
||||||
|
styles={{
|
||||||
|
markLabel: { fontSize: '0.75rem' },
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</Stack>
|
||||||
|
<ObjectTypeFilter
|
||||||
|
value={eventsStore.filters.labels}
|
||||||
|
onChange={handleLabelsChange}
|
||||||
|
/>
|
||||||
|
<EventTypeFilter
|
||||||
|
value={eventsStore.filters.eventType}
|
||||||
|
onChange={handleEventTypeChange}
|
||||||
|
/>
|
||||||
</>
|
</>
|
||||||
}
|
}
|
||||||
</>
|
</>
|
||||||
|
|||||||
@ -2,7 +2,7 @@ import { observer } from 'mobx-react-lite';
|
|||||||
import { useContext } from 'react';
|
import { useContext } from 'react';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { Context } from '../..';
|
import { Context } from '../..';
|
||||||
import HostSelect from '../../shared/components/filters/HostSelect';
|
import SiteSelect from '../../shared/components/filters/SiteSelect';
|
||||||
import UserTagsFilter from '../../shared/components/filters/UserTagsFilter';
|
import UserTagsFilter from '../../shared/components/filters/UserTagsFilter';
|
||||||
import { isProduction } from '../../shared/env.const';
|
import { isProduction } from '../../shared/env.const';
|
||||||
import { useNavigate } from 'react-router-dom';
|
import { useNavigate } from 'react-router-dom';
|
||||||
@ -27,8 +27,8 @@ const MainFiltersRightSide = () => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<HostSelect
|
<SiteSelect
|
||||||
label={t('selectHost')}
|
label={t('selectSite')}
|
||||||
valueId={hostId || undefined}
|
valueId={hostId || undefined}
|
||||||
defaultId={hostId || undefined}
|
defaultId={hostId || undefined}
|
||||||
onChange={handleSelectHost}
|
onChange={handleSelectHost}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user