Skip to content

Commit 3532c89

Browse files
authored
[Feature] Public dashboard and Getting Started pages (alexjustesen#822)
1 parent 2796405 commit 3532c89

File tree

12 files changed

+344
-5
lines changed

12 files changed

+344
-5
lines changed

app/Filament/Widgets/RecentSpeedChartWidget.php

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ protected function getData(): array
5050
return [
5151
'datasets' => [
5252
[
53-
'label' => 'Download (Mbps)',
53+
'label' => 'Download',
5454
'data' => $results->map(fn ($item) => ! blank($item->download) ? toBits(convertSize($item->download), 2) : 0),
5555
'borderColor' => '#0ea5e9',
5656
'backgroundColor' => '#0ea5e9',
@@ -59,7 +59,7 @@ protected function getData(): array
5959
'tension' => 0.4,
6060
],
6161
[
62-
'label' => 'Upload (Mbps)',
62+
'label' => 'Upload',
6363
'data' => $results->map(fn ($item) => ! blank($item->upload) ? toBits(convertSize($item->upload), 2) : 0),
6464
'borderColor' => '#8b5cf6',
6565
'backgroundColor' => '#8b5cf6',
@@ -72,6 +72,27 @@ protected function getData(): array
7272
];
7373
}
7474

75+
protected function getOptions(): array
76+
{
77+
return [
78+
'scales' => [
79+
'x' => [
80+
'display' => true,
81+
'title' => [
82+
'display' => true,
83+
],
84+
],
85+
'y' => [
86+
'display' => true,
87+
'title' => [
88+
'display' => true,
89+
'text' => 'Mbps',
90+
],
91+
],
92+
],
93+
];
94+
}
95+
7596
protected function getType(): string
7697
{
7798
return 'line';
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
3+
namespace App\Http\Controllers;
4+
5+
use App\Models\Result;
6+
use Illuminate\Http\Request;
7+
8+
class HomeController extends Controller
9+
{
10+
/**
11+
* Handle the incoming request.
12+
*/
13+
public function __invoke(Request $request)
14+
{
15+
$hasResults = Result::count() > 0;
16+
17+
return view($hasResults ? 'dashboard' : 'get-started');
18+
}
19+
}

app/View/Components/AppLayout.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?php
2+
3+
namespace App\View\Components;
4+
5+
use Closure;
6+
use Illuminate\Contracts\View\View;
7+
use Illuminate\View\Component;
8+
9+
class AppLayout extends Component
10+
{
11+
public $title = 'Page Title';
12+
13+
public function __construct($title)
14+
{
15+
$this->title = $title;
16+
}
17+
18+
/**
19+
* Get the view / contents that represent the component.
20+
*/
21+
public function render(): View|Closure|string
22+
{
23+
return view('layouts.app');
24+
}
25+
}

public/build/assets/app-d8cd240f.css

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

public/build/manifest.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
{
2+
"resources/css/app.css": {
3+
"file": "assets/app-d8cd240f.css",
4+
"isEntry": true,
5+
"src": "resources/css/app.css"
6+
},
27
"resources/css/filament/admin/theme.css": {
38
"file": "assets/theme-182befaf.css",
49
"isEntry": true,

resources/css/app.css

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
@tailwind base;
2+
@tailwind components;
3+
@tailwind utilities;
4+
5+
@layer base {
6+
[x-cloak] {
7+
display: none !important;
8+
}
9+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<x-app-layout title="Dashboard">
2+
<div class="grid gap-4 sm:grid-cols-6 sm:gap-8">
3+
<div class="col-span-full">
4+
@livewire(\App\Filament\Widgets\StatsOverviewWidget::class)
5+
</div>
6+
7+
<div class="col-span-full">
8+
@livewire(\App\Filament\Widgets\RecentSpeedChartWidget::class)
9+
</div>
10+
11+
<div class="col-span-full">
12+
@livewire(\App\Filament\Widgets\RecentPingChartWidget::class)
13+
</div>
14+
15+
<div class="col-span-full">
16+
@livewire(\App\Filament\Widgets\RecentJitterChartWidget::class)
17+
</div>
18+
</div>
19+
</x-app-layout>
Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
<!DOCTYPE html>
2+
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}" class="h-full">
3+
<head>
4+
<meta charset="utf-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6+
7+
<title>Getting Started - {{ config('app.name') }}</title>
8+
9+
{{-- Fonts --}}
10+
<link href="{{ asset('fonts/inter/inter.css') }}" rel="stylesheet" />
11+
12+
{{-- Styles --}}
13+
@filamentStyles
14+
@vite('resources/css/app.css')
15+
16+
<script>
17+
const theme = localStorage.getItem('theme') ?? 'system'
18+
19+
if (
20+
theme === 'dark' ||
21+
(theme === 'system' &&
22+
window.matchMedia('(prefers-color-scheme: dark)')
23+
.matches)
24+
) {
25+
document.documentElement.classList.add('dark')
26+
}
27+
</script>
28+
</head>
29+
<body class="h-full antialiased bg-gray-50 dark:bg-gray-950 text-gray-950 dark:text-white">
30+
<main class="flex flex-col justify-center min-h-full p-4 space-y-4 sm:mx-auto sm:p-6 lg:p-8 sm:max-w-3xl sm:space-y-8">
31+
<header>
32+
<h1 class="text-2xl font-bold tracking-tight text-gray-950 dark:text-white sm:text-3xl">{{ __("Getting Started") }} - {{ config('app.name') }}</h1>
33+
</header>
34+
35+
<div>
36+
<ul role="list" class="divide dark:divide-white/5 divide-white/80">
37+
<li class="relative flex items-center py-4 space-x-4">
38+
<div class="flex-auto min-w-0">
39+
<div class="flex items-center gap-x-3">
40+
<div class="flex-none p-1 rounded-full text-amber-400 bg-gray-100/10">
41+
<div class="w-2 h-2 bg-current rounded-full"></div>
42+
</div>
43+
44+
<h2 class="min-w-0 text-sm font-semibold leading-6 text-white">
45+
<a href="{{ url('/admin/login') }}" class="flex gap-x-2">
46+
<span class="truncate">Sign In</span>
47+
<span class="text-amber-400">/</span>
48+
<span class="whitespace-nowrap">Admin Panel</span>
49+
<span class="absolute inset-0"></span>
50+
</a>
51+
</h2>
52+
</div>
53+
54+
<div class="mt-3 flex items-center gap-x-2.5 text-sm leading-5 dark:text-gray-400 text-gray-950">
55+
<p class="truncate">
56+
Sign in to the admin panel to run your first speedtest or to setup scheduled tests.
57+
</p>
58+
</div>
59+
</div>
60+
61+
<svg class="flex-none w-5 h-5 text-gray-400" viewBox="0 0 20 20" fill="currentColor" aria-hidden="true">
62+
<path fill-rule="evenodd" d="M7.21 14.77a.75.75 0 01.02-1.06L11.168 10 7.23 6.29a.75.75 0 111.04-1.08l4.5 4.25a.75.75 0 010 1.08l-4.5 4.25a.75.75 0 01-1.06-.02z" clip-rule="evenodd" />
63+
</svg>
64+
</li>
65+
66+
<li class="relative flex items-center py-4 space-x-4">
67+
<div class="flex-auto min-w-0">
68+
<div class="flex items-center gap-x-3">
69+
<div class="flex-none p-1 rounded-full text-amber-400 bg-gray-100/10">
70+
<div class="w-2 h-2 bg-current rounded-full"></div>
71+
</div>
72+
73+
<h2 class="min-w-0 text-sm font-semibold leading-6 text-white">
74+
<a href="https://docs.speedtest-tracker.dev/" target="_blank" rel="nofollow" class="flex gap-x-2">
75+
<span class="truncate">Getting Started</span>
76+
<span class="text-amber-400">/</span>
77+
<span class="whitespace-nowrap">Docs</span>
78+
<span class="absolute inset-0"></span>
79+
</a>
80+
</h2>
81+
</div>
82+
83+
<div class="mt-3 flex items-center gap-x-2.5 text-sm leading-5 dark:text-gray-400 text-gray-950">
84+
<p class="truncate">
85+
Need help getting started with Speedtest Tracker? Check out the docs.
86+
</p>
87+
</div>
88+
</div>
89+
90+
<svg class="flex-none w-5 h-5 text-gray-400" viewBox="0 0 20 20" fill="currentColor" aria-hidden="true">
91+
<path fill-rule="evenodd" d="M7.21 14.77a.75.75 0 01.02-1.06L11.168 10 7.23 6.29a.75.75 0 111.04-1.08l4.5 4.25a.75.75 0 010 1.08l-4.5 4.25a.75.75 0 01-1.06-.02z" clip-rule="evenodd" />
92+
</svg>
93+
</li>
94+
95+
<li class="relative flex items-center py-4 space-x-4">
96+
<div class="flex-auto min-w-0">
97+
<div class="flex items-center gap-x-3">
98+
<div class="flex-none p-1 rounded-full text-amber-400 bg-gray-100/10">
99+
<div class="w-2 h-2 bg-current rounded-full"></div>
100+
</div>
101+
102+
<h2 class="min-w-0 text-sm font-semibold leading-6 text-white">
103+
<a href="https://github.com/alexjustesen/speedtest-tracker" target="_blank" rel="nofollow" class="flex gap-x-2">
104+
<span class="truncate">GitHub</span>
105+
<span class="text-amber-400">/</span>
106+
<span class="whitespace-nowrap">Repo</span>
107+
<span class="absolute inset-0"></span>
108+
</a>
109+
</h2>
110+
</div>
111+
</div>
112+
113+
<svg class="flex-none w-5 h-5 text-gray-400" viewBox="0 0 20 20" fill="currentColor" aria-hidden="true">
114+
<path fill-rule="evenodd" d="M7.21 14.77a.75.75 0 01.02-1.06L11.168 10 7.23 6.29a.75.75 0 111.04-1.08l4.5 4.25a.75.75 0 010 1.08l-4.5 4.25a.75.75 0 01-1.06-.02z" clip-rule="evenodd" />
115+
</svg>
116+
</li>
117+
118+
<li class="relative flex items-center py-4 space-x-4">
119+
<div class="flex-auto min-w-0">
120+
<div class="flex items-center gap-x-3">
121+
<div class="flex-none p-1 rounded-full text-amber-400 bg-gray-100/10">
122+
<div class="w-2 h-2 bg-current rounded-full"></div>
123+
</div>
124+
125+
<h2 class="min-w-0 text-sm font-semibold leading-6 text-white">
126+
<a href="https://github.com/alexjustesen/speedtest-tracker/discussions" target="_blank" rel="nofollow" class="flex gap-x-2">
127+
<span class="truncate">Discussions</span>
128+
<span class="text-amber-400">/</span>
129+
<span class="whitespace-nowrap">Community</span>
130+
<span class="absolute inset-0"></span>
131+
</a>
132+
</h2>
133+
</div>
134+
</div>
135+
136+
<svg class="flex-none w-5 h-5 text-gray-400" viewBox="0 0 20 20" fill="currentColor" aria-hidden="true">
137+
<path fill-rule="evenodd" d="M7.21 14.77a.75.75 0 01.02-1.06L11.168 10 7.23 6.29a.75.75 0 111.04-1.08l4.5 4.25a.75.75 0 010 1.08l-4.5 4.25a.75.75 0 01-1.06-.02z" clip-rule="evenodd" />
138+
</svg>
139+
</li>
140+
141+
<!-- More items... -->
142+
</ul>
143+
</div>
144+
</main>
145+
146+
{{-- Scripts --}}
147+
@filamentScripts
148+
</body>
149+
</html>
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
<!DOCTYPE html>
2+
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
3+
<head>
4+
<meta charset="utf-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6+
7+
<title>{{ $title }} - {{ config('app.name') }}</title>
8+
9+
{{-- Fonts --}}
10+
<link href="{{ asset('fonts/inter/inter.css') }}" rel="stylesheet" />
11+
12+
{{-- Styles --}}
13+
@filamentStyles
14+
@vite('resources/css/app.css')
15+
16+
<script>
17+
const theme = localStorage.getItem('theme') ?? 'system'
18+
19+
if (
20+
theme === 'dark' ||
21+
(theme === 'system' &&
22+
window.matchMedia('(prefers-color-scheme: dark)')
23+
.matches)
24+
) {
25+
document.documentElement.classList.add('dark')
26+
}
27+
</script>
28+
</head>
29+
<body class="min-h-screen antialiased bg-gray-50 dark:bg-gray-950 text-gray-950 dark:text-white">
30+
<main class="p-4 sm:p-6 lg:p-8 mx-auto max-w-{{ config('speedtest.content_width') }} space-y-4 sm:space-y-8">
31+
<header class="flex flex-col gap-4 sm:flex-row sm:justify-between sm:items-center">
32+
<div>
33+
<h1 class="text-2xl font-bold tracking-tight text-gray-950 dark:text-white sm:text-3xl">{{ $title ?? 'Page Title' }}</h1>
34+
</div>
35+
36+
<div class="flex-shrink-0">
37+
<x-filament::button
38+
href="{{ url('/admin') }}"
39+
tag="a"
40+
>
41+
Admin Panel
42+
</x-filament::button>
43+
</div>
44+
</header>
45+
46+
{{ $slot }}
47+
</main>
48+
49+
{{-- Scripts --}}
50+
@filamentScripts
51+
</body>
52+
</html>

routes/web.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?php
22

3+
use App\Http\Controllers\HomeController;
34
use Illuminate\Support\Facades\Route;
45

56
/*
@@ -13,7 +14,7 @@
1314
|
1415
*/
1516

16-
Route::redirect('/', '/admin');
17+
Route::get('/', HomeController::class);
1718

1819
Route::get('/login', function () {
1920
return redirect('/admin/login');

0 commit comments

Comments
 (0)