mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
adding mktree back! (not sure when it was removed!)
git-svn-id: http://www.observium.org/svn/observer/trunk@392 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
BIN
html/images/bullet.gif
Normal file
BIN
html/images/bullet.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 62 B |
BIN
html/images/minus.gif
Normal file
BIN
html/images/minus.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 87 B |
BIN
html/images/plus.gif
Normal file
BIN
html/images/plus.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 89 B |
177
html/js/mktree.js
Normal file
177
html/js/mktree.js
Normal file
@ -0,0 +1,177 @@
|
|||||||
|
// ===================================================================
|
||||||
|
// Author: Matt Kruse <matt@mattkruse.com>
|
||||||
|
// WWW: http://www.mattkruse.com/
|
||||||
|
//
|
||||||
|
// NOTICE: You may use this code for any purpose, commercial or
|
||||||
|
// private, without any further permission from the author. You may
|
||||||
|
// remove this notice from your final code if you wish, however it is
|
||||||
|
// appreciated by the author if at least my web site address is kept.
|
||||||
|
//
|
||||||
|
// You may *NOT* re-distribute this code in any way except through its
|
||||||
|
// use. That means, you can include it in your product, or your web
|
||||||
|
// site, or any other form where the code is actually being used. You
|
||||||
|
// may not put the plain javascript up on your site for download or
|
||||||
|
// include it in your javascript libraries for download.
|
||||||
|
// If you wish to share this code with others, please just point them
|
||||||
|
// to the URL instead.
|
||||||
|
// Please DO NOT link directly to my .js files from your site. Copy
|
||||||
|
// the files to your server and use them there. Thank you.
|
||||||
|
// ===================================================================
|
||||||
|
|
||||||
|
// HISTORY
|
||||||
|
// ------------------------------------------------------------------
|
||||||
|
// December 9, 2003: Added script to the Javascript Toolbox
|
||||||
|
// December 10, 2003: Added the preProcessTrees variable to allow user
|
||||||
|
// to turn off automatic conversion of UL's onLoad
|
||||||
|
// March 1, 2004: Changed it so if a <li> has a class already attached
|
||||||
|
// to it, that class won't be erased when initialized. This allows
|
||||||
|
// you to set the state of the tree when painting the page simply
|
||||||
|
// by setting some <li>'s class name as being "liOpen" (see example)
|
||||||
|
/*
|
||||||
|
This code is inspired by and extended from Stuart Langridge's aqlist code:
|
||||||
|
http://www.kryogenix.org/code/browser/aqlists/
|
||||||
|
Stuart Langridge, November 2002
|
||||||
|
sil@kryogenix.org
|
||||||
|
Inspired by Aaron's labels.js (http://youngpup.net/demos/labels/)
|
||||||
|
and Dave Lindquist's menuDropDown.js (http://www.gazingus.org/dhtml/?id=109)
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Automatically attach a listener to the window onload, to convert the trees
|
||||||
|
addEvent(window,"load",convertTrees);
|
||||||
|
|
||||||
|
// Utility function to add an event listener
|
||||||
|
function addEvent(o,e,f){
|
||||||
|
if (o.addEventListener){ o.addEventListener(e,f,true); return true; }
|
||||||
|
else if (o.attachEvent){ return o.attachEvent("on"+e,f); }
|
||||||
|
else { return false; }
|
||||||
|
}
|
||||||
|
|
||||||
|
// utility function to set a global variable if it is not already set
|
||||||
|
function setDefault(name,val) {
|
||||||
|
if (typeof(window[name])=="undefined" || window[name]==null) {
|
||||||
|
window[name]=val;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Full expands a tree with a given ID
|
||||||
|
function expandTree(treeId) {
|
||||||
|
var ul = document.getElementById(treeId);
|
||||||
|
if (ul == null) { return false; }
|
||||||
|
expandCollapseList(ul,nodeOpenClass);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fully collapses a tree with a given ID
|
||||||
|
function collapseTree(treeId) {
|
||||||
|
var ul = document.getElementById(treeId);
|
||||||
|
if (ul == null) { return false; }
|
||||||
|
expandCollapseList(ul,nodeClosedClass);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Expands enough nodes to expose an LI with a given ID
|
||||||
|
function expandToItem(treeId,itemId) {
|
||||||
|
var ul = document.getElementById(treeId);
|
||||||
|
if (ul == null) { return false; }
|
||||||
|
var ret = expandCollapseList(ul,nodeOpenClass,itemId);
|
||||||
|
if (ret) {
|
||||||
|
var o = document.getElementById(itemId);
|
||||||
|
if (o.scrollIntoView) {
|
||||||
|
o.scrollIntoView(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Performs 3 functions:
|
||||||
|
// a) Expand all nodes
|
||||||
|
// b) Collapse all nodes
|
||||||
|
// c) Expand all nodes to reach a certain ID
|
||||||
|
function expandCollapseList(ul,cName,itemId) {
|
||||||
|
if (!ul.childNodes || ul.childNodes.length==0) { return false; }
|
||||||
|
// Iterate LIs
|
||||||
|
for (var itemi=0;itemi<ul.childNodes.length;itemi++) {
|
||||||
|
var item = ul.childNodes[itemi];
|
||||||
|
if (itemId!=null && item.id==itemId) { return true; }
|
||||||
|
if (item.nodeName == "LI") {
|
||||||
|
// Iterate things in this LI
|
||||||
|
var subLists = false;
|
||||||
|
for (var sitemi=0;sitemi<item.childNodes.length;sitemi++) {
|
||||||
|
var sitem = item.childNodes[sitemi];
|
||||||
|
if (sitem.nodeName=="UL") {
|
||||||
|
subLists = true;
|
||||||
|
var ret = expandCollapseList(sitem,cName,itemId);
|
||||||
|
if (itemId!=null && ret) {
|
||||||
|
item.className=cName;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (subLists && itemId==null) {
|
||||||
|
item.className = cName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Search the document for UL elements with the correct CLASS name, then process them
|
||||||
|
function convertTrees() {
|
||||||
|
setDefault("treeClass","mktree");
|
||||||
|
setDefault("nodeClosedClass","liClosed");
|
||||||
|
setDefault("nodeOpenClass","liOpen");
|
||||||
|
setDefault("nodeBulletClass","liBullet");
|
||||||
|
setDefault("nodeLinkClass","bullet");
|
||||||
|
setDefault("preProcessTrees",true);
|
||||||
|
if (preProcessTrees) {
|
||||||
|
if (!document.createElement) { return; } // Without createElement, we can't do anything
|
||||||
|
uls = document.getElementsByTagName("ul");
|
||||||
|
for (var uli=0;uli<uls.length;uli++) {
|
||||||
|
var ul=uls[uli];
|
||||||
|
if (ul.nodeName=="UL" && ul.className==treeClass) {
|
||||||
|
processList(ul);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Process a UL tag and all its children, to convert to a tree
|
||||||
|
function processList(ul) {
|
||||||
|
if (!ul.childNodes || ul.childNodes.length==0) { return; }
|
||||||
|
// Iterate LIs
|
||||||
|
for (var itemi=0;itemi<ul.childNodes.length;itemi++) {
|
||||||
|
var item = ul.childNodes[itemi];
|
||||||
|
if (item.nodeName == "LI") {
|
||||||
|
// Iterate things in this LI
|
||||||
|
var subLists = false;
|
||||||
|
for (var sitemi=0;sitemi<item.childNodes.length;sitemi++) {
|
||||||
|
var sitem = item.childNodes[sitemi];
|
||||||
|
if (sitem.nodeName=="UL") {
|
||||||
|
subLists = true;
|
||||||
|
processList(sitem);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var s= document.createElement("SPAN");
|
||||||
|
var t= '\u00A0'; //
|
||||||
|
s.className = nodeLinkClass;
|
||||||
|
if (subLists) {
|
||||||
|
// This LI has UL's in it, so it's a +/- node
|
||||||
|
if (item.className==null || item.className=="") {
|
||||||
|
item.className = nodeClosedClass;
|
||||||
|
}
|
||||||
|
// If it's just text, make the text work as the link also
|
||||||
|
if (item.firstChild.nodeName=="#text") {
|
||||||
|
t = t+item.firstChild.nodeValue;
|
||||||
|
item.removeChild(item.firstChild);
|
||||||
|
}
|
||||||
|
s.onclick = function () {
|
||||||
|
this.parentNode.className = (this.parentNode.className==nodeOpenClass) ? nodeClosedClass : nodeOpenClass;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// No sublists, so it's just a bullet node
|
||||||
|
item.className = nodeBulletClass;
|
||||||
|
s.onclick = function () { return false; }
|
||||||
|
}
|
||||||
|
s.appendChild(document.createTextNode(t));
|
||||||
|
item.insertBefore(s,item.firstChild);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,6 +1,6 @@
|
|||||||
<?
|
<?
|
||||||
|
|
||||||
if($_SESSION['userlevel'] == '10') {
|
if($_SESSION['userlevel'] >= '5') {
|
||||||
$query = "SELECT *,DATE_FORMAT(datetime, '%D %b %Y %T') as humandate FROM `eventlog` ORDER BY `datetime` DESC LIMIT 0,250";
|
$query = "SELECT *,DATE_FORMAT(datetime, '%D %b %Y %T') as humandate FROM `eventlog` ORDER BY `datetime` DESC LIMIT 0,250";
|
||||||
} else {
|
} else {
|
||||||
$query = "SELECT *,DATE_FORMAT(datetime, '%D %b %Y %T') as humandate FROM `eventlog` AS E, devices_perms AS P WHERE E.host = P.device_id AND P.user_id = " . $_SESSION['user_id'] . " ORDER BY `datetime` DESC LIMIT 0,250";
|
$query = "SELECT *,DATE_FORMAT(datetime, '%D %b %Y %T') as humandate FROM `eventlog` AS E, devices_perms AS P WHERE E.host = P.device_id AND P.user_id = " . $_SESSION['user_id'] . " ORDER BY `datetime` DESC LIMIT 0,250";
|
||||||
|
@ -1,29 +1,93 @@
|
|||||||
|
<table cellpadding=2 cellspacing=1 class=devicetable width=100%>
|
||||||
|
<tr bgcolor='#eeeeee' style='padding: 3px;'>
|
||||||
|
<form method='post' action=''>
|
||||||
|
<td width='200' style="padding: 10px;">
|
||||||
|
<select name='device_id' id='device_id'>
|
||||||
|
<option value=''>All Devices</option>
|
||||||
|
<?php
|
||||||
|
$query = mysql_query("SELECT `device_id`,`hostname` FROM `devices` GROUP BY `hostname` ORDER BY `hostname`");
|
||||||
|
while($data = mysql_fetch_array($query)) {
|
||||||
|
echo("<option value='".$data['device_id']."'");
|
||||||
|
if($data['device_id'] == $_POST['device_id']) { echo("selected"); }
|
||||||
|
echo(">".$data['hostname']."</option>");
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
</select>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<select name='state' id='state'>
|
||||||
|
<option value=''>All States</option>
|
||||||
|
<option value='up' <?php if($_POST['state'] == "up") { echo("selected"); } ?>>Up</option>
|
||||||
|
<option value='down'<?php if($_POST['state'] == "down") { echo("selected"); } ?>>Down</option>
|
||||||
|
<option value='admindown' <?php if($_POST['state'] == "admindown") { echo("selected"); } ?>>Shutdown</option>
|
||||||
|
<option value='errors' <?php if($_POST['state'] == "errors") { echo("selected"); } ?>>Errors</option>
|
||||||
|
</select>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<select name='ifSpeed' id='ifSpeed'>
|
||||||
|
<option value=''>All Speeds</option>
|
||||||
|
<?php
|
||||||
|
$query = mysql_query("SELECT `ifSpeed` FROM `interfaces` GROUP BY `ifSpeed` ORDER BY `ifSpeed`");
|
||||||
|
while($data = mysql_fetch_array($query)) {
|
||||||
|
echo("<option value='".$data['ifSpeed']."'");
|
||||||
|
if($data['ifSpeed'] == $_POST['ifSpeed']) { echo("selected"); }
|
||||||
|
echo(">".humanspeed($data['ifSpeed'])."</option>");
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
</select>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<select name='ifType' id='ifType'>
|
||||||
|
<option value=''>All Media</option>
|
||||||
|
<?php
|
||||||
|
$query = mysql_query("SELECT `ifType` FROM `interfaces` GROUP BY `ifType` ORDER BY `ifType`");
|
||||||
|
while($data = mysql_fetch_array($query)) {
|
||||||
|
echo("<option value='".$data['ifType']."'");
|
||||||
|
if($data['ifType'] == $_POST['ifType']) { echo("selected"); }
|
||||||
|
echo(">".$data['ifType']."</option>");
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
</select>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<input type="text" name="ifAlias" id="ifAlias" size=40 value="<?php echo($_POST['ifAlias']); ?>" />
|
||||||
|
<input style="align:right;" type=submit value=Search></div>
|
||||||
|
</td>
|
||||||
|
</form>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
#if ($_SESSION['userlevel'] >= '5') {
|
#if ($_SESSION['userlevel'] >= '5') {
|
||||||
$sql = "SELECT * FROM `interfaces` AS I, `devices` AS D WHERE I.device_id = D.device_id ORDER BY D.hostname, I.ifDescr";
|
# $sql = "SELECT * FROM `interfaces` AS I, `devices` AS D WHERE I.device_id = D.device_id ORDER BY D.hostname, I.ifDescr";
|
||||||
#} else {
|
#} else {
|
||||||
# $sql = "SELECT * FROM `interfaces` AS I, `devices` AS D, `devices_perms` AS P WHERE I.device_id = D.device_id AND D.device_id = P.device_id AND P.user_id = '" . $_SESSION['user_id'] . "' ORDER BY D.hostname, I.ifDescr";
|
# $sql = "SELECT * FROM `interfaces` AS I, `devices` AS D, `devices_perms` AS P WHERE I.device_id = D.device_id AND D.device_id = P.device_id AND P.user_id = '" . $_SESSION['user_id'] . "' ORDER BY D.hostname, I.ifDescr";
|
||||||
#}
|
#}
|
||||||
|
|
||||||
|
|
||||||
|
if($_GET['type'] == "down" || $_POST['state'] == "down") {
|
||||||
if($_GET['type'] == "down") {
|
$where .= "AND I.ifAdminStatus = 'up' AND I.ifOperStatus = 'down'";
|
||||||
$where = "AND I.ifAdminStatus = 'up' AND I.ifOperStatus = 'down'";
|
} elseif ($_GET['type'] == "admindown" || $_POST['state'] == "admindown") {
|
||||||
} elseif ($_GET['type'] == "admindown") {
|
$where .= "AND I.ifAdminStatus = 'down'";
|
||||||
$where = "AND I.ifAdminStatus = 'down'";
|
} elseif ($_GET['type'] == "errors" || $_POST['state'] == "errors") {
|
||||||
} elseif ($_GET['type'] == "errors") {
|
$where .= "AND ( I.`out_errors` > '0' OR I.`in_errors` > '0' )";
|
||||||
$where = "AND ( I.`out_errors` > '0' OR I.`in_errors` > '0' )";
|
} elseif ($_GET['type'] == "up" || $_POST['state'] == "up") {
|
||||||
|
$where .= "AND I.ifOperStatus = 'up'";
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql = "SELECT * FROM `interfaces` AS I, `devices` AS D WHERE I.device_id = D.device_id $where ORDER BY D.hostname, I.ifDescr";
|
if($_POST['device_id']) { $where .= " AND I.device_id = '".$_POST['device_id']."'"; }
|
||||||
|
if($_POST['ifType']) { $where .= " AND I.ifType = '".$_POST['ifType']."'"; }
|
||||||
|
if($_POST['ifSpeed']) { $where .= " AND I.ifSpeed = '".$_POST['ifSpeed']."'"; }
|
||||||
|
if($_POST['ifAlias']) { $where .= " AND I.ifAlias LIKE '%".$_POST['ifAlias']."%'"; }
|
||||||
|
|
||||||
|
|
||||||
|
$sql = "SELECT * FROM `interfaces` AS I, `devices` AS D WHERE I.device_id = D.device_id $where ORDER BY D.hostname, I.ifIndex";
|
||||||
|
|
||||||
|
|
||||||
$query = mysql_query($sql);
|
$query = mysql_query($sql);
|
||||||
|
|
||||||
echo("<table cellspacing=0 cellpadding=2 width=100%>");
|
echo("<tr class=tablehead><th>Device</a></th><th>Interface</th><th>Speed</th><th>Media</th><th>Description</th></tr>");
|
||||||
|
|
||||||
echo("<tr class=tablehead><th width=280>Device</a></th><th>Interface</th><th>Speed</th><th>Media</th><th>Description</th></tr>");
|
|
||||||
|
|
||||||
$row = 1;
|
$row = 1;
|
||||||
|
|
||||||
@ -45,7 +109,7 @@ while($interface = mysql_fetch_array($query)) {
|
|||||||
<td class=list-bold>" . generateiflink($interface, makeshortif(fixifname($interface['ifDescr']))) . " $error_img</td>
|
<td class=list-bold>" . generateiflink($interface, makeshortif(fixifname($interface['ifDescr']))) . " $error_img</td>
|
||||||
<td>$speed</td>
|
<td>$speed</td>
|
||||||
<td>$type</td>
|
<td>$type</td>
|
||||||
<td>" . $interface[ifAlias] . "</td>
|
<td>" . $interface['ifAlias'] . "</td>
|
||||||
</tr>\n");
|
</tr>\n");
|
||||||
|
|
||||||
$row++;
|
$row++;
|
||||||
|
Reference in New Issue
Block a user