diff --git a/lib/controller/data/mysqlitedb.db b/lib/controller/data/mysqlitedb.db index 7af6d3f..7f7b133 100644 Binary files a/lib/controller/data/mysqlitedb.db and b/lib/controller/data/mysqlitedb.db differ diff --git a/lib/controller/data/reports.db b/lib/controller/data/reports.db index d1cb0ea..cddebee 100644 Binary files a/lib/controller/data/reports.db and b/lib/controller/data/reports.db differ diff --git a/lib/controller/doCameraOperation.php b/lib/controller/doCameraOperation.php index d068eef..95b9319 100644 --- a/lib/controller/doCameraOperation.php +++ b/lib/controller/doCameraOperation.php @@ -451,6 +451,13 @@ $Data['status'] = 'ok-19'; break; }; + case 20:{ + $Param = $DATABASE->escape( $_POST['OPCODE'] ); + $QS = "UPDATE `nodes` SET `name`='{$Param}' WHERE `type`>9 AND `type`<14 AND `aux_id`={$CameraID}"; + $DATABASE->Query( $QS ); + $Data['status'] = 'ok-20'; + break; + }; }; break; }; diff --git a/lib/controller/doSensorOperation.php b/lib/controller/doSensorOperation.php index beaa1ee..97c98d2 100644 --- a/lib/controller/doSensorOperation.php +++ b/lib/controller/doSensorOperation.php @@ -175,7 +175,7 @@ $SUN = intval( $_POST['SUN'] ); $WIZ = intval( $_POST['WIZ'] ); $DEL = intval( $_POST['DEL'] ); - $QS = "UPDATE `lrf_detection_profiles` SET `order`={$ORD},`offset`={$OFF},`delta`={$DEL},`flip`={$FLI},`width`={$WIZ},`sst`={$SST},`sun`={$SUN} WHERE `aux_id`={$SNID} AND `profile_id`={$PID} AND `lrf_id`={$LRF} AND `master`=1"; + $QS = "INSERT INTO `lrf_detection_profiles`(`aux_id`,`profile_id`,`master`,`order`,`offset`,`delta`,`flip`,`width`,`sst`,`sun`,`gp`,`spikes`) VALUES({$SNID},{$PID},1,{$ORD},{$OFF},{$DEL},{$FLI},{$WIZ},{$SST},{$SUN},16,1 ) ON CONFLICT(`aux_id`,`lrf_id`,`master`) DO UPDATE SET `order`={$ORD},`offset`={$OFF},`delta`={$DEL},`flip`={$FLI},`width`={$WIZ},`sst`={$SST},`sun`={$SUN}"; $DATABASE->Query( $QS, false ); //Parameter Send to device $RBASE = new SQLite_DB( '/dev/shm/argus/mem_db.db'); diff --git a/lib/controller/getCameraEditor.php b/lib/controller/getCameraEditor.php index 21f2441..cd56822 100644 --- a/lib/controller/getCameraEditor.php +++ b/lib/controller/getCameraEditor.php @@ -10,6 +10,9 @@ $STREAMS = array(); if( count( $Result ) ){ $Cam = $Result[0]; + $QS="SELECT `name` FROM `nodes` WHERE `type`>9 AND `type`<14 AND `aux_id`={$CID}"; + $JJ = $DATABASE->Query( $QS ); + $Cam['node_name'] = $JJ[0]['name']; $Cam['name']=urldecode( $Cam['name'] ); $TB = explode( ' ', $Cam['name'] ); $Cam['name'] = $TB[0]; @@ -931,6 +934,21 @@ CHUPAKABRA; border: false }, items:[{ + width: 200, + html: 'Camera Label' + },{ + xtype: 'textfield', + id: 'cam_label', + width: 200, + value: '{$Cam['node_name']}', + listeners:{ + change: function( a, c, b ){ + doCamOperation( {$CID}, 20, c ); + } + } + },{ + xtype: 'spacer' + },{ width: 200, html: '{$Labels->GetLabel('_CAM_TRIGGERING_MODE_')}' },{ diff --git a/lib/controller/getHistoryDates.php b/lib/controller/getHistoryDates.php index b19a6b2..a29b4d2 100644 --- a/lib/controller/getHistoryDates.php +++ b/lib/controller/getHistoryDates.php @@ -1,15 +1,20 @@ Data['id'] > 1 ){ - $ZIZI = new SQLite_DB( '/srv/www/web/lib/controller/data/reports.db'); - $QS = "SELECT count(`id`) as `cnt`, `ts`/86400 as `ts` FROM `events` GROUP BY `ts`/86400"; + $ZIZI = new SQLite_DB( '/srv/www/web/lib/controller/data/reports/stat.db'); + $TZ = new DateTimeZone( date_default_timezone_get() ); + $DT = new DateTime("now", $TZ ); + $DIDI = $TZ->getOffset( $DT ); + $QS = "SELECT * FROM `days`"; $RR = $ZIZI->Query( $QS ); if( count( $RR ) ){ $DD = array(); foreach( $RR as $R ){ - $CC = intval( $R['cnt'] ); + $CC = intval( $R['session_count'] ); + $DS = $R['year'] . '-' . $R['month'] . '-' . $R['day'] . ' 00:00:00'; + $TS = strtotime( $DS ); if( $CC > 100 ) $CC = 100; - $DD[] = '{"t": '.($R['ts']*86400000).',"v":'.$CC.'}'; + $DD[] = '{"t": '.( $TS * 1000 ).',"v":'.$CC.'}'; //echo '[{"t": 1285891200000,"v": 20},{"t": 1285804800000,"v": 100},{"t": 1672249854000,"v": 50},{"t": 1672279854000,"v": 80}]'; }; echo "[" . implode(",", $DD ) . "]"; diff --git a/lib/controller/getHistoryDay.php b/lib/controller/getHistoryDay.php index b221eca..f7d73a7 100644 --- a/lib/controller/getHistoryDay.php +++ b/lib/controller/getHistoryDay.php @@ -2,76 +2,60 @@ require_once('../ajax_asm.php'); if( $CUser->Data['id'] > 1 ){ $DTS = intval( $_POST['DTS'] ); - if( $DTS ){ - $ZIZI = new SQLite_DB( '/srv/www/web/lib/controller/data/reports.db'); - $DS = $DTS; - $DE = $DS + 86400; // -> 1 Day - /* - $QS ="SELECT DISTINCT `node_id` FROM `events` WHERE `ts` >= {$DS} AND `ts` <= {$DE}"; - $NDD = $ZIZI->Query( $QS ); - $lulu = true; - $E = "]}"; - $NONO = array(); - foreach( $NDD as $NID ){ - $id = intval( $NID['node_id'] ); - $QS = "SELECT `name` FROM `nodes` WHERE `id`={$id}"; - $R = $DATABASE->Query( $QS ); - $Name = $R[0]['name']; - if( $lulu ) { - $S = "{ text: '{$Name}', leaf: false, expanded: true, children:["; - $lulu = false; - } else { - $S = "{ text: '{$Name}', leaf: false, expanded: false, children:["; - }; - $QS = "SELECT `ts`, `id` FROM `events` WHERE `node_id`={$id} AND `ts` >= {$DS} AND `ts` <= {$DE} AND ( `evt_type`=52 ) ORDER BY `ts`, `ts_ms`"; - //echo $QS; - //exit(); - $JJJ = $ZIZI->Query( $QS ); - $JIGA = array(); - foreach( $JJJ as $J ){ - $TM = date( "H:i:s", $J['ts'] ); - $JIGA[] = "{ text: '{$TM}', leaf: true, ts: {$J['ts']}, nid: {$id} }"; - }; - $NONO[] = $S . implode( ",", $JIGA ) . $E; - //echo "{expanded: true, children: [{ text: 'Menu Option 1', leaf: false, expanded: true, children:[{ text: '14:53', leaf: true }] },{ text: 'Menu Option 2', leaf: true },{ text: 'Menu Option 3', leaf: true}]}"; - }; - echo "{expanded: true, children: [".implode(",", $NONO )."]}"; - */ - $QS = "SELECT `id`, `ts`, `evt_type` FROM `events` WHERE `ts` >= {$DS} AND `ts` <= {$DE} AND ( `evt_type`=52 OR `evt_type`=53 OR `evt_type`=54 )"; - $NDD = $ZIZI->Query( $QS ); - if( count( $NDD ) ){ - $st_ignore = true; - $DH = 0; - $JIGA = array(); - foreach( $NDD as $N ){ - if( $st_ignore && $N['evt_type']!=52 ) continue; - if( $st_ignore && $N['evt_type']==52 ) $st_ignore = false; - if( $N['evt_type']==52 ) { - $DH = 0; - $BID = intval( $N['id'] ); - $BTM = date( "H:i:s", $N['ts'] ); - } else { - $DH = 1; - $EID = intval( $N['id'] ); + if( $DTS ){ + $Y = date("Y", $DTS ); + $M = date("m", $DTS ); + $D = date("d", $DTS ); + $DS = date("Y/m/d", $DTS ); + $NONO = ''; + $MUMU = new SQLite_DB( '/srv/www/web/lib/controller/data/reports/stat.db' ); + $QS = "SELECT * FROM `days` WHERE `year`={$Y} AND `month`={$M} AND `day`={$D}"; + $LOLO = $MUMU->Query( $QS ); + $S = 0; + $V = 0; + $E = 0; + if( count( $LOLO ) ){ + $S = intval( $LOLO[0]['session_count'] ); + $V = intval( $LOLO[0]['videos_count'] ); + $E = intval( $LOLO[0]['evt_count'] ); + $ZIZI = new SQLite_DB( '/srv/www/web/lib/controller/data/reports/' . $DS . '/report.db' ); + $QS = "SELECT `id`, `ts`, `evt_type` FROM `events` WHERE ( `evt_type`=52 OR `evt_type`=53 OR `evt_type`=54 )"; + $NDD = $ZIZI->Query( $QS ); + + if( count( $NDD ) ){ + $st_ignore = true; + $DH = 0; + $JIGA = array(); + foreach( $NDD as $N ){ + if( $st_ignore && $N['evt_type']!=52 ) continue; + if( $st_ignore && $N['evt_type']==52 ) $st_ignore = false; + if( $N['evt_type']==52 ) { + $DH = 0; + $BID = intval( $N['id'] ); + $BTM = date( "H:i:s", $N['ts'] ); + } else { + $DH = 1; + $EID = intval( $N['id'] ); + }; + if( $DH == 1 ){ + $JIGA[] = "{ text: '{$BTM}', leaf: true, bid: {$BID}, eid: {$EID} }"; + }; }; - if( $DH == 1 ){ + if( $DH == 0 ){ + //Ongoing Event goes next day - must catch up + $QS = "SELECT `id`, `ts`, `evt_type` FROM `events` WHERE `id` > {$BID} AND ( `evt_type`=53 OR `evt_type`=54 ) LIMIT 1"; + $NDD = $ZIZI->Query( $QS ); + if( count( $NDD ) ){ + $EID = intval( $NDD[0]['id'] ); + } else { + $EID = 1000000000;//Infinity + }; $JIGA[] = "{ text: '{$BTM}', leaf: true, bid: {$BID}, eid: {$EID} }"; }; + $NONO = "{ text: 'Events', leaf: false, expanded: true, children:[". implode( ",", $JIGA ) . "]}"; }; - if( $DH == 0 ){ - //Ongoing Event goes next day - must catch up - $QS = "SELECT `id`, `ts`, `evt_type` FROM `events` WHERE `id` > {$BID} AND ( `evt_type`=53 OR `evt_type`=54 ) LIMIT 1"; - $NDD = $ZIZI->Query( $QS ); - if( count( $NDD ) ){ - $EID = intval( $NDD[0]['id'] ); - } else { - $EID = 1000000000;//Infinity - }; - $JIGA[] = "{ text: '{$BTM}', leaf: true, bid: {$BID}, eid: {$EID} }"; - }; - $NONO = "{ text: 'Events', leaf: false, expanded: true, children:[". implode( ",", $JIGA ) . "]}"; }; - echo "{expanded: true, children: [". $NONO ."]}"; + echo "{expanded: true, children: [". $NONO ."], sessions:{$S}, events:{$E}, videos:{$V} }"; } else { echo "[]"; }; diff --git a/lib/controller/getHistoryEvents.php b/lib/controller/getHistoryEvents.php index 5aff574..b1d7bef 100644 --- a/lib/controller/getHistoryEvents.php +++ b/lib/controller/getHistoryEvents.php @@ -3,13 +3,15 @@ if( $CUser->Data['id'] > 1 ){ $BID = intval( $_POST['BID'] ); $EID = intval( $_POST['EID'] ); + $DTS = intval( $_POST['TS'] ); if( $BID ){ $QS = "SELECT * FROM nodes"; $result = $DATABASE->Query( $QS, false ); $NodeNames = array(); foreach( $result as $R ) $NodeNames[$R['id']] = $R['name']; - $QS = "SELECT `events`.*, `events_2_videos`.* FROM `events` LEFT JOIN `events_2_videos` ON( `events`.`id` = `events_2_videos`.`evt_id` ) WHERE `id` >= {$BID} AND `id`<={$EID} ORDER BY `ts` ASC, `ts_ms` ASC"; - $ZIZI = new SQLite_DB( '/srv/www/web/lib/controller/data/reports.db'); + $DS = date("Y/m/d", $DTS ); + $QS = "SELECT `events`.*, `events_2_videos`.* FROM `events` LEFT JOIN `events_2_videos` ON( `events`.`id` = `events_2_videos`.`evt_id` ) WHERE `events`.`id` >= {$BID} AND `events`.`id`<={$EID} ORDER BY `ts` ASC, `ts_ms` ASC"; + $ZIZI = new SQLite_DB( '/srv/www/web/lib/controller/data/reports/'.$DS.'/report.db'); //$LREC = array_reverse( $ZIZI->Query( $QS ) ); $LREC = $ZIZI->Query( $QS ); $Data['log'] = array(); diff --git a/lib/controller/getSensorEditor.php b/lib/controller/getSensorEditor.php index d2d1a3c..283923e 100644 --- a/lib/controller/getSensorEditor.php +++ b/lib/controller/getSensorEditor.php @@ -23,6 +23,7 @@ JOJOKA; case 4: $NAME = ''.$CR['name'].'
PLS360 ' . $Labels->getLabel('SENSOR'); break; default: $NAME = ''.$CR['name'].'
Unknown Sensor'; }; + $NAME .='
communication errors per minute: '.$CR['com_epm']; $INFO = '
Serial:'.(($CR['serial']!='')?$CR['serial']:'No Serial Defined').'
Version:'.(($CR['version']!='')?$CR['version']:'No Version Info').'
'; $ITEMS[0]="{ xtype:'panel', border: false, frame: false, html: '
{$NAME}
{$INFO}

