montage layout improvements
This commit is contained in:
parent
11449b77a9
commit
b565125df9
|
@ -15,6 +15,7 @@ if ( !($socket = @socket_create( AF_UNIX, SOCK_DGRAM, 0 )) ) {
|
|||
$locSockFile = ZM_PATH_SOCKS.'/zms-'.sprintf("%06d",$_REQUEST['connkey']).'w.sock';
|
||||
if ( file_exists( $locSockFile ) ) {
|
||||
Warning("sock file $locSockFile already exists?! Is someone else talking to zms?");
|
||||
// They could be. We can maybe have concurrent requests from a browser.
|
||||
} else {
|
||||
Logger::Debug("socket file does not exist, we should be good to connect.");
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ class MontageLayout {
|
|||
if ( ! $row ) {
|
||||
Error("Unable to load MontageLayout record for Id=" . $IdOrRow );
|
||||
}
|
||||
} elseif ( is_array( $IdOrRow ) ) {
|
||||
} else if ( is_array( $IdOrRow ) ) {
|
||||
$row = $IdOrRow;
|
||||
} else {
|
||||
Error("Unknown argument passed to MontageLayout Constructor ($IdOrRow)");
|
||||
|
|
|
@ -348,7 +348,7 @@ function getImageStreamHTML( $id, $src, $width, $height, $title='' ) {
|
|||
if ( canStreamIframe() ) {
|
||||
return '<iframe id="'.$id.'" src="'.$src.'" alt="'. validHtmlStr($title) .'" '.($width? ' width="'. validInt($width).'"' : '').($height?' height="'.validInt($height).'"' : '' ).'/>';
|
||||
} else {
|
||||
return '<img id="'.$id.'" src="'.$src.'" alt="'. validHtmlStr($title) .'" style="'.($width? ' width:'. validInt($width) .'px;': '').($height ? ' height:'. validInt( $height ).'px;':'').'"/>';
|
||||
return '<img id="'.$id.'" src="'.$src.'" alt="'. validHtmlStr($title) .'" style="'.($width? ' width:'.$width.';' : '' ).($height ? ' height:'. $height.';' : '' ).'"/>';
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2212,16 +2212,18 @@ function getStreamHTML( $monitor, $options = array() ) {
|
|||
|
||||
if ( isset($options['scale']) and $options['scale'] and ( $options['scale'] != 100 ) ) {
|
||||
//Warning("Scale to " . $options['scale'] );
|
||||
$options['width'] = reScale( $monitor->Width(), $options['scale'] );
|
||||
$options['height'] = reScale( $monitor->Height(), $options['scale'] );
|
||||
$options['width'] = reScale( $monitor->Width(), $options['scale'] ) . 'px';
|
||||
$options['height'] = reScale( $monitor->Height(), $options['scale'] ) . 'px';
|
||||
} else {
|
||||
# scale is empty or 100
|
||||
# There may be a fixed width applied though, in which case we need to leave the height empty
|
||||
if ( ! ( isset($options['width']) and $options['width'] ) ) {
|
||||
$options['width'] = $monitor->Width();
|
||||
$options['width'] = $monitor->Width() . 'px';
|
||||
if ( ! ( isset($options['height']) and $options['height'] ) ) {
|
||||
$options['height'] = $monitor->Height();
|
||||
$options['height'] = $monitor->Height() . 'px';
|
||||
}
|
||||
} else if ( ! isset($options['height']) ) {
|
||||
$options['height'] = '';
|
||||
}
|
||||
}
|
||||
if ( ! isset($options['mode'] ) ) {
|
||||
|
|
|
@ -13,13 +13,6 @@ function Monitor( monitorData ) {
|
|||
this.streamCmdParms += '&auth='+auth_hash;
|
||||
this.streamCmdTimer = null;
|
||||
|
||||
/*
|
||||
this.zm_startup = function( delay ) {
|
||||
console.log("Starting streamwatch for " + this.connKey );
|
||||
this.streamCmdTimer = this.streamCmdQuery.delay( delay, this );
|
||||
};
|
||||
*/
|
||||
|
||||
this.setStateClass = function( element, stateClass ) {
|
||||
if ( !element.hasClass( stateClass ) ) {
|
||||
if ( stateClass != 'alarm' )
|
||||
|
@ -141,7 +134,7 @@ function Monitor( monitorData ) {
|
|||
console.log( this.connKey+": Resending" );
|
||||
this.streamCmdReq.cancel();
|
||||
}
|
||||
console.log("Starting CmdQuery for " + this.connKey );
|
||||
//console.log("Starting CmdQuery for " + this.connKey );
|
||||
this.streamCmdReq.send( this.streamCmdParms+"&command="+CMD_QUERY );
|
||||
};
|
||||
|
||||
|
@ -206,7 +199,7 @@ function selectLayout( element ) {
|
|||
Cookie.write( 'zmMontageScale', '', { duration: 10*365 } );
|
||||
$('scale').set('value', '' );
|
||||
$('width').set('value', '');
|
||||
|
||||
if ( 1 ) {
|
||||
for ( var x = 0; x < monitors.length; x++ ) {
|
||||
var monitor = monitors[x];
|
||||
var streamImg = $( 'liveStream'+monitor.id );
|
||||
|
@ -228,6 +221,7 @@ function selectLayout( element ) {
|
|||
zonesSVG.style.width = '';
|
||||
}
|
||||
} // end foreach monitor
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -62,40 +62,48 @@ if ( ! $scale )
|
|||
$layouts = MontageLayout::find(NULL, array('order'=>"lower('Name')"));
|
||||
$layoutsById = array();
|
||||
foreach ( $layouts as $l ) {
|
||||
$layoutsById[$l->Id()] = $l->Name();
|
||||
$layoutsById[$l->Id()] = $l;
|
||||
}
|
||||
|
||||
|
||||
session_start();
|
||||
|
||||
$layout = '';
|
||||
$layout_id = '';
|
||||
if ( isset($_COOKIE['zmMontageLayout']) ) {
|
||||
$layout = $_SESSION['zmMontageLayout'] = $_COOKIE['zmMontageLayout'];
|
||||
Warning("Setting layout by cookie");
|
||||
$layout_id = $_SESSION['zmMontageLayout'] = $_COOKIE['zmMontageLayout'];
|
||||
} elseif ( isset($_SESSION['zmMontageLayout']) ) {
|
||||
$layout = $_SESSION['zmMontageLayout'];
|
||||
Warning("Setting layout by session");
|
||||
$layout_id = $_SESSION['zmMontageLayout'];
|
||||
}
|
||||
|
||||
$options = array();
|
||||
if ( isset($_COOKIE['zmMontageWidth']) and $_COOKIE['zmMontageWidth'] ) {
|
||||
$_SESSION['zmMontageWidth'] = $options['width'] = $_COOKIE['zmMontageWidth'];
|
||||
} elseif ( isset($_SESSION['zmMontageWidth']) and $_SESSION['zmMontageWidth'] ) {
|
||||
$options['width'] = $_SESSION['zmMontageWidth'];
|
||||
} else
|
||||
$options['width'] = '';
|
||||
$Layout = '';
|
||||
$Positions = '';
|
||||
if ( $layout_id ) {
|
||||
$Layout = $layoutsById[$layout_id];
|
||||
$Positions = json_decode( $Layout->Positions(), true );
|
||||
}
|
||||
if ( $Layout and ( $Layout->Name() != 'Freeform' ) ) {
|
||||
// Use layout instead of other options
|
||||
}
|
||||
|
||||
if ( isset($_COOKIE['zmMontageHeight']) and $_COOKIE['zmMontageHeight'] )
|
||||
$_SESSION['zmMontageHeight'] = $options['height'] = $_COOKIE['zmMontageHeight'];
|
||||
else if ( isset($_SESSION['zmMontageHeight']) and $_SESSION['zmMontageHeight'] )
|
||||
$options['height'] = $_SESSION['zmMontageHeight'];
|
||||
else
|
||||
$options['height'] = '';
|
||||
if ( isset($_COOKIE['zmMontageWidth']) and $_COOKIE['zmMontageWidth'] ) {
|
||||
$_SESSION['zmMontageWidth'] = $options['width'] = $_COOKIE['zmMontageWidth'];
|
||||
} elseif ( isset($_SESSION['zmMontageWidth']) and $_SESSION['zmMontageWidth'] ) {
|
||||
$options['width'] = $_SESSION['zmMontageWidth'];
|
||||
} else
|
||||
$options['width'] = '';
|
||||
|
||||
if ( isset($_COOKIE['zmMontageHeight']) and $_COOKIE['zmMontageHeight'] )
|
||||
$_SESSION['zmMontageHeight'] = $options['height'] = $_COOKIE['zmMontageHeight'];
|
||||
else if ( isset($_SESSION['zmMontageHeight']) and $_SESSION['zmMontageHeight'] )
|
||||
$options['height'] = $_SESSION['zmMontageHeight'];
|
||||
else
|
||||
$options['height'] = '';
|
||||
|
||||
if ( $scale )
|
||||
$options['scale'] = $scale;
|
||||
session_write_close();
|
||||
|
||||
if ( $scale )
|
||||
$options['scale'] = $scale;
|
||||
|
||||
ob_start();
|
||||
include('_monitor_filters.php');
|
||||
$filterbar = ob_get_contents();
|
||||
|
@ -156,7 +164,7 @@ if ( $showZones ) {
|
|||
<span id="scaleControl"><label><?php echo translate('Scale') ?>:</label><?php echo htmlSelect( 'scale', $scales, $scale, 'changeScale(this);' ); ?></span>
|
||||
<span id="layoutControl">
|
||||
<label for="layout"><?php echo translate('Layout') ?>:</label>
|
||||
<?php echo htmlSelect( 'zmMontageLayout', $layoutsById, $layout, array( 'onchange'=>'selectLayout(this);', 'id'=>'zmMontageLayout') ); ?>
|
||||
<?php echo htmlSelect( 'zmMontageLayout', $layoutsById, $layout_id, array( 'onchange'=>'selectLayout(this);', 'id'=>'zmMontageLayout') ); ?>
|
||||
</span>
|
||||
<input type="hidden" name="Positions"/>
|
||||
<input type="button" id="EditLayout" value="<?php echo translate('EditLayout') ?>" onclick="edit_layout(this);"/>
|
||||
|
@ -178,7 +186,22 @@ foreach ( $monitors as $monitor ) {
|
|||
<div id="monitor<?php echo $monitor->Id() ?>" class="monitor idle">
|
||||
<div id="imageFeed<?php echo $monitor->Id() ?>" class="imageFeed" onclick="createPopup( '?view=watch&mid=<?php echo $monitor->Id() ?>', 'zmWatch<?php echo $monitor->Id() ?>', 'watch', <?php echo reScale( $monitor->Width(), $monitor->PopupScale() ); ?>, <?php echo reScale( $monitor->Height(), $monitor->PopupScale() ); ?> );">
|
||||
<?php
|
||||
echo getStreamHTML( $monitor, $options );
|
||||
$monitor_options = $options;
|
||||
if ( $Positions ) {
|
||||
$monitor_options['width'] = '100%';
|
||||
$monitor_options['height'] = '100%';
|
||||
if ( 0 ) {
|
||||
if ( isset($Positions[$monitor->Id()]) ) {
|
||||
$monitor_options = array();
|
||||
#$monitor_options = $Positions[$monitor->Id()];
|
||||
} else if ( isset($Positions['default']) ) {
|
||||
$monitor_options = array();
|
||||
#$monitor_options = $Positions['default'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
echo getStreamHTML( $monitor, $monitor_options );
|
||||
if ( $showZones ) {
|
||||
$height = null;
|
||||
$width = null;
|
||||
|
|
Loading…
Reference in New Issue