mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Use sensor labels for overview/inventory pages, refactor some html-page related code (#10287)
* Refactor: use get_state_label() for the overview
* Move state translation to get_state_label()
Several html pages used similar database calls and sometimes very
different methodology to determine the state label and state text
before calling get_state_label(), so moved that part of the task
into the function itself instead of replicating the same code
multiple times on different pages.
* Move label creation to get_sensor_label_color()
Also removed a duplicate sensor class to unit function.
* Refactor some if/else statements for simplicity.
* Enable state translations for the inventory page.
* Remove blank line found at end of control structure
* Enable unit translation, fix typos.
* Change to dbFetchRow(), return string directly.
* Update functions.inc.php
* Stop displaying the raw value on state labels.
* Apply 1c7c3ca change for default case too.
This commit is contained in:
committed by
Tony Murray
parent
ebd004edc7
commit
9d68f27296
@@ -112,18 +112,7 @@ foreach (dbFetchRows($sql, $param) as $sensor) {
|
||||
|
||||
$sensor['sensor_descr'] = substr($sensor['sensor_descr'], 0, 48);
|
||||
|
||||
if ($graph_type == 'sensor_state') {
|
||||
// If we have a state, let's display a label with textual state translation
|
||||
$state_translation = array();
|
||||
$state_translation = dbFetchRows('SELECT * FROM state_translations as ST, sensors_to_state_indexes as SSI WHERE ST.state_index_id=SSI.state_index_id AND SSI.sensor_id = ? AND ST.state_value = ? ', array($sensor['sensor_id'], $sensor['sensor_current']));
|
||||
|
||||
//$current_label = get_state_label_color($sensor);
|
||||
$sensor_current = get_state_label($state_translation['0']['state_generic_value'], (!empty($state_translation['0']['state_descr'])) ? $state_translation[0]['state_descr'] . " (".$sensor['sensor_current'].")" : $sensor['sensor_current']);
|
||||
} else {
|
||||
// we have another sensor
|
||||
$current_label = get_sensor_label_color($sensor);
|
||||
$sensor_current = "<span class='label $current_label'>".format_si($sensor['sensor_current']).$unit."</span>";
|
||||
}
|
||||
$sensor_current = $graph_type == 'sensor_state' ? get_state_label($sensor) : get_sensor_label_color($sensor);
|
||||
|
||||
$response[] = array(
|
||||
'hostname' => generate_device_link($sensor),
|
||||
|
||||
Reference in New Issue
Block a user