'}"; $QS="SELECT aux_id, device FROM resources WHERE ( type=1 OR type=129 )"; diff --git a/lib/controller/getStatus.php b/lib/controller/getStatus.php index e53faab..815d739 100644 --- a/lib/controller/getStatus.php +++ b/lib/controller/getStatus.php @@ -14,32 +14,38 @@ $Data['CTS'] = time(); $Data['nodes'] = array(); $Data['log'] = array(); - $ZIZI = new SQLite_DB( '/srv/www/web/lib/controller/data/reports.db'); - $QS = "SELECT `id` FROM `events` WHERE `id` > {$LLID} LIMIT 1"; - $CH = $ZIZI->Query( $QS ); - if( count( $CH ) ){ - $QS = "SELECT * FROM nodes"; - $result = $DATABASE->Query( $QS, false ); - $NodeNames = array(); - foreach( $result as $R ) $NodeNames[$R['id']] = $R['name']; - $QS = "SELECT `id`,`node_id`, `evt_type`, `ts`, `ts_ms`, `range_digital`, `azimuth`, `elevation`, `range`, `area` FROM `events` WHERE `id` > {$LLID} ORDER BY `ts` DESC, `ts_ms` DESC LIMIT 32"; - $LREC = $ZIZI->Query( $QS ); - foreach( $LREC as $REC ){ - $CR['id'] = intval( $REC['id'] ); - $CR['node_id'] = intval( $REC['node_id'] ); - $CR['node_name'] = $NodeNames[$CR['node_id']]; - $CR['ts'] = intval( $REC['ts'] ); - $CR['ms'] = sprintf( "%03d", intval( $REC['ts_ms'] )); - $CR['dts'] = date( "H:i:s.{$CR['ms']}", $CR['ts'] ); - $CR['type'] = intval( $REC['evt_type'] ); - $CR['range'] = sprintf( "%0.2f", floatval( $REC['range'] )); - $CR['az'] = sprintf( "%0.2f", floatval( $REC['azimuth'] )); - $CR['el'] = sprintf( "%0.2f", floatval( $REC['elevation'] )); - $CR['r'] = intval( $REC['range_digital'] ); - $CR['width'] = intval( $REC['area'] ); - $Data['log'][] = $CR; + $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 ); + if( count( $STR ) ){ + $DTS = sprintf("%04d/%02d/%02d", intval($STR[0]['year']), intval($STR[0]['month']), intval($STR[0]['day'])); + $ZIZI = new SQLite_DB( '/srv/www/web/lib/controller/data/reports/'.$DTS.'/report.db'); + $QS = "SELECT `id` FROM `events` WHERE `id` > {$LLID} LIMIT 1"; + $CH = $ZIZI->Query( $QS ); + if( count( $CH ) ){ + $QS = "SELECT * FROM nodes"; + $result = $DATABASE->Query( $QS, false ); + $NodeNames = array(); + foreach( $result as $R ) $NodeNames[$R['id']] = $R['name']; + $QS = "SELECT `id`,`node_id`, `evt_type`, `ts`, `ts_ms`, `range_digital`, `azimuth`, `elevation`, `range`, `area` FROM `events` WHERE `id` > {$LLID} ORDER BY `ts` DESC, `ts_ms` DESC LIMIT 32"; + $LREC = $ZIZI->Query( $QS ); + foreach( $LREC as $REC ){ + $CR['id'] = intval( $REC['id'] ); + $CR['node_id'] = intval( $REC['node_id'] ); + $CR['node_name'] = $NodeNames[$CR['node_id']]; + $CR['ts'] = intval( $REC['ts'] ); + $CR['ms'] = sprintf( "%03d", intval( $REC['ts_ms'] )); + $CR['dts'] = date( "H:i:s.{$CR['ms']}", $CR['ts'] ); + $CR['type'] = intval( $REC['evt_type'] ); + $CR['range'] = sprintf( "%0.2f", floatval( $REC['range'] )); + $CR['az'] = sprintf( "%0.2f", floatval( $REC['azimuth'] )); + $CR['el'] = sprintf( "%0.2f", floatval( $REC['elevation'] )); + $CR['r'] = intval( $REC['range_digital'] ); + $CR['width'] = intval( $REC['area'] ); + $Data['log'][] = $CR; + }; }; - }; + } //$QS = "SELECT * FROM nodes ORDER BY `type`"; $QS = "SELECT * FROM nodes WHERE `type` > 0 AND `type` < 14"; $result = $DATABASE->Query( $QS, false ); diff --git a/lib/controller/getVideoInfo.php b/lib/controller/getVideoInfo.php index 0ea2c23..82e249c 100644 --- a/lib/controller/getVideoInfo.php +++ b/lib/controller/getVideoInfo.php @@ -2,12 +2,15 @@ require_once('../ajax_asm.php'); if( $CUser->Data['id'] > 1 ){ $VID = intval( $_POST['VID'] ); - if( $VID ){ + $DTS = intval( $_POST['TS'] ); + if( $VID ){ + $DS = date("Y/m/d", $DTS ); $QS = "SELECT * FROM `videos` WHERE `id` = {$VID}"; - $ZIZI = new SQLite_DB( '/srv/www/web/lib/controller/data/reports.db'); + $ZIZI = new SQLite_DB( '/srv/www/web/lib/controller/data/reports/'.$DS.'/report.db'); $LREC = $ZIZI->Query( $QS ); if( count( $LREC ) ){ $Data = $LREC[0]; + $Data['base'] = $DS; $QS = "SELECT `no`.`id` as `node_id` FROM `nodes` `no` LEFT JOIN `cameras` `ca` ON ( `no`.`aux_id` = `ca`.`id` ) WHERE ( `no`.`type` = 10 OR `no`.`type` = 11 OR `no`.`type` = 12 OR `no`.`type` = 13 )AND `ca`.`stream_id`={$Data['media_stream_id']} LIMIT 1"; $TT = $DATABASE->Query( $QS ); $Data['qs'] = $QS; diff --git a/lib/controller/upgrade_report.php b/lib/controller/upgrade_report.php new file mode 100644 index 0000000..04dcbd1 --- /dev/null +++ b/lib/controller/upgrade_report.php @@ -0,0 +1,98 @@ +getOffset( $DT ); + $QS = "SELECT count(`id`) as `cnt`, `ts` as `ts` FROM `events` GROUP BY (`ts`+({$DIDI}))/86400"; + $RR = $ZIZI->Query( $QS ); + if( count( $RR ) ){ + $DD = array(); + $STATA = new SQLite_DB( '/srv/www/web/lib/controller/data/reports/stat.db'); + foreach( $RR as $R ){ + $CC = intval( $R['cnt'] ); + if( $CC > 100 ) $CC = 100; + $Y = date("Y", $R['ts'] ); + $M = date("m", $R['ts'] ); + $D = date("d", $R['ts'] ); + echo "Upgrading Date: {$Y}/{$M}/{$D}\n"; + $FD = '/srv/www/web/lib/controller/data/reports/'.$Y; + if( !file_exists( $FD ) ){ + mkdir( $FD, 0765 ); + chown( $FD, 'www-data' ); + chgrp( $FD, 'www-data' ); + }; + $FD = '/srv/www/web/lib/controller/data/reports/'.$Y.'/'.$M; + if( !file_exists( $FD ) ){ + mkdir( $FD, 0765 ); + chown( $FD, 'www-data' ); + chgrp( $FD, 'www-data' ); + }; + $FD = '/srv/www/web/lib/controller/data/reports/'.$Y.'/'.$M.'/'.$D; + if( !file_exists( $FD ) ){ + mkdir( $FD, 0765 ); + chown( $FD, 'www-data' ); + chgrp( $FD, 'www-data' ); + }; + if( !file_exists( $FD . '/report.db' ) ){ + $NREP = new SQLite_DB( $FD . '/report.db' ); + $NREP->Query("CREATE TABLE \"events\" ( \"id\" INTEGER NOT NULL, \"node_id\" INTEGER NOT NULL, \"uuid\" TEXT NOT NULL UNIQUE, \"ts\" INTEGER NOT NULL, \"ts_ms\" INTEGER NOT NULL, \"evt_type\" INTEGER NOT NULL, \"range_digital\" INTEGER, \"azimuth\" REAL, \"elevation\" REAL, \"range\" REAL, \"area\" REAL, \"lat\" REAL, \"lon\" REAL, \"alt\" REAL, \"ref_id\" INTEGER, \"ref_uuid\" TEXT, PRIMARY KEY(\"id\" AUTOINCREMENT) )"); + $NREP->Query("CREATE TABLE \"events_2_pictures\" ( \"evt_id\" INTEGER NOT NULL, \"picture_id\" INTEGER NOT NULL )"); + $NREP->Query("CREATE TABLE \"events_2_videos\" ( \"evt_id\" INTEGER NOT NULL, \"video_id\" INTEGER NOT NULL, \"frame\" INTEGER DEFAULT 0, \"tss\" INTEGER, \"tms\" INTEGER )"); + $NREP->Query("CREATE TABLE \"pictures\" ( \"id\" INTEGER NOT NULL, \"media_stream_id\" INTEGER NOT NULL, \"md5\" TEXT NOT NULL UNIQUE, \"uts\" INTEGER NOT NULL, \"uts_ms\" INTEGER NOT NULL, \"ext\" TEXT NOT NULL, \"data\" BLOB COLLATE BINARY, PRIMARY KEY(\"id\" AUTOINCREMENT) )"); + $NREP->Query("CREATE TABLE \"videos\" ( \"id\" INTEGER NOT NULL, \"media_stream_id\" INTEGER NOT NULL, \"md5\" TEXT NOT NULL UNIQUE, \"uts\" INTEGER NOT NULL, \"uts_ms\" INTEGER NOT NULL, \"ext\" TEXT NOT NULL, \"fps\" INTEGER NOT NULL, \"flength\" INTEGER, PRIMARY KEY(\"id\" AUTOINCREMENT) )"); + chmod( $FD . '/report.db', 0664 ); + chown( $FD . '/report.db', 'www-data' ); + chgrp( $FD . '/report.db', 'www-data' ); + } else { + $NREP = new SQLite_DB( $FD . '/report.db' ); + }; + $QS = "SELECT * FROM `events` WHERE `ts`>={$R['ts']} AND `ts`<=({$R['ts']}+86400)"; + $JPP = $ZIZI->Query( $QS ); + $EVCON = count( $JPP ); + $SECON = 0; + foreach( $JPP as $J ){ + $FIELDS = array(); + $VALS = array(); + if( $J['ts_ms'] == '' ) $J['ts_ms'] = '0'; + foreach( $J as $F=>$V ) if( $V!=''){ + $FIELDS[] = "`".$F."`"; + $VALS[] = "'".$V."'"; + }; + $QS = "INSERT INTO `events`(".implode(',', $FIELDS ).") VALUES(".implode(',', $VALS ).")"; + $NREP->Query( $QS ); + if( $J['evt_type'] == 52 ) $SECON++; + $QS = "SELECT * FROM `events_2_videos` WHERE `evt_id`={$J['id']}"; + $WUWU = $ZIZI->Query( $QS ); + foreach( $WUWU as $W ){ + $FIELDS = array(); + $VALS = array(); + foreach( $W as $F=>$V ) if( $V!=''){ + $FIELDS[] = "`".$F."`"; + $VALS[] = "'".$V."'"; + }; + $QS = "INSERT INTO `events_2_videos`(".implode(',', $FIELDS ).") VALUES(".implode(',', $VALS ).")"; + $NREP->Query( $QS ); + }; + }; + $QS = "SELECT * FROM `videos` WHERE `uts`>={$R['ts']} AND `uts`<=({$R['ts']}+86400)"; + $JPP = $ZIZI->Query( $QS ); + $VICON = count( $JPP ); + foreach( $JPP as $J ){ + $QS = "INSERT INTO `videos`(`id`,`media_stream_id`,`md5`,`uts`,`uts_ms`,`ext`,`fps`) VALUES({$J['id']},{$J['media_stream_id']},'{$J['md5']}',{$J['uts']},{$J['uts_ms']},'{$J['ext']}',{$J['fps']})"; + $NREP->Query( $QS ); + $SOURCE = '/srv/www/web/lib/controller/data/videos/'.$J['md5'] . ".".$J['ext']; + $TARGET = $FD . '/' . $J['md5'] . ".".$J['ext']; + echo "{$SOURCE} --> {$TARGET}\n"; + copy( $SOURCE, $TARGET ); + chmod( $TARGET, 0664 ); + chown( $TARGET, 'www-data' ); + chgrp( $TARGET, 'www-data' ); + }; + $QS = "INSERT INTO `days`(`year`,`month`,`day`,`evt_count`,`videos_count`,`session_count`, `session_closed`) VALUES('{$Y}','{$M}','{$D}',{$EVCON},{$VICON},{$SECON},1)"; + echo $QS ."\n"; + $STATA->Query( $QS ); + }; + }; +?> \ No newline at end of file diff --git a/lib/javascript/jsapi_dynamic/mojo_dashboard.js b/lib/javascript/jsapi_dynamic/mojo_dashboard.js index 7005960..e40f67f 100644 --- a/lib/javascript/jsapi_dynamic/mojo_dashboard.js +++ b/lib/javascript/jsapi_dynamic/mojo_dashboard.js @@ -66,6 +66,11 @@ function log_et_Renderer( value, meta, record ){ case 52: ov = 'Event Started'; break; case 53: ov = 'Event Ended'; break; case 54: ov = 'Event Closed Manual'; break; + case 55: ov = 'Connected'; break; + case 56: ov = 'Disconnection'; break; + case 57: ov = 'Communication Jamed'; break; + case 58: ov = 'Video Framerate Decreased'; break; + case 59: ov = 'Video Framerate Increased'; break; default: ov = 'Event ['+value+']'; }; return '
'+ov+'
'; @@ -691,7 +696,7 @@ function draw2DTargets( a ){ var rk = bBox.width / ( max * 2 ); var cpx = bBox.width / 2.0; var cpy = bBox.height / 2.0; - console.log( '2 box: '+ bBox.width+'x'+bBox.height ); + //console.log( '2 box: '+ bBox.width+'x'+bBox.height ); if( targets_2d[a] != undefined ){ if( targets_2d[a].length ) { var ak = 2.0*Math.PI/360; @@ -871,7 +876,7 @@ function draw2DDraw( a, zzz = '' ){ }; var newpath = document.createElementNS('http://www.w3.org/2000/svg', "polygon"); var ak = 2.0*Math.PI/draws_2d[a].length; - console.log( '1 box: '+ bBox.width+'x'+bBox.height ); + //console.log( '1 box: '+ bBox.width+'x'+bBox.height ); var cpx = bBox.width / 2.0; var cpy = bBox.height / 2.0; var max = 1024; diff --git a/lib/javascript/jsapi_dynamic/mojo_reports.js b/lib/javascript/jsapi_dynamic/mojo_reports.js index 17bc56a..db317bf 100644 --- a/lib/javascript/jsapi_dynamic/mojo_reports.js +++ b/lib/javascript/jsapi_dynamic/mojo_reports.js @@ -68,6 +68,11 @@ function rep_et_Renderer( value, meta, record ){ case 52: ov = 'Event Started'; break; case 53: ov = 'Event Ended'; break; case 54: ov = 'Event Closed Manual'; break; + case 55: ov = 'Connected'; break; + case 56: ov = 'Disconnection'; break; + case 57: ov = 'Communication Jamed'; break; + case 58: ov = 'Video Framerate Decreased'; break; + case 59: ov = 'Video Framerate Increased'; break; default: ov = 'Event ['+value+']'; }; return '
'+ov+'
'; @@ -820,18 +825,24 @@ function loadEventProperties( EventRec ){ }; var VideoLinks = []; +var VideoPlayer = null; var cEventTSS = 0; var cEventETS = 0; function loadEventData( record ){ ReportSelectionMode = 3; // Just One Event - cEventTSS = record.ts+record.ms/1000; - markEventOnRadar( record.node_id, record.az, record.r ); + cEventTSS = record.ts+record.ms/1000; + clearAllRadars(); + if( record.type == 13 || record.type == 14 || record.type == 36 ){ + markEventOnRadar( record.node_id, record.az, record.r ); + }; if( record.video_id > 0 ){ + showVideo(); Ext.Ajax.request({ url: '/lib/controller/getVideoInfo.php', params: { UID: , SID: '', + TS: record.ts, VID: record.video_id }, success: function( response, opts ){ @@ -850,27 +861,47 @@ function loadEventData( record ){ } else { cEventETS = 0; }; - video = videojs( video_t ); - var tVL = '/lib/controller/data/videos/'+data.md5+'.'+data.ext; + VideoPlayer = videojs( video_t ); + var tVL = '/lib/controller/data/reports/'+data.base+'/'+data.md5+'.'+data.ext; if( tVL != VideoLinks[data.node_id] ){ VideoLinks[data.node_id] = tVL; - video.src({ + VideoPlayer.src({ type: 'video/mp4', src: VideoLinks[data.node_id] }); + VideoPlayer.poster('/style/assets/no-signal.png'); }; var CT = cEventTSS - ( data.uts+data.uts_ms/1000 ); - video.currentTime( CT ); - video.play(); + VideoPlayer.currentTime( CT ); + VideoPlayer.play(); }; } }); } else { var t = Ext.getCmp('db_download_video'); if( t != undefined ){ + alert("ZagZag"); t.toggle( false, true ); t.disable(); } + //var video_t = document.getElementById( 'video-'+record.node_id ); + if( VideoPlayer != null ){ + //VideoPlayer.dispose(); + //VideoPlayer = null; + VideoPlayer.pause(); + VideoPlayer.poster('/style/assets/no-signal.png'); + VideoPlayer.posterImage.show(); + }; + }; +}; + +function clearAllRadars(){ + for( i=1; i< 1000; i++ ){ + var csvg = document.getElementById( 'draw_svgr_' + i ); + if( csvg!= undefined ){ + var roi = csvg.getElementById( "roi" ); + if( roi != null ) csvg.removeChild( roi ); + }; }; }; @@ -1442,7 +1473,7 @@ function shutImg( img, a = '' ){ var ReportMask = null; var ReportLayoutLoadded = false; var ReportSelectionMode = 0; //All -function loadReportSegment( bid, eid ){ +function loadReportSegment( ts, bid, eid ){ if( !ReportLayoutLoadded ){ ReportMask = new Ext.LoadMask(Ext.getCmp('main_content').getEl(), {msg:"Please wait..."}); ReportMask.show(); @@ -1479,28 +1510,30 @@ function loadReportSegment( bid, eid ){ tPanel.doLayout(); ReportMask.hide(); ReportLayoutLoadded = true; - loadReportData( bid, eid ); + loadReportData( ts, bid, eid ); }, error: function(){ ReportMask.hide(); } }); } else { - loadReportData( bid, eid ); + loadReportData( ts, bid, eid ); }; }; -function loadReportData( bid, eid ){ +function loadReportData( ts, bid, eid ){ ReportSelectionMode = 2; // Session Selected Ext.Ajax.request({ url: '/lib/controller/getHistoryEvents.php', params: { UID: , SID: '', + TS: ts, BID: bid, EID: eid, }, success: function(response, opts ){ + hideVideo(); var data = Ext.decode( response.responseText ); if( data.log != undefined ){ if( data.log.length ){ @@ -1546,7 +1579,7 @@ function loadReportDayTree( ts ){ xtype: 'spacer', height: 3 },{ - html: '

