From beb5f27d52a9223b1d8c5f1e92928f5d3ce66da0 Mon Sep 17 00:00:00 2001 From: Tony Murray Date: Tue, 3 Dec 2024 01:34:27 +0000 Subject: [PATCH] Apply fixes from StyleCI --- LibreNMS/Data/ChartData.php | 18 +++++++++--------- LibreNMS/Data/ChartDataset.php | 3 ++- LibreNMS/Data/Source/RrdCommand.php | 5 ++--- app/Filament/Pages/Dashboard.php | 1 - app/Filament/Widgets/DeviceTypeCounts.php | 2 +- app/Filament/Widgets/Graph.php | 3 +-- app/Filament/Widgets/NetworkChart.php | 6 +++--- .../Filament/LibrenmsPanelProvider.php | 2 +- 8 files changed, 19 insertions(+), 21 deletions(-) diff --git a/LibreNMS/Data/ChartData.php b/LibreNMS/Data/ChartData.php index 5dde4dc14947..ae8acde633b7 100644 --- a/LibreNMS/Data/ChartData.php +++ b/LibreNMS/Data/ChartData.php @@ -8,7 +8,8 @@ protected function __construct( protected string $format, protected array $data, protected array $map = [], - ) {} + ) { + } public static function createFromRrd(array $legend, array $data): static { @@ -22,7 +23,7 @@ public static function createFromRrd(array $legend, array $data): static } /** - * @param ChartDataset[] $chartDatasets + * @param ChartDataset[] $chartDatasets * @return array */ public function forChartJs(array $chartDatasets): array @@ -33,15 +34,15 @@ public function forChartJs(array $chartDatasets): array $timestamp_index = $this->map['_timestamp']; $ds = array_diff_key($this->map, ['_timestamp' => null]); - foreach($this->data as $point) { - foreach($ds as $name => $index) { + foreach ($this->data as $point) { + foreach ($ds as $name => $index) { $data[$name][] = ['x' => (int) $point[$timestamp_index] * 1000, 'y' => $point[$index]]; } } } $datasets = []; - foreach($chartDatasets as $ds) { + foreach ($chartDatasets as $ds) { $datasets[] = [ 'label' => $ds->label, 'data' => $data[$ds->name], @@ -57,7 +58,7 @@ public function forChartJs(array $chartDatasets): array } /** - * @param ChartDataset[] $chartDatasets + * @param ChartDataset[] $chartDatasets * @return array */ public function forApexCharts(array $chartDatasets): array @@ -74,9 +75,8 @@ public function forApexCharts(array $chartDatasets): array $output[$ds[$chartDataset->name]]['color'] = $chartDataset->color; } - - foreach($this->data as $point) { - foreach($ds as $name => $index) { + foreach ($this->data as $point) { + foreach ($ds as $name => $index) { $output[$index]['data'][] = [(int) $point[$timestamp_index] * 1000, $point[$index]]; } } diff --git a/LibreNMS/Data/ChartDataset.php b/LibreNMS/Data/ChartDataset.php index 6d6a08bd2e4d..45cb41694317 100644 --- a/LibreNMS/Data/ChartDataset.php +++ b/LibreNMS/Data/ChartDataset.php @@ -9,5 +9,6 @@ public function __construct( public string $label, public ?string $color = null, public ?string $fill = null, - ){} + ) { + } } diff --git a/LibreNMS/Data/Source/RrdCommand.php b/LibreNMS/Data/Source/RrdCommand.php index 2d8c994c0788..9cbe41b2e79b 100644 --- a/LibreNMS/Data/Source/RrdCommand.php +++ b/LibreNMS/Data/Source/RrdCommand.php @@ -24,7 +24,6 @@ public static function make(int $start, ?int $end = null): static public function get(): array { - } public function def(string $label, string $dataset, string $rrd = null, RrdCF $consolidationFunction = RrdCF::AVERAGE): static @@ -55,7 +54,7 @@ public function graph(): string public function xport(array $defs): ChartData { // set up XPORT options either ds only or ds => label - foreach($defs as $def) { + foreach ($defs as $def) { $this->options[] = "XPORT:$def:$def"; } @@ -86,7 +85,7 @@ private function run(string $command): string $proc->run(); $error = $proc->getErrorOutput(); - if($error) { + if ($error) { throw new \Exception($error); } diff --git a/app/Filament/Pages/Dashboard.php b/app/Filament/Pages/Dashboard.php index 21b551dd449e..898c3c2c4935 100644 --- a/app/Filament/Pages/Dashboard.php +++ b/app/Filament/Pages/Dashboard.php @@ -4,5 +4,4 @@ class Dashboard extends \Filament\Pages\Dashboard { - } diff --git a/app/Filament/Widgets/DeviceTypeCounts.php b/app/Filament/Widgets/DeviceTypeCounts.php index 0c431f91fad9..e39fd2cca288 100644 --- a/app/Filament/Widgets/DeviceTypeCounts.php +++ b/app/Filament/Widgets/DeviceTypeCounts.php @@ -15,7 +15,7 @@ protected function getStats(): array ->select('type', DB::raw('count(*) total')) ->groupBy('type') ->get() - ->map(fn($t) => Stat::make(Str::title($t->type ?: 'None'), $t->total)) + ->map(fn ($t) => Stat::make(Str::title($t->type ?: 'None'), $t->total)) ->all(); } } diff --git a/app/Filament/Widgets/Graph.php b/app/Filament/Widgets/Graph.php index 905b3f2981ef..99918a165956 100644 --- a/app/Filament/Widgets/Graph.php +++ b/app/Filament/Widgets/Graph.php @@ -5,7 +5,6 @@ use App\Models\Device; use Filament\Widgets\ChartWidget; use LibreNMS\Data\ChartDataset; -use LibreNMS\Data\ChartDatasets; use LibreNMS\Data\Source\RrdCommand; class Graph extends ChartWidget @@ -44,7 +43,7 @@ protected function getType(): string return 'line'; } - protected int | string | array $columnSpan = [ + protected int|string|array $columnSpan = [ 'md' => 2, 'xl' => 3, ]; diff --git a/app/Filament/Widgets/NetworkChart.php b/app/Filament/Widgets/NetworkChart.php index e2f098a3beca..c273d4f7a851 100644 --- a/app/Filament/Widgets/NetworkChart.php +++ b/app/Filament/Widgets/NetworkChart.php @@ -44,7 +44,7 @@ protected function getFormSchema(): array TextInput::make('title') ->default('NetworkChart'), -// ->reactive(), + // ->reactive(), DateRangePicker::make('timerange') ->ranges(self::$timeRanges) @@ -98,7 +98,7 @@ protected function getOptions(): array 'series' => $series, 'xaxis' => [ 'type' => 'datetime', -// 'range' => 'XAXISRANGE', + // 'range' => 'XAXISRANGE', 'labels' => [ 'style' => [ 'fontFamily' => 'inherit', @@ -112,7 +112,7 @@ protected function getOptions(): array ], ], ], -// 'colors' => ['#82b52d', '#8989c9'], + // 'colors' => ['#82b52d', '#8989c9'], 'stroke' => [ 'curve' => 'smooth', ], diff --git a/app/Providers/Filament/LibrenmsPanelProvider.php b/app/Providers/Filament/LibrenmsPanelProvider.php index 50506b7eae77..da3e7cd1e12f 100644 --- a/app/Providers/Filament/LibrenmsPanelProvider.php +++ b/app/Providers/Filament/LibrenmsPanelProvider.php @@ -31,7 +31,7 @@ public function panel(Panel $panel): Panel 'primary' => Color::Amber, ]) ->plugins([ - FilamentApexChartsPlugin::make() + FilamentApexChartsPlugin::make(), ]) ->discoverResources(in: app_path('Filament/Resources'), for: 'App\\Filament\\Resources') ->discoverPages(in: app_path('Filament/Pages'), for: 'App\\Filament\\Pages')