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