mirror of
https://github.com/pelican-dev/panel.git
synced 2025-06-30 15:31:08 +02:00
Various fixes
This commit is contained in:
parent
0c3baa5cd8
commit
1e530d589f
@ -27,7 +27,6 @@ use Filament\Pages\Concerns\InteractsWithHeaderActions;
|
||||
use Filament\Pages\Page;
|
||||
use Filament\Schemas\Components\Actions;
|
||||
use Filament\Schemas\Components\Component;
|
||||
use Filament\Schemas\Components\Form;
|
||||
use Filament\Schemas\Components\Group;
|
||||
use Filament\Schemas\Components\Section;
|
||||
use Filament\Schemas\Components\StateCasts\BooleanStateCast;
|
||||
@ -42,9 +41,10 @@ use Illuminate\Support\Facades\Artisan;
|
||||
use Illuminate\Support\Facades\Notification as MailNotification;
|
||||
use Illuminate\Support\Str;
|
||||
use Filament\Schemas\Contracts\HasSchemas;
|
||||
use Filament\Schemas\Schema;
|
||||
|
||||
/**
|
||||
* @property Form $form
|
||||
* @property Schema $form
|
||||
*/
|
||||
class Settings extends Page implements HasSchemas
|
||||
{
|
||||
@ -84,6 +84,7 @@ class Settings extends Page implements HasSchemas
|
||||
|
||||
/**
|
||||
* @return array<Component>
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
protected function getFormSchema(): array
|
||||
|
@ -82,15 +82,15 @@ class ListEggs extends ListRecords
|
||||
])
|
||||
->groupedBulkActions([
|
||||
DeleteBulkAction::make()
|
||||
->before(fn (DeleteBulkAction $action, Collection $records) => $action->records($records->filter(function ($egg) {
|
||||
->before(fn (Collection &$records) => $records = $records->filter(function ($egg) {
|
||||
/** @var Egg $egg */
|
||||
return $egg->servers_count <= 0;
|
||||
}))),
|
||||
})),
|
||||
UpdateEggBulkAction::make()
|
||||
->before(fn (UpdateEggBulkAction $action, Collection $records) => $action->records($records->filter(function ($egg) {
|
||||
->before(fn (Collection &$records) => $records = $records->filter(function ($egg) {
|
||||
/** @var Egg $egg */
|
||||
return cache()->get("eggs.$egg->uuid.update", false);
|
||||
}))),
|
||||
})),
|
||||
])
|
||||
->emptyStateIcon('tabler-eggs')
|
||||
->emptyStateDescription('')
|
||||
|
@ -8,7 +8,8 @@ use App\Filament\Components\Tables\Filters\TagsFilter;
|
||||
use App\Models\Node;
|
||||
use App\Traits\Filament\CanCustomizeHeaderActions;
|
||||
use App\Traits\Filament\CanCustomizeHeaderWidgets;
|
||||
use Filament\Actions;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Actions\ActionGroup;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
use Filament\Actions\CreateAction;
|
||||
use Filament\Actions\EditAction;
|
||||
@ -78,7 +79,7 @@ class ListNodes extends ListRecords
|
||||
]);
|
||||
}
|
||||
|
||||
/** @return array<Actions\Action|Actions\ActionGroup> */
|
||||
/** @return array<Action|ActionGroup> */
|
||||
protected function getDefaultHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
|
@ -132,20 +132,6 @@ class EditServer extends EditRecord
|
||||
->getOptionLabelFromRecordUsing(fn (User $user) => "$user->username ($user->email)")
|
||||
->preload()
|
||||
->required(),
|
||||
//
|
||||
// ToggleButtons::make('condition')
|
||||
// ->label(trans('admin/server.server_status'))
|
||||
// ->formatStateUsing(fn (Server $server) => $server->condition)
|
||||
// ->options(fn ($state) => [$state->value => $state->getLabel()])
|
||||
// ->colors(fn ($state) => [$state->value => $state->getColor()])
|
||||
// ->icons(fn ($state) => [$state->value => $state->getIcon()])
|
||||
// ->columnSpan([
|
||||
// 'default' => 2,
|
||||
// 'sm' => 1,
|
||||
// 'md' => 1,
|
||||
// 'lg' => 1,
|
||||
// ]),
|
||||
|
||||
ToggleButtons::make('condition')
|
||||
->label(trans('admin/server.server_status'))
|
||||
->formatStateUsing(fn (Server $server) => $server->condition)
|
||||
|
@ -7,9 +7,9 @@ use App\Filament\Admin\Resources\ServerResource;
|
||||
use App\Models\Server;
|
||||
use App\Traits\Filament\CanCustomizeHeaderActions;
|
||||
use App\Traits\Filament\CanCustomizeHeaderWidgets;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Actions\ActionGroup;
|
||||
use Filament\Actions\CreateAction;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Tables\Columns\SelectColumn;
|
||||
@ -106,7 +106,7 @@ class ListServers extends ListRecords
|
||||
]);
|
||||
}
|
||||
|
||||
/** @return array<Actions\Action|Actions\ActionGroup> */
|
||||
/** @return array<Action|ActionGroup> */
|
||||
protected function getDefaultHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
|
@ -9,7 +9,6 @@ use Filament\Resources\Pages\ListRecords;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Actions\ActionGroup;
|
||||
use Filament\Actions\CreateAction;
|
||||
use Filament\Actions\DeleteAction;
|
||||
|
||||
class ListUsers extends ListRecords
|
||||
{
|
||||
@ -18,7 +17,7 @@ class ListUsers extends ListRecords
|
||||
|
||||
protected static string $resource = UserResource::class;
|
||||
|
||||
/** @return array<Action|ActionGroup|CreateAction|DeleteAction> */
|
||||
/** @return array<Action|ActionGroup> */
|
||||
protected function getDefaultHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
|
@ -17,7 +17,6 @@ use Filament\Actions\ActionGroup;
|
||||
use Filament\Notifications\Notification;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
use Filament\Schemas\Components\Tabs\Tab;
|
||||
use Filament\Support\Enums\Alignment;
|
||||
use Filament\Support\Enums\TextSize;
|
||||
use Filament\Tables\Columns\Column;
|
||||
use Filament\Tables\Columns\Layout\Stack;
|
||||
@ -66,7 +65,8 @@ class ListServers extends ListRecords
|
||||
{
|
||||
return [
|
||||
TextColumn::make('condition')
|
||||
->label('')
|
||||
->label('Status')
|
||||
->alignCenter()
|
||||
->default('unknown')
|
||||
->wrap()
|
||||
->size(TextSize::Medium)
|
||||
@ -75,9 +75,9 @@ class ListServers extends ListRecords
|
||||
->icon(fn (Server $server) => $server->condition->getIcon())
|
||||
->color(fn (Server $server) => $server->condition->getColor()),
|
||||
TextColumn::make('name')
|
||||
->label('Server')
|
||||
->description(fn (Server $server) => $server->description)
|
||||
->grow()
|
||||
->label('')
|
||||
->size(TextSize::Medium)
|
||||
->searchable(),
|
||||
TextColumn::make('allocation.address')
|
||||
@ -87,7 +87,6 @@ class ListServers extends ListRecords
|
||||
->copyable(request()->isSecure()),
|
||||
TextColumn::make('cpuUsage')
|
||||
->label('Resources')
|
||||
->label('')
|
||||
->size(TextSize::Medium)
|
||||
->icon('tabler-cpu')
|
||||
->tooltip(fn (Server $server) => 'Usage Limit: ' . $server->formatResource('cpu', limit: true, type: ServerResourceType::Percentage, precision: 0))
|
||||
@ -97,7 +96,6 @@ class ListServers extends ListRecords
|
||||
->label('')
|
||||
->icon('tabler-device-desktop-analytics')
|
||||
->size(TextSize::Medium)
|
||||
->icon('tabler-memory')
|
||||
->tooltip(fn (Server $server) => 'Usage Limit: ' . $server->formatResource('memory', limit: true))
|
||||
->state(fn (Server $server) => $server->formatResource('memory_bytes'))
|
||||
->color(fn (Server $server) => $this->getResourceColor($server, 'memory')),
|
||||
@ -105,7 +103,6 @@ class ListServers extends ListRecords
|
||||
->label('')
|
||||
->icon('tabler-device-sd-card')
|
||||
->size(TextSize::Medium)
|
||||
->icon('tabler-device-floppy')
|
||||
->tooltip(fn (Server $server) => 'Usage Limit: ' . $server->formatResource('disk', limit: true))
|
||||
->state(fn (Server $server) => $server->formatResource('disk_bytes'))
|
||||
->color(fn (Server $server) => $this->getResourceColor($server, 'disk')),
|
||||
@ -126,10 +123,9 @@ class ListServers extends ListRecords
|
||||
->query(fn () => $baseQuery)
|
||||
->poll('15s')
|
||||
->columns($usingGrid ? $this->gridColumns() : $this->tableColumns())
|
||||
->recordUrl(!$usingGrid ? (fn (Server $server) => Console::getUrl(panel: 'server', tenant: $server)) : null)
|
||||
->recordActions(!$usingGrid ? ActionGroup::make(static::getPowerActions()) : [])
|
||||
->recordActionsAlignment(Alignment::Center->value)
|
||||
->contentGrid($usingGrid ? ['default' => 1, 'md' => 2] : null)
|
||||
->recordActions($usingGrid ? [] : ActionGroup::make(static::getPowerActions())->icon('tabler-power')->tooltip('Power Actions'))
|
||||
->recordUrl(fn (Server $server) => $usingGrid ? null : Console::getUrl(panel: 'server', tenant: $server))
|
||||
->emptyStateIcon('tabler-brand-docker')
|
||||
->emptyStateDescription('')
|
||||
->emptyStateHeading(fn () => $this->activeTab === 'my' ? 'You don\'t own any servers!' : 'You don\'t have access to any servers!')
|
||||
@ -238,34 +234,34 @@ class ListServers extends ListRecords
|
||||
}
|
||||
|
||||
/** @return Action[] */
|
||||
public static function getPowerActions(Server $server): array
|
||||
public static function getPowerActions(?Server $server = null): array
|
||||
{
|
||||
return [
|
||||
Action::make('start')
|
||||
->color('primary')
|
||||
->icon('tabler-player-play-filled')
|
||||
->authorize(fn () => auth()->user()->can(Permission::ACTION_CONTROL_START, $server))
|
||||
->visible(fn () => !$server->isInConflictState() & $server->retrieveStatus()->isStartable())
|
||||
->dispatch('powerAction', fn () => ['server' => $server, 'action' => 'start']),
|
||||
->authorize(fn (?Server $record) => auth()->user()->can(Permission::ACTION_CONTROL_START, $record ?? $server))
|
||||
->visible(fn (?Server $record) => !($record ?? $server)->isInConflictState() & ($record ?? $server)->retrieveStatus()->isStartable())
|
||||
->dispatch('powerAction', fn (?Server $record) => ['server' => $record ?? $server, 'action' => 'start']),
|
||||
Action::make('restart')
|
||||
->color('gray')
|
||||
->icon('tabler-reload')
|
||||
->authorize(fn () => auth()->user()->can(Permission::ACTION_CONTROL_RESTART, $server))
|
||||
->visible(fn () => !$server->isInConflictState() & $server->retrieveStatus()->isRestartable())
|
||||
->dispatch('powerAction', fn () => ['server' => $server, 'action' => 'restart']),
|
||||
->authorize(fn (?Server $record) => auth()->user()->can(Permission::ACTION_CONTROL_RESTART, $record ?? $server))
|
||||
->visible(fn (?Server $record) => !($record ?? $server)->isInConflictState() & ($record ?? $server)->retrieveStatus()->isRestartable())
|
||||
->dispatch('powerAction', fn (?Server $record) => ['server' => $record ?? $server, 'action' => 'restart']),
|
||||
Action::make('stop')
|
||||
->color('danger')
|
||||
->icon('tabler-player-stop-filled')
|
||||
->authorize(fn () => auth()->user()->can(Permission::ACTION_CONTROL_STOP, $server))
|
||||
->visible(fn () => !$server->isInConflictState() & $server->retrieveStatus()->isStoppable())
|
||||
->dispatch('powerAction', fn () => ['server' => $server, 'action' => 'stop']),
|
||||
->authorize(fn (?Server $record) => auth()->user()->can(Permission::ACTION_CONTROL_STOP, $record ?? $server))
|
||||
->visible(fn (?Server $record) => !($record ?? $server)->isInConflictState() & ($record ?? $server)->retrieveStatus()->isStoppable())
|
||||
->dispatch('powerAction', fn (?Server $record) => ['server' => $record ?? $server, 'action' => 'stop']),
|
||||
Action::make('kill')
|
||||
->color('danger')
|
||||
->icon('tabler-alert-square')
|
||||
->tooltip('This can result in data corruption and/or data loss!')
|
||||
->authorize(fn () => auth()->user()->can(Permission::ACTION_CONTROL_STOP, $server))
|
||||
->visible(fn () => !$server->isInConflictState() & $server->retrieveStatus()->isKillable())
|
||||
->dispatch('powerAction', fn () => ['server' => $server, 'action' => 'kill']),
|
||||
->authorize(fn (?Server $record) => auth()->user()->can(Permission::ACTION_CONTROL_STOP, $record ?? $server))
|
||||
->visible(fn (?Server $record) => !($record ?? $server)->isInConflictState() & ($record ?? $server)->retrieveStatus()->isKillable())
|
||||
->dispatch('powerAction', fn (?Server $record) => ['server' => $record ?? $server, 'action' => 'kill']),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ use App\Extensions\Captcha\Providers\CaptchaProvider;
|
||||
use App\Extensions\OAuth\Providers\OAuthProvider;
|
||||
use App\Facades\Activity;
|
||||
use App\Models\User;
|
||||
use Filament\Auth\Http\Responses\LoginResponse;
|
||||
use Filament\Auth\Http\Responses\Contracts\LoginResponse;
|
||||
use Filament\Facades\Filament;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
|
@ -3,14 +3,11 @@
|
||||
namespace App\Filament\Server\Components;
|
||||
|
||||
use Closure;
|
||||
use Filament\Support\Concerns\EvaluatesClosures;
|
||||
use Filament\Widgets\StatsOverviewWidget\Stat;
|
||||
use Illuminate\Contracts\View\View;
|
||||
|
||||
class SmallStatBlock extends Stat
|
||||
{
|
||||
use EvaluatesClosures;
|
||||
|
||||
protected bool|Closure $copyOnClick = false;
|
||||
|
||||
public function copyOnClick(bool|Closure $copyOnClick = true): static
|
||||
@ -27,6 +24,6 @@ class SmallStatBlock extends Stat
|
||||
|
||||
public function render(): View
|
||||
{
|
||||
return view('filament.components.server-small-data-block', $this->data());
|
||||
return view('filament.components.server-small-data-block', array_merge($this->getViewData(), $this->extractPublicMethods()));
|
||||
}
|
||||
}
|
||||
|
@ -20,6 +20,7 @@ use Filament\Facades\Filament;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Actions\ActionGroup;
|
||||
use Filament\Pages\Page;
|
||||
use Filament\Schemas\Components\Concerns\HasHeaderActions;
|
||||
use Filament\Support\Enums\Size;
|
||||
use Filament\Widgets\Widget;
|
||||
use Filament\Widgets\WidgetConfiguration;
|
||||
@ -27,7 +28,9 @@ use Livewire\Attributes\On;
|
||||
|
||||
class Console extends Page
|
||||
{
|
||||
use CanCustomizeHeaderActions;
|
||||
use CanCustomizeHeaderActions, HasHeaderActions {
|
||||
CanCustomizeHeaderActions::getHeaderActions insteadof HasHeaderActions;
|
||||
}
|
||||
use InteractsWithActions;
|
||||
|
||||
protected static ?int $navigationSort = 1;
|
||||
@ -141,9 +144,7 @@ class Console extends Page
|
||||
$this->status = ContainerStatus::from($state);
|
||||
}
|
||||
|
||||
$this->cachedHeaderActions = [];
|
||||
|
||||
$this->cacheHeaderActions();
|
||||
$this->headerActions($this->getHeaderActions());
|
||||
}
|
||||
|
||||
/** @return array<Action|ActionGroup> */
|
||||
|
@ -8,13 +8,12 @@ use App\Traits\Filament\CanCustomizeHeaderActions;
|
||||
use App\Traits\Filament\CanCustomizeHeaderWidgets;
|
||||
use Filament\Facades\Filament;
|
||||
use Filament\Forms\Concerns\InteractsWithForms;
|
||||
use Filament\Schemas\Components\Form;
|
||||
use Filament\Pages\Concerns\InteractsWithFormActions;
|
||||
use Filament\Pages\Page;
|
||||
use Filament\Schemas\Schema;
|
||||
|
||||
/**
|
||||
* @property Form $form
|
||||
* @property Schema $form
|
||||
*/
|
||||
abstract class ServerFormPage extends Page
|
||||
{
|
||||
@ -26,6 +25,7 @@ abstract class ServerFormPage extends Page
|
||||
|
||||
protected string $view = 'filament.server.pages.server-form-page';
|
||||
|
||||
/** @var array<string, mixed>|null */
|
||||
public ?array $data = [];
|
||||
|
||||
public function mount(): void
|
||||
@ -58,4 +58,6 @@ abstract class ServerFormPage extends Page
|
||||
|
||||
return $server;
|
||||
}
|
||||
|
||||
public function save(): void {}
|
||||
}
|
||||
|
@ -24,7 +24,6 @@ use Filament\Pages\Concerns\InteractsWithFormActions;
|
||||
use Filament\Panel;
|
||||
use Filament\Resources\Pages\Page;
|
||||
use Filament\Resources\Pages\PageRegistration;
|
||||
use Filament\Schemas\Components\Form;
|
||||
use Filament\Schemas\Components\Section;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Support\Enums\Alignment;
|
||||
@ -36,7 +35,7 @@ use Illuminate\Support\Facades\Route as RouteFacade;
|
||||
use Livewire\Attributes\Locked;
|
||||
|
||||
/**
|
||||
* @property Schema $schema
|
||||
* @property Schema $form
|
||||
*/
|
||||
class EditFiles extends Page
|
||||
{
|
||||
@ -56,6 +55,7 @@ class EditFiles extends Page
|
||||
|
||||
private DaemonFileRepository $fileRepository;
|
||||
|
||||
/** @var array<string, mixed>|null */
|
||||
public ?array $data = [];
|
||||
|
||||
/**
|
||||
@ -201,7 +201,7 @@ class EditFiles extends Page
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<int | string, string | Form>
|
||||
* @return array<string, Schema>
|
||||
*/
|
||||
protected function getForms(): array
|
||||
{
|
||||
|
@ -11,8 +11,9 @@ use App\Traits\Filament\CanCustomizeHeaderActions;
|
||||
use App\Traits\Filament\CanCustomizeHeaderWidgets;
|
||||
use Exception;
|
||||
use Filament\Actions\CreateAction;
|
||||
use Filament\Facades\Filament;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Actions\ActionGroup;
|
||||
use Filament\Facades\Filament;
|
||||
use Filament\Forms\Components\CheckboxList;
|
||||
use Filament\Schemas\Components\Actions;
|
||||
use Filament\Schemas\Components\Grid;
|
||||
@ -32,7 +33,7 @@ class ListUsers extends ListRecords
|
||||
|
||||
protected static string $resource = UserResource::class;
|
||||
|
||||
/** @return array<Actions\Action|Actions\ActionGroup> */
|
||||
/** @return array<Action|ActionGroup> */
|
||||
protected function getDefaultHeaderActions(): array
|
||||
{
|
||||
/** @var Server $server */
|
||||
|
@ -17,10 +17,11 @@ use Exception;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Schemas\Components\Wizard;
|
||||
use Filament\Forms\Concerns\InteractsWithForms;
|
||||
use Filament\Schemas\Components\Form;
|
||||
use Filament\Notifications\Notification;
|
||||
use Filament\Pages\SimplePage;
|
||||
use Filament\Schemas\Components\Component;
|
||||
use Filament\Schemas\Contracts\HasSchemas;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Support\Enums\Width;
|
||||
use Filament\Support\Exceptions\Halt;
|
||||
use Illuminate\Support\Facades\Artisan;
|
||||
@ -28,7 +29,7 @@ use Illuminate\Support\Facades\Blade;
|
||||
use Illuminate\Support\HtmlString;
|
||||
|
||||
/**
|
||||
* @property Form $form
|
||||
* @property Schema $schema
|
||||
*/
|
||||
class PanelInstaller extends SimplePage implements HasSchemas
|
||||
{
|
||||
@ -36,6 +37,7 @@ class PanelInstaller extends SimplePage implements HasSchemas
|
||||
use EnvironmentWriterTrait;
|
||||
use InteractsWithForms;
|
||||
|
||||
/** @var array<string, mixed> */
|
||||
public array $data = [];
|
||||
|
||||
protected string $view = 'filament.pages.installer';
|
||||
@ -54,9 +56,10 @@ class PanelInstaller extends SimplePage implements HasSchemas
|
||||
{
|
||||
abort_if(self::isInstalled(), 404);
|
||||
|
||||
$this->form->fill();
|
||||
$this->schema->fill();
|
||||
}
|
||||
|
||||
/** @return Component[] */
|
||||
protected function getFormSchema(): array
|
||||
{
|
||||
return [
|
||||
|
@ -25,7 +25,7 @@ trait CanCustomizeHeaderActions
|
||||
return [];
|
||||
}
|
||||
|
||||
/** @return array<Action|ActionGroup|CreateAction|DeleteAction>
|
||||
/** @return array<Action|ActionGroup>
|
||||
* @throws Exception
|
||||
*/
|
||||
protected function getHeaderActions(): array
|
||||
|
Loading…
x
Reference in New Issue
Block a user