'+( new Date( ts * 1000)).toLocaleDateString()+'

', + html: '

'+( new Date( ts * 1000)).toLocaleDateString()+'

'+data.sessions+'

'+data.events+'

'+data.videos+'

', frame: false, width: '100%', border: false @@ -1557,11 +1590,11 @@ function loadReportDayTree( ts ){ xtype: 'treepanel', autoScroll: true, width: '100%', -Data['access'] > 3 ){ ?> - height: PanelH-177, +Data['access'] > 3 ){ ?> + height: PanelH-260, - height: PanelH-130, - + height: PanelH-209, + border: true, frame: true, loader: new Ext.tree.TreeLoader(), @@ -1571,8 +1604,8 @@ function loadReportDayTree( ts ){ click: function(n) { if( n.attributes.leaf ){ Ext.getCmp('chu_adate').show(); - sPanel.doLayout(); - loadReportSegment( n.attributes.bid, n.attributes.eid ); + sPanel.doLayout(); + loadReportSegment( ts, n.attributes.bid, n.attributes.eid ); //Ext.Msg.alert('Navigation Tree Click', 'You clicked: "' + n.attributes.ts + '"'); }; } @@ -1613,6 +1646,24 @@ function loadReportDayTree( ts ){ }); }; +function hideVideo(){ + var juja = undefined; + for( i = 1; i++; i < 1000 ){ + var juja = document.getElementById( 'video-'+i ); + if( juja != undefined ) break; + }; + if( juja != undefined ) juja.style.display = "none"; +}; + +function showVideo(){ + var juja = undefined; + for( i = 1; i++; i < 1000 ){ + var juja = document.getElementById( 'video-'+i ); + if( juja != undefined ) break; + }; + if( juja != undefined ) juja.style.display = "block"; +}; + function initReportsView(){ ReportSelectionMode = 0; // All History if( tlInterval!= null ){ diff --git a/style/style.css b/style/style.css index 402f393..4770926 100644 --- a/style/style.css +++ b/style/style.css @@ -1309,3 +1309,45 @@ A.CalendarDS:hover { font-size: 16px!important; text-align: center; } +.cur_videos{ + font-weight: bold; + background-color: green; + border-radius: 4px; + padding: 5px; + margin-top: 3px; + margin-bottom: 1px; + font-size: 12px!important; + background-image: url(wicons/030.png); + background-size: 16px 16px; + background-repeat: no-repeat; + background-position: 6px 4px; + text-align: center; +} +.cur_sessions{ + font-weight: bold; + background-color: blue; + border-radius: 4px; + padding: 5px; + margin-top: 3px; + margin-bottom: 1px; + font-size: 12px!important; + background-image: url(wicons/050.png); + background-size: 16px 16px; + background-repeat: no-repeat; + background-position: 6px 4px; + text-align: center; +} +.cur_events{ + font-weight: bold; + background-color: red; + border-radius: 4px; + padding: 5px; + margin-top: 3px; + margin-bottom: 1px; + font-size: 12px!important; + background-image: url(wicons/046.png); + background-size: 16px 16px; + background-repeat: no-repeat; + background-position: 6px 4px; + text-align: center; +} diff --git a/style/wicons/050.png b/style/wicons/050.png index 50dc11d..71f1e4f 100644 Binary files a/style/wicons/050.png and b/style/wicons/050.png differ