Skip to content

Commit

Permalink
Ports UI update (#16115)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
murrant and murrant committed Jun 16, 2024
1 parent a717e08 commit 075ba4c
Show file tree
Hide file tree
Showing 86 changed files with 1,135 additions and 990 deletions.
4 changes: 3 additions & 1 deletion LibreNMS/Interfaces/UI/DeviceTab.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
namespace LibreNMS\Interfaces\UI;

use App\Models\Device;
use Illuminate\Http\Request;

interface DeviceTab
{
Expand Down Expand Up @@ -62,7 +63,8 @@ public function name(): string;
* Collect data to send to the view
*
* @param Device $device
* @param Request $request
* @return array
*/
public function data(Device $device): array;
public function data(Device $device, Request $request): array;
}
9 changes: 9 additions & 0 deletions LibreNMS/Util/Color.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,15 @@ public static function percentage($percentage, $component_perc_warn = null): arr
];
}

public static function percent(int|float $numerator = null, int|float $denominator = null, int|float $percent = null): string
{
$percent = $percent ? round($percent) : Number::calculatePercent($numerator, $denominator, 0);
$r = min(255, 5 * ($percent - 25));
$b = max(0, 255 - (5 * ($percent + 25)));

return sprintf('#%02x%02x%02x', $r, $b, $b);
}

/**
* Get highlight color based on device status
*/
Expand Down
12 changes: 12 additions & 0 deletions LibreNMS/Util/Rewrite.php
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,18 @@ public static function location($location)
return $location;
}

public static function dslLineType(string $lineType): string
{
return match ($lineType) {
'noChannel' => 'No Channel',
'fastOnly' => 'Fastpath',
'interleavedOnly' => 'Interleaved',
'fastOrInterleaved' => 'Fast/Interleaved',
'fastAndInterleaved' => 'Fast+Interleaved',
default => $lineType,
};
}

public static function vmwareGuest($guest_id)
{
$guests = [
Expand Down
3 changes: 2 additions & 1 deletion app/Http/Controllers/Device/Tabs/AccessPointsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
namespace App\Http\Controllers\Device\Tabs;

use App\Models\Device;
use Illuminate\Http\Request;
use LibreNMS\Interfaces\UI\DeviceTab;

class AccessPointsController implements DeviceTab
Expand All @@ -50,7 +51,7 @@ public function name(): string
return __('Access Points');
}

public function data(Device $device): array
public function data(Device $device, Request $request): array
{
return [];
}
Expand Down
3 changes: 2 additions & 1 deletion app/Http/Controllers/Device/Tabs/AlertStatsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
namespace App\Http\Controllers\Device\Tabs;

use App\Models\Device;
use Illuminate\Http\Request;
use LibreNMS\Interfaces\UI\DeviceTab;

class AlertStatsController implements DeviceTab
Expand All @@ -50,7 +51,7 @@ public function name(): string
return __('Alert Stats');
}

public function data(Device $device): array
public function data(Device $device, Request $request): array
{
return [];
}
Expand Down
3 changes: 2 additions & 1 deletion app/Http/Controllers/Device/Tabs/AlertsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
namespace App\Http\Controllers\Device\Tabs;

use App\Models\Device;
use Illuminate\Http\Request;
use LibreNMS\Interfaces\UI\DeviceTab;

class AlertsController implements DeviceTab
Expand All @@ -50,7 +51,7 @@ public function name(): string
return __('Alerts');
}

public function data(Device $device): array
public function data(Device $device, Request $request): array
{
return [];
}
Expand Down
3 changes: 2 additions & 1 deletion app/Http/Controllers/Device/Tabs/AppsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
namespace App\Http\Controllers\Device\Tabs;

use App\Models\Device;
use Illuminate\Http\Request;
use LibreNMS\Interfaces\UI\DeviceTab;

class AppsController implements DeviceTab
Expand All @@ -50,7 +51,7 @@ public function name(): string
return __('Apps');
}

public function data(Device $device): array
public function data(Device $device, Request $request): array
{
return [];
}
Expand Down
3 changes: 2 additions & 1 deletion app/Http/Controllers/Device/Tabs/CaptureController.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
namespace App\Http\Controllers\Device\Tabs;

use App\Models\Device;
use Illuminate\Http\Request;

