Welcome, Guest. Please login or register.

Author Topic: GUI Modifications proposition  (Read 3168 times)

richard.lajaunie

  • Newbie
  • *
  • Posts: 26
    • View Profile
GUI Modifications proposition
« on: June 12, 2009, 10:34:05 AM »
Hi ALL!
First, i want to thank all of you for this very great soft.
I'm network administrator in a medium size company.
We are 2 network admin and about 10 technicians for the maintainance for 2 sites.
We're using Nedi for about six month and it's very usefull.

For a more user friendly GUI i've made some modifications of the GUI code.
i would like to present these and why i've made it.

We have 2 Nedi servers and for each update i had to reproduce the display setting for
Devices-List and Nodes-List. So i decide move these parameters in nedi.conf
Here is the code modifications i've made:

Nedi.conf
#To define what columns to display in Devices-List and Nodes-List
devicesDisplay  name    ip      serial  os      location        firstseen       lastseen
orderDevDisplay name
nodesDisplay    name    ip      ifnamel mac     vlanid  firstseen       lastseen
orderNoDisplay  ip

Libmisc.php after line 75
elseif ($v[0] == "devicesDisplay")   {for($ii=1;$ii<count($v);$ii++){$devicesDisplay[] = $v[$ii];}}
elseif ($v[0] == "orderDevDisplay")    {$orderDevDisplay = $v[1];}
elseif ($v[0] == "nodesDisplay")   {for($ii=1;$ii<count($v);$ii++){$nodesDisplay[] = $v[$ii];}}
elseif ($v[0] == "orderNoDisplay")    {$orderNoDisplay = $v[1];}

Devices-List.php
line 31: $ord = isset($_GET['ord']) ? $_GET['ord'] : $orderDevDisplay;
line 32: $col = isset($_GET['col']) ? $_GET['col'] : $devicesDisplay;

Nodes-List.php
line 33: $ord = isset($_GET['ord']) ? $_GET['ord'] : $orderNoDisplay;
line 34: $col = isset($_GET['col']) ? $_GET['col'] : $nodesDisplay;


In our normal activitie whe have intensive use of the Nodes-List page and very often
we switch from this page to Devices-Status page. To ease this switching i've add a link
in the Nodes-List page for each node in the list, in the column  ifname .

Nodes-List.php
line 187: echo "<td><a href=\"Devices-Status.php?dev=$ud\"><img src=\"img/16/swit.png\"></a><a href=\"?ina=device&opa==&sta=$ud&ord=ifname\">$n[6]</a>";


In our company we have classified the Ip Addresses by nodes types.
By example, printers have 1.xx.200.yy type address, Pc 1.xx.150.yy type address,
specials Pc 1.xx.250.yy type address, etc... So to retrieve specific type of node in the
Nodes-List.php page we have to search Ip Addresses in the RegExp way:

Nodes-List.php
after line 37: "ips"=>"IP String $adrlbl",

libdb-msq.php
after line 103: }elseif($c == 'ips'){
         $c = "inet_ntoa(ip)";


To avoid the need of switching between Devices-Status.php and Devices-Config.php to view
a specific interface configuration, i create a page that Pop-Up on a click on  ifname  column:

Devices-Status.php
line 559: echo "<td><a href=\"javascript:void()\" onclick=\"window.open('Devices-PopConf.php?device=$shd&ifname=$in','Help','menubar=no,location=no,width=800,height=500,scrollbars');\"><b>$in</b></a></td>\n";

Devices-PopConf.php (specific to cisco at this time)
<?php
session_start();
require_once ('inc/libmisc.php');
if(isset ($_SESSION['group']) ){
   ReadConf($_SESSION['group']);
}else{
   echo "<script>document.location.href='index.php?goto=".rawurlencode($_SERVER["REQUEST_URI"])."';</script>\n";
   die;
}
require_once ("languages/$_SESSION[lang]/gui.php");
require_once ("inc/libdb-" . strtolower($backend) . ".php");

$_GET = sanitize($_GET);

$arr_ifabr = array('/Et/', '/Fa/', '/Gi/', '/Te/', '/Vl/', '/Po/', '/Lo/');
$arr_iflong = array('Ethernet', 'FastEthernet', 'GigabitEthernet', 'TenGigabitEthernet', 'Vlan', 'Port-channel', 'Loopback');
$ifnum = preg_replace("/(\\w{2})(\\d\\/\\d)/", "$2", $_GET['ifname']);
$iftype = preg_replace($arr_ifabr, $arr_iflong, $_GET['ifname']);
$iftype = preg_replace("/(\\w{2}\\d\\/\\d)(-\\w*)/", "$1", $iftype);

if ($_GET['device']){
   $clink  = @DbConnect($dbhost,$dbuser,$dbpass,$dbname);
   $cquery = "SELECT substring_index(substr(config,position('interface $iftype' in config)), '!', 1) FROM configs where device='{$_GET['device']}'";
   $cres   = @DbQuery($cquery,$clink);
   if ( @DbNumRows($cres) == 1) {
           $caho = @DbFetchRow($cres);
   }
   @DbFreeResult($cres);
}

?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=<?=$charset?>">
<link href="themes/<?=$_SESSION[theme]?>.css" type="text/css" rel="stylesheet">
</head>
<body>
<h1><?=$_GET['device']?></h1>
<div class="net1">
<h2>Port Configuration of <?=$_GET['ifname']?></h2>
</div>
<div class="net2 code">
<b></b>
<font size="+0"><? echo $caho[0]; ?></font>
<table>
<td><? echo "<img src=inc/drawrrd.php?dv={$_GET['device']}&if%5B%5D={$_GET['ifname']}&s=4&t=trf>\n"; ?></td>
<td><? echo "<img src=inc/drawrrd.php?dv={$_GET['device']}&if%5B%5D={$_GET['ifname']}&s=4&t=err>\n"; ?></td>
</table>
</div>
</body>
</html>


Voila!
That's all for today.
I hope these modifications will be agreed and inserted in the project.

P.S. : Soon, i will publish some modification for integration of Hirschmann MICE MS20 switches....
P.S. : excuse my poor english writing, i'm not very comfortable whis it.

rickli

  • Administrator
  • Hero Member
  • *****
  • Posts: 2701
    • View Profile
    • NeDi
Re: GUI Modifications proposition
« Reply #1 on: June 12, 2009, 08:18:30 PM »
Thanks for your input, I'll look into it as soon as I find the time. BTW I've been using URLs in the message area of User-Profile quite a bit, to present dynamic maps, lists etc...
Please consider Other-Invoices on your NeDi installation for an annual contribution, tx!
-Remo

rickli

  • Administrator
  • Hero Member
  • *****
  • Posts: 2701
    • View Profile
    • NeDi
Re: GUI Modifications proposition
« Reply #2 on: October 25, 2009, 02:47:56 PM »
Ok, better late than never...

1. Hmm, still constrains every user to a given set of columns. How about put it in the session variable? I'll think aobut it...

2. done, but with the official device-status icon  ;)

3. Good idea, thanks for the suggestions. How about only touching the lib, thus allowing regexp IP searches for all modules:
               }elseif(preg_match("/^(origip|ip)$/",$c)  and $o = 'regexp'){
                  $c = "inet_ntoa(ip)";
4. Need to look at this more closely as it's too vendor specific and circumvents the dblib. How about using middle mouse button on config icon for now?
« Last Edit: October 25, 2009, 02:50:50 PM by rickli »
Please consider Other-Invoices on your NeDi installation for an annual contribution, tx!
-Remo