Skip to content

Commit

Permalink
Merge pull request #486 from andreapollastri/4.x
Browse files Browse the repository at this point in the history
Dashboard and Server Wip
  • Loading branch information
andreapollastri authored Mar 19, 2024
2 parents 1c4fe2f + f1a7d8f commit f8fc976
Show file tree
Hide file tree
Showing 16 changed files with 750 additions and 662 deletions.
1 change: 0 additions & 1 deletion VERSION.md

This file was deleted.

58 changes: 58 additions & 0 deletions app/Filament/Pages/Dashboard.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?php

namespace App\Filament\Pages;

use App\Helpers\Scripts;
use Filament\Actions\Action;
use Filament\Notifications\Actions\ActionGroup;
use Filament\Notifications\Notification;
use Filament\Pages\Dashboard as BaseDashboard;

class Dashboard extends BaseDashboard
{
protected function getHeaderActions(): array
{
return [
ActionGroup::make([
Action::make('restart-nginx')
->label('Restart nginx')
->icon('heroicon-o-arrow-path'),
Action::make('restart-php')
->label('Restart PHP-FPM')
->icon('heroicon-o-arrow-path'),
Action::make('restart-mysql')
->label('Restart MySql')
->icon('heroicon-o-arrow-path'),
Action::make('restart-redis')
->label('Restart Redis')
->icon('heroicon-o-arrow-path'),
Action::make('restart-supervisor')
->label('Restart Supervisor')
->icon('heroicon-o-arrow-path'),
Action::make('edit-server-name')
->label('Edit Server Name')
->icon('heroicon-o-pencil-square')
->fillForm(fn (): array => [
'serverName' => config('panel.serverName'),
])
->form([
\Filament\Forms\Components\TextInput::make('serverName')
->label('Name')
->hint('The name of the server, e.g. "Production Server", "Staging Server", etc.')
->required(),
])
->action(function (array $data): void {
Scripts::updateServerName($data['serverName']);

Notification::make()
->title('Server name updated successfully.')
->success()
->send();
}),
Action::make('reset-server-password')
->label('Reset Server Password')
->icon('heroicon-o-key'),
]),
];
}
}
4 changes: 2 additions & 2 deletions app/Filament/Resources/SiteResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ class SiteResource extends Resource

public static function form(Form $form): Form
{
$username = 'cp'.Str::lower(Str::random(10));
$password = Str::random(16);
$username = 'cp'.uniqid();
$password = Str::random(20);

return $form
->schema([
Expand Down
2 changes: 1 addition & 1 deletion app/Filament/Widgets/StatsOverview.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

class StatsOverview extends BaseWidget
{
protected static ?string $pollingInterval = '45s';
protected static ?string $pollingInterval = '5s';

protected function getColumns(): int
{
Expand Down
15 changes: 15 additions & 0 deletions app/Helpers/Scripts.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,19 @@ public static function getHddStatus()
Process::run('sh '.self::shFile('getHddStatus'))->output()
)->trim();
}

public static function updateServerName($name)
{
// TODO - Make a Job with this logic
$env = Str::replace(
'PANEL_SERVER_NAME="'.config('panel.serverName').'"',
'PANEL_SERVER_NAME="'.$name.'"',
file_get_contents(base_path('.env'))
);

unlink(base_path('.env'));
file_put_contents(base_path('.env'), $env);

Process::run('php artisan cache:clear');
}
}
2 changes: 1 addition & 1 deletion app/Providers/Filament/CipiPanelProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function panel(Panel $panel): Panel
->discoverResources(in: app_path('Filament/Resources'), for: 'App\\Filament\\Resources')
->discoverPages(in: app_path('Filament/Pages'), for: 'App\\Filament\\Pages')
->pages([
Pages\Dashboard::class,
// Pages\Dashboard::class,
])
->plugins([
\Jeffgreco13\FilamentBreezy\BreezyCore::make()
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
16 changes: 16 additions & 0 deletions bin/dev/setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash

cp .env.example .env

docker run --rm \
-u "$(id -u):$(id -g)" \
-v "$(pwd):/var/www/html" \
-w /var/www/html \
laravelsail/php83-composer:latest \
composer install --ignore-platform-reqs

./vendor/bin/sail up -d

./vendor/bin/sail bash -c "php artisan key:generate"

./vendor/bin/sail bash -c "php artisan storage:link"
File renamed without changes.
Loading

0 comments on commit f8fc976

Please sign in to comment.