class CaptureController implements \LibreNMS\Interfaces\UI\DeviceTab
{
Expand All @@ -49,7 +50,7 @@ public function name(): string
return __('Capture');
}

public function data(Device $device): array
public function data(Device $device, Request $request): array
{
return [];
}
Expand Down
3 changes: 2 additions & 1 deletion app/Http/Controllers/Device/Tabs/CollectdController.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
namespace App\Http\Controllers\Device\Tabs;

use App\Models\Device;
use Illuminate\Http\Request;
use LibreNMS\Config;
use LibreNMS\Interfaces\UI\DeviceTab;

Expand All @@ -51,7 +52,7 @@ public function name(): string
return __('CollectD');
}

public function data(Device $device): array
public function data(Device $device, Request $request): array
{
return [];
}
Expand Down
3 changes: 2 additions & 1 deletion app/Http/Controllers/Device/Tabs/EditController.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
namespace App\Http\Controllers\Device\Tabs;

use App\Models\Device;
use Illuminate\Http\Request;

class EditController implements \LibreNMS\Interfaces\UI\DeviceTab
{
Expand All @@ -49,7 +50,7 @@ public function name(): string
return __('Edit');
}

public function data(Device $device): array
public function data(Device $device, Request $request): array
{
return [];
}
Expand Down
3 changes: 2 additions & 1 deletion app/Http/Controllers/Device/Tabs/GraphsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
namespace App\Http\Controllers\Device\Tabs;

use App\Models\Device;
use Illuminate\Http\Request;
use LibreNMS\Interfaces\UI\DeviceTab;

class GraphsController implements DeviceTab
Expand All @@ -50,7 +51,7 @@ public function name(): string
return __('Graphs');
}

public function data(Device $device): array
public function data(Device $device, Request $request): array
{
return [];
}
Expand Down
3 changes: 2 additions & 1 deletion app/Http/Controllers/Device/Tabs/HealthController.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
namespace App\Http\Controllers\Device\Tabs;

use App\Models\Device;
use Illuminate\Http\Request;
use LibreNMS\Interfaces\UI\DeviceTab;

class HealthController implements DeviceTab
Expand All @@ -50,7 +51,7 @@ public function name(): string
return __('Health');
}

public function data(Device $device): array
public function data(Device $device, Request $request): array
{
return [];
}
Expand Down
3 changes: 2 additions & 1 deletion app/Http/Controllers/Device/Tabs/InventoryController.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

use App\Facades\DeviceCache;
use App\Models\Device;
use Illuminate\Http\Request;
use LibreNMS\Config;
use LibreNMS\Interfaces\UI\DeviceTab;

Expand Down Expand Up @@ -67,7 +68,7 @@ public function name(): string
return __('Inventory');
}

