@@ -6,11 +6,11 @@ import {
6
6
import { notifications } from '@mantine/notifications' ;
7
7
import {
8
8
IconCircleChevronLeft ,
9
- IconDeviceComputerCamera , IconDeviceDesktop , IconInfoCircle ,
9
+ IconDeviceComputerCamera , IconDeviceDesktop , IconInfoCircle , IconX ,
10
10
} from '@tabler/icons-react' ;
11
11
import mpegts from 'mpegts.js' ;
12
12
13
- function VideoPlayer ( { client = null , type = 'camera' } ) {
13
+ function VideoPlayer ( { client, type = 'camera' } ) {
14
14
const videoRef = React . useRef ( null ) ;
15
15
const needProxy = client && client [ type ] . startsWith ( 'proxy://' ) ;
16
16
const src = `${ needProxy ? '/stream/' : 'http://' } ${ client . ip } ${
@@ -142,6 +142,24 @@ export function MonitorInfo({
142
142
}
143
143
144
144
export function MonitorInfoButton ( { monitor, action } ) {
145
+ const del = async ( m ) => {
146
+ try {
147
+ const res = await ( await fetch ( '/monitor' , {
148
+ method : 'POST' ,
149
+ headers : { 'Content-Type' : 'application/json' } ,
150
+ body : JSON . stringify ( { _id : m . _id , operation : 'delete' } ) ,
151
+ } ) ) . json ( ) ;
152
+ if ( res . error ) {
153
+ notifications . show ( { title : 'Error' , message : `${ res . error . message } (${ res . error . params } )` , color : 'red' } ) ;
154
+ return ;
155
+ }
156
+ notifications . show ( { title : 'Success' , message : 'Client deleted' , color : 'green' } ) ;
157
+ } catch ( e ) {
158
+ console . error ( e ) ;
159
+ notifications . show ( { title : 'Error' , message : 'Failed to delete client' , color : 'red' } ) ;
160
+ }
161
+ } ;
162
+
145
163
return (
146
164
< Group >
147
165
< Tooltip label = "Info" >
@@ -161,6 +179,9 @@ export function MonitorInfoButton({ monitor, action }) {
161
179
</ ActionIcon >
162
180
</ Tooltip >
163
181
) }
182
+ < Tooltip label = "Delete" >
183
+ < ActionIcon variant = "transparent" color = "red" aria-label = 'Delete' onClick = { ( ) => del ( monitor ) } > < IconX /> </ ActionIcon >
184
+ </ Tooltip >
164
185
</ Group >
165
186
) ;
166
187
}
0 commit comments