Bug 170 - Added support for ordering of monitors
git-svn-id: http://svn.zoneminder.com/svn/zm/trunk@1518 e3e1d417-86f3-4887-817a-d78f3d33393f
This commit is contained in:
parent
6d1ab95f17
commit
8a66238a2b
|
@ -1,10 +1,11 @@
|
|||
--
|
||||
-- This updates a 1.21.2 database to 1.21.3
|
||||
--
|
||||
alter table Monitors add column WebColour varchar(32) NOT NULL default 'red';
|
||||
alter table Monitors add column WebColour varchar(32) not null default 'red';
|
||||
update Monitors set WebColour = concat( '#', hex(14*rand()),hex(15*rand()),hex(14*rand()),hex(15*rand()),hex(14*rand()),hex(15*rand()) );
|
||||
alter table Events add column Height smallint(5) unsigned NOT NULL default '0' after EndTime;
|
||||
alter table Events add column Width smallint(5) unsigned NOT NULL default '0' after EndTime;
|
||||
alter table Monitors add column Sequence smallint unsigned;
|
||||
alter table Events add column Height smallint(5) unsigned not null default '0' after EndTime;
|
||||
alter table Events add column Width smallint(5) unsigned not null default '0' after EndTime;
|
||||
--
|
||||
-- These are optional, but we might as well do it now
|
||||
--
|
||||
|
|
|
@ -428,6 +428,20 @@ if ( $version )
|
|||
my $res = $sth->execute( $monitor->{Width}, $monitor->{Height}, $monitor->{Id} ) or die( "Can't execute: ".$sth->errstr() );
|
||||
}
|
||||
$sth->finish();
|
||||
|
||||
# Add sequence numbers
|
||||
print( "Updating monitor sequences. Please wait\n" );
|
||||
my $sql = "select * from Monitors order by Id";
|
||||
my $sth = $dbh->prepare_cached( $sql ) or die( "Can't prepare '$sql': ".$dbh->errstr() );
|
||||
my $res = $sth->execute() or die( "Can't execute: ".$sth->errstr() );
|
||||
my $sequence = 1;
|
||||
while( my $monitor = $sth->fetchrow_hashref() )
|
||||
{
|
||||
my $sql = "update Monitors set Sequence = ? where MonitorId = ?";
|
||||
my $sth = $dbh->prepare_cached( $sql ) or die( "Can't prepare '$sql': ".$dbh->errstr() );
|
||||
my $res = $sth->execute( $sequence++, $monitor->{Id} ) or die( "Can't execute: ".$sth->errstr() );
|
||||
}
|
||||
$sth->finish();
|
||||
$cascade = !undef;
|
||||
}
|
||||
if ( !$cascade )
|
||||
|
|
|
@ -17,7 +17,9 @@ web_DATA = \
|
|||
arrow-ur.gif \
|
||||
arrow-l-u.gif \
|
||||
arrow-l-d.gif \
|
||||
center.gif
|
||||
center.gif \
|
||||
seq-u.gif \
|
||||
seq-d.gif
|
||||
|
||||
EXTRA_DIST = $(web_DATA)
|
||||
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 68 B |
Binary file not shown.
After Width: | Height: | Size: 68 B |
|
@ -894,6 +894,12 @@ if ( isset($action) )
|
|||
}
|
||||
elseif ( !$user['MonitorIds'] )
|
||||
{
|
||||
$sql = "select max(Sequence) as MaxSequence from Monitors";
|
||||
if ( !$result )
|
||||
die( mysql_error() );
|
||||
$row = mysql_fetch_assoc( $result );
|
||||
$changes[] = "Sequence = ".($row['MaxSequence']+1);
|
||||
|
||||
$sql = "insert into Monitors set ".implode( ", ", $changes );
|
||||
$result = mysql_query( $sql );
|
||||
if ( !$result )
|
||||
|
@ -967,8 +973,31 @@ if ( isset($action) )
|
|||
list( $brightness, $contrast, $hue, $colour ) = split( ' ', $zmu_output );
|
||||
$sql = "update Monitors set Brightness = '$brightness', Contrast = '$contrast', Hue = '$hue', Colour = '$colour' where Id = '$mid'";
|
||||
$result = mysql_query( $sql );
|
||||
if ( !$result )
|
||||
die( mysql_error() );
|
||||
if ( !$result )
|
||||
die( mysql_error() );
|
||||
}
|
||||
elseif ( $action == "sequence" && isset( $mid ) && isset($smid) )
|
||||
{
|
||||
$result = mysql_query( "select * from Monitors where Id = '$mid'" );
|
||||
if ( !$result )
|
||||
die( mysql_error() );
|
||||
$monitor = mysql_fetch_assoc( $result );
|
||||
$result = mysql_query( "select * from Monitors where Id = '$smid'" );
|
||||
if ( !$result )
|
||||
die( mysql_error() );
|
||||
$smonitor = mysql_fetch_assoc( $result );
|
||||
|
||||
$sql = "update Monitors set Sequence = '".$smonitor['Sequence']."' where Id = '".$monitor['Id']."'";
|
||||
$result = mysql_query( $sql );
|
||||
if ( !$result )
|
||||
die( mysql_error() );
|
||||
$sql = "update Monitors set Sequence = '".$monitor['Sequence']."' where Id = '".$smonitor['Id']."'";
|
||||
$result = mysql_query( $sql );
|
||||
if ( !$result )
|
||||
die( mysql_error() );
|
||||
|
||||
$refresh_parent = true;
|
||||
fixSequences();
|
||||
}
|
||||
elseif ( $action == "delete" )
|
||||
{
|
||||
|
@ -1032,6 +1061,7 @@ if ( isset($action) )
|
|||
if ( !$result )
|
||||
die( mysql_error() );
|
||||
|
||||
fixSequences();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -156,7 +156,7 @@ function loadConfig()
|
|||
// Javascript window sizes
|
||||
$jws = array(
|
||||
'bandwidth' => array( 'w'=>200, 'h'=>90 ),
|
||||
'console' => array( 'w'=>720, 'h'=>312 ),
|
||||
'console' => array( 'w'=>750, 'h'=>312 ),
|
||||
'control' => array( 'w'=>380, 'h'=>480 ),
|
||||
'controlcaps' => array( 'w'=>700, 'h'=>320 ),
|
||||
'controlcap' => array( 'w'=>360, 'h'=>440 ),
|
||||
|
|
|
@ -1046,4 +1046,24 @@ function verNum( $version )
|
|||
}
|
||||
return( $vNum );
|
||||
}
|
||||
|
||||
function fixSequences()
|
||||
{
|
||||
$sql = "select * from Monitors order by Sequence asc, Id asc";
|
||||
$result = mysql_query( $sql );
|
||||
if ( !$result )
|
||||
echo mysql_error();
|
||||
$sequence = 1;
|
||||
while ( $monitor = mysql_fetch_assoc( $result ) )
|
||||
{
|
||||
if ( $monitor['Sequence'] != $sequence )
|
||||
{
|
||||
$sql2 = "update Monitors set Sequence = '".$sequence."' where Id = '".$monitor['Id']."'";
|
||||
$result2 = mysql_query( $sql2 );
|
||||
if ( !$result2 )
|
||||
echo mysql_error();
|
||||
}
|
||||
$sequence++;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
|
@ -40,7 +40,7 @@ header("Cache-Control: post-check=0, pre-check=0", false);
|
|||
header("Pragma: no-cache"); // HTTP/1.0
|
||||
|
||||
$db_now = strftime( "%Y-%m-%d %H:%M:%S" );
|
||||
$sql = "select * from Monitors order by Id";
|
||||
$sql = "select * from Monitors order by Sequence asc";
|
||||
$result = mysql_query( $sql );
|
||||
if ( !$result )
|
||||
echo mysql_error();
|
||||
|
@ -48,6 +48,9 @@ $monitors = array();
|
|||
$max_width = 0;
|
||||
$max_height = 0;
|
||||
$cycle_count = 0;
|
||||
$min_sequence = 0;
|
||||
$max_sequence = 1;
|
||||
$seq_id_list = array();
|
||||
while( $row = mysql_fetch_assoc( $result ) )
|
||||
{
|
||||
if ( !visibleMonitor( $row['Id'] ) )
|
||||
|
@ -58,6 +61,14 @@ while( $row = mysql_fetch_assoc( $result ) )
|
|||
{
|
||||
continue;
|
||||
}
|
||||
if ( empty($min_sequence) || ($row['Sequence'] < $min_sequence) )
|
||||
{
|
||||
$min_sequence = $row['Sequence'];
|
||||
}
|
||||
if ( $row['Sequence'] > $max_sequence )
|
||||
{
|
||||
$max_sequence = $row['Sequence'];
|
||||
}
|
||||
$row['zmc'] = zmcStatus( $row );
|
||||
$row['zma'] = zmaStatus( $row );
|
||||
$sql = "select count(Id) as ZoneCount from Zones where MonitorId = '".$row['Id']."'";
|
||||
|
@ -77,6 +88,27 @@ while( $row = mysql_fetch_assoc( $result ) )
|
|||
if ( $max_height < $row['Height'] ) $max_height = $row['Height'];
|
||||
}
|
||||
$monitors[] = $row = array_merge( $row, $row2, $row3 );
|
||||
$seq_id_list[] = $row['Id'];
|
||||
}
|
||||
$last_id = 0;
|
||||
$seq_id_u_list = array();
|
||||
foreach ( $seq_id_list as $seq_id )
|
||||
{
|
||||
if ( !empty($last_id) )
|
||||
{
|
||||
$seq_id_u_list[$seq_id] = $last_id;
|
||||
}
|
||||
$last_id = $seq_id;
|
||||
}
|
||||
$last_id = 0;
|
||||
$seq_id_d_list = array();
|
||||
foreach ( array_reverse($seq_id_list) as $seq_id )
|
||||
{
|
||||
if ( !empty($last_id) )
|
||||
{
|
||||
$seq_id_d_list[$seq_id] = $last_id;
|
||||
}
|
||||
$last_id = $seq_id;
|
||||
}
|
||||
|
||||
if ( $cycle_count )
|
||||
|
@ -232,6 +264,14 @@ else
|
|||
<td align="right" class="smallhead"><?= $zmSlangMonth ?></td>
|
||||
<td align="right" class="smallhead"><?= $zmSlangArchive ?></td>
|
||||
<td align="right" class="smallhead"><?= $zmSlangZones ?></td>
|
||||
<?php
|
||||
if ( canEdit('Monitors') )
|
||||
{
|
||||
?>
|
||||
<td align="center" class="smallhead"><?= $zmSlangOrder ?></td>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
<td align="center" class="smallhead"><?= $zmSlangMark ?></td>
|
||||
</tr>
|
||||
<?php
|
||||
|
@ -304,6 +344,14 @@ foreach( $monitors as $monitor )
|
|||
<td align="right" class="text"><?= makeLink( "javascript: scrollWindow( '$PHP_SELF?view=$events_view&page=1&filter=1&trms=3&attr1=MonitorId&op1=%3d&val1=".$monitor['Id']."&cnj2=and&attr2=Archived&val2=0&cnj3=and&attr3=DateTime&op3=%3e%3d&val3=-1+month', '$events_window', ".$jws[$events_view]['w'].", ".$jws[$events_view]['h']." );", $monitor['MonthEventCount'], canView( 'Events' ) ) ?></td>
|
||||
<td align="right" class="text"><?= makeLink( "javascript: scrollWindow( '$PHP_SELF?view=$events_view&page=1&filter=1&trms=2&attr1=MonitorId&op1=%3d&val1=".$monitor['Id']."&cnj2=and&attr2=Archived&val2=1', '$events_window', ".$jws[$events_view]['w'].", ".$jws[$events_view]['h']." );", $monitor['ArchEventCount'], canView( 'Events' ) ) ?></td>
|
||||
<td align="right" class="text"><?= makeLink( "javascript: newWindow( '$PHP_SELF?view=zones&mid=".$monitor['Id']."', 'zmZones', ".($monitor['Width']+$jws['zones']['w']).", ".($monitor['Height']+$jws['zones']['h'])." );", $monitor['ZoneCount'], canView( 'Monitors' ) ) ?></td>
|
||||
<?php
|
||||
if ( canEdit('Monitors') )
|
||||
{
|
||||
?>
|
||||
<td align="right" class="text"><?= makeLink( "$PHP_SELF?view=$view&action=sequence&mid=".$monitor['Id']."&smid=".$seq_id_u_list[$monitor['Id']], '<img src="graphics/seq-u.gif" alt="" width="12" height="11" border="0">', $monitor['Sequence']>$min_sequence ) ?><?= makeLink( "$PHP_SELF?view=$view&action=sequence&mid=".$monitor['Id']."&smid=".$seq_id_d_list[$monitor['Id']], '<img src="graphics/seq-d.gif" alt="" width="12" height="11" border="0">', $monitor['Sequence']<$max_sequence ) ?></td>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
<td align="center" class="text"><input type="checkbox" name="mark_mids[]" value="<?= $monitor['Id'] ?>" onClick="configureButton( document.monitor_form, 'mark_mids' );"<?php if ( !canEdit( 'Monitors' ) || $user['MonitorIds'] ) {?> disabled<?php } ?>></td>
|
||||
</tr>
|
||||
<?php
|
||||
|
@ -323,7 +371,7 @@ foreach( $monitors as $monitor )
|
|||
<td align="right" class="text"><?= makeLink( "javascript: scrollWindow( '$PHP_SELF?view=$events_view&page=1&filter=1&trms=2&attr1=Archived&val1=0&cnj2=and&attr2=DateTime&op2=%3e%3d&val2=-1+month', '$events_window', ".$jws[$events_view]['w'].", ".$jws[$events_view]['h']." );", $month_event_count, canView( 'Events' ) ) ?></td>
|
||||
<td align="right" class="text"><?= makeLink( "javascript: scrollWindow( '$PHP_SELF?view=$events_view&page=1&filter=1&trms=1&attr1=Archived&val1=1', '$events_window', ".$jws[$events_view]['w'].", ".$jws[$events_view]['h']." );", $arch_event_count, canView( 'Events' ) ) ?></td>
|
||||
<td align="right" class="text"><?= $zone_count ?></td>
|
||||
<td align="center"><input type="submit" name="delete_btn" value="<?= $zmSlangDelete ?>" class="form" disabled></td>
|
||||
<td align="center" colspan="<?= canEdit('Monitors')?2:1 ?>"><input type="submit" name="delete_btn" value="<?= $zmSlangDelete ?>" class="form" disabled></td>
|
||||
</tr>
|
||||
</form>
|
||||
</table>
|
||||
|
|
|
@ -33,7 +33,7 @@ if ( $group )
|
|||
$row = mysql_fetch_assoc( $result );
|
||||
$group_sql = "and find_in_set( Id, '".$row['MonitorIds']."' )";
|
||||
}
|
||||
$sql = "select * from Monitors where Function != 'None' and Controllable = 1 $group_sql order by Id";
|
||||
$sql = "select * from Monitors where Function != 'None' and Controllable = 1 $group_sql order by Sequence";
|
||||
$result = mysql_query( $sql );
|
||||
if ( !$result )
|
||||
die( mysql_error() );
|
||||
|
|
|
@ -41,7 +41,7 @@ if ( $group )
|
|||
$group_sql = "and find_in_set( Id, '".$row['MonitorIds']."' )";
|
||||
}
|
||||
|
||||
$sql = "select * from Monitors where Function != 'None' $group_sql order by Id";
|
||||
$sql = "select * from Monitors where Function != 'None' $group_sql order by Sequence";
|
||||
$result = mysql_query( $sql );
|
||||
if ( !$result )
|
||||
die( mysql_error() );
|
||||
|
|
|
@ -34,7 +34,7 @@ if ( $group )
|
|||
$group_sql = "and find_in_set( Id, '".$row['MonitorIds']."' )";
|
||||
}
|
||||
|
||||
$sql = "select * from Monitors where Function != 'None' $group_sql order by Id";
|
||||
$sql = "select * from Monitors where Function != 'None' $group_sql order by Sequence";
|
||||
$result = mysql_query( $sql );
|
||||
if ( !$result )
|
||||
die( mysql_error() );
|
||||
|
|
|
@ -49,7 +49,7 @@ elseif ( ZM_OPT_CONTROL )
|
|||
$row = mysql_fetch_assoc( $result );
|
||||
$group_sql = "and find_in_set( Id, '".$row['MonitorIds']."' )";
|
||||
}
|
||||
$sql = "select * from Monitors where Function != 'None' and Controllable = 1 $group_sql order by Id";
|
||||
$sql = "select * from Monitors where Function != 'None' and Controllable = 1 $group_sql order by Sequence";
|
||||
$result = mysql_query( $sql );
|
||||
if ( !$result )
|
||||
die( mysql_error() );
|
||||
|
|
|
@ -94,7 +94,7 @@ $chart = array(
|
|||
);
|
||||
|
||||
$monitors = array();
|
||||
$monitors_sql = "select * from Monitors order by Id asc";
|
||||
$monitors_sql = "select * from Monitors order by Sequence asc";
|
||||
if ( !($result = mysql_query( $monitors_sql )) )
|
||||
die( mysql_error() );
|
||||
srand( 97981 );
|
||||
|
|
|
@ -413,6 +413,7 @@ $zmSlangOptionRestartWarning = 'These changes may not come into effect fully\nwh
|
|||
$zmSlangOptions = 'Options';
|
||||
$zmSlangOrEnterNewName = 'or enter new name';
|
||||
$zmSlangOrientation = 'Orientation';
|
||||
$zmSlangOrder = 'Order';
|
||||
$zmSlangOut = 'Out';
|
||||
$zmSlangOverwriteExisting = 'Overwrite Existing';
|
||||
$zmSlangPaged = 'Paged';
|
||||
|
|
|
@ -24,7 +24,7 @@ if ( !$result )
|
|||
echo mysql_error();
|
||||
$group = mysql_fetch_assoc( $result );
|
||||
|
||||
$result = mysql_query( "select * from Monitors where Function != 'None' order by Id" );
|
||||
$result = mysql_query( "select * from Monitors where Function != 'None' order by Sequence" );
|
||||
$monitors = array();
|
||||
$max_width = 0;
|
||||
$max_height = 0;
|
||||
|
|
|
@ -62,7 +62,7 @@ $fps_string = sprintf( "%.2f", $fps );
|
|||
$new_alarm = ( $status > STATE_PREALARM && $last_status <= STATE_PREALARM );
|
||||
$old_alarm = ( $status <= STATE_PREALARM && $last_status > STATE_PREALARM );
|
||||
|
||||
$result = mysql_query( "select * from Monitors where Function != 'None' order by Id" );
|
||||
$result = mysql_query( "select * from Monitors where Function != 'None' order by Sequence" );
|
||||
$monitors = array();
|
||||
$mon_idx = 0;
|
||||
$max_width = 0;
|
||||
|
|
Loading…
Reference in New Issue