public function data(Device $device): array
public function data(Device $device, Request $request): array
{
return [
'tab' => $this->type, // inject to load correct legacy file
Expand Down
8 changes: 4 additions & 4 deletions app/Http/Controllers/Device/Tabs/LatencyController.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@

use App\Models\Device;
use Carbon\Carbon;
use Illuminate\Http\Request;
use LibreNMS\Config;
use LibreNMS\Interfaces\UI\DeviceTab;
use LibreNMS\Util\Smokeping;
use Request;

class LatencyController implements DeviceTab
{
Expand All @@ -54,10 +54,10 @@ public function name(): string
return __('Latency');
}

public function data(Device $device): array
public function data(Device $device, Request $request): array
{
$from = Request::get('dtpickerfrom', Carbon::now(session('preferences.timezone'))->subDays(2)->format(Config::get('dateformat.byminute')));
$to = Request::get('dtpickerto', Carbon::now(session('preferences.timezone'))->format(Config::get('dateformat.byminute')));
$from = $request->get('dtpickerfrom', Carbon::now(session('preferences.timezone'))->subDays(2)->format(Config::get('dateformat.byminute')));
$to = $request->get('dtpickerto', Carbon::now(session('preferences.timezone'))->format(Config::get('dateformat.byminute')));

$smokeping = new Smokeping($device);
$smokeping_tabs = [];
Expand Down
3 changes: 2 additions & 1 deletion app/Http/Controllers/Device/Tabs/LoadBalancerController.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

use App\Facades\DeviceCache;
use App\Models\Device;
use Illuminate\Http\Request;
use LibreNMS\Interfaces\UI\DeviceTab;

class LoadBalancerController implements DeviceTab
Expand Down Expand Up @@ -93,7 +94,7 @@ public function name(): string
return __('Load Balancer');
}

public function data(Device $device): array
public function data(Device $device, Request $request): array
{
return [
'loadbalancer_tabs' => $this->tabs,
Expand Down
3 changes: 2 additions & 1 deletion app/Http/Controllers/Device/Tabs/LogsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
namespace App\Http\Controllers\Device\Tabs;

use App\Models\Device;
use Illuminate\Http\Request;
use LibreNMS\Interfaces\UI\DeviceTab;

class LogsController implements DeviceTab
Expand All @@ -50,7 +51,7 @@ public function name(): string
return __('Logs');
}

public function data(Device $device): array
public function data(Device $device, Request $request): array
{
return [];
}
Expand Down
3 changes: 2 additions & 1 deletion app/Http/Controllers/Device/Tabs/MefController.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
namespace App\Http\Controllers\Device\Tabs;

use App\Models\Device;
use Illuminate\Http\Request;
use LibreNMS\Interfaces\UI\DeviceTab;

class MefController implements DeviceTab
Expand All @@ -50,7 +51,7 @@ public function name(): string
return __('Metro Ethernet');
}

public function data(Device $device): array
public function data(Device $device, Request $request): array
{
return [];
}
Expand Down
3 changes: 2 additions & 1 deletion app/Http/Controllers/Device/Tabs/MuninController.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
namespace App\Http\Controllers\Device\Tabs;

use App\Models\Device;
use Illuminate\Http\Request;
use LibreNMS\Interfaces\UI\DeviceTab;

class MuninController implements DeviceTab
Expand All @@ -50,7 +51,7 @@ public function name(): string
return __('Munin');
}

public function data(Device $device): array
public function data(Device $device, Request $request): array
{
return [];
}
Expand Down
3 changes: 2 additions & 1 deletion app/Http/Controllers/Device/Tabs/NacController.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
namespace App\Http\Controllers\Device\Tabs;

use App\Models\Device;
use Illuminate\Http\Request;
use LibreNMS\Interfaces\UI\DeviceTab;

class NacController implements DeviceTab
Expand All @@ -50,7 +51,7 @@ public function name(): string
return __('NAC');
}

public function data(Device $device): array
public function data(Device $device, Request $request): array
{
return [];
}
Expand Down
3 changes: 2 additions & 1 deletion app/Http/Controllers/Device/Tabs/NeighboursController.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

use App\Models\Device;
use App\Models\Link;
use Illuminate\Http\Request;
use LibreNMS\Interfaces\UI\DeviceTab;

class NeighboursController implements DeviceTab
Expand All @@ -53,7 +54,7 @@ public function name(): string
return __('Neighbours');
}

public function data(Device $device): array
public function data(Device $device, Request $request): array
{
return [];
}
Expand Down
3 changes: 2 additions & 1 deletion app/Http/Controllers/Device/Tabs/NetflowController.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
namespace App\Http\Controllers\Device\Tabs;

use App\Models\Device;
use Illuminate\Http\Request;
use LibreNMS\Config;
use LibreNMS\Interfaces\UI\DeviceTab;

Expand Down Expand Up @@ -72,7 +73,7 @@ public function name(): string
return __('Netflow');
}

public function data(Device $device): array
public function data(Device $device, Request $request): array
{
return [
'tab' => 'nfsen',
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/Device/Tabs/NotesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public function name(): string
return __('Notes');
}

public function data(Device $device): array
public function data(Device $device, Request $request): array
{
return [];
}
Expand Down
3 changes: 2 additions & 1 deletion app/Http/Controllers/Device/Tabs/OverviewController.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
namespace App\Http\Controllers\Device\Tabs;

use App\Models\Device;
use Illuminate\Http\Request;
use LibreNMS\Interfaces\UI\DeviceTab;
use Session;

Expand All @@ -51,7 +52,7 @@ public function name(): string
return __('Overview');
}

public function data(Device $device): array
public function data(Device $device, Request $request): array
{
return [];
}
Expand Down
Loading

0 comments on commit 075ba4c

Please sign in to comment.