Merge branch 'monitorSize' of git://github.com/chriswiggins/ZoneMinder into modern

This commit is contained in:
Chris Wiggins 2013-09-20 17:49:04 +12:00
commit 99bae6386e
5 changed files with 15 additions and 4 deletions

2
web/app/Controller/MonitorsController.php Normal file → Executable file
View File

@ -5,7 +5,7 @@
public function index() {
$zmBandwidth = $this->Cookie->read('zmBandwidth');
$this->set('width', Configure::read('ZM_WEB_LIST_THUMB_WIDTH'));
$monitoroptions = array('fields' => array('Name', 'Id', 'Function', 'Enabled', 'Sequence', 'Function'), 'order' => 'Sequence ASC', 'recursive' => -1);
$monitoroptions = array('fields' => array('Name', 'Id', 'Function', 'Enabled', 'Sequence', 'Function', 'Width'), 'order' => 'Sequence ASC', 'recursive' => -1);
$this->set('monitors', $this->Monitor->find('all', $monitoroptions));
$monitors = $this->Monitor->find('all', array('recursive' => -1, 'fields' => array('Id', 'StreamReplayBuffer')));
foreach ($monitors as $monitor => $mon) {

4
web/app/View/Helper/LiveStreamHelper.php Normal file → Executable file
View File

@ -3,12 +3,12 @@ App::uses('AppHelper', 'View/Helper');
class LiveStreamHelper extends AppHelper {
public function makeLiveStream($name, $src, $id, $width=0) {
$liveStream = "<img id=\"liveStream_$id\" alt=\"Live Stream of $name\" src=\"$src&monitor=$id\" width=\"$width\">";
$liveStream = "<img class=\"livestream_resize\" id=\"liveStream_$id\" alt=\"Live Stream of $name\" src=\"$src&monitor=$id\" width=\"$width\">";
return $liveStream;
}
public function showNoImage($name, $src, $id, $width=0) {
$liveStream = "<img id=\"liveStream_$id\" alt=\"Live Stream of $name\" src=\"/img/no-image.jpg\".width?\"width=\"$width\">";
$liveStream = "<img class=\"livestream_resize\" id=\"liveStream_$id\" alt=\"No Live stream available for $name\" src=\"/img/no-image.png\">";
return $liveStream;
}
}

2
web/app/View/Monitors/index.ctp Normal file → Executable file
View File

@ -10,7 +10,7 @@
<div class="thumbnail">
<?php
if($daemonStatus && $mon['Monitor']['Function'] != "None" && $mon['Monitor']['Enabled'])
echo $this->LiveStream->makeLiveStream($mon['Monitor']['Name'], $streamSrc[$monitor], $mon['Monitor']['Id'], $width);
echo $this->LiveStream->makeLiveStream($mon['Monitor']['Name'], $streamSrc[$monitor], $mon['Monitor']['Id'], $mon['Monitor']['Width']);
else
echo $this->LiveStream->showNoImage($mon['Monitor']['Name'], $streamSrc[$monitor], $mon['Monitor']['Id'], $width);
?>

BIN
web/app/webroot/img/no-image.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.8 KiB

11
web/app/webroot/js/main.js Normal file → Executable file
View File

@ -199,6 +199,17 @@ $(document).ready(function() {
}
});
});
$(".livestream_resize").each(function(index, element){
if($(element).attr('src').indexOf('scale=') >= 0){
var newScale = Math.ceil(($(element).width() / $(element).attr('width')) * 100);
var src = $(element).attr('src').replace('scale=100', 'scale='+newScale);
$(element).attr('src', src);
console.log("resized");
}
});
return false;
// Monitors //