Files
librenms-librenms/app/Models/Sensor.php
SourceDoctor cc2894c0df Widget Eventlog Sensors Link and Mouseover functionality (#11380)
* Global Settings - Alert Default Settings

* Revert "Global Settings - Alert Default Settings"

This reverts commit a1af62b146.

* 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 from 9eee7fad58

Co-authored-by: Tony Murray <murraytony@gmail.com>
2020-04-19 12:57:49 -05:00

73 lines
2.2 KiB
PHP

<?php
namespace App\Models;
class Sensor extends DeviceRelatedModel
{
public $timestamps = false;
protected $primaryKey = 'sensor_id';
protected static $icons = [
'airflow' => 'angle-double-right',
'ber' => 'sort-amount-desc',
'charge' => 'battery-half',
'chromatic_dispersion' => 'indent',
'cooling' => 'thermometer-full',
'count' => 'hashtag',
'current' => 'bolt fa-flip-horizontal',
'dbm' => 'sun-o',
'delay' => 'clock-o',
'eer' => 'snowflake-o',
'fanspeed' => 'refresh',
'frequency' => 'line-chart',
'humidity' => 'tint',
'load' => 'percent',
'power' => 'power-off',
'power_consumed' => 'plug',
'power_factor' => 'calculator',
'pressure' => 'thermometer-empty',
'quality_factor' => 'arrows',
'runtime' => 'hourglass-half',
'signal' => 'wifi',
'snr' => 'signal',
'state' => 'bullseye',
'temperature' => 'thermometer-three-quarters',
'voltage' => 'bolt',
'waterflow' => 'tint',
];
// ---- Helper Functions ----
public function classDescr()
{
$nice = collect([
'ber' => 'BER',
'dbm' => 'dBm',
'eer' => 'EER',
'snr' => 'SNR',
]);
return $nice->get($this->sensor_class, ucwords(str_replace('_', ' ', $this->sensor_class)));
}
public function icon()
{
return collect(self::$icons)->get($this->sensor_class, 'delicius');
}
public static function getTypes()
{
return array_keys(self::$icons);
}
// for the legacy menu
public static function getIconMap()
{
return self::$icons;
}
// ---- Define Relationships ----
public function events()
{
return $this->morphMany(Eventlog::class, 'events', 'type', 'reference');
}
}