mirror of
https://github.com/pelican-dev/panel.git
synced 2025-05-20 04:04:45 +02:00
wip
This commit is contained in:
parent
63cf4bd1a8
commit
ad494b68b6
@ -2,11 +2,16 @@
|
|||||||
|
|
||||||
namespace App\Features;
|
namespace App\Features;
|
||||||
|
|
||||||
use Filament\Forms\Components\Actions\Action;
|
use Filament\Actions\Concerns\InteractsWithActions;
|
||||||
use Filament\Forms\Components\Field;
|
use Filament\Actions\Contracts\HasActions;
|
||||||
|
use Filament\Forms\Concerns\InteractsWithForms;
|
||||||
|
use Filament\Forms\Contracts\HasForms;
|
||||||
|
use Filament\Forms\Form;
|
||||||
|
|
||||||
abstract class Feature
|
abstract class Feature implements HasActions, HasForms
|
||||||
{
|
{
|
||||||
|
use InteractsWithActions, InteractsWithForms;
|
||||||
|
|
||||||
/** you need to agree to the eula in order to run the server */
|
/** you need to agree to the eula in order to run the server */
|
||||||
abstract public function listeners(): array;
|
abstract public function listeners(): array;
|
||||||
|
|
||||||
@ -14,7 +19,7 @@ abstract class Feature
|
|||||||
abstract public function featureName(): string;
|
abstract public function featureName(): string;
|
||||||
|
|
||||||
// abstract public function action(): Action;
|
// abstract public function action(): Action;
|
||||||
abstract public function modal(): Field;
|
abstract public function modal(): Form;
|
||||||
|
|
||||||
public function matchesListeners(string $line): bool
|
public function matchesListeners(string $line): bool
|
||||||
{
|
{
|
||||||
|
@ -4,7 +4,11 @@ namespace App\Features;
|
|||||||
|
|
||||||
use App\Repositories\Daemon\DaemonFileRepository;
|
use App\Repositories\Daemon\DaemonFileRepository;
|
||||||
use Filament\Actions\Action;
|
use Filament\Actions\Action;
|
||||||
|
use Filament\Forms\Components\Actions;
|
||||||
use Filament\Forms\Components\Placeholder;
|
use Filament\Forms\Components\Placeholder;
|
||||||
|
use Filament\Forms\Components\TextInput;
|
||||||
|
use Filament\Forms\Form;
|
||||||
|
use Filament\Forms\Get;
|
||||||
use Filament\Notifications\Notification;
|
use Filament\Notifications\Notification;
|
||||||
|
|
||||||
class JavaVersion extends Feature
|
class JavaVersion extends Feature
|
||||||
@ -25,12 +29,27 @@ class JavaVersion extends Feature
|
|||||||
return 'java_version';
|
return 'java_version';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function modal(): \Filament\Forms\Components\Field
|
public function modal(): Form
|
||||||
{
|
{
|
||||||
return CustomModal::make('modal-java-version')
|
return $this->makeForm()
|
||||||
->heading('Java Version')
|
->schema([
|
||||||
->description('bla bla')
|
Placeholder::make('see me bitches'),
|
||||||
->registerActions([/* if neccessary */]);
|
TextInput::make('name'),
|
||||||
|
Actions::make([
|
||||||
|
Actions\Action::make('closeUserModal')
|
||||||
|
->label('Close')
|
||||||
|
->color('secondary')
|
||||||
|
->extraAttributes([
|
||||||
|
'x-on:click' => 'isOpen = false', // close modal [FASTER]
|
||||||
|
]),
|
||||||
|
Actions\Action::make('saveUserModal')
|
||||||
|
->label('Save')
|
||||||
|
->color('primary')
|
||||||
|
->action(function (Get $get) {
|
||||||
|
logger($get('name'));
|
||||||
|
}),
|
||||||
|
])->fullWidth(),
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function action(): Action
|
public function action(): Action
|
||||||
|
@ -3,9 +3,13 @@
|
|||||||
namespace App\Features;
|
namespace App\Features;
|
||||||
|
|
||||||
use App\Repositories\Daemon\DaemonFileRepository;
|
use App\Repositories\Daemon\DaemonFileRepository;
|
||||||
|
use Filament\Forms\Components\Actions;
|
||||||
use Filament\Forms\Components\Actions\Action;
|
use Filament\Forms\Components\Actions\Action;
|
||||||
use Filament\Forms\Components\Field;
|
use Filament\Forms\Components\Field;
|
||||||
use Filament\Forms\Components\Placeholder;
|
use Filament\Forms\Components\Placeholder;
|
||||||
|
use Filament\Forms\Components\TextInput;
|
||||||
|
use Filament\Forms\Form;
|
||||||
|
use Filament\Forms\Get;
|
||||||
use Filament\Notifications\Notification;
|
use Filament\Notifications\Notification;
|
||||||
|
|
||||||
class MinecraftEula extends Feature
|
class MinecraftEula extends Feature
|
||||||
@ -22,7 +26,43 @@ class MinecraftEula extends Feature
|
|||||||
return 'eula';
|
return 'eula';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function modal(): Field
|
public function modal(): Form
|
||||||
|
{
|
||||||
|
return $this->makeForm()
|
||||||
|
->schema([
|
||||||
|
Placeholder::make('By pressing "I Accept" below you are indicating your agreement to the Minecraft EULA'),
|
||||||
|
Actions::make([
|
||||||
|
Actions\Action::make('closeModal')
|
||||||
|
->label('Close')
|
||||||
|
->color('secondary')
|
||||||
|
->extraAttributes([
|
||||||
|
'x-on:click' => 'isOpen = false', // close modal [FASTER]
|
||||||
|
]),
|
||||||
|
Actions\Action::make('acceptEula')
|
||||||
|
->label('Save')
|
||||||
|
->color('primary')
|
||||||
|
->extraAttributes([
|
||||||
|
// 'x-on:click' => '$dispatch("minecraft-eula-accept")', // close modal [FASTER]
|
||||||
|
])
|
||||||
|
->action(function (DaemonFileRepository $fileRepository) {
|
||||||
|
try {
|
||||||
|
dd('success');
|
||||||
|
$fileRepository->putContent('eula.txt', 'eula=true');
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
dd($e);
|
||||||
|
Notification::make()
|
||||||
|
->title('Error')
|
||||||
|
->body($e->getMessage())
|
||||||
|
->danger()
|
||||||
|
->send();
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
])
|
||||||
|
->fullWidth()->label('Minecraft EULA'),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function field(): Field
|
||||||
{
|
{
|
||||||
return CustomModal::make('modal-eula')
|
return CustomModal::make('modal-eula')
|
||||||
->heading('Minecraft EULA')
|
->heading('Minecraft EULA')
|
||||||
|
@ -173,8 +173,8 @@ class ServerConsole extends Widget implements HasForms
|
|||||||
if ($feature->matchesListeners($line)) {
|
if ($feature->matchesListeners($line)) {
|
||||||
logger()->info('Feature listens for this', compact(['feature', 'line']));
|
logger()->info('Feature listens for this', compact(['feature', 'line']));
|
||||||
|
|
||||||
// $this->dispatch('open-modal', id: "modal-{$feature->featureName()}");
|
$this->dispatch('open-modal', id: "modal-{$feature->featureName()}");
|
||||||
$this->dispatch('open-modal', id: 'edit-user');
|
// $this->dispatch('open-modal', id: 'edit-user');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -196,9 +196,11 @@
|
|||||||
@endscript
|
@endscript
|
||||||
|
|
||||||
|
|
||||||
<x-filament::modal id="edit-user" :close-by-clicking-away="false">
|
@foreach ($this->getActiveFeatures() as $feature)
|
||||||
{{ $this->getUserModal() }}
|
<x-filament::modal id="modal-{{ $feature->featureName() }}" :close-by-clicking-away="false">
|
||||||
|
{{ $feature->modal() }}
|
||||||
</x-filament::modal>
|
</x-filament::modal>
|
||||||
|
@endforeach
|
||||||
|
|
||||||
|
|
||||||
</x-filament::widget>
|
</x-filament::widget>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user