Let he user know if all selected interfaces are down

in the interface statistics widget.
At the moment, if all the selected interfaces are down, the widget will just display no columns. That will make users wonder what happened.
(cherry picked from commit b22fceb2d7)
This commit is contained in:
Phil Davis 2017-04-29 21:17:58 +05:45 committed by Renato Botelho
parent e639325a7c
commit c180fdbede

View File

@ -81,7 +81,8 @@ if ($_REQUEST && $_REQUEST['ajax']) {
);
$skipinterfaces = explode(",", $user_settings['widgets']['interface_statistics']['iffilter']);
$interface_is_displayed = false;
$an_interface_is_selected = false; // decide if at least 1 interface is selected for display
$an_interface_is_displayed = false; // decide if at least 1 interface is displayed (i.e. not down)
print("<thead>");
print( "<tr>");
@ -92,17 +93,20 @@ if ($_REQUEST && $_REQUEST['ajax']) {
continue;
}
$interface_is_displayed = true;
$an_interface_is_selected = true;
$ifinfo_arr[$ifdescr] = get_interface_info($ifdescr);
$ifinfo_arr[$ifdescr]['inbytes'] = format_bytes($ifinfo_arr[$ifdescr]['inbytes']);
$ifinfo_arr[$ifdescr]['outbytes'] = format_bytes($ifinfo_arr[$ifdescr]['outbytes']);
if ($ifinfo_arr[$ifdescr]['status'] != "down") {
$an_interface_is_displayed = true;
print("<th>" . $ifname . "</th>");
}
}
if (!$interface_is_displayed) {
if (!$an_interface_is_selected) {
print("<th>" . gettext('All interfaces are hidden.') . "</th>");
} else if (!$an_interface_is_displayed) {
print("<th>" . gettext('All selected interfaces are down.') . "</th>");
}
print( "</tr>");