From 341b6e799727f509943622b2d1b850ab2580f415 Mon Sep 17 00:00:00 2001 From: Evgeny Gagua Date: Mon, 9 Oct 2023 20:40:03 -0700 Subject: [PATCH] Before ATP of MER Group (preluminary) --- lib/controller/getHistoryEvents.php | 18 +++ lib/controller/getReportLayout.php | 117 +++++++++++++++--- lib/controller/getStatus.php | 12 +- lib/controller/report/node_1.js | 29 +++-- lib/controller/report/node_13.js | 2 +- lib/controller/report/node_3.js | 29 +++-- .../jsapi_dynamic/mojo_dashboard.js | 2 +- lib/javascript/jsapi_dynamic/mojo_map.js | 76 ++++++++++-- lib/javascript/jsapi_dynamic/mojo_reports.js | 68 ++++++++-- 9 files changed, 304 insertions(+), 49 deletions(-) diff --git a/lib/controller/getHistoryEvents.php b/lib/controller/getHistoryEvents.php index b1d7bef..c82ed42 100644 --- a/lib/controller/getHistoryEvents.php +++ b/lib/controller/getHistoryEvents.php @@ -5,6 +5,10 @@ $EID = intval( $_POST['EID'] ); $DTS = intval( $_POST['TS'] ); if( $BID ){ + $QS = "SELECT * FROM `system_props` LIMIT 1"; + $SPD = $DATABASE->Query( $QS ); + $SP = $SPD[0]; + $QS = "SELECT * FROM nodes"; $result = $DATABASE->Query( $QS, false ); $NodeNames = array(); @@ -29,6 +33,20 @@ $CR['r'] = intval( $REC['range_digital'] ); $CR['width'] = intval( $REC['area'] ); $CR['video_id'] = intval( $REC['video_id'] ); + if( $REC['lat'] != 0 && $REC['lon'] != 0 ){ + $CR['geo'] = true; + if( $SP['local_binding'] != 0 ){ + $CR['lon'] = floatval( $SP['anchor_lon'] ) + floatval( $REC['lon'] ); + $CR['lat'] = floatval( $SP['anchor_lat'] ) + floatval( $REC['lat'] ); + } else { + $CR['lon'] = floatval( $REC['lon'] ); + $CR['lat'] = floatval( $REC['lat'] ); + }; + } else { + $CR['geo'] = false; + if( isset( $CR['lon'] ) ) unset( $CR['lon'] ); + if( isset( $CR['lat'] ) ) unset( $CR['lat'] ); + }; $Data['log'][] = $CR; }; echo json_encode( $Data ); diff --git a/lib/controller/getReportLayout.php b/lib/controller/getReportLayout.php index 204d2ff..9155dc0 100644 --- a/lib/controller/getReportLayout.php +++ b/lib/controller/getReportLayout.php @@ -9,7 +9,7 @@ $SP = $SPD[0]; $DUMMY = array(); if( $CUser->Data['access'] > 5 ){ - $TABA =<<  
    ', @@ -52,9 +52,9 @@ } } } -jodjhowierewt; +_DATA_BOUNDARY; -$LOGIO=<<Query( $QS ); + $idx = 0; + if( count( $R ) ){ + foreach( $R as $DD ){ + if( $idx < 1 ){ + $TFN = 'report/node_' . $DD['type'] . '.js'; + if(!file_exists( $TFN )) continue; + $TPL = file_get_contents( $TFN ); + $TPL = str_replace('%%%NODEID%%%', ''.$DD['id'] , $TPL ); + $TPL = str_replace('%%%NODENAME%%%', ''.urldecode($DD['name']) , $TPL ); + $QS="SELECT * FROM `nodes` WHERE `id`={$DD['id']}"; + $Z=$DATABASE->Query( $QS ); + $QS="SELECT * FROM `module_eve` WHERE `id`=1"; + $S=$DATABASE->Query( $QS ); + $MODULE_DATA = $S[0]; + $TPL = str_replace( '%%%NODENAME%%%', urldecode( $Z[0]['name'] ) , $TPL ); + //$FU = 'http://' . $_SERVER['SERVER_ADDR'].':' . $MODULE_DATA['web_port'] .'/stream?id='. $Z[0]['aux_parameter']; + $FU = '/video_feed/stream?id='. $Z[0]['aux_parameter']; + $CS[] = '[' . $Z[0]['aux_parameter'] . ',\'[ 120x120] Video\',\''. $FU .'\']'; + $TPL = str_replace( '%%%URLS%%%', '[' . implode( ',', $CS ) . ']' , $TPL ); + $TPL = str_replace( '%%%SELID%%%', 'value: '. $Z[0]['aux_parameter'] .',', $TPL ); + $TPL = str_replace( '%%%SELURL%%%', $FU, $TPL ); + $TPL = str_replace( '%%%STREAMID%%%', $DD['aux_parameter'], $TPL ); + + $FK = $MODULE_DATA['height'] /$MODULE_DATA['width']; + $W = 244; + $H = $W * $FK; + + $TPL = str_replace( '%%%WIDTH%%%', $W, $TPL ); + $TPL = str_replace( '%%%HEIGHT%%%', $H, $TPL ); + $OUT[]= $STA[1+$idx] . $TPL . $END; + } else break; + $idx++; + }; + if( $idx < 1 ){ + for( ;$idx<1;$idx++ ){ + $T = str_replace( '%%ID%%', 2+$idx , $DUMMY['camera'] ); + $OUT[]= $STA[1+$idx] . $T . $END; + }; + }; + } else { + for( ;$idx<1;$idx++ ){ + $T = str_replace( '%%ID%%', 4+$idx , $DUMMY['camera'] ); + $OUT[]= $STA[1+$idx] . $T . $END; + }; + }; + $QS = "SELECT * FROM `nodes` WHERE `type`>0 AND `type`< 10 AND `enable`=1"; + $R = $DATABASE->Query( $QS ); + $idx = 0; + if( count( $R ) ){ + foreach( $R as $DD ){ + if( $idx < 2 ){ + $TFN = 'report/node_' . $DD['type'] . '.js'; + if(!file_exists( $TFN )) continue; + $TPL = file_get_contents( $TFN ); + $TPL = str_replace('%%%NODEID%%%', ''.$DD['id'] , $TPL ); + $TPL = str_replace('%%%NODENAME%%%', ''.html_entity_decode( $DD['name'] ) , $TPL ); + $OUT[]= $STA[2+$idx] . $TPL . $END; + } else break; + $idx++; }; - case 1:{ - // LA Metro - $OUT[]= $STA[3] . $DUMMY['log'] . $END; - break; + + } else { + for( ;$idx<1;$idx++ ){ + $OUT[]= $STA[2+$idx] . $DUMMY['sensor'] . $END; }; - } + }; + $OUT[]= $STA[3] . $DUMMY['log'] . $END; }; $Data = '[' . implode( ',' , $OUT ) . ']'; } else { diff --git a/lib/controller/getStatus.php b/lib/controller/getStatus.php index 815d739..07bd0e1 100644 --- a/lib/controller/getStatus.php +++ b/lib/controller/getStatus.php @@ -14,6 +14,9 @@ $Data['CTS'] = time(); $Data['nodes'] = array(); $Data['log'] = array(); + $QS = "SELECT * FROM `system_props` LIMIT 1"; + $SD = $DATABASE->Query( $QS ); + $SYS = $SD[0]; $STATS = new SQLite_DB( '/srv/www/web/lib/controller/data/reports/stat.db'); $QS = "SELECT `year`, `month`, `day` FROM `days` ORDER BY `year` DESC, `month` DESC, `day` DESC LIMIT 1"; $STR = $STATS->Query( $QS ); @@ -129,8 +132,13 @@ //if( !( $TT == 10 || $TT == 11 ||$TT == 12 ||$TT == 13 || $TT == 14 || $TT == 36 ) ) continue; //$CT['type'] = $TT; $CT['digital'] = intval( $Z['range_digital']); - $CT['lat'] = floatval( $Z['lon'] ); - $CT['lon'] = floatval( $Z['lat'] ); + if( $SYS['local_binding'] == 0 ){ + $CT['lat'] = floatval( $Z['lat'] ); + $CT['lon'] = floatval( $Z['lon'] ); + } else { + $CT['lat'] = floatval( $SYS['anchor_lat'] ) + floatval( $Z['lat'] ); + $CT['lon'] = floatval( $SYS['anchor_lon'] ) + floatval( $Z['lon'] ); + }; $CT['az'] = floatval( $Z['azimuth'] ); $CN['targets'][] = $CT; }; diff --git a/lib/controller/report/node_1.js b/lib/controller/report/node_1.js index 9277c25..228619b 100644 --- a/lib/controller/report/node_1.js +++ b/lib/controller/report/node_1.js @@ -19,12 +19,27 @@ masks_statuses[%%%NODEID%%%] = 0; masks_exist[%%%NODEID%%%] = 0; - var W=p.getWidth(); - var H=9*(W/8); - p.setHeight( H + 32 ); - Ext.getCmp( 'cp_radar_%%%NODEID%%%' ).setHeight( H - 18 ); - //document.getElementById('draw_svg_%%%NODEID%%%').setAttribute("width", H-45 ); - set2DZoomLevel( %%%NODEID%%%, 100 ); + var W = p.getWidth(); + //var H=9*(W/16) - 28; + //var H = PanelH - p.ownerCt.ownerCt.getHeight() + 64; + var H = document.body.clientHeight - p.ownerCt.ownerCt.getHeight(); + //var W = 16*(H/9); + //p.ownerCt.setWidth( W ); + p.setHeight( H ); + Ext.getCmp( 'cp_radar_%%%NODEID%%%' ).setHeight( H - 70 ); + Ext.getCmp( 'cp_radar_%%%NODEID%%%' ).setWidth( H - 70 ); + //alert( W+" "+H ); + //Ext.getCmp( 'toolbox_%%%NODEID%%%' ).setWidth( W - H + 50 ); + //Ext.getCmp( 'toolbox_%%%NODEID%%%' ).doLayout( false, true ); + //if( H > W ){ + //document.getElementById('draw_svg_%%%NODEID%%%').setAttribute("width", "100%" ); + //} else { + document.getElementById('draw_svgr_%%%NODEID%%%').setAttribute("width", H-80 ); + //document.getElementById('draw_svg_%%%NODEID%%%').setAttribute("height", H-80 );//"100%" ); + //if( W > ( H+130 ) ) Ext.getCmp( 'toolbox_%%%NODEID%%%' ).expand( false ); + //}; + //alert( W +' '+ ( H+130 ) ); + //set2DZoomLevel( %%%NODEID%%%, 100 ); var el = document.getElementById('div_radar_%%%NODEID%%%'); el.addEventListener( "fullscreenchange", ( evt )=>{ if( document.fullscreenElement ){ @@ -32,7 +47,7 @@ if( fsDrawID ){ var el = document.getElementById('draw_svgr_'+fsDrawID ); el.removeAttribute("width"); - el.setAttribute( "width", '100%' ); + el.setAttribute( "width", H-80 );//'86%' ); fsDrawID = 0; }; }; diff --git a/lib/controller/report/node_13.js b/lib/controller/report/node_13.js index 5c76bac..1ebeb9a 100644 --- a/lib/controller/report/node_13.js +++ b/lib/controller/report/node_13.js @@ -66,7 +66,7 @@ }; }, afterrender: function( p ){ - var xx = p.getWidth() * %%%HEIGHT%%% / %%%WIDTH%%%; + var xx = p.getWidth() * ( %%%HEIGHT%%% / %%%WIDTH%%% ); p.setHeight( xx + 32 ); VideoLinks[%%%NODEID%%%] = ''; /* diff --git a/lib/controller/report/node_3.js b/lib/controller/report/node_3.js index 9277c25..228619b 100644 --- a/lib/controller/report/node_3.js +++ b/lib/controller/report/node_3.js @@ -19,12 +19,27 @@ masks_statuses[%%%NODEID%%%] = 0; masks_exist[%%%NODEID%%%] = 0; - var W=p.getWidth(); - var H=9*(W/8); - p.setHeight( H + 32 ); - Ext.getCmp( 'cp_radar_%%%NODEID%%%' ).setHeight( H - 18 ); - //document.getElementById('draw_svg_%%%NODEID%%%').setAttribute("width", H-45 ); - set2DZoomLevel( %%%NODEID%%%, 100 ); + var W = p.getWidth(); + //var H=9*(W/16) - 28; + //var H = PanelH - p.ownerCt.ownerCt.getHeight() + 64; + var H = document.body.clientHeight - p.ownerCt.ownerCt.getHeight(); + //var W = 16*(H/9); + //p.ownerCt.setWidth( W ); + p.setHeight( H ); + Ext.getCmp( 'cp_radar_%%%NODEID%%%' ).setHeight( H - 70 ); + Ext.getCmp( 'cp_radar_%%%NODEID%%%' ).setWidth( H - 70 ); + //alert( W+" "+H ); + //Ext.getCmp( 'toolbox_%%%NODEID%%%' ).setWidth( W - H + 50 ); + //Ext.getCmp( 'toolbox_%%%NODEID%%%' ).doLayout( false, true ); + //if( H > W ){ + //document.getElementById('draw_svg_%%%NODEID%%%').setAttribute("width", "100%" ); + //} else { + document.getElementById('draw_svgr_%%%NODEID%%%').setAttribute("width", H-80 ); + //document.getElementById('draw_svg_%%%NODEID%%%').setAttribute("height", H-80 );//"100%" ); + //if( W > ( H+130 ) ) Ext.getCmp( 'toolbox_%%%NODEID%%%' ).expand( false ); + //}; + //alert( W +' '+ ( H+130 ) ); + //set2DZoomLevel( %%%NODEID%%%, 100 ); var el = document.getElementById('div_radar_%%%NODEID%%%'); el.addEventListener( "fullscreenchange", ( evt )=>{ if( document.fullscreenElement ){ @@ -32,7 +47,7 @@ if( fsDrawID ){ var el = document.getElementById('draw_svgr_'+fsDrawID ); el.removeAttribute("width"); - el.setAttribute( "width", '100%' ); + el.setAttribute( "width", H-80 );//'86%' ); fsDrawID = 0; }; }; diff --git a/lib/javascript/jsapi_dynamic/mojo_dashboard.js b/lib/javascript/jsapi_dynamic/mojo_dashboard.js index 2fe1233..b93b8d4 100644 --- a/lib/javascript/jsapi_dynamic/mojo_dashboard.js +++ b/lib/javascript/jsapi_dynamic/mojo_dashboard.js @@ -1652,7 +1652,7 @@ function fetchSiteStatus(){ }; if( data.notifications.length > 0 ){ - sndExcl.play(); + playSound(); for( i=0; i < data.notifications.length; i++ ){ /*const not = PNotify.alert({ title: 'You Will Receive a Side', diff --git a/lib/javascript/jsapi_dynamic/mojo_map.js b/lib/javascript/jsapi_dynamic/mojo_map.js index ba1e47c..a69d54b 100644 --- a/lib/javascript/jsapi_dynamic/mojo_map.js +++ b/lib/javascript/jsapi_dynamic/mojo_map.js @@ -87,11 +87,11 @@ function turnAllGzOn(){ map.flyToBounds( cVisible.getBounds() ); }; -function loadMapZones( SID ){ +function loadMapZones( SiteID ){ Ext.Ajax.request({ url: '/lib/controller/getGeoZones.php', params: { - SITE: SID, + SITE: SiteID, UID: , SID: '' }, @@ -207,8 +207,8 @@ function showEventsOnMap( data, removeCursor ){ //switch( data.log[i].event ){ // case 36: cp_color='#0000FF'; break; //}; - cLon = data[i].targets[j].lat; - cLat = data[i].targets[j].lon; + cLon = data[i].targets[j].lon; + cLat = data[i].targets[j].lat; cevt[idx] = L.circleMarker( [cLat, cLon], {id:data[i].id, color: cp_color, radius: 5, stroke: false, fillOpacity: ( 1.0 - i * zz ) } );//.on('click', function( e, a ){ // loadEventPropertiesByID( this.options.id ); //} ); @@ -280,11 +280,12 @@ function LoadMapEventsZ( Mode ){ function initMapMonitoring(){ var aK = true; if( MAP_SET.attribution == '' ) aK = false; - var mapLayers = []; - + var mapLayers = []; if( map != null ){ + //ToDo: must be moved to Upper Menu changer map.off(); map.remove(); + map = null; }; if( MAP_SET.type == 1 ){ map = L.map( 'event_map',{ @@ -311,6 +312,7 @@ function initMapMonitoring(){ minZoom: 0, maxZoom: MAP_SET.maxZoom }).addTo( map ); + //map.setView([SiteLat, SiteLon], 17 ); } else { map = L.map( 'event_map',{ crs: L.CRS.Simple, @@ -326,8 +328,66 @@ function initMapMonitoring(){ }); var bounds = [[MAP_SET.bounds_lx,MAP_SET.bounds_ly], [MAP_SET.bounds_rx,MAP_SET.bounds_ry]]; var image = L.imageOverlay( '/lib/controller/data/assets/images/'+MAP_SET.layer_url, bounds ).addTo( map ); - } - map.setView([SiteLat, SiteLon], 17 ); + //map.setView([SiteLat, SiteLon], -1 ); + }; + //ToDo: Fix Initial Zoom level -> May be saving into a user profile + loadMapZones( 0 ); +}; + +function initMapReporting(){ + var aK = true; + if( MAP_SET.attribution == '' ) aK = false; + var mapLayers = []; + if( map != null ){ + //ToDo: must be moved to Upper Menu changer + map.off(); + map.remove(); + map = null; + }; + if( MAP_SET.type == 1 ){ + map = L.map( 'report_map',{ + //attributionControl: aK, + attributionControl: false, + preferCanvas: true, + zoomControl: true, + center: [SiteLat, SiteLon], + /*zoomControl: false, + zoom: 17, + minZoom: 17, + maxZoom: 17,*/ + keyboard: false + }); + //mapLayers[ MAP_SET.name ] = L.tileLayer( MAP_SET.layer_url, { + // attribution: MAP_SET.attribution, + // maxNativeZoom: MAP_SET.maxNativeZoom, + // maxZoom: MAP_SET.maxZoom + //}); + L.tileLayer( MAP_SET.layer_url, { + attribution: MAP_SET.attribution, + attributionControl: false, + maxNativeZoom: MAP_SET.maxNativeZoom, + minZoom: 0, + maxZoom: MAP_SET.maxZoom + }).addTo( map ); + //map.setView([SiteLat, SiteLon], 17 ); + } else { + map = L.map( 'report_map',{ + crs: L.CRS.Simple, + attributionControl: false, + preferCanvas: true, + zoomControl: true, + center: [SiteLat, SiteLon], + /*zoomControl: false,*/ + zoom: 0, + minZoom: -1, + maxZoom: 4, + keyboard: false + }); + var bounds = [[MAP_SET.bounds_lx,MAP_SET.bounds_ly], [MAP_SET.bounds_rx,MAP_SET.bounds_ry]]; + var image = L.imageOverlay( '/lib/controller/data/assets/images/'+MAP_SET.layer_url, bounds ).addTo( map ); + //map.setView([SiteLat, SiteLon], -1 ); + }; + //ToDo: Fix Initial Zoom level -> May be saving into a user profile loadMapZones( 0 ); }; diff --git a/lib/javascript/jsapi_dynamic/mojo_reports.js b/lib/javascript/jsapi_dynamic/mojo_reports.js index eb65ecf..da56920 100644 --- a/lib/javascript/jsapi_dynamic/mojo_reports.js +++ b/lib/javascript/jsapi_dynamic/mojo_reports.js @@ -20,6 +20,7 @@ var rep_store = new Ext.data.JsonStore({ fields: [ {name: 'id', type: 'int' }, {name: 'node_id', type: 'int' }, + {name: 'geo', type: 'bool' }, {name: 'node_name', type: 'string' }, {name: 'dts', type: 'string'}, {name: 'ts', type: 'int'}, @@ -30,9 +31,9 @@ var rep_store = new Ext.data.JsonStore({ {name: 'el', type: 'string'}, {name: 'r', type: 'int'}, {name: 'width', type: 'int'}, - {name: 'video_id',type: 'int'} - //{name: 'lat', type: 'float'}, - //{name: 'lon', type: 'float'}, + {name: 'video_id',type: 'int'}, + {name: 'lat', type: 'float'}, + {name: 'lon', type: 'float'} //{name: 'alt', type: 'float'}, //{name: 'area', type: 'float'}, //{name: 'video', type: 'string'}, @@ -100,6 +101,16 @@ var rep_SelModel_ops = { listeners: { rowselect: function(sm, row, rec ) { cRowSelected = row; + if( selectedMarker!= null ){ + selectedMarker.remove(); + if( rec.data.geo ){ + //alert( 'Geo!' ); + //map.removeLayer( selectedMarker ); + //tt = ''+EventRec.geo.lat+' '+EventRec.geo.lon; + selectedMarker.setLatLng([rec.data.lat, rec.data.lon]); + selectedMarker.addTo( map ); + }; + }; loadEventData( rec.data ); //alert( rec.data.id ); //loadEventProperties( rec.data ); @@ -117,6 +128,47 @@ var rep_SelModel_ops = { } }; +var cevt = Array(); +var coz = Array(); + +function showHistoryOnMap( data, removeCursor = true ){ + if( removeCursor ) map.removeLayer( selectedMarker ); + if( cevt.length ){ + for( i=0; i< cevt.length; i++ ){ + if( cevt[i]!= null ){ + cevt[i].remove(); + delete( cevt[i] ); + cevt[i] = null; + }; + }; + }; + if( coz.length ){ + for( i=0; i< coz.length; i++ ){ + if( coz[i]!= null ){ + coz[i].remove(); + delete( coz[i] ); + coz[i]=null; + }; + }; + }; + if( data.log.length ){ + var zz = 1.0 / ( data.log.length + 1 ); + var idx = 0; + for( i=0; i < data.log.length; i++ ){ + if( data.log[i].geo ){ + var cp_color='#FF0000'; + var opa = ( 1.0 - i * zz ); + switch( data.log[i].type ){ + case 36: cp_color='#0000FF'; opa = 1.0; break; + }; + cevt[idx] = L.circleMarker( [data.log[i].lat, data.log[i].lon], {id:data.log[i].id, color: cp_color, radius: 5, stroke: false, fillOpacity: opa } );//.on('click', function( e, a ){ loadEventPropertiesByID( this.options.id ); } ); + cevt[idx].addTo(map); + idx++; + }; + }; + }; +}; + var selectedMarkerIcon = L.icon({ iconUrl: '/style/assets/cursor.png', iconSize: [32, 32], @@ -723,8 +775,8 @@ function loadEventData( record ){ //VideoPlayer.dispose(); //VideoPlayer = null; VideoPlayer.pause(); - VideoPlayer.poster('/style/assets/no-signal.png'); - VideoPlayer.posterImage.show(); + //VideoPlayer.poster('/style/assets/no-signal.png'); + //VideoPlayer.posterImage.show(); }; }; }; @@ -821,7 +873,7 @@ function getData( Mode, ST = 0, ET = 0, SR = 0, DR = 0 ){ eventsListStore.loadData( data, false ); if( Mode == 'arch' ){ - showEventsOnMap( data, true ); + showHistoryOnMap( data, true ); Ext.MessageBox.hide(); if( DR > 0 ){ Ext.getCmp('evtArchLog').getView().focusRow( eventsListStore.getCount() - 1 ); @@ -832,7 +884,7 @@ function getData( Mode, ST = 0, ET = 0, SR = 0, DR = 0 ){ Ext.getCmp('evtArchLog').getSelectionModel().selectFirstRow(); }; } else { - showEventsOnMap( data, false ); + showHistoryOnMap( data, false ); //LoadMapEventsZ( Mode ); }; }, @@ -1370,6 +1422,7 @@ function loadReportData( ts, bid, eid ){ hideVideo(); var data = Ext.decode( response.responseText ); if( data.log != undefined ){ + showHistoryOnMap( data, true ); if( data.log.length ){ rep_store_id = data.log[0].id; rep_array = data.log;//.concat( rep_array ); @@ -1379,6 +1432,7 @@ function loadReportData( ts, bid, eid ){ rep_store.removeAll(); rep_store.loadData( rep_array ); }; + } else { alert('No Log'); // clear the log