Skip to content

Commit

Permalink
Apply fixes from StyleCI
Browse files Browse the repository at this point in the history
  • Loading branch information
murrant authored and StyleCIBot committed Dec 3, 2024
1 parent 3d35371 commit beb5f27
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 21 deletions.
18 changes: 9 additions & 9 deletions LibreNMS/Data/ChartData.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -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
Expand All @@ -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],
Expand All @@ -57,7 +58,7 @@ public function forChartJs(array $chartDatasets): array
}

/**
* @param ChartDataset[] $chartDatasets
* @param ChartDataset[] $chartDatasets
* @return array
*/
public function forApexCharts(array $chartDatasets): array
Expand All @@ -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]];
}
}
Expand Down
3 changes: 2 additions & 1 deletion LibreNMS/Data/ChartDataset.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ public function __construct(
public string $label,
public ?string $color = null,
public ?string $fill = null,
){}
) {
}
}
5 changes: 2 additions & 3 deletions LibreNMS/Data/Source/RrdCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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";
}

Expand Down Expand Up @@ -86,7 +85,7 @@ private function run(string $command): string
$proc->run();

$error = $proc->getErrorOutput();
if($error) {
if ($error) {
throw new \Exception($error);
}

Expand Down
1 change: 0 additions & 1 deletion app/Filament/Pages/Dashboard.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,4 @@

class Dashboard extends \Filament\Pages\Dashboard
{

}
2 changes: 1 addition & 1 deletion app/Filament/Widgets/DeviceTypeCounts.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
3 changes: 1 addition & 2 deletions app/Filament/Widgets/Graph.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -44,7 +43,7 @@ protected function getType(): string
return 'line';
}

protected int | string | array $columnSpan = [
protected int|string|array $columnSpan = [
'md' => 2,
'xl' => 3,
];
Expand Down
6 changes: 3 additions & 3 deletions app/Filament/Widgets/NetworkChart.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ protected function getFormSchema(): array

TextInput::make('title')
->default('NetworkChart'),
// ->reactive(),
// ->reactive(),

DateRangePicker::make('timerange')
->ranges(self::$timeRanges)
Expand Down Expand Up @@ -98,7 +98,7 @@ protected function getOptions(): array
'series' => $series,
'xaxis' => [
'type' => 'datetime',
// 'range' => 'XAXISRANGE',
// 'range' => 'XAXISRANGE',
'labels' => [
'style' => [
'fontFamily' => 'inherit',
Expand All @@ -112,7 +112,7 @@ protected function getOptions(): array
],
],
],
// 'colors' => ['#82b52d', '#8989c9'],
// 'colors' => ['#82b52d', '#8989c9'],
'stroke' => [
'curve' => 'smooth',
],
Expand Down
2 changes: 1 addition & 1 deletion app/Providers/Filament/LibrenmsPanelProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down

0 comments on commit beb5f27

Please sign in to comment.