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
|
||||
TotalEvents=(SELECT COUNT(*) FROM Events WHERE MonitorId=Monitors.Id),
|
||||
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) ),
|
||||
HourEventDiskSpace=(SELECT SUM(DiskSpace) FROM Events WHERE MonitorId=Monitors.Id AND StartTime > DATE_SUB(NOW(), INTERVAL 1 hour) AND DiskSpace IS NOT NULL),
|
||||
DayEvents=(SELECT COUNT(*) FROM Events WHERE MonitorId=Monitors.Id AND StartTime > DATE_SUB(NOW(), INTERVAL 1 day)),
|
||||
DayEventDiskSpace=(SELECT SUM(DiskSpace) FROM Events WHERE MonitorId=Monitors.Id AND StartTime > DATE_SUB(NOW(), INTERVAL 1 day) AND DiskSpace IS NOT NULL),
|
||||
WeekEvents=(SELECT COUNT(Id) FROM Events WHERE MonitorId=Monitors.Id AND StartTime > DATE_SUB(NOW(), INTERVAL 1 week)),
|
||||
WeekEventDiskSpace=(SELECT SUM(DiskSpace) FROM Events WHERE MonitorId=Monitors.Id AND StartTime > DATE_SUB(NOW(), INTERVAL 1 week) AND DiskSpace IS NOT NULL),
|
||||
MonthEvents=(SELECT COUNT(Id) FROM Events WHERE MonitorId=Monitors.Id AND StartTime > DATE_SUB( NOW(), INTERVAL 1 month)),
|
||||
MonthEventDiskSpace=(SELECT SUM(DiskSpace) FROM Events WHERE MonitorId=Monitors.Id AND StartTime > DATE_SUB(NOW(), INTERVAL 1 month) AND DiskSpace IS NOT NULL),
|
||||
ArchivedEvents=(SELECT COUNT(Id) FROM Events WHERE MonitorId=Monitors.Id AND Archived=1),
|
||||
ArchivedEventDiskSpace=(SELECT SUM(DiskSpace) FROM Events WHERE MonitorId=Monitors.Id AND Archived=1 AND DiskSpace IS NOT NULL);
|
||||
HourEvents=(SELECT COUNT(*) FROM Events_Hour WHERE MonitorId=Monitors.Id),
|
||||
HourEventDiskSpace=(SELECT SUM(DiskSpace) FROM Events_Hour WHERE MonitorId=Monitors.Id AND DiskSpace IS NOT NULL),
|
||||
DayEvents=(SELECT COUNT(*) FROM Events_Day WHERE MonitorId=Monitors.Id),
|
||||
DayEventDiskSpace=(SELECT SUM(DiskSpace) FROM Events_Day WHERE MonitorId=Monitors.Id AND DiskSpace IS NOT NULL),
|
||||
WeekEvents=(SELECT COUNT(Id) FROM Events_Week WHERE MonitorId=Monitors.Id),
|
||||
WeekEventDiskSpace=(SELECT SUM(DiskSpace) FROM Events_Week WHERE MonitorId=Monitors.Id AND DiskSpace IS NOT NULL),
|
||||
MonthEvents=(SELECT COUNT(Id) FROM Events_Month WHERE MonitorId=Monitors.Id),
|
||||
MonthEventDiskSpace=(SELECT SUM(DiskSpace) FROM Events_Month WHERE MonitorId=Monitors.Id AND DiskSpace IS NOT NULL),
|
||||
ArchivedEvents=(SELECT COUNT(Id) FROM Events_Archived WHERE MonitorId=Monitors.Id),
|
||||
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 ) {
|
||||
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;
|
||||
} else {
|
||||
# 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'} ) )) ) {
|
||||
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.
|
||||
return( false );
|
||||
}
|
||||
# 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'} ) )) ) {
|
||||
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.
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if ( ZM_WEB_LIST_THUMB_WIDTH ) {
|
||||
|
@ -234,21 +237,22 @@ class Event {
|
|||
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 ) {
|
||||
return ( false );
|
||||
return false;
|
||||
}
|
||||
$thumbData = $frame;
|
||||
$thumbData['Path'] = $imageData['thumbPath'];
|
||||
$thumbData['Width'] = (int)$thumbWidth;
|
||||
$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
|
||||
|
||||
// frame is an array representing the db row for a frame.
|
||||
function getImageSrc( $frame, $scale=SCALE_BASE, $captureOnly=false, $overwrite=false ) {
|
||||
$Storage = new Storage( isset($this->{'StorageId'}) ? $this->{'StorageId'} : NULL );
|
||||
function getImageSrc($frame, $scale=SCALE_BASE, $captureOnly=false, $overwrite=false) {
|
||||
$Storage = new Storage(isset($this->{'StorageId'}) ? $this->{'StorageId'} : NULL);
|
||||
$Event = $this;
|
||||
$eventPath = $Event->Path();
|
||||
|
||||
|
@ -258,10 +262,11 @@ class Event {
|
|||
$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
|
||||
$captImage = 'snapshot.jpg';
|
||||
Logger::Debug("Frame not specified, using snapshot");
|
||||
$frame = array('FrameId'=>'snapshot', 'Type'=>'');
|
||||
} else {
|
||||
$captImage = sprintf( '%0'.ZM_EVENT_IMAGE_DIGITS.'d-analyze.jpg', $frame['FrameId'] );
|
||||
if ( ! file_exists( $eventPath.'/'.$captImage ) ) {
|
||||
|
@ -358,9 +363,10 @@ class Event {
|
|||
'imageClass' => $alarmFrame?'alarm':'normal',
|
||||
'isAnalImage' => $isAnalImage,
|
||||
'hasAnalImage' => $hasAnalImage,
|
||||
'FrameId' => $frame['FrameId'],
|
||||
);
|
||||
|
||||
return( $imageData );
|
||||
return $imageData;
|
||||
}
|
||||
|
||||
public static function find_all( $parameters = null, $options = null ) {
|
||||
|
|
|
@ -200,16 +200,11 @@ while ( $event_row = dbFetchNext( $results ) ) {
|
|||
}
|
||||
if ( ZM_WEB_LIST_THUMBS ) {
|
||||
if ( $thumbData = $event->createListThumbnail() ) {
|
||||
#Logger::Debug(print_r($thumbData,true));
|
||||
?>
|
||||
<td class="colThumbnail">
|
||||
<?php
|
||||
if ( ( $event->SaveJPEGs() == 0 ) and file_exists($event->Path().'/snapshot.jpg') ) {
|
||||
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'];
|
||||
}
|
||||
$imgSrc = $thumbData['url'];
|
||||
$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.'\';"/>';
|
||||
|
|
Loading…
Reference in New Issue