Files
librenms-librenms/app/View/Components/DeviceLink.php
Tony Murray c5b63bde86 New Blade Components: x-device-link, x-port-link, x-graph-row, x-popup (#13197)
* working popover

* popup component

* cleanup

* finalize device-link component

* attributes WIP

* working graph component

* widgets WIP

* More dynamic configs

* Graph row component

* Build CSS so we can use a dark theme

* graph row set columns

* only one popup visible at a time.

* Just set graph row width statically

* responsive WIP

* rsponsive option for graph-row "working"

* remove @deviceLink and @portLink

* fix non-responsive graph row

* update js/css

* fix style

* bad type?

* types

* types

* types #3

* remove testing code

* full rebel, no closing tags for meta and link

* match previous formatting

* fix vlans display

* restore newline

* remove silly comment

* remove unused line

* style I guess
2021-09-10 08:07:08 -05:00

67 lines
1.5 KiB
PHP

<?php
namespace App\View\Components;
use App\Facades\DeviceCache;
use App\Models\Device;
use Illuminate\View\Component;
use LibreNMS\Util\Graph;
class DeviceLink extends Component
{
/**
* @var \App\Models\Device
*/
public $device;
/**
* @var string|null
*/
public $tab;
/**
* @var string|null
*/
public $section;
/**
* @var string
*/
public $status;
/**
* Create a new component instance.
*
* @param int|\App\Models\Device $device
*/
public function __construct($device, ?string $tab = null, ?string $section = null)
{
$this->device = $device instanceof Device ? $device : DeviceCache::get($device);
$this->tab = $tab;
$this->section = $section;
$this->status = $this->status();
}
/**
* Get the view / contents that represent the component.
*
* @return \Illuminate\Contracts\View\View|\Closure|string
*/
public function render()
{
if (! $this->device->canAccess(auth()->user())) {
return view('components.device-link-no-access');
}
return view('components.device-link', [
'graphs' => Graph::getOverviewGraphsForDevice($this->device),
]);
}
public function status(): string
{
if ($this->device->disabled) {
return 'disabled';
}
return $this->device->status ? 'up' : ($this->device->ignore ? 'disabled' : 'down');
}
}