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',
|
'ChooseLogFormat' => 'Choose a log format',
|
||||||
'ChooseLogSelection' => 'Choose a log selection',
|
'ChooseLogSelection' => 'Choose a log selection',
|
||||||
'ChoosePreset' => 'Choose Preset',
|
'ChoosePreset' => 'Choose Preset',
|
||||||
|
'CloneMonitor' => 'Clone Monitor',
|
||||||
'Close' => 'Close',
|
'Close' => 'Close',
|
||||||
'Colour' => 'Colour',
|
'Colour' => 'Colour',
|
||||||
'Command' => 'Command',
|
'Command' => 'Command',
|
||||||
|
|
|
@ -182,6 +182,7 @@ $seqDownFile = getSkinFile( 'graphics/seq-d.gif' );
|
||||||
|
|
||||||
$versionClass = (ZM_DYN_DB_VERSION&&(ZM_DYN_DB_VERSION!=ZM_VERSION))?'errorText':'';
|
$versionClass = (ZM_DYN_DB_VERSION&&(ZM_DYN_DB_VERSION!=ZM_VERSION))?'errorText':'';
|
||||||
|
|
||||||
|
|
||||||
xhtmlHeaders( __FILE__, translate('Console') );
|
xhtmlHeaders( __FILE__, translate('Console') );
|
||||||
?>
|
?>
|
||||||
<body>
|
<body>
|
||||||
|
@ -270,7 +271,8 @@ if ( canEdit('Monitors') )
|
||||||
<tr>
|
<tr>
|
||||||
<td class="colLeftButtons" colspan="<?php echo count($servers) ? 4 : 3 ?>">
|
<td class="colLeftButtons" colspan="<?php echo count($servers) ? 4 : 3 ?>">
|
||||||
<input type="button" value="<?php echo translate('Refresh') ?>" onclick="location.reload(true);"/>
|
<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' ) ) ?>
|
<?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>
|
</td>
|
||||||
<?php
|
<?php
|
||||||
|
|
|
@ -1,3 +1,6 @@
|
||||||
|
var jsTranslatedAddText;
|
||||||
|
var jsTranslatedCloneText;
|
||||||
|
|
||||||
function setButtonStates( element )
|
function setButtonStates( element )
|
||||||
{
|
{
|
||||||
var form = element.form;
|
var form = element.form;
|
||||||
|
@ -15,9 +18,36 @@ function setButtonStates( element )
|
||||||
}
|
}
|
||||||
$(element).getParent( 'tr' ).toggleClass( 'highlight' );
|
$(element).getParent( 'tr' ).toggleClass( 'highlight' );
|
||||||
form.editBtn.disabled = (checked!=1);
|
form.editBtn.disabled = (checked!=1);
|
||||||
|
form.addBtn.value = (checked==1) ? jsTranslatedCloneText:jsTranslatedAddText;
|
||||||
|
|
||||||
form.deleteBtn.disabled = (checked==0);
|
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 )
|
function editMonitor( element )
|
||||||
{
|
{
|
||||||
var form = element.form;
|
var form = element.form;
|
||||||
|
@ -55,6 +85,8 @@ function reloadWindow()
|
||||||
|
|
||||||
function initPage()
|
function initPage()
|
||||||
{
|
{
|
||||||
|
jsTranslatedAddText = translatedAddText;
|
||||||
|
jsTranslatedCloneText = translatedCloneText;
|
||||||
reloadWindow.periodical( consoleRefreshTimeout );
|
reloadWindow.periodical( consoleRefreshTimeout );
|
||||||
if ( showVersionPopup )
|
if ( showVersionPopup )
|
||||||
createPopup( '?view=version', 'zmVersion', 'version' );
|
createPopup( '?view=version', 'zmVersion', 'version' );
|
||||||
|
|
|
@ -26,7 +26,7 @@ elseif ( ZM_DYN_SHOW_DONATE_REMINDER )
|
||||||
?>
|
?>
|
||||||
var showVersionPopup = <?php echo isset($showVersionPopup )?'true':'false' ?>;
|
var showVersionPopup = <?php echo isset($showVersionPopup )?'true':'false' ?>;
|
||||||
var showDonatePopup = <?php echo isset($showDonatePopup )?'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 {
|
} else {
|
||||||
|
|
||||||
$nextId = getTableAutoInc( 'Monitors' );
|
$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(
|
$monitor = array(
|
||||||
'Id' => 0,
|
'Id' => 0,
|
||||||
'Name' => translate('Monitor').'-'.$nextId,
|
'Name' => "willbereplaced",
|
||||||
'Function' => "Monitor",
|
'Function' => "Monitor",
|
||||||
'Enabled' => true,
|
'Enabled' => true,
|
||||||
'LinkedMonitors' => "",
|
'LinkedMonitors' => "",
|
||||||
|
@ -125,14 +148,7 @@ if ( ! empty($_REQUEST['mid']) ) {
|
||||||
'ServerId' => $Server['Id'],
|
'ServerId' => $Server['Id'],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
return ($monitor);
|
||||||
if ( ZM_OPT_X10 && empty($x10Monitor) )
|
|
||||||
{
|
|
||||||
$x10Monitor = array(
|
|
||||||
'Activation' => '',
|
|
||||||
'AlarmInput' => '',
|
|
||||||
'AlarmOutput' => '',
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function fourcc( $a, $b, $c, $d )
|
function fourcc( $a, $b, $c, $d )
|
||||||
|
@ -450,6 +466,21 @@ xhtmlHeaders(__FILE__, translate('Monitor')." - ".validHtmlStr($monitor['Name'])
|
||||||
if ( canEdit( 'Monitors' ) )
|
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">
|
<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>
|
<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
|
<?php
|
||||||
|
@ -956,6 +987,7 @@ switch ( $tab )
|
||||||
<div id="contentButtons">
|
<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()"/>
|
<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>
|
</div>
|
||||||
|
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in New Issue