mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Widget Eventlog Sensors Link and Mouseover functionality (#11380)
* Global Settings - Alert Default Settings * Revert "Global Settings - Alert Default Settings" This reverts commita1af62b146
. * Widget Eventlog - Sensors link and overlib Image * travis fix * handling via AppServiceProvider * collect function * Travis ... * static list of Sensor Types * adding all sensor graph_types * remove collect * correct getTypes - remove change to lower case * class sensor_descr switch * class sensor_descr switch - revert * Use standard sensor type names * move types to attribute list * going back to changes from9eee7fad58
Co-authored-by: Tony Murray <murraytony@gmail.com>
This commit is contained in:
@@ -171,6 +171,53 @@ class Url
|
||||
return Rewrite::normalizeIfName($text);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Sensor $sensor
|
||||
* @param string $text
|
||||
* @param string $type
|
||||
* @param boolean $overlib
|
||||
* @param boolean $single_graph
|
||||
* @return mixed|string
|
||||
*/
|
||||
public static function sensorLink($sensor, $text = null, $type = null, $overlib = true, $single_graph = false)
|
||||
{
|
||||
|
||||
$label = $sensor->sensor_descr;
|
||||
if (!$text) {
|
||||
$text = $label;
|
||||
}
|
||||
|
||||
$content = '<div class=list-large>' . addslashes(htmlentities($sensor->device->displayName() . ' - ' . $label)) . '</div>';
|
||||
|
||||
$content .= "<div style=\'width: 850px\'>";
|
||||
$graph_array = [
|
||||
'type' => $type ?: 'sensor_' . $sensor->sensor_class,
|
||||
'legend' => 'yes',
|
||||
'height' => 100,
|
||||
'width' => 340,
|
||||
'to' => Carbon::now()->timestamp,
|
||||
'from' => Carbon::now()->subDay()->timestamp,
|
||||
'id' => $sensor->sensor_id,
|
||||
];
|
||||
|
||||
$content .= self::graphTag($graph_array);
|
||||
if (!$single_graph) {
|
||||
$graph_array['from'] = Carbon::now()->subWeek()->timestamp;
|
||||
$content .= self::graphTag($graph_array);
|
||||
$graph_array['from'] = Carbon::now()->subMonth()->timestamp;
|
||||
$content .= self::graphTag($graph_array);
|
||||
$graph_array['from'] = Carbon::now()->subYear()->timestamp;
|
||||
$content .= self::graphTag($graph_array);
|
||||
}
|
||||
|
||||
$content .= '</div>';
|
||||
|
||||
if (!$overlib) {
|
||||
return $content;
|
||||
}
|
||||
return self::overlibLink(self::sensorUrl($sensor), $text, $content, self::sensorLinkDisplayClass($sensor));
|
||||
}
|
||||
|
||||
public static function deviceUrl($device, $vars = [])
|
||||
{
|
||||
return self::generate(['page' => 'device', 'device' => $device->device_id], $vars);
|
||||
@@ -181,6 +228,11 @@ class Url
|
||||
return self::generate(['page' => 'device', 'device' => $port->device_id, 'tab' => 'port', 'port' => $port->port_id], $vars);
|
||||
}
|
||||
|
||||
public static function sensorUrl($sensor, $vars = [])
|
||||
{
|
||||
return self::generate(['page' => 'device', 'device' => $sensor->device_id, 'tab' => 'health' , 'metric' => $sensor->sensor_class], $vars);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Port $port
|
||||
* @return string
|
||||
@@ -369,6 +421,25 @@ class Url
|
||||
return "interface-upup";
|
||||
}
|
||||
|
||||
/**
|
||||
* Get html class for a sensor
|
||||
*
|
||||
* @param Sensor $sensor
|
||||
* @return string
|
||||
*/
|
||||
public static function sensorLinkDisplayClass($sensor)
|
||||
{
|
||||
if ($sensor->sensor_current >> $sensor->sensor_limit) {
|
||||
return "sensor-high";
|
||||
}
|
||||
|
||||
if ($sensor->sensor_current << $sensor->sensor_limit_low) {
|
||||
return "sensor-low";
|
||||
}
|
||||
|
||||
return 'sensor-ok';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $os
|
||||
* @param string $feature
|
||||
|
Reference in New Issue
Block a user