Files
librenms-librenms/includes/html/pages/device/loadbalancer/ace_rservers.inc.php
Tony Murray 075ba4c932 Ports UI update (#16115)
* WIP Device Ports porting to Laravel

* WIP port links

* Port Links WIP

* Port Links

* in_array -> isset

* Add request to DeviceTab data

* Add initial Pagination

* Missing select component

* Collapsed and expandable port neighbors
New expandable component

* Port sorting

* Fix port transfer

* Use menu entries to filter ports

* Add translatable strings

* style fixes and cleanup

* update css

* graph views and tidy controller
basic port link view

* cleanup

* port row blade to reuse in legacy port view

* Legacy tab url handling
work properly in subdirectory
remove includes from sub tab directory to prevent oddity

* fallback to detail list when the view doesn't exist

* Use named variable to simplify

* Fix issue from file that was a symlink

* Submenu handle sub items and query string urls

* extract pageLinks to improve readability

* fix typo

* Apply fixes from StyleCI

* phpstan was not happy using the relationship HasMany query

* Don't allow *bps etc to be on a second line

* Improve table on small screens

* Fix sort

---------

Co-authored-by: Tony Murray <murrant@users.noreply.github.com>
2024-06-16 11:29:06 -05:00

103 lines
2.8 KiB
PHP

<?php
print_optionbar_start();
echo "<span style='font-weight: bold;'>Serverfarm Rservers</span> &#187; ";
// $auth = TRUE;
$menu_options = ['basic' => 'Basic'];
if (! $_GET['opta']) {
$_GET['opta'] = 'basic';
}
$sep = '';
foreach ($menu_options as $option => $text) {
if ($_GET['optd'] == $option) {
echo "<span class='pagemenu-selected'>";
}
echo '<a href="device/device=' . $device['device_id'] . '/tab=routing/type=loadbalancer_rservers/' . $option . '/">' . $text . '</a>';
if ($_GET['optd'] == $option) {
echo '</span>';
}
echo ' | ';
}
unset($sep);
echo ' Graphs: ';
// $graph_types = array("bits" => "Bits",
// "pkts" => "Packets",
// "errors" => "Errors");
$graph_types = [
'curr' => 'CurrentConns',
'failed' => 'FailedConns',
'total' => 'TotalConns',
];
foreach ($graph_types as $type => $descr) {
echo "$type_sep";
if ($_GET['opte'] == $type) {
echo "<span class='pagemenu-selected'>";
}
echo '<a href="device/device=' . $device['device_id'] . '/tab=routing/type=loadbalancer_rservers/graphs/' . $type . '/">' . $descr . '</a>';
if ($_GET['opte'] == $type) {
echo '</span>';
}
$type_sep = ' | ';
}
print_optionbar_end();
echo "<div style='margin: 5px;'><table border=0 cellspacing=0 cellpadding=0 width=100%>";
$i = '0';
foreach (dbFetchRows('SELECT * FROM `loadbalancer_rservers` WHERE `device_id` = ? ORDER BY `farm_id`', [$device['device_id']]) as $rserver) {
if (is_integer($i / 2)) {
$bg_colour = \LibreNMS\Config::get('list_colour.even');
} else {
$bg_colour = \LibreNMS\Config::get('list_colour.odd');
}
if ($rserver['StateDescr'] == 'Server is now operational') {
$rserver_class = 'green';
} else {
$rserver_class = 'red';
}
echo "<tr bgcolor='$bg_colour'>";
// echo("<td width=320 class=list-large>" . $tunnel['local_addr'] . " &#187; " . $tunnel['peer_addr'] . "</a></td>");
echo '<td width=700 class=list-small>' . $rserver['farm_id'] . '</a></td>';
// echo("<td width=150 class=box-desc>" . $rserver['farm_id'] . "</td>");
echo "<td width=230 class=list-small><span class='" . $rserver_class . "'>" . $rserver['StateDescr'] . '</span></td>';
echo '</tr>';
if ($_GET['optd'] == 'graphs') {
echo '<tr class="list-bold">';
echo '<td colspan = 3>';
$graph_type = 'rserver_' . $_GET['opte'];
$graph_array['height'] = '100';
$graph_array['width'] = '215';
$graph_array['to'] = \LibreNMS\Config::get('time.now');
$graph_array['id'] = $rserver['rserver_id'];
$graph_array['type'] = $graph_type;
require 'includes/html/print-graphrow.inc.php';
echo '
</td>
</tr>';
}
echo '</td>';
echo '</tr>';
$i++;
}
echo '</table></div>';