Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions app/Filament/Widgets/Concerns/HasChartFilters.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace App\Filament\Widgets\Concerns;

use Livewire\Attributes\On;

trait HasChartFilters
{
protected function getFilters(): ?array
Expand All @@ -10,6 +12,26 @@ protected function getFilters(): ?array
'24h' => 'Last 24 hours',
'week' => 'Last 7 days',
'month' => 'Last 30 days',
'mtd' => 'Month to date',
'90d' => 'Last 90 days',
'ytd' => 'Year to date',
'365d' => 'Last 365 days',
'5y' => 'Last 5 years',
'10y' => 'Last 10 years',
'all' => 'All time',
];
}

public function updatedFilter($value): void
{
$this->dispatch('filterChanged', filter: $value);
}

#[On('filterChanged')]
public function updateFilterFromEvent($filter): void
{
if ($this->filter !== $filter) {
$this->filter = $filter;
}
}
}
18 changes: 18 additions & 0 deletions app/Filament/Widgets/RecentDownloadChartWidget.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,24 @@ protected function getData(): array
->when($this->filter === 'month', function ($query) {
$query->where('created_at', '>=', now()->subMonth());
})
->when($this->filter === 'mtd', function ($query) {
$query->where('created_at', '>=', now()->startOfMonth());
})
->when($this->filter === '90d', function ($query) {
$query->where('created_at', '>=', now()->subDays(90));
})
->when($this->filter === 'ytd', function ($query) {
$query->where('created_at', '>=', now()->startOfYear());
})
->when($this->filter === '365d', function ($query) {
$query->where('created_at', '>=', now()->subYear());
})
->when($this->filter === '5y', function ($query) {
$query->where('created_at', '>=', now()->subYears(5));
})
->when($this->filter === '10y', function ($query) {
$query->where('created_at', '>=', now()->subYears(10));
})
->orderBy('created_at')
->get();

Expand Down
18 changes: 18 additions & 0 deletions app/Filament/Widgets/RecentDownloadLatencyChartWidget.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,24 @@ protected function getData(): array
->when($this->filter === 'month', function ($query) {
$query->where('created_at', '>=', now()->subMonth());
})
->when($this->filter === 'mtd', function ($query) {
$query->where('created_at', '>=', now()->startOfMonth());
})
->when($this->filter === '90d', function ($query) {
$query->where('created_at', '>=', now()->subDays(90));
})
->when($this->filter === 'ytd', function ($query) {
$query->where('created_at', '>=', now()->startOfYear());
})
->when($this->filter === '365d', function ($query) {
$query->where('created_at', '>=', now()->subYear());
})
->when($this->filter === '5y', function ($query) {
$query->where('created_at', '>=', now()->subYears(5));
})
->when($this->filter === '10y', function ($query) {
$query->where('created_at', '>=', now()->subYears(10));
})
->orderBy('created_at')
->get();

Expand Down
18 changes: 18 additions & 0 deletions app/Filament/Widgets/RecentJitterChartWidget.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,24 @@ protected function getData(): array
->when($this->filter === 'month', function ($query) {
$query->where('created_at', '>=', now()->subMonth());
})
->when($this->filter === 'mtd', function ($query) {
$query->where('created_at', '>=', now()->startOfMonth());
})
->when($this->filter === '90d', function ($query) {
$query->where('created_at', '>=', now()->subDays(90));
})
->when($this->filter === 'ytd', function ($query) {
$query->where('created_at', '>=', now()->startOfYear());
})
->when($this->filter === '365d', function ($query) {
$query->where('created_at', '>=', now()->subYear());
})
->when($this->filter === '5y', function ($query) {
$query->where('created_at', '>=', now()->subYears(5));
})
->when($this->filter === '10y', function ($query) {
$query->where('created_at', '>=', now()->subYears(10));
})
->orderBy('created_at')
->get();

Expand Down
18 changes: 18 additions & 0 deletions app/Filament/Widgets/RecentPingChartWidget.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,24 @@ protected function getData(): array
->when($this->filter === 'month', function ($query) {
$query->where('created_at', '>=', now()->subMonth());
})
->when($this->filter === 'mtd', function ($query) {
$query->where('created_at', '>=', now()->startOfMonth());
})
->when($this->filter === '90d', function ($query) {
$query->where('created_at', '>=', now()->subDays(90));
})
->when($this->filter === 'ytd', function ($query) {
$query->where('created_at', '>=', now()->startOfYear());
})
->when($this->filter === '365d', function ($query) {
$query->where('created_at', '>=', now()->subYear());
})
->when($this->filter === '5y', function ($query) {
$query->where('created_at', '>=', now()->subYears(5));
})
->when($this->filter === '10y', function ($query) {
$query->where('created_at', '>=', now()->subYears(10));
})
->orderBy('created_at')
->get();

Expand Down
18 changes: 18 additions & 0 deletions app/Filament/Widgets/RecentUploadChartWidget.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,24 @@ protected function getData(): array
->when($this->filter === 'month', function ($query) {
$query->where('created_at', '>=', now()->subMonth());
})
->when($this->filter === 'mtd', function ($query) {
$query->where('created_at', '>=', now()->startOfMonth());
})
->when($this->filter === '90d', function ($query) {
$query->where('created_at', '>=', now()->subDays(90));
})
->when($this->filter === 'ytd', function ($query) {
$query->where('created_at', '>=', now()->startOfYear());
})
->when($this->filter === '365d', function ($query) {
$query->where('created_at', '>=', now()->subYear());
})
->when($this->filter === '5y', function ($query) {
$query->where('created_at', '>=', now()->subYears(5));
})
->when($this->filter === '10y', function ($query) {
$query->where('created_at', '>=', now()->subYears(10));
})
->orderBy('created_at')
->get();

Expand Down
18 changes: 18 additions & 0 deletions app/Filament/Widgets/RecentUploadLatencyChartWidget.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,24 @@ protected function getData(): array
->when($this->filter === 'month', function ($query) {
$query->where('created_at', '>=', now()->subMonth());
})
->when($this->filter === 'mtd', function ($query) {
$query->where('created_at', '>=', now()->startOfMonth());
})
->when($this->filter === '90d', function ($query) {
$query->where('created_at', '>=', now()->subDays(90));
})
->when($this->filter === 'ytd', function ($query) {
$query->where('created_at', '>=', now()->startOfYear());
})
->when($this->filter === '365d', function ($query) {
$query->where('created_at', '>=', now()->subYear());
})
->when($this->filter === '5y', function ($query) {
$query->where('created_at', '>=', now()->subYears(5));
})
->when($this->filter === '10y', function ($query) {
$query->where('created_at', '>=', now()->subYears(10));
})
->orderBy('created_at')
->get();

Expand Down
Loading