Merge branch 'storageareas' of github.com:ConnorTechnology/ZoneMinder into storageareas
This commit is contained in:
commit
52bca9d3ae
|
@ -264,13 +264,13 @@ DELIMITER ;
|
||||||
UPDATE Monitors SET
|
UPDATE Monitors SET
|
||||||
TotalEvents=(SELECT COUNT(*) FROM Events WHERE MonitorId=Monitors.Id),
|
TotalEvents=(SELECT COUNT(*) FROM Events WHERE MonitorId=Monitors.Id),
|
||||||
TotalEventDiskSpace=(SELECT SUM(DiskSpace) FROM Events WHERE MonitorId=Monitors.Id AND DiskSpace IS NOT NULL),
|
TotalEventDiskSpace=(SELECT SUM(DiskSpace) FROM Events WHERE MonitorId=Monitors.Id AND DiskSpace IS NOT NULL),
|
||||||
HourEvents=(SELECT COUNT(*) FROM Events WHERE MonitorId=Monitors.Id AND StartTime > DATE_SUB( NOW(), INTERVAL 1 hour) ),
|
HourEvents=(SELECT COUNT(*) FROM Events_Hour WHERE MonitorId=Monitors.Id),
|
||||||
HourEventDiskSpace=(SELECT SUM(DiskSpace) FROM Events WHERE MonitorId=Monitors.Id AND StartTime > DATE_SUB(NOW(), INTERVAL 1 hour) AND DiskSpace IS NOT NULL),
|
HourEventDiskSpace=(SELECT SUM(DiskSpace) FROM Events_Hour WHERE MonitorId=Monitors.Id AND DiskSpace IS NOT NULL),
|
||||||
DayEvents=(SELECT COUNT(*) FROM Events WHERE MonitorId=Monitors.Id AND StartTime > DATE_SUB(NOW(), INTERVAL 1 day)),
|
DayEvents=(SELECT COUNT(*) FROM Events_Day WHERE MonitorId=Monitors.Id),
|
||||||
DayEventDiskSpace=(SELECT SUM(DiskSpace) FROM Events WHERE MonitorId=Monitors.Id AND StartTime > DATE_SUB(NOW(), INTERVAL 1 day) AND DiskSpace IS NOT NULL),
|
DayEventDiskSpace=(SELECT SUM(DiskSpace) FROM Events_Day WHERE MonitorId=Monitors.Id AND DiskSpace IS NOT NULL),
|
||||||
WeekEvents=(SELECT COUNT(Id) FROM Events WHERE MonitorId=Monitors.Id AND StartTime > DATE_SUB(NOW(), INTERVAL 1 week)),
|
WeekEvents=(SELECT COUNT(Id) FROM Events_Week WHERE MonitorId=Monitors.Id),
|
||||||
WeekEventDiskSpace=(SELECT SUM(DiskSpace) FROM Events WHERE MonitorId=Monitors.Id AND StartTime > DATE_SUB(NOW(), INTERVAL 1 week) AND DiskSpace IS NOT NULL),
|
WeekEventDiskSpace=(SELECT SUM(DiskSpace) FROM Events_Week WHERE MonitorId=Monitors.Id AND DiskSpace IS NOT NULL),
|
||||||
MonthEvents=(SELECT COUNT(Id) FROM Events WHERE MonitorId=Monitors.Id AND StartTime > DATE_SUB( NOW(), INTERVAL 1 month)),
|
MonthEvents=(SELECT COUNT(Id) FROM Events_Month WHERE MonitorId=Monitors.Id),
|
||||||
MonthEventDiskSpace=(SELECT SUM(DiskSpace) FROM Events WHERE MonitorId=Monitors.Id AND StartTime > DATE_SUB(NOW(), INTERVAL 1 month) AND DiskSpace IS NOT NULL),
|
MonthEventDiskSpace=(SELECT SUM(DiskSpace) FROM Events_Month WHERE MonitorId=Monitors.Id AND DiskSpace IS NOT NULL),
|
||||||
ArchivedEvents=(SELECT COUNT(Id) FROM Events WHERE MonitorId=Monitors.Id AND Archived=1),
|
ArchivedEvents=(SELECT COUNT(Id) FROM Events_Archived WHERE MonitorId=Monitors.Id),
|
||||||
ArchivedEventDiskSpace=(SELECT SUM(DiskSpace) FROM Events WHERE MonitorId=Monitors.Id AND Archived=1 AND DiskSpace IS NOT NULL);
|
ArchivedEventDiskSpace=(SELECT SUM(DiskSpace) FROM Events_Archived WHERE MonitorId=Monitors.Id AND DiskSpace IS NOT NULL);
|
||||||
|
|
|
@ -211,15 +211,18 @@ class Event {
|
||||||
}
|
}
|
||||||
|
|
||||||
function createListThumbnail( $overwrite=false ) {
|
function createListThumbnail( $overwrite=false ) {
|
||||||
if ( (!$this->SaveJPEGs()) and file_exists($this->Path().'/snapshot.jpg') ) {
|
# The idea here is that we don't really want to use the analysis jpeg as the thumbnail.
|
||||||
|
# The snapshot image will be generated during capturing
|
||||||
|
if ( file_exists($this->Path().'/snapshot.jpg') ) {
|
||||||
|
Logger::Debug("snapshot exists");
|
||||||
$frame = null;
|
$frame = null;
|
||||||
} else {
|
} else {
|
||||||
# Load the frame with the highest score to use as a thumbnail
|
# Load the frame with the highest score to use as a thumbnail
|
||||||
if ( !($frame = dbFetchOne( 'SELECT * FROM Frames WHERE EventId=? AND Score=? ORDER BY FrameId LIMIT 1', NULL, array( $this->{'Id'}, $this->{'MaxScore'} ) )) ) {
|
if ( !($frame = dbFetchOne( 'SELECT * FROM Frames WHERE EventId=? AND Score=? ORDER BY FrameId LIMIT 1', NULL, array( $this->{'Id'}, $this->{'MaxScore'} ) )) ) {
|
||||||
Error("Unable to find a Frame matching max score " . $this->{'MaxScore'} . ' for event ' . $this->{'Id'} );
|
Error("Unable to find a Frame matching max score " . $this->{'MaxScore'} . ' for event ' . $this->{'Id'} );
|
||||||
// FIXME: What if somehow the db frame was lost or score was changed? Should probably try another search for any frame.
|
// FIXME: What if somehow the db frame was lost or score was changed? Should probably try another search for any frame.
|
||||||
return( false );
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ZM_WEB_LIST_THUMB_WIDTH ) {
|
if ( ZM_WEB_LIST_THUMB_WIDTH ) {
|
||||||
|
@ -234,21 +237,22 @@ class Event {
|
||||||
Fatal( "No thumbnail width or height specified, please check in Options->Web" );
|
Fatal( "No thumbnail width or height specified, please check in Options->Web" );
|
||||||
}
|
}
|
||||||
|
|
||||||
$imageData = $this->getImageSrc( $frame, $scale, false, $overwrite );
|
$imageData = $this->getImageSrc($frame, $scale, false, $overwrite);
|
||||||
if ( ! $imageData ) {
|
if ( ! $imageData ) {
|
||||||
return ( false );
|
return false;
|
||||||
}
|
}
|
||||||
$thumbData = $frame;
|
$thumbData = $frame;
|
||||||
$thumbData['Path'] = $imageData['thumbPath'];
|
$thumbData['Path'] = $imageData['thumbPath'];
|
||||||
$thumbData['Width'] = (int)$thumbWidth;
|
$thumbData['Width'] = (int)$thumbWidth;
|
||||||
$thumbData['Height'] = (int)$thumbHeight;
|
$thumbData['Height'] = (int)$thumbHeight;
|
||||||
|
$thumbData['url'] = '?view=image&eid='.$this->Id().'&fid='.$imageData['FrameId'].'&width='.$thumbData['Width'].'&height='.$thumbData['Height'];
|
||||||
|
|
||||||
return( $thumbData );
|
return $thumbData;
|
||||||
} // end function createListThumbnail
|
} // end function createListThumbnail
|
||||||
|
|
||||||
// frame is an array representing the db row for a frame.
|
// frame is an array representing the db row for a frame.
|
||||||
function getImageSrc( $frame, $scale=SCALE_BASE, $captureOnly=false, $overwrite=false ) {
|
function getImageSrc($frame, $scale=SCALE_BASE, $captureOnly=false, $overwrite=false) {
|
||||||
$Storage = new Storage( isset($this->{'StorageId'}) ? $this->{'StorageId'} : NULL );
|
$Storage = new Storage(isset($this->{'StorageId'}) ? $this->{'StorageId'} : NULL);
|
||||||
$Event = $this;
|
$Event = $this;
|
||||||
$eventPath = $Event->Path();
|
$eventPath = $Event->Path();
|
||||||
|
|
||||||
|
@ -258,10 +262,11 @@ class Event {
|
||||||
$frame = array( 'FrameId'=>$frame, 'Type'=>'' );
|
$frame = array( 'FrameId'=>$frame, 'Type'=>'' );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ( ! $frame ) and file_exists( $eventPath.'/snapshot.jpg' ) ) {
|
if ( ( ! $frame ) and file_exists($eventPath.'/snapshot.jpg') ) {
|
||||||
# No frame specified, so look for a snapshot to use
|
# No frame specified, so look for a snapshot to use
|
||||||
$captImage = 'snapshot.jpg';
|
$captImage = 'snapshot.jpg';
|
||||||
Logger::Debug("Frame not specified, using snapshot");
|
Logger::Debug("Frame not specified, using snapshot");
|
||||||
|
$frame = array('FrameId'=>'snapshot', 'Type'=>'');
|
||||||
} else {
|
} else {
|
||||||
$captImage = sprintf( '%0'.ZM_EVENT_IMAGE_DIGITS.'d-analyze.jpg', $frame['FrameId'] );
|
$captImage = sprintf( '%0'.ZM_EVENT_IMAGE_DIGITS.'d-analyze.jpg', $frame['FrameId'] );
|
||||||
if ( ! file_exists( $eventPath.'/'.$captImage ) ) {
|
if ( ! file_exists( $eventPath.'/'.$captImage ) ) {
|
||||||
|
@ -358,9 +363,10 @@ class Event {
|
||||||
'imageClass' => $alarmFrame?'alarm':'normal',
|
'imageClass' => $alarmFrame?'alarm':'normal',
|
||||||
'isAnalImage' => $isAnalImage,
|
'isAnalImage' => $isAnalImage,
|
||||||
'hasAnalImage' => $hasAnalImage,
|
'hasAnalImage' => $hasAnalImage,
|
||||||
|
'FrameId' => $frame['FrameId'],
|
||||||
);
|
);
|
||||||
|
|
||||||
return( $imageData );
|
return $imageData;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function find_all( $parameters = null, $options = null ) {
|
public static function find_all( $parameters = null, $options = null ) {
|
||||||
|
|
|
@ -200,16 +200,11 @@ while ( $event_row = dbFetchNext( $results ) ) {
|
||||||
}
|
}
|
||||||
if ( ZM_WEB_LIST_THUMBS ) {
|
if ( ZM_WEB_LIST_THUMBS ) {
|
||||||
if ( $thumbData = $event->createListThumbnail() ) {
|
if ( $thumbData = $event->createListThumbnail() ) {
|
||||||
|
#Logger::Debug(print_r($thumbData,true));
|
||||||
?>
|
?>
|
||||||
<td class="colThumbnail">
|
<td class="colThumbnail">
|
||||||
<?php
|
<?php
|
||||||
if ( ( $event->SaveJPEGs() == 0 ) and file_exists($event->Path().'/snapshot.jpg') ) {
|
$imgSrc = $thumbData['url'];
|
||||||
Logger::Debug("Using snapshot" . $event->Path().'/snapshot.jpg' );
|
|
||||||
$imgSrc = '?view=image&eid='.$event->Id().'&fid=snapshot&width='.$thumbData['Width'].'&height='.$thumbData['Height'];
|
|
||||||
} else {
|
|
||||||
Logger::Debug("Not Using snapshot" . $event->Path().'/snapshot.jpg' );
|
|
||||||
$imgSrc = '?view=image&eid='.$event->Id().'&fid='.$thumbData['FrameId'].'&width='.$thumbData['Width'].'&height='.$thumbData['Height'];
|
|
||||||
}
|
|
||||||
$streamSrc = $event->getStreamSrc( array( 'mode'=>'jpeg', 'scale'=>$scale, 'maxfps'=>ZM_WEB_VIDEO_MAXFPS, 'replay'=>'single') );
|
$streamSrc = $event->getStreamSrc( array( 'mode'=>'jpeg', 'scale'=>$scale, 'maxfps'=>ZM_WEB_VIDEO_MAXFPS, 'replay'=>'single') );
|
||||||
|
|
||||||
$imgHtml = '<img id="thumbnail'.$event->id().'" src="'.$imgSrc.'" alt="'. validHtmlStr('Event '.$event->Id()) .'" style="width:'. validInt($thumbData['Width']) .'px;height:'. validInt($thumbData['Height']).'px;" onmouseover="this.src=\''.$streamSrc.'\';" onmouseout="this.src=\''.$imgSrc.'\';"/>';
|
$imgHtml = '<img id="thumbnail'.$event->id().'" src="'.$imgSrc.'" alt="'. validHtmlStr('Event '.$event->Id()) .'" style="width:'. validInt($thumbData['Width']) .'px;height:'. validInt($thumbData['Height']).'px;" onmouseover="this.src=\''.$streamSrc.'\';" onmouseout="this.src=\''.$imgSrc.'\';"/>';
|
||||||
|
|
Loading…
Reference in New Issue