Merge branch 'storageareas' into tesla

This commit is contained in:
Isaac Connor 2018-01-12 11:26:19 -08:00
commit bfa31297be
9 changed files with 88 additions and 17 deletions

View File

@ -480,6 +480,8 @@ Debug(2,"last_write_index(%d), last_write_time(%d)", shared_data->last_write_ind
( shared_data->last_write_index == (unsigned int)image_buffer_count ) ( shared_data->last_write_index == (unsigned int)image_buffer_count )
&& &&
( shared_data->last_write_time == 0) ( shared_data->last_write_time == 0)
&&
( !zm_terminate )
) { ) {
Warning( "Waiting for capture daemon" ); Warning( "Waiting for capture daemon" );
sleep( 1 ); sleep( 1 );

View File

@ -135,6 +135,61 @@ public $defaults = array(
return $this->{'MonitorIds'}; return $this->{'MonitorIds'};
} }
public static function get_group_dropdown() {
session_start();
$selected_group_id = 0;
if ( isset($_REQUEST['groups']) ) {
$selected_group_id = $group_id = $_SESSION['groups'] = $_REQUEST['groups'];
} else if ( isset( $_SESSION['groups'] ) ) {
$selected_group_id = $group_id = $_SESSION['groups'];
} else if ( isset($_REQUEST['filtering']) ) {
unset($_SESSION['groups']);
}
session_write_close();
$Groups = array();
foreach ( Group::find_all( ) as $Group ) {
$Groups[$Group->Id()] = $Group;
}
# This array is indexed by parent_id
global $children;
$children = array();
foreach ( $Groups as $id=>$Group ) {
if ( $Group->ParentId() != null ) {
if ( ! isset( $children[$Group->ParentId()] ) )
$children[$Group->ParentId()] = array();
$children[$Group->ParentId()][] = $Group;
}
}
function get_options( $Group ) {
global $children;
$options = array( $Group->Id() => str_repeat('   ', $Group->depth() ) . $Group->Name() );
if ( isset($children[$Group->Id()]) ) {
foreach ( $children[$Group->Id()] as $child ) {
$options += get_options( $child );
}
}
return $options;
}
$group_options = array();
foreach ( $Groups as $id=>$Group ) {
if ( ! $Group->ParentId() ) {
$group_options += get_options( $Group );
}
}
return htmlSelect( 'Group[]', $group_options, isset($_SESSION['Group'])?$_SESSION['Group']:null, array(
'onchange' => 'this.form.submit();',
'class'=>'chosen',
'multiple'=>'multiple',
'data-placeholder'=>'All',
) );
} # end public static function get_group_dropdown
public static function get_group_dropdowns() { public static function get_group_dropdowns() {
# This will end up with the group_id of the deepest selection # This will end up with the group_id of the deepest selection
$group_id = 0; $group_id = 0;
@ -142,6 +197,8 @@ public $defaults = array(
$groups = array(); $groups = array();
$parent_group_ids = null; $parent_group_ids = null;
session_start(); session_start();
$group_options = array(0=>'All');
while(1) { while(1) {
$Groups = Group::find_all( array('ParentId'=>$parent_group_ids) ); $Groups = Group::find_all( array('ParentId'=>$parent_group_ids) );
if ( ! count( $Groups ) ) if ( ! count( $Groups ) )
@ -161,15 +218,17 @@ public $defaults = array(
if ( ! isset( $groups[$depth] ) ) { if ( ! isset( $groups[$depth] ) ) {
$groups[$depth] = array(0=>'All'); $groups[$depth] = array(0=>'All');
} }
$group_options[$Group->Id()] = str_repeat( ' ', $depth ) . $Group->Name();
$groups[$depth][$Group->Id()] = $Group->Name(); $groups[$depth][$Group->Id()] = $Group->Name();
if ( $selected_group_id and ( $selected_group_id == $Group->Id() ) ) if ( $selected_group_id and ( $selected_group_id == $Group->Id() ) )
$parent_group_ids[] = $Group->Id(); $parent_group_ids[] = $Group->Id();
} }
echo htmlSelect( 'group'.$depth, $groups[$depth], $selected_group_id, "this.form.submit();" ); //echo htmlSelect( 'group'.$depth, $groups[$depth], $selected_group_id, "this.form.submit();" );
if ( ! count($parent_group_ids) ) break; if ( ! count($parent_group_ids) ) break;
$depth += 1; $depth += 1;
} }
echo htmlSelect( 'groups', $group_options, $selected_group_id, 'this.form.submit();' );
session_write_close(); session_write_close();
return $group_id; return $group_id;
@ -179,9 +238,17 @@ public $defaults = array(
public static function get_group_sql( $group_id ) { public static function get_group_sql( $group_id ) {
$groupSql = ''; $groupSql = '';
if ( $group_id ) { if ( $group_id ) {
if ( is_array( $group_id ) ) {
$group_id_sql_part = ' IN ('.implode(',', array_map(function(){return '?';}, $group_id ) ).')';
$MonitorIds = dbFetchAll( 'SELECT MonitorId FROM Groups_Monitors WHERE GroupId'.$group_id_sql_part, 'MonitorId', $group_id );
$MonitorIds = array_merge( $MonitorIds, dbFetchAll( 'SELECT MonitorId FROM Groups_Monitors WHERE GroupId IN (SELECT Id FROM Groups WHERE ParentId'.$group_id_sql_part.')', 'MonitorId', $group_id ) );
} else {
$MonitorIds = dbFetchAll( 'SELECT MonitorId FROM Groups_Monitors WHERE GroupId=?', 'MonitorId', array($group_id) ); $MonitorIds = dbFetchAll( 'SELECT MonitorId FROM Groups_Monitors WHERE GroupId=?', 'MonitorId', array($group_id) );
$MonitorIds = array_merge( $MonitorIds, dbFetchAll( 'SELECT MonitorId FROM Groups_Monitors WHERE GroupId IN (SELECT Id FROM Groups WHERE ParentId = ?)', 'MonitorId', array($group_id) ) ); $MonitorIds = array_merge( $MonitorIds, dbFetchAll( 'SELECT MonitorId FROM Groups_Monitors WHERE GroupId IN (SELECT Id FROM Groups WHERE ParentId = ?)', 'MonitorId', array($group_id) ) );
}
$groupSql = " find_in_set( Id, '".implode( ',', $MonitorIds )."' )"; $groupSql = " find_in_set( Id, '".implode( ',', $MonitorIds )."' )";
} }
return $groupSql; return $groupSql;

View File

@ -636,10 +636,10 @@ function getFormChanges( $values, $newValues, $types=false, $columns=false ) {
{ {
if ( is_array( $newValues[$key] ) ) { if ( is_array( $newValues[$key] ) ) {
if ( join(',',$newValues[$key]) != $values[$key] ) { if ( join(',',$newValues[$key]) != $values[$key] ) {
$changes[$key] = "$key = ".dbEscape(join(',',$newValues[$key])); $changes[$key] = "`$key` = ".dbEscape(join(',',$newValues[$key]));
} }
} elseif ( $values[$key] ) { } elseif ( $values[$key] ) {
$changes[$key] = "$key = ''"; $changes[$key] = "`$key` = ''";
} }
break; break;
} }
@ -696,9 +696,9 @@ function getFormChanges( $values, $newValues, $types=false, $columns=false ) {
{ {
if ( !isset($values[$key]) || ($values[$key] != $value) ) { if ( !isset($values[$key]) || ($values[$key] != $value) ) {
if ( ! isset($value) || $value == '' ) { if ( ! isset($value) || $value == '' ) {
$changes[$key] = "$key = NULL"; $changes[$key] = "`$key` = NULL";
} else { } else {
$changes[$key] = $key . ' = '.dbEscape(trim($value)); $changes[$key] = "`$key` = ".dbEscape(trim($value));
} }
} }
break; break;

View File

@ -82,9 +82,11 @@ echo output_link_if_exists( array(
'/js/dateTimePicker/jquery-ui-timepicker-addon.css', '/js/dateTimePicker/jquery-ui-timepicker-addon.css',
'/js/jquery-ui-structure.css', '/js/jquery-ui-structure.css',
'/css/'.$css.'/jquery-ui-theme.css', '/css/'.$css.'/jquery-ui-theme.css',
'/js/chosen/chosen.min.css',
) )
); );
?>
<link rel="stylesheet" href="skins/classic/js/chosen/chosen.min.css" type="text/css"/>
<?php
if ($basename == 'watch') { if ($basename == 'watch') {
echo output_link_if_exists( array( echo output_link_if_exists( array(
'/css/base/views/control.css', '/css/base/views/control.css',

View File

@ -24,7 +24,7 @@ foreach ( $servers as $S ) {
$ServersById[$S->Id()] = $S; $ServersById[$S->Id()] = $S;
} }
session_start(); session_start();
foreach ( array('ServerId','StorageId','Status','MonitorId') as $var ) { foreach ( array('Group', 'ServerId','StorageId','Status','MonitorId') as $var ) {
if ( isset( $_REQUEST[$var] ) ) { if ( isset( $_REQUEST[$var] ) ) {
if ( $_REQUEST[$var] != '' ) { if ( $_REQUEST[$var] != '' ) {
$_SESSION[$var] = $_REQUEST[$var]; $_SESSION[$var] = $_REQUEST[$var];
@ -49,7 +49,8 @@ foreach ( $storage_areas as $S ) {
<span id="groupControl"><label><?php echo translate('Group') ?>:</label> <span id="groupControl"><label><?php echo translate('Group') ?>:</label>
<?php <?php
# This will end up with the group_id of the deepest selection # This will end up with the group_id of the deepest selection
$group_id = Group::get_group_dropdowns(); $group_id = isset($_SESSION['Group']) ? $_SESSION['Group'] : null;
echo Group::get_group_dropdown();
$groupSql = Group::get_group_sql( $group_id ); $groupSql = Group::get_group_sql( $group_id );
?> ?>
</span> </span>

View File

@ -92,7 +92,8 @@ if ( $newGroup->Id() )
$sql = 'SELECT Id,Name from Groups'.(count($kids)?' WHERE Id NOT IN ('.implode(',',array_map(function(){return '?';}, $kids )).')' : '').' ORDER BY Name'; $sql = 'SELECT Id,Name from Groups'.(count($kids)?' WHERE Id NOT IN ('.implode(',',array_map(function(){return '?';}, $kids )).')' : '').' ORDER BY Name';
$options = array(''=>'None'); $options = array(''=>'None');
foreach ( dbFetchAll( $sql, null, $kids ) as $option ) { foreach ( dbFetchAll( $sql, null, $kids ) as $option ) {
$options[$option['Id']] = $option['Name'];
$options[$option['Id']] = str_repeat('&nbsp;&nbsp;', $Groups[$option['Id']]->depth() ) . $option['Name'];
} }
echo htmlSelect( 'newGroup[ParentId]', $options, $newGroup->ParentId(), array('onchange'=>'configureButtons(this);' )); echo htmlSelect( 'newGroup[ParentId]', $options, $newGroup->ParentId(), array('onchange'=>'configureButtons(this);' ));
?> ?>

View File

@ -64,8 +64,7 @@ function group_line( $Group ) {
global $children; global $children;
global $max_depth; global $max_depth;
$html = '<tr>'; $html = '<tr>';
for ( $i = 1; $i<$Group->depth(); $i+=1 ) $html .= str_repeat( '<td class="colName">&nbsp;</td>', $Group->depth() );
$html .= '<td class="colName">&nbsp;</td>';
$html .= '<td class="colName" colspan="'.($max_depth-($Group->depth()-1)).'">'; $html .= '<td class="colName" colspan="'.($max_depth-($Group->depth()-1)).'">';
if ( canEdit('Groups') ) { if ( canEdit('Groups') ) {
$html .= '<a href="#" onclick="editGroup('.$Group->Id().');">'. validHtmlStr($Group->Id() . ' ' . $Group->Name()).'</a>'; $html .= '<a href="#" onclick="editGroup('.$Group->Id().');">'. validHtmlStr($Group->Id() . ' ' . $Group->Name()).'</a>';

View File

@ -526,7 +526,7 @@ function clicknav(minSecs,maxSecs,live) {// we use the current time if we can
if ( monitorZoomScale[monitorPtr[i]] < 0.99 || monitorZoomScale[monitorPtr[i]] > 1.01 ) // allow for some up/down changes and just treat as 1 of almost 1 if ( monitorZoomScale[monitorPtr[i]] < 0.99 || monitorZoomScale[monitorPtr[i]] > 1.01 ) // allow for some up/down changes and just treat as 1 of almost 1
zoomStr += "&z" + monitorPtr[i].toString() + "=" + monitorZoomScale[monitorPtr[i]].toFixed(2); zoomStr += "&z" + monitorPtr[i].toString() + "=" + monitorZoomScale[monitorPtr[i]].toFixed(2);
var uri = "?view=" + currentView + '&fit='+(fitMode==1?'1':'0') + groupStr + minStr + maxStr + currentStr + intervalStr + liveStr + zoomStr + "&scale=" + $j("#scaleslider")[0].value + "&speed=" + speeds[$j("#speedslider")[0].value]; var uri = "?view=" + currentView + '&fit='+(fitMode==1?'1':'0') + minStr + maxStr + currentStr + intervalStr + liveStr + zoomStr + "&scale=" + $j("#scaleslider")[0].value + "&speed=" + speeds[$j("#speedslider")[0].value];
window.location = uri; window.location = uri;
} // end function clicknav } // end function clicknav
@ -745,7 +745,7 @@ function changeDateTime(e) {
if ( monitorZoomScale[monitorPtr[i]] < 0.99 || monitorZoomScale[monitorPtr[i]] > 1.01 ) // allow for some up/down changes and just treat as 1 of almost 1 if ( monitorZoomScale[monitorPtr[i]] < 0.99 || monitorZoomScale[monitorPtr[i]] > 1.01 ) // allow for some up/down changes and just treat as 1 of almost 1
zoomStr += "&z" + monitorPtr[i].toString() + "=" + monitorZoomScale[monitorPtr[i]].toFixed(2); zoomStr += "&z" + monitorPtr[i].toString() + "=" + monitorZoomScale[monitorPtr[i]].toFixed(2);
var uri = "?view=" + currentView + fitStr + groupStr + minStr + maxStr + liveStr + zoomStr + "&scale=" + $j("#scaleslider")[0].value + "&speed=" + speeds[$j("#speedslider")[0].value]; var uri = "?view=" + currentView + fitStr + minStr + maxStr + liveStr + zoomStr + "&scale=" + $j("#scaleslider")[0].value + "&speed=" + speeds[$j("#speedslider")[0].value];
window.location = uri; window.location = uri;
} }

View File

@ -27,7 +27,6 @@ var eStorageId = [];
var eStartSecs = []; var eStartSecs = [];
var eEndSecs = []; var eEndSecs = [];
var eventFrames = []; // this is going to presume all frames equal durationlength var eventFrames = []; // this is going to presume all frames equal durationlength
var groupStr=<?php echo $group_id ? "'&group=$group_id'" : '""'; ?>;
<?php <?php