fixes to montage review and cleanup in group filtering/editing

This commit is contained in:
Isaac Connor committed 2017-10-05 10:46:04 -04:00
1 parent de03726675
commit b56a976d7a
7 files changed
+146 -199

No files matched your search

+55 -1
View File
@@ -119,6 +119,60 @@ public $defaults = array(
}
return $this->{'depth'};
} // end public function depth
} # end class Group
public static function get_group_dropdowns() {
# This will end up with the group_id of the deepest selection
$group_id = 0;
$depth = 0;
$groups = array();
$parent_group_ids = null;
while(1) {
$Groups = Group::find_all( array('ParentId'=>$parent_group_ids) );
if ( ! count( $Groups ) )
break;
$parent_group_ids = array();
$selected_group_id = 0;
if ( isset($_REQUEST['group'.$depth]) and $_REQUEST['group'.$depth] > 0 ) {
$selected_group_id = $group_id = $_REQUEST['group'.$depth];
} else if ( isset($_COOKIE['zmGroup'.$depth] ) and $_COOKIE['zmGroup'.$depth] > 0 ) {
$selected_group_id = $group_id = $_COOKIE['zmGroup'.$depth];
}
foreach ( $Groups as $Group ) {
if ( ! isset( $groups[$depth] ) ) {
$groups[$depth] = array(0=>'All');
}
$groups[$depth][$Group->Id()] = $Group->Name();
if ( $selected_group_id and ( $selected_group_id == $Group->Id() ) )
$parent_group_ids[] = $Group->Id();
}
echo htmlSelect( 'group'.$depth, $groups[$depth], $selected_group_id, "changeGroup(this,$depth);" );
if ( ! count($parent_group_ids) ) break;
$depth += 1;
}
return $group_id;
} # end public static function get_group_dropdowns()
public static function get_group_sql( $group_id ) {
$groupSql = '';
if ( $group_id ) {
if ( $group = dbFetchOne( 'SELECT MonitorIds FROM Groups WHERE Id=?', NULL, array($group_id) ) ) {
$groupIds = array();
if ( $group['MonitorIds'] )
$groupIds = explode( ',', $group['MonitorIds'] );
Warning("Group ids" . implode(',',$groupIds) );
foreach ( dbFetchAll( 'SELECT MonitorIds FROM Groups WHERE ParentId = ?', NULL, array($group_id) ) as $group )
if ( $group['MonitorIds'] )
$groupIds = array_merge( $groupIds, explode( ',', $group['MonitorIds'] ) );
}
Warning("Group ids" . implode(',',$groupIds) );
$groupSql = " find_in_set( Id, '".implode( ',', $groupIds )."' )";
}
return $groupSql;
} # end public static function get_group_sql( $group_id )
} # end class Group
?>
+4 -4
View File
@@ -556,10 +556,10 @@ function htmlSelect( $name, $contents, $values, $behaviours=false ) {
}
$html = "<select name=\"$name\" id=\"$name\"$behaviourText>";
for ( $i = 0; $i < count($contents); $i +=2 ) {
//foreach ( $contents as $value=>$text ) {
$value = $contents[$i];
$text = $contents[$i+1];
foreach ( $contents as $value=>$text ) {
//for ( $i = 0; $i < count($contents); $i +=2 ) {
//$value = $contents[$i];
//$text = $contents[$i+1];
$selected = is_array( $values ) ? in_array( $value, $values ) : $value==$values;
$html .= "<option value=\"$value\"".($selected?" selected=\"selected\"":'').">$text</option>";
}
+20 -50
View File
@@ -114,60 +114,21 @@ xhtmlHeaders( __FILE__, translate('Console') );
<div class="controlHeader">
<span id="groupControl"><label><?php echo translate('Group') ?>:</label>
<?php
# This will end up with the group_id of the deepest selection
$group_id = 0;
$depth = 0;
$groups = array();
$parent_group_ids = null;
while(1) {
$Groups = Group::find_all( array('ParentId'=>$parent_group_ids) );
if ( ! count( $Groups ) )
break;
$parent_group_ids = array();
$selected_group_id = 0;
if ( isset($_REQUEST['group'.$depth]) and $_REQUEST['group'.$depth] > 0 ) {
$selected_group_id = $group_id = $_REQUEST['group'.$depth];
} else if ( isset($_COOKIE['zmGroup'.$depth] ) and $_COOKIE['zmGroup'.$depth] > 0 ) {
$selected_group_id = $group_id = $_COOKIE['zmGroup'.$depth];
}
foreach ( $Groups as $Group ) {
if ( ! isset( $groups[$depth] ) ) {
$groups[$depth] = array(0=>'All');
}
$groups[$depth][$Group->Id()] = $Group->Name();
if ( $selected_group_id and ( $selected_group_id == $Group->Id() ) )
$parent_group_ids[] = $Group->Id();
}
echo htmlSelect( 'group'.$depth, $groups[$depth], $selected_group_id, "changeGroup(this,$depth);" );
if ( ! count($parent_group_ids) ) break;
$depth += 1;
}
$groupSql = '';
if ( $group_id ) {
if ( $group = dbFetchOne( 'SELECT MonitorIds FROM Groups WHERE Id = ?', NULL, array($group_id) ) ) {
$groupIds = array();
if ( $group['MonitorIds'] )
$groupIds = explode( ',', $group['MonitorIds'] );
foreach ( dbFetchAll( 'SELECT MonitorIds FROM Groups WHERE ParentId = ?', NULL, array($group_id) ) as $group )
if ( $group['MonitorIds'] )
$groupIds += explode( ',', $group['MonitorIds'] );
}
$groupSql = " WHERE find_in_set( Id, '".implode( ',', $groupIds )."' )";
}
# This will end up with the group_id of the deepest selection
$group_id = Group::get_group_dropdowns();
$groupSql = Group::get_group_sql( $group_id );
?>
</span>
<span id="monitorControl"><label><?php echo translate('Monitor') ?>:</label>
<?php
$maxWidth = 0;
$maxHeight = 0;
# Used to determine if the Cycle button should be made available
$monitors = dbFetchAll( "SELECT * FROM Monitors$groupSql ORDER BY Sequence ASC" );
$monitors = dbFetchAll( 'SELECT * FROM Monitors'.($groupSql?' WHERE '.$groupSql:'').' ORDER BY Sequence ASC' );
$displayMonitors = array();
$monitors_dropdown = array(''=>'All');
for ( $i = 0; $i < count($monitors); $i++ ) {
if ( !visibleMonitor( $monitors[$i]['Id'] ) ) {
continue;
@@ -179,11 +140,20 @@ xhtmlHeaders( __FILE__, translate('Console') );
if ( $maxHeight < $scaleHeight ) $maxHeight = $scaleHeight;
}
$displayMonitors[] = $monitors[$i];
$monitors_dropdown[$monitors[$i]['Id']] = $monitors[$i]['Name'];
}
$monitor_id = 0;
if ( isset( $_REQUEST['monitor_id'] ) ) {
$monitor_id = $_REQUEST['monitor_id'];
} else if ( isset($_COOKIE['zmMonitorId']) ) {
$monitor_id = $_COOKIE['zmMonitorId'];
}
echo htmlSelect( 'monitor_id', $monitors_dropdown, $monitor_id, array('onchange'=>'changeMonitor(this);') );
$cycleWidth = $maxWidth;
$cycleHeight = $maxHeight;
$zoneCount = 0;
$zoneCount = 0;
for( $i = 0; $i < count($displayMonitors); $i += 1 ) {
$monitor = $displayMonitors[$i];
+2 -3
View File
@@ -91,10 +91,9 @@ $kids[] = $newGroup->Id();
function get_question_marks() {
return '?';
}
$options = array('','None');
$options = array(''=>'None');
foreach ( dbFetchAll( 'SELECT Id,Name from Groups WHERE Id NOT IN ('.implode(',',array_map('get_question_marks', $kids )).') ORDER BY Name', null, $kids ) as $option ) {
$options[] = $option['Id'];
$options[] = $option['Name'];
$options[$option['Id']] = $option['Name'];
}
echo htmlSelect( 'newGroup[ParentId]', $options, $newGroup->ParentId(), array('onchange'=>'configureButtons(this);' ));
?>
+12 -14
View File
@@ -423,13 +423,12 @@ function setScale(newscale) // makes actual change
currentScale=newscale;
}
function showSpeed(val) // updates slider only
{
$('speedslideroutput').innerHTML = parseFloat(speeds[val]).toFixed(2).toString() + " x";
function showSpeed(val) {
// updates slider only
$('speedslideroutput').innerHTML = parseFloat(speeds[val]).toFixed(2).toString() + " x";
}
function setSpeed(val) // Note parameter is the index not the speed
{
function setSpeed(val) { // Note parameter is the index not the speed
var t;
if(liveMode==1) return; // we shouldn't actually get here but just in case
currentSpeed=parseFloat(speeds[val]);
@@ -439,8 +438,7 @@ function setSpeed(val) // Note parameter is the index not the speed
if( timerInterval != currentDisplayInterval || currentSpeed == 0 ) timerFire(); // if the timer isn't firing we need to trigger it to update
}
function setLive(value)
{
function setLive(value) {
liveMode=value;
redrawScreen();
}
@@ -491,38 +489,38 @@ function clicknav(minSecs,maxSecs,arch,live) {// we use the current time if we c
window.location = uri;
} // end function clickNav
function lastHour() {
function click_lastHour() {
var now = new Date() / 1000;
clicknav(now - 3600 + 1, now,1,0);
}
function lastEight() {
function click_lastEight() {
var now = new Date() / 1000;
clicknav(now - 3600*8 + 1, now,1,0);
}
function zoomin() {
function click_zoomin() {
rangeTimeSecs = parseInt(rangeTimeSecs / 2);
minTimeSecs = parseInt(currentTimeSecs - rangeTimeSecs/2); // this is the slider current time, we center on that
maxTimeSecs = parseInt(currentTimeSecs + rangeTimeSecs/2);
clicknav(minTimeSecs,maxTimeSecs,1,0);
}
function zoomout() {
function click_zoomout() {
rangeTimeSecs = parseInt(rangeTimeSecs * 2);
minTimeSecs = parseInt(currentTimeSecs - rangeTimeSecs/2); // this is the slider current time, we center on that
maxTimeSecs = parseInt(currentTimeSecs + rangeTimeSecs/2);
clicknav(minTimeSecs,maxTimeSecs,1,0);
}
function panleft() {
function click_panleft() {
minTimeSecs = parseInt(minTimeSecs - rangeTimeSecs/2);
maxTimeSecs = minTimeSecs + rangeTimeSecs - 1;
clicknav(minTimeSecs,maxTimeSecs,1,0);
}
function panright() {
function click_panright() {
minTimeSecs = parseInt(minTimeSecs + rangeTimeSecs/2);
maxTimeSecs = minTimeSecs + rangeTimeSecs - 1;
clicknav(minTimeSecs,maxTimeSecs,1,0);
}
function allof() {
function click_all_events() {
clicknav(0,0,1,0);
}
function allnon() {
+35 -71
View File
@@ -23,39 +23,6 @@ if ( !canView('Stream') ) {
return;
}
$group_id = 0;
if ( isset($_REQUEST['group']) ) {
$group_id = $_REQUEST['group'];
} else if ( isset($_COOKIE['zmGroup'] ) ) {
$group_id = $_COOKIE['zmGroup'];
}
$subgroup_id = 0;
if ( isset($_REQUEST['subgroup']) ) {
$subgroup_id = $_REQUEST['subgroup'];
} else if ( isset($_COOKIE['zmSubGroup'] ) ) {
$subgroup_id = $_COOKIE['zmSubGroup'];
}
$groupIds = null;
if ( $group_id ) {
$groupIds = array();
if ( $group = dbFetchOne( 'SELECT MonitorIds FROM Groups WHERE Id = ?', NULL, array($group_id) ) )
if ( $group['MonitorIds'] )
$groupIds = explode( ',', $group['MonitorIds'] );
if ( $subgroup_id ) {
if ( $group = dbFetchOne( 'SELECT MonitorIds FROM Groups WHERE Id = ?', NULL, array($subgroup_id) ) )
if ( $group['MonitorIds'] )
$groupIds = array_merge( $groupIds, explode( ',', $group['MonitorIds'] ) );
} else {
foreach ( dbFetchAll( 'SELECT MonitorIds FROM Groups WHERE ParentId = ?', NULL, array($group_id) ) as $group )
if ( $group['MonitorIds'] )
$groupIds = array_merge( $groupIds, explode( ',', $group['MonitorIds'] ) );
}
}
$groupSql = '';
if ( $groupIds )
$groupSql = " and find_in_set( Id, '".implode( ',', $groupIds )."' )";
$showControl = false;
$showZones = false;
if ( isset( $_REQUEST['showZones'] ) ) {
@@ -63,7 +30,6 @@ if ( isset( $_REQUEST['showZones'] ) ) {
$showZones = true;
}
}
$monitors = array();
$widths = array(
'' => 'auto',
160 => 160,
@@ -91,27 +57,6 @@ if ( isset( $_REQUEST['scale'] ) ) {
if ( ! $scale )
$scale = 100;
$sql = "SELECT * FROM Monitors WHERE Function != 'None'$groupSql ORDER BY Sequence";
foreach( dbFetchAll( $sql ) as $row ) {
if ( !visibleMonitor( $row['Id'] ) ) {
continue;
}
$row['Scale'] = $scale;
$row['PopupScale'] = reScale( SCALE_BASE, $row['DefaultScale'], ZM_WEB_DEFAULT_SCALE );
if ( ZM_OPT_CONTROL && $row['ControlId'] && $row['Controllable'] )
$showControl = true;
$row['connKey'] = generateConnKey();
$monitors[] = new Monitor( $row );
if ( ! isset( $widths[$row['Width']] ) ) {
$widths[$row['Width']] = $row['Width'];
}
if ( ! isset( $heights[$row['Height']] ) ) {
$heights[$row['Height']] = $row['Height'];
}
} # end foreach Monitor
$focusWindow = true;
$layouts = array(
@@ -138,11 +83,42 @@ else
if ( $scale )
$options['scale'] = $scale;
ob_start();
# This will end up with the group_id of the deepest selection
$group_id = Group::get_group_dropdowns();
$group_dropdowns = ob_get_contents();
ob_end_clean();
$groupSql = Group::get_group_sql( $group_id );
$monitors = array();
$sql = "SELECT * FROM Monitors WHERE Function != 'None'";
if ( $groupSql ) { $sql .= ' AND ' . $groupSql; };
$sql .= 'ORDER BY Sequence';
foreach( dbFetchAll( $sql ) as $row ) {
if ( !visibleMonitor( $row['Id'] ) ) {
continue;
}
$row['Scale'] = $scale;
$row['PopupScale'] = reScale( SCALE_BASE, $row['DefaultScale'], ZM_WEB_DEFAULT_SCALE );
if ( ZM_OPT_CONTROL && $row['ControlId'] && $row['Controllable'] )
$showControl = true;
$row['connKey'] = generateConnKey();
$monitors[] = new Monitor( $row );
if ( ! isset( $widths[$row['Width']] ) ) {
$widths[$row['Width']] = $row['Width'];
}
if ( ! isset( $heights[$row['Height']] ) ) {
$heights[$row['Height']] = $row['Height'];
}
} # end foreach Monitor
xhtmlHeaders(__FILE__, translate('Montage') );
?>
<body>
<div id="page">
<?php echo getNavBarHTML() ?>
<?php echo getNavBarHTML() ?>
<div id="header">
<div id="headerButtons">
<?php
@@ -165,21 +141,9 @@ if ( $showZones ) {
<div id="headerControl">
<span id="groupControl"><label><?php echo translate('Group') ?>:</label>
<?php
$groups = array(0=>'All');
foreach ( Group::find_all( array('ParentId'=>null) ) as $Group ) {
$groups[$Group->Id()] = $Group->Name();
}
echo htmlSelect( 'group', $groups, $group_id, 'changeGroup(this);' );
$groups = array(0=>'All');
if ( $group_id ) {
foreach ( Group::find_all( array('ParentId'=>$group_id) ) as $Group ) {
$groups[$Group->Id()] = $Group->Name();
}
}
echo htmlSelect( 'subgroup', $groups, $subgroup_id, 'changeSubGroup(this);' );
echo $group_dropdowns;
?>
</span>
</span>
<span id="widthControl"><label><?php echo translate('Width') ?>:</label><?php echo htmlSelect( 'width', $widths, $options['width'], 'changeSize(this);' ); ?></span>
<span id="heightControl"><label><?php echo translate('Height') ?>:</label><?php echo htmlSelect( 'height', $heights, $options['height'], 'changeSize(this);' ); ?></span>
<span id="scaleControl"><label><?php echo translate('Scale') ?>:</label><?php echo htmlSelect( 'scale', $scales, $scale, 'changeScale(this);' ); ?></span>
@@ -190,7 +154,7 @@ echo htmlSelect( 'subgroup', $groups, $subgroup_id, 'changeSubGroup(this);' );
<div id="monitors">
<?php
foreach ( $monitors as $monitor ) {
$connkey = $monitor->connKey(); // Minor hack
$connkey = $monitor->connKey(); // Minor hack
?>
<div id="monitorFrame<?php echo $monitor->Id() ?>" class="monitorFrame" title="<?php echo $monitor->Id() . ' ' .$monitor->Name() ?>">
<div id="monitor<?php echo $monitor->Id() ?>" class="monitor idle">
+18 -56
View File
@@ -54,38 +54,13 @@ if ( !canView( 'Events' ) ) {
return;
}
$group_id = 0;
if ( isset($_REQUEST['group']) ) {
$group_id = $_REQUEST['group'];
} else if ( isset($_COOKIE['zmGroup'] ) ) {
$group_id = $_COOKIE['zmGroup'];
}
ob_start();
# This will end up with the group_id of the deepest selection
$group_id = Group::get_group_dropdowns();
$group_dropdowns = ob_get_contents();
ob_end_clean();
$subgroup_id = 0;
if ( isset($_REQUEST['subgroup']) ) {
$subgroup_id = $_REQUEST['subgroup'];
} else if ( isset($_COOKIE['zmSubGroup'] ) ) {
$subgroup_id = $_COOKIE['zmSubGroup'];
}
$groupIds = null;
if ( $group_id ) {
$groupIds = array();
if ( $group = dbFetchOne( 'SELECT MonitorIds FROM Groups WHERE Id = ?', NULL, array($group_id) ) )
if ( $group['MonitorIds'] )
$groupIds = explode( ',', $group['MonitorIds'] );
if ( $subgroup_id ) {
if ( $group = dbFetchOne( 'SELECT MonitorIds FROM Groups WHERE Id = ?', NULL, array($subgroup_id) ) )
if ( $group['MonitorIds'] )
$groupIds = array_merge( $groupIds, explode( ',', $group['MonitorIds'] ) );
} else {
foreach ( dbFetchAll( 'SELECT MonitorIds FROM Groups WHERE ParentId = ?', NULL, array($group_id) ) as $group )
if ( $group['MonitorIds'] )
$groupIds = array_merge( $groupIds, explode( ',', $group['MonitorIds'] ) );
}
}
$groupSql = '';
if ( $groupIds )
$groupSql = " and find_in_set( Id, '".implode( ',', $groupIds )."' )";
$groupSql = Group::get_group_sql( $group_id );
session_start();
foreach ( array('minTime','maxTime') as $var ) {
@@ -95,7 +70,7 @@ if ( isset( $_REQUEST[$var] ) ) {
}
session_write_close();
$monitorsSql = "SELECT * FROM Monitors WHERE Function != 'None'$groupSql";
$monitorsSql = "SELECT * FROM Monitors WHERE Function != 'None'" . ( $groupSql ? ' AND ' . $groupSql : '');
// Note that this finds incomplete events as well, and any frame records written, but still cannot "see" to the end frame
// if the bulk record has not been written - to be able to include more current frames reduce bulk frame sizes (event size can be large)
@@ -127,9 +102,9 @@ $frameSql = '
// This program only calls itself with the time range involved -- it does all monitors (the user can see, in the called group) all the time
if ( ! empty( $user['MonitorIds'] ) ) {
$eventsSql .= ' AND M.Id IN ('.$user['MonitorIds'].')';
$monitorsSql .= ' AND Id IN ('.$user['MonitorIds'].')';
$frameSql .= ' AND E.MonitorId IN ('.$user['MonitorIds'].')';
$eventsSql .= ' AND M.Id IN ('.$user['MonitorIds'].')';
$monitorsSql .= ' AND Id IN ('.$user['MonitorIds'].')';
$frameSql .= ' AND E.MonitorId IN ('.$user['MonitorIds'].')';
}
// Parse input parameters -- note for future, validate/clean up better in case we don't get called from self.
@@ -224,20 +199,7 @@ xhtmlHeaders(__FILE__, translate('MontageReview') );
<div id="header">
<div id="headerControl">
<span id="groupControl"><label><?php echo translate('Group') ?>:</label>
<?php
$groups = array(0=>'All');
foreach ( Group::find_all(array('ParentId'=>null)) as $Group ) {
$groups[$Group->Id()] = $Group->Name();
}
echo htmlSelect( 'group', $groups, $group_id, 'changeGroup(this);' );
$groups = array(0=>'All');
if ( $group_id ) {
foreach ( Group::find_all( array('ParentId'=>$group_id) ) as $Group ) {
$groups[$Group->Id()] = $Group->Name();
}
}
echo htmlSelect( 'subgroup', $groups, $subgroup_id, 'changeSubGroup(this);' );
?>
<?php echo $group_dropdowns; ?>
</span>
<div id="DateTimeDiv">
<input type="datetime-local" name="minTime" id="minTime" value="<?php echo preg_replace('/ /', 'T', $minTime ) ?>" onchange="changeDateTime(this);"> to
@@ -254,15 +216,15 @@ xhtmlHeaders(__FILE__, translate('MontageReview') );
<span id="speedslideroutput"><?php echo $speeds[$speedIndex] ?> fps</span>
</div>
<div style="display: inline-flex; border: 1px solid black; flex-flow: row wrap;">
<button type="button" id="panleft" onclick="panleft();" >&lt; <?php echo translate('Pan') ?></button>
<button type="button" id="zoomin" onclick="zoomin();" ><?php echo translate('In +') ?></button>
<button type="button" id="zoomout" onclick="zoomout();" ><?php echo translate('Out -') ?></button>
<button type="button" id="lasteight" onclick="lastEight();" ><?php echo translate('8 Hour') ?></button>
<button type="button" id="lasthour" onclick="lastHour();" ><?php echo translate('1 Hour') ?></button>
<button type="button" id="allof" onclick="allof();" ><?php echo translate('All Events') ?></button>
<button type="button" id="panleft" onclick="click_panleft();" >&lt; <?php echo translate('Pan') ?></button>
<button type="button" id="zoomin" onclick="click_zoomin();" ><?php echo translate('In +') ?></button>
<button type="button" id="zoomout" onclick="click_zoomout();" ><?php echo translate('Out -') ?></button>
<button type="button" id="lasteight" onclick="click_lastEight();" ><?php echo translate('8 Hour') ?></button>
<button type="button" id="lasthour" onclick="click_lastHour();" ><?php echo translate('1 Hour') ?></button>
<button type="button" id="allof" onclick="click_all_events();" ><?php echo translate('All Events') ?></button>
<button type="button" id="live" onclick="setLive(1-liveMode);"><?php echo translate('Live') ?></button>
<button type="button" id="fit" onclick="setFit(1-fitMode);" ><?php echo translate('Fit') ?></button>
<button type="button" id="panright" onclick="panright();" ><?php echo translate('Pan') ?> &gt;</button>
<button type="button" id="panright" onclick="click_panright();" ><?php echo translate('Pan') ?> &gt;</button>
</div>
<div id="timelinediv">
<canvas id="timeline" onmousemove="mmove(event);" ontouchmove="tmove(event);" onmousedown="mdown(event);" onmouseup="mup(event);" onmouseout="mout(event);"></canvas>