From ae4d69b6801e02b7f0865fd38126ca198ea15610 Mon Sep 17 00:00:00 2001 From: Adam Amstrong Date: Fri, 27 Mar 2009 09:04:21 +0000 Subject: [PATCH] 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 --- html/images/bullet.gif | Bin 0 -> 62 bytes html/images/minus.gif | Bin 0 -> 87 bytes html/images/plus.gif | Bin 0 -> 89 bytes html/js/mktree.js | 177 ++++++++++++++++++++++++++++++++++++++ html/pages/eventlog.php | 2 +- html/pages/interfaces.php | 90 ++++++++++++++++--- 6 files changed, 255 insertions(+), 14 deletions(-) create mode 100644 html/images/bullet.gif create mode 100644 html/images/minus.gif create mode 100644 html/images/plus.gif create mode 100644 html/js/mktree.js diff --git a/html/images/bullet.gif b/html/images/bullet.gif new file mode 100644 index 0000000000000000000000000000000000000000..6305baea0d4abcf93396243e8f8964c5c392ed0a GIT binary patch literal 62 zcmZ?wbhEHb6lM@+XkcUjf_LxUDgI;uG8q|kKzxu41CwY^|H{*E`4`XGqSv6wW_6pt L?U9EQD}yxv$P^G% literal 0 HcmV?d00001 diff --git a/html/images/minus.gif b/html/images/minus.gif new file mode 100644 index 0000000000000000000000000000000000000000..154e45a5ee2baa0bd114ee01417a3c595e13a7b4 GIT binary patch literal 87 zcmZ?wbhEHb6lM@+n8?iV|NsAnh6V-(hIjAYDgI<(WME)s&;fFRvce1uOd50gSDt>$ rpUk}_OuXTqLc+dE;T4@eYD+S|Pkc6Mr|u7}Yr0Q=o%`<0$Y2cs-bNsJ literal 0 HcmV?d00001 diff --git a/html/images/plus.gif b/html/images/plus.gif new file mode 100644 index 0000000000000000000000000000000000000000..93d2ade3d4e3ee96950d68dfd0f5b5ce496ed07f GIT binary patch literal 89 zcmZ?wbhEHb6lM@+n8?iV|NsAnh6V-(hIjAYDgI<(WME)s&;fFRvce1uOj>jLSDt>$ tpUk}_OuXTq!UNr$dn{e^8y4MN-g@gq%39AN{j|tS=f3~5*I;0<1^_HKAv6F0 literal 0 HcmV?d00001 diff --git a/html/js/mktree.js b/html/js/mktree.js new file mode 100644 index 0000000000..41812d2235 --- /dev/null +++ b/html/js/mktree.js @@ -0,0 +1,177 @@ +// =================================================================== +// Author: Matt Kruse +// 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
  • 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
  • '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= '5') { $query = "SELECT *,DATE_FORMAT(datetime, '%D %b %Y %T') as humandate FROM `eventlog` ORDER BY `datetime` DESC LIMIT 0,250"; } 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"; diff --git a/html/pages/interfaces.php b/html/pages/interfaces.php index e3b2351563..ff0a9443cc 100644 --- a/html/pages/interfaces.php +++ b/html/pages/interfaces.php @@ -1,29 +1,93 @@ + + + + + + + + + + + + = '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 { # $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") { - $where = "AND I.ifAdminStatus = 'up' AND I.ifOperStatus = 'down'"; -} elseif ($_GET['type'] == "admindown") { - $where = "AND I.ifAdminStatus = 'down'"; -} elseif ($_GET['type'] == "errors") { - $where = "AND ( I.`out_errors` > '0' OR I.`in_errors` > '0' )"; +if($_GET['type'] == "down" || $_POST['state'] == "down") { + $where .= "AND I.ifAdminStatus = 'up' AND I.ifOperStatus = 'down'"; +} elseif ($_GET['type'] == "admindown" || $_POST['state'] == "admindown") { + $where .= "AND I.ifAdminStatus = 'down'"; +} elseif ($_GET['type'] == "errors" || $_POST['state'] == "errors") { + $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); -echo("
    + + + + + + + + + + +
    "); - -echo(""); +echo(""); $row = 1; @@ -45,7 +109,7 @@ while($interface = mysql_fetch_array($query)) { - + \n"); $row++;
    DeviceInterfaceSpeedMediaDescription
    DeviceInterfaceSpeedMediaDescription
    " . generateiflink($interface, makeshortif(fixifname($interface['ifDescr']))) . " $error_img $speed $type" . $interface[ifAlias] . "" . $interface['ifAlias'] . "