Skip to content

Commit f8fc976

Browse files
Merge pull request #486 from andreapollastri/4.x
Dashboard and Server Wip
2 parents 1c4fe2f + f1a7d8f commit f8fc976

File tree

16 files changed

+750
-662
lines changed

16 files changed

+750
-662
lines changed

VERSION.md

Lines changed: 0 additions & 1 deletion
This file was deleted.

app/Filament/Pages/Dashboard.php

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
<?php
2+
3+
namespace App\Filament\Pages;
4+
5+
use App\Helpers\Scripts;
6+
use Filament\Actions\Action;
7+
use Filament\Notifications\Actions\ActionGroup;
8+
use Filament\Notifications\Notification;
9+
use Filament\Pages\Dashboard as BaseDashboard;
10+
11+
class Dashboard extends BaseDashboard
12+
{
13+
protected function getHeaderActions(): array
14+
{
15+
return [
16+
ActionGroup::make([
17+
Action::make('restart-nginx')
18+
->label('Restart nginx')
19+
->icon('heroicon-o-arrow-path'),
20+
Action::make('restart-php')
21+
->label('Restart PHP-FPM')
22+
->icon('heroicon-o-arrow-path'),
23+
Action::make('restart-mysql')
24+
->label('Restart MySql')
25+
->icon('heroicon-o-arrow-path'),
26+
Action::make('restart-redis')
27+
->label('Restart Redis')
28+
->icon('heroicon-o-arrow-path'),
29+
Action::make('restart-supervisor')
30+
->label('Restart Supervisor')
31+
->icon('heroicon-o-arrow-path'),
32+
Action::make('edit-server-name')
33+
->label('Edit Server Name')
34+
->icon('heroicon-o-pencil-square')
35+
->fillForm(fn (): array => [
36+
'serverName' => config('panel.serverName'),
37+
])
38+
->form([
39+
\Filament\Forms\Components\TextInput::make('serverName')
40+
->label('Name')
41+
->hint('The name of the server, e.g. "Production Server", "Staging Server", etc.')
42+
->required(),
43+
])
44+
->action(function (array $data): void {
45+
Scripts::updateServerName($data['serverName']);
46+
47+
Notification::make()
48+
->title('Server name updated successfully.')
49+
->success()
50+
->send();
51+
}),
52+
Action::make('reset-server-password')
53+
->label('Reset Server Password')
54+
->icon('heroicon-o-key'),
55+
]),
56+
];
57+
}
58+
}

app/Filament/Resources/SiteResource.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ class SiteResource extends Resource
1919

2020
public static function form(Form $form): Form
2121
{
22-
$username = 'cp'.Str::lower(Str::random(10));
23-
$password = Str::random(16);
22+
$username = 'cp'.uniqid();
23+
$password = Str::random(20);
2424

2525
return $form
2626
->schema([

app/Filament/Widgets/StatsOverview.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
class StatsOverview extends BaseWidget
1111
{
12-
protected static ?string $pollingInterval = '45s';
12+
protected static ?string $pollingInterval = '5s';
1313

1414
protected function getColumns(): int
1515
{

app/Helpers/Scripts.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,19 @@ public static function getHddStatus()
3232
Process::run('sh '.self::shFile('getHddStatus'))->output()
3333
)->trim();
3434
}
35+
36+
public static function updateServerName($name)
37+
{
38+
// TODO - Make a Job with this logic
39+
$env = Str::replace(
40+
'PANEL_SERVER_NAME="'.config('panel.serverName').'"',
41+
'PANEL_SERVER_NAME="'.$name.'"',
42+
file_get_contents(base_path('.env'))
43+
);
44+
45+
unlink(base_path('.env'));
46+
file_put_contents(base_path('.env'), $env);
47+
48+
Process::run('php artisan cache:clear');
49+
}
3550
}

app/Providers/Filament/CipiPanelProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public function panel(Panel $panel): Panel
3636
->discoverResources(in: app_path('Filament/Resources'), for: 'App\\Filament\\Resources')
3737
->discoverPages(in: app_path('Filament/Pages'), for: 'App\\Filament\\Pages')
3838
->pages([
39-
Pages\Dashboard::class,
39+
// Pages\Dashboard::class,
4040
])
4141
->plugins([
4242
\Jeffgreco13\FilamentBreezy\BreezyCore::make()
File renamed without changes.
File renamed without changes.
File renamed without changes.

bin/dev/setup.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/bin/bash
2+
3+
cp .env.example .env
4+
5+
docker run --rm \
6+
-u "$(id -u):$(id -g)" \
7+
-v "$(pwd):/var/www/html" \
8+
-w /var/www/html \
9+
laravelsail/php83-composer:latest \
10+
composer install --ignore-platform-reqs
11+
12+
./vendor/bin/sail up -d
13+
14+
./vendor/bin/sail bash -c "php artisan key:generate"
15+
16+
./vendor/bin/sail bash -c "php artisan storage:link"

0 commit comments

Comments
 (0)