mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
stp-ports bootgrid 1
This commit is contained in:
37
html/includes/common/stp-ports.inc.php
Normal file
37
html/includes/common/stp-ports.inc.php
Normal file
@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
$common_output[] = '
|
||||
<div class="table-responsive">
|
||||
<table id="stp-ports" class="table table-condensed table-hover table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th data-column-id="port">Port</th>
|
||||
<th data-column-id="priority">Priority</th>
|
||||
<th data-column-id="state">State</th>
|
||||
<th data-column-id="enable">Enable</th>
|
||||
<th data-column-id="pathCost">Path cost</th>
|
||||
<th data-column-id="designatedRoot">Designated root</th>
|
||||
<th data-column-id="designatedCost">Designated cost</th>
|
||||
<th data-column-id="designatedBridge">Designated bridge</th>
|
||||
<th data-column-id="designatedPort">Designated port</th>
|
||||
<th data-column-id="forwardTransitions">Fwd trasitions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<table>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
|
||||
var grid = $("#stp-ports").bootgrid( {
|
||||
ajax: true,
|
||||
post: function ()
|
||||
{
|
||||
return {
|
||||
id: "stp-ports"
|
||||
};
|
||||
},
|
||||
url: "ajax_table.php"
|
||||
});
|
||||
|
||||
</script>
|
||||
';
|
@ -1,64 +0,0 @@
|
||||
<?php
|
||||
echo "<div class='table-responsive'>";
|
||||
echo "<table id='port-stp' class='table table-condensed table-hover table-striped'>";
|
||||
echo '<thead>';
|
||||
echo '<tr>
|
||||
<th data-column-id="port">Port</th>
|
||||
<th data-column-id="priority">Priority</th>
|
||||
<th data-column-id="state">State</th>
|
||||
<th data-column-id="enable">Enable</th>
|
||||
<th data-column-id="pathCost">Path cost</th>
|
||||
<th data-column-id="designatedRoot">Designated root</th>
|
||||
<th data-column-id="designatedCost">Designated cost</th>
|
||||
<th data-column-id="designatedBridge">Designated bridge</th>
|
||||
<th data-column-id="designatedPort">Designated port</th>
|
||||
<th data-column-id="forwardTransitions">Fwd trasitions</th>
|
||||
</tr>';
|
||||
echo '</thead>';
|
||||
echo '<tbody>';
|
||||
|
||||
foreach (dbFetchRows("SELECT `ps`.*, `p`.* FROM `ports_stp` `ps` JOIN `ports` `p` ON `ps`.`port_id`=`p`.`port_id` WHERE `ps`.`device_id` = ?", array($device['device_id'])) as $stp_ports_db) {
|
||||
|
||||
$bridge_device = dbFetchRow("SELECT `devices`.*, `stp`.`device_id`, `stp`.`bridgeAddress` FROM `devices` JOIN `stp` ON `devices`.`device_id`=`stp`.`device_id` WHERE `stp`.`bridgeAddress` = ?", array($stp_ports_db['designatedBridge']));
|
||||
$root_device = dbFetchRow("SELECT `devices`.*, `stp`.`device_id`, `stp`.`bridgeAddress` FROM `devices` JOIN `stp` ON `devices`.`device_id`=`stp`.`device_id` WHERE `stp`.`bridgeAddress` = ?", array($stp_ports_db['designatedRoot']));
|
||||
|
||||
$stp_ports = [
|
||||
generate_port_link($stp_ports_db, $stp_ports_db['ifName'])."<br>".$stp_ports_db['ifAlias'],
|
||||
$stp_ports_db['priority'],
|
||||
$stp_ports_db['state'],
|
||||
$stp_ports_db['enable'],
|
||||
$stp_ports_db['pathCost'],
|
||||
generate_device_link($root_device, $root_device['hostname'])."<br>".$stp_ports_db['designatedRoot'],
|
||||
$stp_ports_db['designatedCost'],
|
||||
generate_device_link($bridge_device, $bridge_device['hostname'])."<br>".$stp_ports_db['designatedBridge'],
|
||||
$stp_ports_db['designatedPort'],
|
||||
$stp_ports_db['forwardTransitions']
|
||||
];
|
||||
|
||||
echo "<tr>";
|
||||
foreach ($stp_ports as $value) {
|
||||
echo "<td>$value</td>";
|
||||
}
|
||||
echo '</tr>';
|
||||
}
|
||||
echo '</tbody>';
|
||||
echo '</table>';
|
||||
echo '</div>';
|
||||
// FIXME make table with links and searcheable
|
||||
//
|
||||
?>
|
||||
|
||||
<script>
|
||||
//$("#port-stp").bootgrid();
|
||||
/*
|
||||
$("#port-stp").bootgrid( {
|
||||
ajax: true,
|
||||
post: function () {
|
||||
return {
|
||||
id: "port-stp"
|
||||
};
|
||||
},
|
||||
url: "ajax_table.php"
|
||||
});
|
||||
*/
|
||||
</script>
|
55
html/includes/table/stp-ports.inc.php
Normal file
55
html/includes/table/stp-ports.inc.php
Normal file
@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
$param[] = $device['device_id'];
|
||||
|
||||
$sql = " `FROM `ports_stp` `ps` JOIN `ports` `p` ON `ps`.`port_id`=`p`.`port_id` WHERE `ps`.`device_id` = ?";
|
||||
|
||||
$count_sql = "SELECT COUNT(ports_stp_id) $sql";
|
||||
$total = dbFetchCell($count_sql, $param);
|
||||
if (empty($total)) {
|
||||
$total = 0;
|
||||
}
|
||||
|
||||
if (!isset($sort) || empty($sort)) {
|
||||
$sort = 'port_id DESC';
|
||||
}
|
||||
|
||||
$sql .= " ORDER BY $sort";
|
||||
|
||||
if (isset($current)) {
|
||||
$limit_low = (($current * $rowCount) - ($rowCount));
|
||||
$limit_high = $rowCount;
|
||||
}
|
||||
|
||||
if ($rowCount != -1) {
|
||||
$sql .= " LIMIT $limit_low,$limit_high";
|
||||
}
|
||||
|
||||
$sql = "SELECT `ps`.*, `p`.* $sql";
|
||||
|
||||
foreach (dbFetchRows($sql, array($device['device_id'])) as $stp_ports_db) {
|
||||
|
||||
$bridge_device = dbFetchRow("SELECT `devices`.*, `stp`.`device_id`, `stp`.`bridgeAddress` FROM `devices` JOIN `stp` ON `devices`.`device_id`=`stp`.`device_id` WHERE `stp`.`bridgeAddress` = ?", array($stp_ports_db['designatedBridge']));
|
||||
$root_device = dbFetchRow("SELECT `devices`.*, `stp`.`device_id`, `stp`.`bridgeAddress` FROM `devices` JOIN `stp` ON `devices`.`device_id`=`stp`.`device_id` WHERE `stp`.`bridgeAddress` = ?", array($stp_ports_db['designatedRoot']));
|
||||
|
||||
$response[] = array (
|
||||
'port' => generate_port_link($stp_ports_db, $stp_ports_db['ifName'])."<br>".$stp_ports_db['ifAlias'],
|
||||
'priority' => $stp_ports_db['priority'],
|
||||
'state' => $stp_ports_db['state'],
|
||||
'enable' => $stp_ports_db['enable'],
|
||||
'pathCost' => $stp_ports_db['pathCost'],
|
||||
'designatedRoot' => generate_device_link($root_device, $root_device['hostname'])."<br>".$stp_ports_db['designatedRoot'],
|
||||
'designatedCost' => $stp_ports_db['designatedCost'],
|
||||
'designatedBridge' => generate_device_link($bridge_device, $bridge_device['hostname'])."<br>".$stp_ports_db['designatedBridge'],
|
||||
'designatedPort' => $stp_ports_db['designatedPort'],
|
||||
'forwardTransitions' => $stp_ports_db['forwardTransitions']
|
||||
);
|
||||
}
|
||||
|
||||
$output = array(
|
||||
'current' => $current,
|
||||
'rowCount' => $rowCount,
|
||||
'rows' => $response,
|
||||
'total' => $total,
|
||||
);
|
||||
echo _json_encode($output);
|
@ -46,7 +46,8 @@ if ($vars['view'] == 'basic') {
|
||||
}
|
||||
|
||||
if ($vars['view'] == 'ports') {
|
||||
include 'includes/print-stp-ports.inc.php';
|
||||
include 'includes/common/stp-ports.inc.php';
|
||||
echo implode('',$common_output);
|
||||
}
|
||||
|
||||
echo '</table>';
|
||||
|
Reference in New Issue
Block a user