From f83ce13a7adbf6069b62bed727c7853c1c744399 Mon Sep 17 00:00:00 2001 From: Tony Murray Date: Tue, 2 Jul 2019 07:11:58 -0500 Subject: [PATCH] Fixed tabs and units on the wireless page (#10401) --- includes/html/functions.inc.php | 7 +++++-- includes/html/pages/wireless.inc.php | 4 ++-- includes/html/table/sensors-common.php | 2 +- includes/html/table/sensors.inc.php | 1 + includes/html/table/wireless-sensors.inc.php | 1 + 5 files changed, 10 insertions(+), 5 deletions(-) diff --git a/includes/html/functions.inc.php b/includes/html/functions.inc.php index 6c08054b8e..10f1a24917 100644 --- a/includes/html/functions.inc.php +++ b/includes/html/functions.inc.php @@ -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)) { @@ -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 "".trim(format_si($sensor['sensor_current']).$unit).""; } diff --git a/includes/html/pages/wireless.inc.php b/includes/html/pages/wireless.inc.php index 9420c545a5..d0094a1516 100644 --- a/includes/html/pages/wireless.inc.php +++ b/includes/html/pages/wireless.inc.php @@ -43,7 +43,7 @@ foreach ($valid_wireless_types as $type => $details) { $linkoptions .= ''; } - $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 .= ''; @@ -76,7 +76,7 @@ if ($vars['view'] != "graphs") { 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 { diff --git a/includes/html/table/sensors-common.php b/includes/html/table/sensors-common.php index e571990e09..6a96071d3e 100644 --- a/includes/html/table/sensors-common.php +++ b/includes/html/table/sensors-common.php @@ -112,7 +112,7 @@ foreach (dbFetchRows($sql, $param) as $sensor) { $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), diff --git a/includes/html/table/sensors.inc.php b/includes/html/table/sensors.inc.php index 471c04ea02..c308075a52 100644 --- a/includes/html/table/sensors.inc.php +++ b/includes/html/table/sensors.inc.php @@ -17,5 +17,6 @@ $table = 'sensors'; $tab = 'health'; +$translations = 'sensors'; include 'sensors-common.php'; diff --git a/includes/html/table/wireless-sensors.inc.php b/includes/html/table/wireless-sensors.inc.php index 0df3452aa1..c9ed411de7 100644 --- a/includes/html/table/wireless-sensors.inc.php +++ b/includes/html/table/wireless-sensors.inc.php @@ -2,5 +2,6 @@ $table = 'wireless_sensors'; $tab = 'wireless'; +$translations = 'wireless'; include 'sensors-common.php';