mirror of
https://github.com/pelican-dev/panel.git
synced 2025-05-29 16:44:44 +02:00
Work In Progress
This commit is contained in:
parent
366a49dba3
commit
791f04c5d9
17
app/Features/CustomModal.php
Normal file
17
app/Features/CustomModal.php
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Features;
|
||||||
|
|
||||||
|
use Filament\Forms\Components\Concerns\HasActions;
|
||||||
|
use Filament\Forms\Components\Field;
|
||||||
|
use Filament\Support\Concerns\HasDescription;
|
||||||
|
use Filament\Support\Concerns\HasHeading;
|
||||||
|
|
||||||
|
class CustomModal extends Field
|
||||||
|
{
|
||||||
|
use HasActions;
|
||||||
|
use HasHeading;
|
||||||
|
use HasDescription;
|
||||||
|
|
||||||
|
protected string $view = 'livewire.custom-modal';
|
||||||
|
}
|
@ -7,12 +7,12 @@ use Filament\Actions\Action;
|
|||||||
abstract class Feature
|
abstract class Feature
|
||||||
{
|
{
|
||||||
/** 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 static public function listeners(): array;
|
abstract public function listeners(): array;
|
||||||
|
|
||||||
/** eula */
|
/** eula */
|
||||||
abstract static public function featureName(): string;
|
abstract public function featureName(): string;
|
||||||
|
|
||||||
abstract static public function action(): Action;
|
abstract public function action(): Action;
|
||||||
|
|
||||||
public function matchesListeners(string $line): bool
|
public function matchesListeners(string $line): bool
|
||||||
{
|
{
|
||||||
|
@ -9,7 +9,7 @@ use Filament\Notifications\Notification;
|
|||||||
|
|
||||||
class JavaVersion extends Feature
|
class JavaVersion extends Feature
|
||||||
{
|
{
|
||||||
public static function listeners(): array
|
public function listeners(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'minecraft 1.17 requires running the server with java 16 or above',
|
'minecraft 1.17 requires running the server with java 16 or above',
|
||||||
@ -20,12 +20,12 @@ class JavaVersion extends Feature
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function featureName(): string
|
public function featureName(): string
|
||||||
{
|
{
|
||||||
return 'java_version';
|
return 'java_version';
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function action(): Action
|
public function action(): Action
|
||||||
{
|
{
|
||||||
return Action::make('eula')
|
return Action::make('eula')
|
||||||
->form([
|
->form([
|
||||||
|
@ -9,21 +9,21 @@ use Filament\Notifications\Notification;
|
|||||||
|
|
||||||
class MinecraftEula extends Feature
|
class MinecraftEula extends Feature
|
||||||
{
|
{
|
||||||
public static function listeners(): array
|
public function listeners(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'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',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function featureName(): string
|
public function featureName(): string
|
||||||
{
|
{
|
||||||
return 'eula';
|
return 'eula';
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function action(): Action
|
public function action(): Action
|
||||||
{
|
{
|
||||||
return Action::make('eula')
|
return Action::make($this->featureName())
|
||||||
->form([
|
->form([
|
||||||
Placeholder::make('eula')
|
Placeholder::make('eula')
|
||||||
->label('By pressing I Accept below you are indicating your agreement to the Minecraft® EULA.'),
|
->label('By pressing I Accept below you are indicating your agreement to the Minecraft® EULA.'),
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
namespace App\Filament\Server\Widgets;
|
namespace App\Filament\Server\Widgets;
|
||||||
|
|
||||||
use App\Exceptions\Http\HttpForbiddenException;
|
use App\Exceptions\Http\HttpForbiddenException;
|
||||||
|
use App\Features\Feature;
|
||||||
use App\Models\Permission;
|
use App\Models\Permission;
|
||||||
use App\Models\Server;
|
use App\Models\Server;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
@ -10,10 +11,9 @@ use App\Services\Nodes\NodeJWTService;
|
|||||||
use App\Services\Servers\GetUserPermissionsService;
|
use App\Services\Servers\GetUserPermissionsService;
|
||||||
use Filament\Widgets\Widget;
|
use Filament\Widgets\Widget;
|
||||||
use Illuminate\Support\Arr;
|
use Illuminate\Support\Arr;
|
||||||
use Illuminate\Support\Collection;
|
|
||||||
use Illuminate\Support\Facades\Log;
|
|
||||||
use Livewire\Attributes\On;
|
use Livewire\Attributes\On;
|
||||||
use App\Features;
|
use App\Features;
|
||||||
|
use App\Features\CustomModal;
|
||||||
|
|
||||||
class ServerConsole extends Widget
|
class ServerConsole extends Widget
|
||||||
{
|
{
|
||||||
@ -33,6 +33,14 @@ class ServerConsole extends Widget
|
|||||||
|
|
||||||
public string $input = '';
|
public string $input = '';
|
||||||
|
|
||||||
|
public function modal(): CustomModal
|
||||||
|
{
|
||||||
|
return CustomModal::make('modal-eula')
|
||||||
|
->heading('Info!')
|
||||||
|
->description('Description')
|
||||||
|
->registerActions([/* if neccessary */]);
|
||||||
|
}
|
||||||
|
|
||||||
protected function getToken(): string
|
protected function getToken(): string
|
||||||
{
|
{
|
||||||
if (!$this->user || !$this->server || $this->user->cannot(Permission::ACTION_WEBSOCKET_CONNECT, $this->server)) {
|
if (!$this->user || !$this->server || $this->user->cannot(Permission::ACTION_WEBSOCKET_CONNECT, $this->server)) {
|
||||||
@ -108,18 +116,23 @@ class ServerConsole extends Widget
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Feature[]
|
||||||
|
*/
|
||||||
public function getActiveFeatures(): array
|
public function getActiveFeatures(): array
|
||||||
{
|
{
|
||||||
return [new Features\MinecraftEula(), new Features\JavaVersion()];
|
return [new Features\MinecraftEula(), new Features\JavaVersion()];
|
||||||
}
|
}
|
||||||
|
|
||||||
#[On('line-to-check')]
|
#[On('line-to-check')]
|
||||||
public function lineToCheck(string $line)
|
public function lineToCheck(string $line): void
|
||||||
{
|
{
|
||||||
foreach ($this->getActiveFeatures() as $feature) {
|
foreach ($this->getActiveFeatures() as $feature) {
|
||||||
if ($feature->matchesListeners($line)) {
|
if ($feature->matchesListeners($line)) {
|
||||||
Log::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()}");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -154,5 +154,6 @@
|
|||||||
"displayName": true,
|
"displayName": true,
|
||||||
"fileName": true
|
"fileName": true
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
"packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"
|
||||||
}
|
}
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
@php use App\Features\CustomModal; @endphp
|
||||||
<x-filament::widget>
|
<x-filament::widget>
|
||||||
@assets
|
@assets
|
||||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@xterm/xterm/css/xterm.min.css">
|
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@xterm/xterm/css/xterm.min.css">
|
||||||
@ -105,7 +106,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
const checkListeners = (line) => {
|
const checkListeners = (line) => {
|
||||||
$dispatch('line-to-check', { line })
|
$dispatch('line-to-check', { line });
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleTransferStatus = (status) =>
|
const handleTransferStatus = (status) =>
|
||||||
@ -193,4 +194,7 @@
|
|||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
@endscript
|
@endscript
|
||||||
|
|
||||||
|
{{ $this->modal()->render() }}
|
||||||
|
|
||||||
</x-filament::widget>
|
</x-filament::widget>
|
||||||
|
17
resources/views/livewire/custom-modal.blade.php
Normal file
17
resources/views/livewire/custom-modal.blade.php
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
<x-filament::modal id="{{ $getName() }}" :width="'xl'">
|
||||||
|
<div class="text-xl font-bold text-center">
|
||||||
|
{{ $getHeading() }}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="text-lg text-center">
|
||||||
|
{{ $getDescription() }}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="w-full flex justify-center mt-3">
|
||||||
|
@if ($actions = $getActions())
|
||||||
|
<x-filament::actions
|
||||||
|
:actions="$actions"
|
||||||
|
/>
|
||||||
|
@endif
|
||||||
|
</div>
|
||||||
|
</x-filament::modal>
|
Loading…
x
Reference in New Issue
Block a user