Bug 380 - Added control preset labels

git-svn-id: http://svn.zoneminder.com/svn/zm/trunk@2037 e3e1d417-86f3-4887-817a-d78f3d33393f
This commit is contained in:
stan 2006-11-07 12:05:19 +00:00
parent cd709e4f2c
commit f6e871932f
7 changed files with 96 additions and 13 deletions

View File

@ -17,6 +17,16 @@ update Filters set Background = 1 where (AutoArchive = 1 or AutoVideo = 1 or Aut
--
alter table Monitors add column DefaultView enum ('Events','Control') not null default 'Events' after ReturnDelay;
--
-- Create new preset labels table
--
CREATE TABLE `ControlPresets` (
`MonitorId` int(10) unsigned NOT NULL default '0',
`Preset` int(10) unsigned NOT NULL default '0',
`Label` varchar(64) NOT NULL default '',
PRIMARY KEY (`MonitorId`,`Preset`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
--
-- These are optional, but we might as well do it now
--

View File

@ -239,7 +239,7 @@ if ( !empty($action) )
{
if ( $action == "control" )
{
$result = mysql_query( "select * from Monitors as M inner join Controls as C on (M.ControlId = C.Id ) where M.Id = '$mid'" );
$result = mysql_query( "select C.*,M.* from Monitors as M inner join Controls as C on (M.ControlId = C.Id ) where M.Id = '$mid'" );
if ( !$result )
die( mysql_error() );
$monitor = mysql_fetch_assoc( $result );
@ -911,6 +911,26 @@ if ( !empty($action) )
}
elseif ( $control == "preset_set" )
{
if ( canEdit( 'Control' ) )
{
$sql = "select * from ControlPresets where MonitorId = '".$monitor['Id']."' and Preset = '".$preset."'";
$result = mysql_query( $sql );
if ( !$result )
die( mysql_error() );
$row = mysql_fetch_assoc( $result );
mysql_free_result( $result );
if ( $new_label != $row['Label'] )
{
if ( $new_label )
$sql = "replace into ControlPresets ( MonitorId, Preset, Label ) values ( '".$monitor['Id']."', '".$preset."', '".addslashes($new_label)."' )";
else
$sql = "delete from ControlPresets where MonitorId = '".$monitor['Id']."' and Preset = '".$preset."'";
$result = mysql_query( $sql );
if ( !$result )
die( mysql_error() );
$refresh_parent = true;
}
}
$ctrl_command .= " --preset ".$preset;
$view = 'none';
}

View File

@ -428,11 +428,22 @@ function controlPreset( command )
<tr>
<td align="center">
<?php
$sql = "select * from ControlPresets where MonitorId = '".$monitor['Id']."'";
$result = mysql_query( $sql );
if ( !$result )
die( mysql_error() );
$labels = array();
while( $row = mysql_fetch_assoc( $result ) )
{
$labels[$row['Preset']] = $row['Label'];
}
mysql_free_result( $result );
$preset_break = (int)(($monitor['NumPresets']+1)/((int)(($monitor['NumPresets']-1)/MAX_PRESETS)+1));
for ( $i = 1; $i <= $monitor['NumPresets']; $i++ )
{
?>
<input type="button" class="numbutton" value="<?= $i ?>" onClick="controlPreset( '<?= $cmds['PresetGoto'] ?><?=$i?>' );"><?php (($i%$preset_break)==0)?"<br>":"&nbsp;&nbsp;" ?>
<input type="button" class="numbutton" title="<?= $labels[$i]?$labels[$i]:"" ?>" value="<?= $i ?>" onClick="controlPreset( '<?= $cmds['PresetGoto'] ?><?=$i?>' );"><?php (($i%$preset_break)==0)?"<br>":"&nbsp;&nbsp;" ?>
<?php
if ( $i && (($i%$preset_break) == 0) )
{

View File

@ -132,7 +132,7 @@ $jws = array(
'montage' => array( 'w'=>10, 'h'=>20 ),
'optionhelp' => array( 'w'=>320, 'h'=>284 ),
'options' => array( 'w'=>780, 'h'=>540 ),
'preset' => array( 'w'=>240, 'h'=>90 ),
'preset' => array( 'w'=>400, 'h'=>90 ),
'restarting' => array( 'w'=>250, 'h'=>150 ),
'settings' => array( 'w'=>200, 'h'=>225 ),
'state' => array( 'w'=>300, 'h'=>120 ),

View File

@ -134,7 +134,6 @@ foreach ( $tabs as $name=>$value )
<td class="nontab">&nbsp;</td>
</tr>
</table>
<table border="0" cellspacing="0" cellpadding="2" width="100%">
<form name="control_form" method="post" action="<?= $PHP_SELF ?>" onsubmit="return validateForm( document.control_form )">
<input type="hidden" name="view" value="<?= $view ?>">
<input type="hidden" name="tab" value="<?= $tab ?>">
@ -288,6 +287,7 @@ if ( $tab != 'presets' )
<?php
}
?>
<table border="0" cellspacing="0" cellpadding="2" width="100%">
<tr>
<td align="left" class="smallhead" width="50%"><?= $zmSlangParameter ?></td><td align="left" class="smallhead" width="50%"><?= $zmSlangValue ?></td>
</tr>
@ -459,7 +459,7 @@ switch ( $tab )
<tr>
<td colspan="2" align="right"><input type="submit" value="<?= $zmSlangSave ?>" class="form"<?php if ( !canEdit( 'Control' ) ) { ?> disabled<?php } ?>>&nbsp;&nbsp;<input type="button" value="<?= $zmSlangCancel ?>" class="form" onClick="closeWindow()"></td>
</tr>
</form>
</table>
</form>
</body>
</html>

View File

@ -24,16 +24,31 @@ if ( !canEdit( 'Monitors' ) )
return;
}
$result = mysql_query( "select * from Monitors as M inner join Controls as C on (M.ControlId = C.Id ) where M.Id = '$mid'" );
$result = mysql_query( "select C.*,M.* from Monitors as M inner join Controls as C on (M.ControlId = C.Id ) where M.Id = '$mid'" );
if ( !$result )
die( mysql_error() );
$monitor = mysql_fetch_assoc( $result );
mysql_free_result( $result );
$sql = "select * from ControlPresets where MonitorId = '".$monitor['Id']."'";
$result = mysql_query( $sql );
if ( !$result )
die( mysql_error() );
$labels = array();
while( $row = mysql_fetch_assoc( $result ) )
{
$labels[$row['Preset']] = $row['Label'];
}
mysql_free_result( $result );
$presets = array();
for ( $i = 1; $i <= $monitor['NumPresets']; $i++ )
{
$presets[$i] = "Preset $i";
$presets[$i] = "$zmSlangPreset $i";
if ( $labels[$i] )
{
$presets[$i] .= " (".htmlentities(addslashes($labels[$i])).")";
}
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
@ -51,6 +66,27 @@ opener.location.reload(true);
}
?>
window.focus();
var labels = new Array();
<?php
foreach ( $labels as $index=>$label )
{
?>
labels[<?= $index ?>] = "<?= htmlentities(addslashes($label)) ?>";
<?php
}
?>
function updateLabel( form )
{
var preset_index = form.preset.options[form.preset.selectedIndex].value;
if ( labels[preset_index] )
{
form.new_label.value = labels[preset_index];
}
else
{
form.new_label.value = "";
}
}
function refreshWindow()
{
window.location.reload(true);
@ -62,24 +98,28 @@ function closeWindow()
</script>
</head>
<body>
<table border="0" cellspacing="0" cellpadding="4" width="100%">
<tr>
<td colspan="4" align="center" class="head">ZoneMinder - <?= $zmSlangSetPreset ?></td>
</tr>
<form name="preset_form" method="post" action="<?= $PHP_SELF ?>">
<input type="hidden" name="view" value="<?= $view ?>">
<input type="hidden" name="mid" value="<?= $mid ?>">
<input type="hidden" name="action" value="control">
<input type="hidden" name="control" value="preset_set">
<table border="0" cellspacing="0" cellpadding="4" width="100%">
<tr>
<td colspan="2" align="center"><?= buildSelect( "preset", $presets ) ?></td>
<td colspan="4" align="center" class="head">ZoneMinder - <?= $zmSlangSetPreset ?></td>
</tr>
<tr>
<td align="right"><?= buildSelect( "preset", $presets, "updateLabel( this.form )" ) ?></td>
<td align="left" class="text"><?= $zmSlangNewLabel ?>&nbsp;<input type="text" name="new_label" value="<?= $new_user['MonitorIds'] ?>" size="16" class="form"></td>
</tr>
</table>
<table border="0" cellspacing="0" cellpadding="1" width="100%">
<tr>
<td align="right"><input type="submit" value="<?= $zmSlangSave ?>" class="form">&nbsp;&nbsp;<input type="button" value="<?= $zmSlangCancel ?>" class="form" onClick="closeWindow()"></td>
</tr>
</form>
</table>
</form>
<script type="text/javascript">
updateLabel( document.preset_form );
</script>
</body>
</html>

View File

@ -340,6 +340,7 @@ $zmSlangInclude = 'Include';
$zmSlangIn = 'In';
$zmSlangInverted = 'Inverted';
$zmSlangIris = 'Iris';
$zmSlangLabel = 'Label';
$zmSlangLanguage = 'Language';
$zmSlangLast = 'Last';
$zmSlangLimitResultsPost = 'results only;'; // This is used at the end of the phrase 'Limit to first N results only'
@ -437,6 +438,7 @@ $zmSlangNear = 'Near';
$zmSlangNetwork = 'Network';
$zmSlangNewGroup = 'New Group';
$zmSlangNew = 'New';
$zmSlangNewLabel = 'New Label';
$zmSlangNewPassword = 'New Password';
$zmSlangNewState = 'New State';
$zmSlangNewUser = 'New User';