11import { useStore } from '@/store/useStore' ;
22import { Button , Field , Input , Select , Textarea } from './UiKit' ;
3- import { api } from '@/api/client' ;
43import { useState , useEffect } from 'react' ;
54
65function formatDate ( dateStr ?: string ) : string {
@@ -29,8 +28,6 @@ export default function Sidebar() {
2928 const [ cameraSource , setCameraSource ] = useState ( camera ?. source || '' ) ;
3029 const [ cameraCalib , setCameraCalib ] = useState ( '' ) ;
3130 const [ cameraIsActive , setCameraIsActive ] = useState ( camera ?. is_active !== false ) ;
32- const [ cameraImageWidth , setCameraImageWidth ] = useState ( camera ?. image_width ?. toString ( ) || '' ) ;
33- const [ cameraImageHeight , setCameraImageHeight ] = useState ( camera ?. image_height ?. toString ( ) || '' ) ;
3431
3532 useEffect ( ( ) => {
3633 if ( s . cameraId && ! s . cameraMeta ) {
@@ -50,31 +47,9 @@ export default function Sidebar() {
5047 setCameraSource ( camera . source || '' ) ;
5148 setCameraCalib ( camera . calib ? JSON . stringify ( camera . calib , null , 2 ) : '' ) ;
5249 setCameraIsActive ( camera . is_active !== false ) ;
53- setCameraImageWidth ( camera . image_width ?. toString ( ) || '' ) ;
54- setCameraImageHeight ( camera . image_height ?. toString ( ) || '' ) ;
5550 }
5651 } , [ camera ] ) ;
5752
58- async function autoFillImageDimensions ( ) {
59- if ( ! camera ?. camera_id ) return ;
60- try {
61- const snap = await api . getSnapshot ( camera . camera_id ) ;
62- if ( snap ?. image_url ) {
63- const img = new Image ( ) ;
64- img . onload = ( ) => {
65- setCameraImageWidth ( img . naturalWidth . toString ( ) ) ;
66- setCameraImageHeight ( img . naturalHeight . toString ( ) ) ;
67- } ;
68- img . onerror = ( ) => {
69- s . error = 'Ошибка загрузки изображения для получения размеров' ;
70- } ;
71- img . src = snap . image_url ;
72- }
73- } catch ( e : any ) {
74- s . error = String ( e ) ;
75- }
76- }
77-
7853 async function saveCamera ( ) {
7954 if ( ! camera ) return ;
8055 let calibParsed : any = null ;
@@ -90,9 +65,7 @@ export default function Sidebar() {
9065 title : cameraTitle ,
9166 source : cameraSource ,
9267 calib : calibParsed ,
93- is_active : cameraIsActive ,
94- image_width : parseInt ( cameraImageWidth || '0' , 10 ) || undefined ,
95- image_height : parseInt ( cameraImageHeight || '0' , 10 ) || undefined
68+ is_active : cameraIsActive
9669 } ) ;
9770 }
9871
@@ -149,29 +122,6 @@ export default function Sidebar() {
149122 style = { { fontFamily : 'monospace' , fontSize : '12px' } }
150123 />
151124 </ Field >
152- < Field label = "Image Width" >
153- < div className = "row" style = { { gap : 6 } } >
154- < Input
155- type = "number"
156- min = { 1 }
157- value = { cameraImageWidth }
158- onChange = { e => setCameraImageWidth ( e . target . value ) }
159- placeholder = "1920"
160- />
161- < Button className = "ghost" onClick = { autoFillImageDimensions } title = "Автозаполнить из snapshot" >
162- Авто
163- </ Button >
164- </ div >
165- </ Field >
166- < Field label = "Image Height" >
167- < Input
168- type = "number"
169- min = { 1 }
170- value = { cameraImageHeight }
171- onChange = { e => setCameraImageHeight ( e . target . value ) }
172- placeholder = "1080"
173- />
174- </ Field >
175125 < Field label = "Is Active" >
176126 < label style = { { display : 'flex' , alignItems : 'center' , gap : 8 } } >
177127 < input
0 commit comments