@@ -68,12 +68,32 @@ function restartCameraViewing() {
6868 }
6969}
7070
71+ async function takeTestRecording ( ) {
72+ document . getElementById ( "take-snapshot-recording" ) ! . innerText = 'Making a test recording' ;
73+ document . getElementById ( "take-snapshot-recording" ) ! . setAttribute ( "disabled" , "true" ) ;
74+ console . log ( "making a test recording" ) ;
75+ fetch ( '/api/camera/snapshot-recording' , {
76+ method : 'PUT' ,
77+ headers : {
78+ 'Authorization' : 'Basic YWRtaW46ZmVhdGhlcnM='
79+ } } )
80+
81+ . then ( response => console . log ( response ) )
82+ . then ( data => console . log ( data ) )
83+ . catch ( error => console . error ( error ) )
84+ //TODO handle errors better and check that recording was made properly instead of just waiting..
85+ await new Promise ( r => setTimeout ( r , 3000 ) ) ;
86+ document . getElementById ( "take-snapshot-recording" ) ! . removeAttribute ( "disabled" ) ;
87+ document . getElementById ( "take-snapshot-recording" ) ! . innerText = 'Take test recording' ;
88+ }
89+
7190window . onload = function ( ) {
7291 const urlParams = new URLSearchParams ( window . location . search ) ;
7392 if ( urlParams . get ( "timeout" ) == "off" ) {
7493 snapshotLimit = Number . MAX_SAFE_INTEGER ;
7594 }
7695 document . getElementById ( "snapshot-restart" ) ! . onclick = restartCameraViewing ;
96+ document . getElementById ( "take-snapshot-recording" ) ! . onclick = takeTestRecording ;
7797 cameraConnection = new CameraConnection (
7898 window . location . hostname ,
7999 window . location . port ,
0 commit comments