Merge pull request #1418 from pliablepixels/1417-clone-monitor
Clone feature added
This commit is contained in:
commit
81757a0465
|
@ -230,6 +230,7 @@ $SLANG = array(
|
|||
'ChooseLogFormat' => 'Choose a log format',
|
||||
'ChooseLogSelection' => 'Choose a log selection',
|
||||
'ChoosePreset' => 'Choose Preset',
|
||||
'CloneMonitor' => 'Clone Monitor',
|
||||
'Close' => 'Close',
|
||||
'Colour' => 'Colour',
|
||||
'Command' => 'Command',
|
||||
|
|
|
@ -182,6 +182,7 @@ $seqDownFile = getSkinFile( 'graphics/seq-d.gif' );
|
|||
|
||||
$versionClass = (ZM_DYN_DB_VERSION&&(ZM_DYN_DB_VERSION!=ZM_VERSION))?'errorText':'';
|
||||
|
||||
|
||||
xhtmlHeaders( __FILE__, translate('Console') );
|
||||
?>
|
||||
<body>
|
||||
|
@ -270,7 +271,8 @@ if ( canEdit('Monitors') )
|
|||
<tr>
|
||||
<td class="colLeftButtons" colspan="<?php echo count($servers) ? 4 : 3 ?>">
|
||||
<input type="button" value="<?php echo translate('Refresh') ?>" onclick="location.reload(true);"/>
|
||||
<?php echo makePopupButton( '?view=monitor', 'zmMonitor0', 'monitor', translate('AddNewMonitor'), (canEdit( 'Monitors' ) && !$user['MonitorIds']) ) ?>
|
||||
<input type="button" name="addBtn" value="<?php echo translate('AddNewMonitor') ?>" onclick="addMonitor( this )"/>
|
||||
<!-- <?php echo makePopupButton( '?view=monitor', 'zmMonitor0', 'monitor', translate('AddNewMonitor'), (canEdit( 'Monitors' ) && !$user['MonitorIds']) ) ?> -->
|
||||
<?php echo makePopupButton( '?view=filter&filter[terms][0][attr]=DateTime&filter[terms][0][op]=%3c&filter[terms][0][val]=now', 'zmFilter', 'filter', translate('Filters'), canView( 'Events' ) ) ?>
|
||||
</td>
|
||||
<?php
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
var jsTranslatedAddText;
|
||||
var jsTranslatedCloneText;
|
||||
|
||||
function setButtonStates( element )
|
||||
{
|
||||
var form = element.form;
|
||||
|
@ -15,9 +18,36 @@ function setButtonStates( element )
|
|||
}
|
||||
$(element).getParent( 'tr' ).toggleClass( 'highlight' );
|
||||
form.editBtn.disabled = (checked!=1);
|
||||
form.addBtn.value = (checked==1) ? jsTranslatedCloneText:jsTranslatedAddText;
|
||||
|
||||
form.deleteBtn.disabled = (checked==0);
|
||||
}
|
||||
|
||||
function addMonitor( element)
|
||||
{
|
||||
|
||||
var form = element.form;
|
||||
var dupParam;
|
||||
var monitorId=-1;
|
||||
if (form.addBtn.value == jsTranslatedCloneText)
|
||||
{
|
||||
// get the value of the first checkbox
|
||||
for ( var i = 0; i < form.elements.length; i++ )
|
||||
{
|
||||
if ( form.elements[i].type == "checkbox" )
|
||||
{
|
||||
if ( form.elements[i].checked )
|
||||
{
|
||||
monitorId = form.elements[i].value;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
dupParam = (monitorId == -1 ) ? '': '&dupId='+monitorId;
|
||||
createPopup( '?view=monitor'+dupParam, 'zmMonitor0','monitor' );
|
||||
}
|
||||
|
||||
function editMonitor( element )
|
||||
{
|
||||
var form = element.form;
|
||||
|
@ -55,6 +85,8 @@ function reloadWindow()
|
|||
|
||||
function initPage()
|
||||
{
|
||||
jsTranslatedAddText = translatedAddText;
|
||||
jsTranslatedCloneText = translatedCloneText;
|
||||
reloadWindow.periodical( consoleRefreshTimeout );
|
||||
if ( showVersionPopup )
|
||||
createPopup( '?view=version', 'zmVersion', 'version' );
|
||||
|
|
|
@ -26,7 +26,7 @@ elseif ( ZM_DYN_SHOW_DONATE_REMINDER )
|
|||
?>
|
||||
var showVersionPopup = <?php echo isset($showVersionPopup )?'true':'false' ?>;
|
||||
var showDonatePopup = <?php echo isset($showDonatePopup )?'true':'false' ?>;
|
||||
|
||||
|
||||
var translatedAddText = "<?php echo translate('AddNewMonitor') ?>";
|
||||
var translatedCloneText = "<?php echo translate('CloneMonitor') ?>";
|
||||
|
||||
|
||||
|
|
|
@ -57,9 +57,32 @@ if ( ! empty($_REQUEST['mid']) ) {
|
|||
} else {
|
||||
|
||||
$nextId = getTableAutoInc( 'Monitors' );
|
||||
$monitor = getMonitorObject($_REQUEST['dupId']);
|
||||
$clonedName = $monitor['Name'];
|
||||
$monitor['Name'] = translate('Monitor').'-'.$nextId;
|
||||
$monitor['Id']='0';
|
||||
}
|
||||
|
||||
if ( ZM_OPT_X10 && empty($x10Monitor) )
|
||||
{
|
||||
$x10Monitor = array(
|
||||
'Activation' => '',
|
||||
'AlarmInput' => '',
|
||||
'AlarmOutput' => '',
|
||||
);
|
||||
}
|
||||
|
||||
function getMonitorObject( $mid = null)
|
||||
{
|
||||
if ($mid !== null)
|
||||
{
|
||||
$monitor = dbFetchMonitor($mid);
|
||||
}
|
||||
else
|
||||
{
|
||||
$monitor = array(
|
||||
'Id' => 0,
|
||||
'Name' => translate('Monitor').'-'.$nextId,
|
||||
'Name' => "willbereplaced",
|
||||
'Function' => "Monitor",
|
||||
'Enabled' => true,
|
||||
'LinkedMonitors' => "",
|
||||
|
@ -124,15 +147,8 @@ if ( ! empty($_REQUEST['mid']) ) {
|
|||
'V4LCapturesPerFrame' => 1,
|
||||
'ServerId' => $Server['Id'],
|
||||
);
|
||||
}
|
||||
|
||||
if ( ZM_OPT_X10 && empty($x10Monitor) )
|
||||
{
|
||||
$x10Monitor = array(
|
||||
'Activation' => '',
|
||||
'AlarmInput' => '',
|
||||
'AlarmOutput' => '',
|
||||
);
|
||||
}
|
||||
return ($monitor);
|
||||
}
|
||||
|
||||
function fourcc( $a, $b, $c, $d )
|
||||
|
@ -450,6 +466,21 @@ xhtmlHeaders(__FILE__, translate('Monitor')." - ".validHtmlStr($monitor['Name'])
|
|||
if ( canEdit( 'Monitors' ) )
|
||||
{
|
||||
?>
|
||||
|
||||
<?php
|
||||
if ( isset ($_REQUEST['dupId']))
|
||||
{
|
||||
$dupId = $_REQUEST['dupId'];
|
||||
?>
|
||||
|
||||
<div class="alert alert-info">
|
||||
Configuration cloned from Monitor: <?php echo $clonedName ?>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
|
||||
<div id="headerButtons">
|
||||
<a href="#" onclick="createPopup( '?view=monitorprobe&mid=<?php echo $monitor['Id'] ?>', 'zmMonitorProbe<?php echo $monitor['Id'] ?>', 'monitorprobe' ); return( false );"><?php echo translate('Probe') ?></a>
|
||||
<?php
|
||||
|
@ -956,6 +987,7 @@ switch ( $tab )
|
|||
<div id="contentButtons">
|
||||
<input type="submit" value="<?php echo translate('Save') ?>"<?php if ( !canEdit( 'Monitors' ) ) { ?> disabled="disabled"<?php } ?>/><input type="button" value="<?php echo translate('Cancel') ?>" onclick="closeWindow()"/>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
|
Loading…
Reference in New Issue