Skip to content

Commit

Permalink
Fixed tabs and units on the wireless page (#10401)
Browse files Browse the repository at this point in the history
  • Loading branch information
murrant authored and laf committed Jul 2, 2019
1 parent f419419 commit f83ce13
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 5 deletions.
7 changes: 5 additions & 2 deletions includes/html/functions.inc.php
Expand Up @@ -1616,8 +1616,11 @@ function get_state_label($sensor)

/**
* Get sensor label and state color
* @param array $sensor
* @param string $type sensors or wireless
* @return string
*/
function get_sensor_label_color($sensor)
function get_sensor_label_color($sensor, $type = 'sensors')
{
$label_style = "label-success";
if (is_null($sensor)) {
Expand All @@ -1635,6 +1638,6 @@ function get_sensor_label_color($sensor)
if (!is_null($sensor['sensor_limit_low']) && $sensor['sensor_current'] < $sensor['sensor_limit_low']) {
$label_style = "label-danger";
}
$unit = __('sensors.' . $sensor['sensor_class'] . '.unit');
$unit = __("$type.{$sensor['sensor_class']}.unit");
return "<span class='label $label_style'>".trim(format_si($sensor['sensor_current']).$unit)."</span>";
}
4 changes: 2 additions & 2 deletions includes/html/pages/wireless.inc.php
Expand Up @@ -43,7 +43,7 @@
$linkoptions .= '<span class="pagemenu-selected">';
}

$linkoptions .= generate_link($details['short'], $link_array, array('metric'=> $type, 'view' => $vars['view']));
$linkoptions .= generate_link(__("wireless.$type.short"), $link_array, array('metric'=> $type, 'view' => $vars['view']));

if ($class == $type) {
$linkoptions .= '</span>';
Expand Down Expand Up @@ -76,7 +76,7 @@

if (isset($valid_wireless_types[$class])) {
$graph_type = 'wireless_' . $class;
$unit = $valid_wireless_types[$class]['unit'];
$unit = __("wireless.$class.unit");
$pagetitle[] = "Wireless :: ".$class;
include \LibreNMS\Config::get('install_dir') . '/includes/html/pages/wireless/sensors.inc.php';
} else {
Expand Down
2 changes: 1 addition & 1 deletion includes/html/table/sensors-common.php
Expand Up @@ -112,7 +112,7 @@

$sensor['sensor_descr'] = substr($sensor['sensor_descr'], 0, 48);

$sensor_current = $graph_type == 'sensor_state' ? get_state_label($sensor) : get_sensor_label_color($sensor);
$sensor_current = $graph_type == 'sensor_state' ? get_state_label($sensor) : get_sensor_label_color($sensor, $translations);

$response[] = array(
'hostname' => generate_device_link($sensor),
Expand Down
1 change: 1 addition & 0 deletions includes/html/table/sensors.inc.php
Expand Up @@ -17,5 +17,6 @@

$table = 'sensors';
$tab = 'health';
$translations = 'sensors';

include 'sensors-common.php';
1 change: 1 addition & 0 deletions includes/html/table/wireless-sensors.inc.php
Expand Up @@ -2,5 +2,6 @@

$table = 'wireless_sensors';
$tab = 'wireless';
$translations = 'wireless';

include 'sensors-common.php';

0 comments on commit f83ce13

Please sign in to comment.