mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
port ignore patch, from paul gear
git-svn-id: http://www.observium.org/svn/observer/trunk@2006 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
@ -67,6 +67,8 @@ if ($config['page_refresh']) { echo("<meta http-equiv='refresh' content='".$conf
|
||||
<body>
|
||||
<script type="text/javascript" src="js/mktree.js"></script>
|
||||
<script type="text/javascript" src="js/sorttable.js"></script>
|
||||
<script type="text/javascript" src="js/jquery.js"></script>
|
||||
<script type="text/javascript" src="js/jquery-checkbox.js"></script>
|
||||
<script type="text/javascript">
|
||||
<!-- Begin
|
||||
function popUp(URL)
|
||||
|
20
html/js/jquery-checkbox.js
vendored
Normal file
20
html/js/jquery-checkbox.js
vendored
Normal file
@ -0,0 +1,20 @@
|
||||
// Checkbox manipulation function from http://docs.jquery.com/Tutorials:Getting_Started_with_jQuery
|
||||
// assumed to be under the same license as jQuery itself: MIT or GPLv2
|
||||
jQuery.fn.check = function(mode) {
|
||||
// if mode is undefined, use 'on' as default
|
||||
var mode = mode || 'on';
|
||||
return this.each(function() {
|
||||
switch(mode) {
|
||||
case 'on':
|
||||
this.checked = true;
|
||||
break;
|
||||
case 'off':
|
||||
this.checked = false;
|
||||
break;
|
||||
case 'toggle':
|
||||
this.checked = !this.checked;
|
||||
break;
|
||||
}
|
||||
});
|
||||
};
|
||||
|
@ -24,16 +24,84 @@ echo("<div style='float: left; width: 100%'>
|
||||
|
||||
echo("<table cellpadding=3 cellspacing=0 width=100%>
|
||||
<tr align=center>
|
||||
<th width=75>Index</th>
|
||||
<th width=150>Name</th>
|
||||
<th width=100>Index</th>
|
||||
<th width=100>Name</th>
|
||||
<th width=50>Admin</th>
|
||||
<th width=50>Oper</th>
|
||||
<th width=50>Disable</th>
|
||||
<th width=50>Ignore</th>
|
||||
<th width=100>Oper</th>
|
||||
<th width=100>Disable</th>
|
||||
<th width=100>Ignore</th>
|
||||
<th>Description</th>
|
||||
|
||||
</tr>
|
||||
<tr align=center>
|
||||
<td><input type='submit' value='Save' title='Save current port disable/ignore settings'/><input type='submit' value='Reset' id='form-reset' title='Reset form to previously-saved settings'/></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td><input type='submit' value='Alerted' id='alerted-toggle' title='Toggle alerting on all currently-alerted ports'/><input type='submit' value='Down' id='down-select' title='Disable alerting on all currently-down ports'/></td>
|
||||
<td><input type='submit' value='Toggle' id='disable-toggle' title='Toggle polling for all ports'/><input type='submit' value='Select' id='disable-select' title='Disable polling on all ports'/></td>
|
||||
<td><input type='submit' value='Toggle' id='ignore-toggle' title='Toggle alerting for all ports'/><input type='submit' value='Select' id='ignore-select' title='Disable alerting on all ports'/></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
");
|
||||
?>
|
||||
|
||||
<script>
|
||||
$(document).ready(function(){
|
||||
$('#disable-toggle').click(function(event){
|
||||
// invert selection on all disable buttons
|
||||
event.preventDefault();
|
||||
$('[name^="disabled_"]').check('toggle');
|
||||
});
|
||||
$('#ignore-toggle').click(function(event){
|
||||
// invert selection on all ignore buttons
|
||||
event.preventDefault();
|
||||
$('[name^="ignore_"]').check('toggle');
|
||||
});
|
||||
$('#disable-select').click(function(event){
|
||||
// select all disable buttons
|
||||
event.preventDefault();
|
||||
$('[name^="disabled_"]').check();
|
||||
});
|
||||
$('#ignore-select').click(function(event){
|
||||
// select all ignore buttons
|
||||
event.preventDefault();
|
||||
$('[name^="ignore_"]').check();
|
||||
});
|
||||
$('#down-select').click(function(event){
|
||||
// select ignore buttons for all ports which are down
|
||||
event.preventDefault();
|
||||
$('[name^="operstatus_"]').each(function(){
|
||||
var name = $(this).attr('name');
|
||||
var text = $(this).text();
|
||||
if (name && text == 'down') {
|
||||
// get the interface number from the object name
|
||||
var interface_id = name.split('_')[1];
|
||||
// find its corresponding checkbox and toggle it
|
||||
$('[name="ignore_' + interface_id + '"]').check();
|
||||
}
|
||||
});
|
||||
});
|
||||
$('#alerted-toggle').click(function(event){
|
||||
// toggle ignore buttons for all ports which are in class red
|
||||
event.preventDefault();
|
||||
$('.red').each(function(){
|
||||
var name = $(this).attr('name');
|
||||
if (name) {
|
||||
// get the interface number from the object name
|
||||
var interface_id = name.split('_')[1];
|
||||
// find its corresponding checkbox and toggle it
|
||||
$('[name="ignore_' + interface_id + '"]').check('toggle');
|
||||
}
|
||||
});
|
||||
});
|
||||
$('#form-reset').click(function(event){
|
||||
// reset objects in the form to their previous values
|
||||
event.preventDefault();
|
||||
$('#ignoreport')[0].reset();
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
<?php
|
||||
|
||||
$row=1;
|
||||
|
||||
@ -54,9 +122,9 @@ while ($port = mysql_fetch_array($query))
|
||||
# - as to draw the attention to a possible problem.
|
||||
$isportbad = ($port['ifOperStatus'] == 'down' && $port['ifAdminStatus'] != 'down') ? 1 : 0;
|
||||
$dowecare = ($port['ignore'] == 0 && $port['disabled'] == 0) ? $isportbad : !$isportbad;
|
||||
$outofsync = $dowecare ? "class=red" : "";
|
||||
$outofsync = $dowecare ? " class='red'" : "";
|
||||
|
||||
echo("<td align=right><span ".$outofsync.">". $port['ifOperStatus']."</span></td>");
|
||||
echo("<td align=right><span name='operstatus_".$port['interface_id']."'".$outofsync.">". $port['ifOperStatus']."</span></td>");
|
||||
|
||||
echo("<td align=center>");
|
||||
echo("<input type=checkbox name='disabled_".$port['interface_id']."'".($port['disabled'] ? 'checked' : '').">");
|
||||
@ -76,7 +144,6 @@ while ($port = mysql_fetch_array($query))
|
||||
|
||||
}
|
||||
|
||||
echo('<tr><td></td><td></td><td></td><td></td><td><input type="submit" value="Save"></td></tr>');
|
||||
echo('</table>');
|
||||
echo('</form>');
|
||||
echo('</div>');
|
||||
|
Reference in New Issue
Block a user