mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
* WIP Device Ports porting to Laravel * WIP port links * Port Links WIP * Port Links * in_array -> isset * Add request to DeviceTab data * Add initial Pagination * Missing select component * Collapsed and expandable port neighbors New expandable component * Port sorting * Fix port transfer * Use menu entries to filter ports * Add translatable strings * style fixes and cleanup * update css * graph views and tidy controller basic port link view * cleanup * port row blade to reuse in legacy port view * Legacy tab url handling work properly in subdirectory remove includes from sub tab directory to prevent oddity * fallback to detail list when the view doesn't exist * Use named variable to simplify * Fix issue from file that was a symlink * Submenu handle sub items and query string urls * extract pageLinks to improve readability * fix typo * Apply fixes from StyleCI * phpstan was not happy using the relationship HasMany query * Don't allow *bps etc to be on a second line * Improve table on small screens * Fix sort --------- Co-authored-by: Tony Murray <murrant@users.noreply.github.com>
93 lines
1.8 KiB
PHP
93 lines
1.8 KiB
PHP
<?php
|
|
|
|
namespace App\View\Components;
|
|
|
|
use Illuminate\View\Component;
|
|
|
|
class Submenu extends Component
|
|
{
|
|
/**
|
|
* The submenu title.
|
|
*
|
|
* @var string
|
|
*/
|
|
public $title;
|
|
|
|
/**
|
|
* The submenu menu.
|
|
*
|
|
* @var string
|
|
*/
|
|
public $menu;
|
|
|
|
/**
|
|
* The submenu device_id.
|
|
*
|
|
* @var string
|
|
*/
|
|
public $device_id;
|
|
|
|
/**
|
|
* The submenu current_tab.
|
|
*
|
|
* @var string
|
|
*/
|
|
public $current_tab;
|
|
|
|
/**
|
|
* The submenu selected.
|
|
*
|
|
* @var string
|
|
*/
|
|
public $selected;
|
|
|
|
/**
|
|
* Create a new component instance.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function __construct($title, $menu, $deviceId, $currentTab, $selected)
|
|
{
|
|
$this->title = $title;
|
|
$this->menu = $menu;
|
|
$this->device_id = $deviceId;
|
|
$this->current_tab = $currentTab;
|
|
$this->selected = $selected;
|
|
}
|
|
|
|
/**
|
|
* Determine if the given option is the current selected option.
|
|
*
|
|
* @param string $url
|
|
* @return bool
|
|
*/
|
|
public function isSelected($url)
|
|
{
|
|
// check for get parameters
|
|
$parsed_url = parse_url($url);
|
|
if (isset($parsed_url['query']) && $parsed_url['path'] === $this->selected) {
|
|
parse_str($parsed_url['query'], $vars);
|
|
$request = request();
|
|
foreach ($vars as $key => $value) {
|
|
if ($request->input($key) !== $value) {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
return $url === $this->selected;
|
|
}
|
|
|
|
/**
|
|
* Get the view / contents that represent the component.
|
|
*
|
|
* @return \Illuminate\View\View|string
|
|
*/
|
|
public function render()
|
|
{
|
|
return view('components.submenu');
|
|
}
|
|
}
|