mirror of
https://github.com/vitodeploy/vito.git
synced 2025-07-04 07:22:34 +00:00
Add phpstan level 7(#544)
This commit is contained in:
@ -20,19 +20,25 @@ class FilterForm extends Widget implements HasForms
|
||||
|
||||
protected static string $view = 'components.form';
|
||||
|
||||
/**
|
||||
* @var ?array<string, mixed>
|
||||
*/
|
||||
public ?array $data = [
|
||||
'period' => '1h',
|
||||
'from' => null,
|
||||
'to' => null,
|
||||
];
|
||||
|
||||
public function updated($name, $value): void
|
||||
public function updated(string $name, mixed $value): void
|
||||
{
|
||||
if ($value !== 'custom') {
|
||||
$this->dispatch('updateFilters', filters: $this->data);
|
||||
}
|
||||
|
||||
if ($value === 'custom' && $this->data['from'] && $this->data['to']) {
|
||||
$from = $this->data['from'] ?? null;
|
||||
$to = $this->data['to'] ?? null;
|
||||
|
||||
if ($value === 'custom' && $from && $to) {
|
||||
$this->dispatch('updateFilters', filters: $this->data);
|
||||
}
|
||||
}
|
||||
@ -61,12 +67,12 @@ public function form(Form $form): Form
|
||||
->rules(fn (Get $get) => GetMetrics::rules($get())['period']),
|
||||
DatePicker::make('from')
|
||||
->reactive()
|
||||
->visible(fn (Get $get) => $get('period') === 'custom')
|
||||
->visible(fn (Get $get): bool => $get('period') === 'custom')
|
||||
->maxDate(fn (Get $get) => now())
|
||||
->rules(fn (Get $get) => GetMetrics::rules($get())['from']),
|
||||
DatePicker::make('to')
|
||||
->reactive()
|
||||
->visible(fn (Get $get) => $get('period') === 'custom')
|
||||
->visible(fn (Get $get): bool => $get('period') === 'custom')
|
||||
->minDate(fn (Get $get) => $get('from') ?: now())
|
||||
->maxDate(now())
|
||||
->rules(fn (Get $get) => GetMetrics::rules($get())['to']),
|
||||
|
@ -20,6 +20,9 @@ class MetricDetails extends Widget implements HasForms, HasInfolists
|
||||
use InteractsWithForms;
|
||||
use InteractsWithInfolists;
|
||||
|
||||
/**
|
||||
* @var array<string>
|
||||
*/
|
||||
protected $listeners = ['$refresh'];
|
||||
|
||||
protected static bool $isLazy = false;
|
||||
|
@ -14,10 +14,16 @@ class Metrics extends BaseWidget
|
||||
{
|
||||
public Server $server;
|
||||
|
||||
/**
|
||||
* @var array<string, mixed>
|
||||
*/
|
||||
public array $filters = [];
|
||||
|
||||
protected static bool $isLazy = false;
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $filters
|
||||
*/
|
||||
#[On('updateFilters')]
|
||||
public function updateFilters(array $filters): void
|
||||
{
|
||||
@ -34,13 +40,13 @@ protected function getStats(): array
|
||||
$metrics = app(GetMetrics::class)->filter($this->server, $this->filters);
|
||||
|
||||
return [
|
||||
Stat::make('CPU Load', $lastMetric?->load ?? 0)
|
||||
Stat::make('CPU Load', $lastMetric->load ?? 0)
|
||||
->color('success')
|
||||
->chart($metrics->pluck('load')->toArray()),
|
||||
Stat::make('Memory Usage', Number::fileSize($lastMetric?->memory_used_in_bytes ?? 0, 2))
|
||||
Stat::make('Memory Usage', Number::fileSize($lastMetric->memory_used_in_bytes ?? 0, 2))
|
||||
->color('warning')
|
||||
->chart($metrics->pluck('memory_used')->toArray()),
|
||||
Stat::make('Disk Usage', Number::fileSize($lastMetric?->disk_used_in_bytes ?? 0, 2))
|
||||
Stat::make('Disk Usage', Number::fileSize($lastMetric->disk_used_in_bytes ?? 0, 2))
|
||||
->color('primary')
|
||||
->chart($metrics->pluck('disk_used')->toArray()),
|
||||
];
|
||||
|
Reference in New Issue
Block a user