mirror of
https://github.com/pelican-dev/panel.git
synced 2025-05-28 10:24:45 +02:00
Merge branch 'feature/filament' of github.com:pelican-dev/panel into feature/filament
# Conflicts: # app/Filament/Resources/ServerResource.php # app/Filament/Resources/ServerResource/Pages/CreateServer.php
This commit is contained in:
commit
287c657e60
@ -33,7 +33,7 @@ class ApiKeyResource extends Resource
|
||||
];
|
||||
}
|
||||
|
||||
public function getDefaultActiveTab(): string | int | null
|
||||
public function getDefaultActiveTab(): string|int|null
|
||||
{
|
||||
return 'application';
|
||||
}
|
||||
@ -73,32 +73,31 @@ class ApiKeyResource extends Resource
|
||||
->default(ApiKey::TYPE_APPLICATION),
|
||||
|
||||
Forms\Components\Fieldset::make('Permissions')->schema(
|
||||
collect(ApiKey::RESOURCES)->map(fn ($resource) =>
|
||||
Forms\Components\ToggleButtons::make("r_$resource")
|
||||
->label(str($resource)->replace('_', ' ')->title())
|
||||
->options([
|
||||
0 => 'None',
|
||||
1 => 'Read',
|
||||
// 2 => 'Write',
|
||||
3 => 'Read & Write',
|
||||
])
|
||||
->icons([
|
||||
0 => 'tabler-book-off',
|
||||
1 => 'tabler-book',
|
||||
2 => 'tabler-writing',
|
||||
3 => 'tabler-writing',
|
||||
])
|
||||
->colors([
|
||||
0 => 'success',
|
||||
1 => 'warning',
|
||||
2 => 'danger',
|
||||
3 => 'danger',
|
||||
])
|
||||
->inline()
|
||||
->required()
|
||||
->disabledOn('edit')
|
||||
->default(0),
|
||||
)->all(),
|
||||
collect(ApiKey::RESOURCES)->map(fn ($resource) => Forms\Components\ToggleButtons::make("r_$resource")
|
||||
->label(str($resource)->replace('_', ' ')->title())
|
||||
->options([
|
||||
0 => 'None',
|
||||
1 => 'Read',
|
||||
// 2 => 'Write',
|
||||
3 => 'Read & Write',
|
||||
])
|
||||
->icons([
|
||||
0 => 'tabler-book-off',
|
||||
1 => 'tabler-book',
|
||||
2 => 'tabler-writing',
|
||||
3 => 'tabler-writing',
|
||||
])
|
||||
->colors([
|
||||
0 => 'success',
|
||||
1 => 'warning',
|
||||
2 => 'danger',
|
||||
3 => 'danger',
|
||||
])
|
||||
->inline()
|
||||
->required()
|
||||
->disabledOn('edit')
|
||||
->default(0),
|
||||
)->all(),
|
||||
),
|
||||
|
||||
Forms\Components\TagsInput::make('allowed_ips')
|
||||
|
@ -3,7 +3,6 @@
|
||||
namespace App\Filament\Resources\ApiKeyResource\Pages;
|
||||
|
||||
use App\Filament\Resources\ApiKeyResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateApiKey extends CreateRecord
|
||||
|
@ -25,17 +25,15 @@ class ListApiKeys extends ListRecords
|
||||
return [
|
||||
'all' => Tab::make('All Keys'),
|
||||
'application' => Tab::make('Application Keys')
|
||||
->modifyQueryUsing(fn (Builder $query) =>
|
||||
$query->where('key_type', ApiKey::TYPE_APPLICATION)
|
||||
->modifyQueryUsing(fn (Builder $query) => $query->where('key_type', ApiKey::TYPE_APPLICATION)
|
||||
),
|
||||
'account' => Tab::make('Account Keys')
|
||||
->modifyQueryUsing(fn (Builder $query) =>
|
||||
$query->where('key_type', ApiKey::TYPE_ACCOUNT)
|
||||
->modifyQueryUsing(fn (Builder $query) => $query->where('key_type', ApiKey::TYPE_ACCOUNT)
|
||||
),
|
||||
];
|
||||
}
|
||||
|
||||
public function getDefaultActiveTab(): string | int | null
|
||||
public function getDefaultActiveTab(): string|int|null
|
||||
{
|
||||
return 'application';
|
||||
}
|
||||
|
@ -3,15 +3,12 @@
|
||||
namespace App\Filament\Resources;
|
||||
|
||||
use App\Filament\Resources\DatabaseHostResource\Pages;
|
||||
use App\Filament\Resources\DatabaseHostResource\RelationManagers;
|
||||
use App\Models\DatabaseHost;
|
||||
use Filament\Forms;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Tables;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||
|
||||
class DatabaseHostResource extends Resource
|
||||
{
|
||||
@ -81,12 +78,6 @@ class DatabaseHostResource extends Resource
|
||||
Tables\Columns\TextColumn::make('node.name')
|
||||
->numeric()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('created_at')
|
||||
->dateTime()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('updated_at')
|
||||
->dateTime()
|
||||
->sortable(),
|
||||
])
|
||||
->filters([
|
||||
//
|
||||
|
@ -3,7 +3,6 @@
|
||||
namespace App\Filament\Resources\DatabaseHostResource\Pages;
|
||||
|
||||
use App\Filament\Resources\DatabaseHostResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateDatabaseHost extends CreateRecord
|
||||
|
@ -3,15 +3,12 @@
|
||||
namespace App\Filament\Resources;
|
||||
|
||||
use App\Filament\Resources\DatabaseResource\Pages;
|
||||
use App\Filament\Resources\DatabaseResource\RelationManagers;
|
||||
use App\Models\Database;
|
||||
use Filament\Forms;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Tables;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||
|
||||
class DatabaseResource extends Resource
|
||||
{
|
||||
|
@ -3,7 +3,6 @@
|
||||
namespace App\Filament\Resources\DatabaseResource\Pages;
|
||||
|
||||
use App\Filament\Resources\DatabaseResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateDatabase extends CreateRecord
|
||||
|
@ -20,7 +20,6 @@ class EggResource extends Resource
|
||||
|
||||
protected static ?string $recordRouteKeyName = 'id';
|
||||
|
||||
|
||||
public static function form(Form $form): Form
|
||||
{
|
||||
return $form
|
||||
@ -94,7 +93,7 @@ class EggResource extends Resource
|
||||
Forms\Components\TextInput::make('env_variable')->maxLength(191),
|
||||
Forms\Components\TextInput::make('default_value')->maxLength(191),
|
||||
Forms\Components\Textarea::make('rules')->rows(3)->columnSpanFull()->required(),
|
||||
])
|
||||
]),
|
||||
]),
|
||||
Forms\Components\Tabs\Tab::make('Install Script')
|
||||
->columns(3)
|
||||
|
@ -3,7 +3,6 @@
|
||||
namespace App\Filament\Resources\EggResource\Pages;
|
||||
|
||||
use App\Filament\Resources\EggResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateEgg extends CreateRecord
|
||||
|
@ -53,7 +53,7 @@ class ListEggs extends ListRecords
|
||||
->send();
|
||||
|
||||
redirect()->route('filament.admin.resources.eggs.edit', [$newEgg]);
|
||||
})
|
||||
}),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@ -3,15 +3,15 @@
|
||||
namespace App\Filament\Resources;
|
||||
|
||||
use App\Filament\Resources\MountResource\Pages;
|
||||
use App\Filament\Resources\MountResource\RelationManagers;
|
||||
use App\Models\Mount;
|
||||
use Filament\Forms;
|
||||
use Filament\Forms\Components\Group;
|
||||
use Filament\Forms\Components\Section;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Tables;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||
|
||||
class MountResource extends Resource
|
||||
{
|
||||
@ -23,57 +23,78 @@ class MountResource extends Resource
|
||||
{
|
||||
return $form
|
||||
->schema([
|
||||
Forms\Components\TextInput::make('name')
|
||||
->required()
|
||||
->helperText('Unique name used to separate this mount from another.')
|
||||
->maxLength(191),
|
||||
Forms\Components\ToggleButtons::make('read_only')
|
||||
->label('Read only?')
|
||||
->helperText('Is the mount read only inside the container?')
|
||||
->options([
|
||||
false => 'Writeable',
|
||||
true => 'Read only',
|
||||
])
|
||||
->icons([
|
||||
false => 'tabler-writing',
|
||||
true => 'tabler-writing-off',
|
||||
])
|
||||
->colors([
|
||||
false => 'warning',
|
||||
true => 'success',
|
||||
])
|
||||
->inline()
|
||||
->default(false)
|
||||
->required(),
|
||||
Forms\Components\TextInput::make('source')
|
||||
->required()
|
||||
->helperText('File path on the host system to mount to a container.')
|
||||
->maxLength(191),
|
||||
Forms\Components\TextInput::make('target')
|
||||
->required()
|
||||
->helperText('Where the mount will be accessible inside a container.')
|
||||
->maxLength(191),
|
||||
Forms\Components\ToggleButtons::make('user_mountable')
|
||||
->hidden()
|
||||
->label('User mountable?')
|
||||
->options([
|
||||
false => 'No',
|
||||
true => 'Yes',
|
||||
])
|
||||
->icons([
|
||||
false => 'tabler-user-cancel',
|
||||
true => 'tabler-user-bolt',
|
||||
])
|
||||
->colors([
|
||||
false => 'success',
|
||||
true => 'warning',
|
||||
])
|
||||
->default(false)
|
||||
->inline()
|
||||
->required(),
|
||||
Forms\Components\Textarea::make('description')
|
||||
->helperText('A longer description for this mount.')
|
||||
->columnSpanFull(),
|
||||
Section::make()->schema([
|
||||
Forms\Components\TextInput::make('name')
|
||||
->required()
|
||||
->helperText('Unique name used to separate this mount from another.')
|
||||
->maxLength(64),
|
||||
Forms\Components\ToggleButtons::make('read_only')
|
||||
->label('Read only?')
|
||||
->helperText('Is the mount read only inside the container?')
|
||||
->options([
|
||||
false => 'Writeable',
|
||||
true => 'Read only',
|
||||
])
|
||||
->icons([
|
||||
false => 'tabler-writing',
|
||||
true => 'tabler-writing-off',
|
||||
])
|
||||
->colors([
|
||||
false => 'warning',
|
||||
true => 'success',
|
||||
])
|
||||
->inline()
|
||||
->default(false)
|
||||
->required(),
|
||||
Forms\Components\TextInput::make('source')
|
||||
->required()
|
||||
->helperText('File path on the host system to mount to a container.')
|
||||
->maxLength(191),
|
||||
Forms\Components\TextInput::make('target')
|
||||
->required()
|
||||
->helperText('Where the mount will be accessible inside a container.')
|
||||
->maxLength(191),
|
||||
Forms\Components\ToggleButtons::make('user_mountable')
|
||||
->hidden()
|
||||
->label('User mountable?')
|
||||
->options([
|
||||
false => 'No',
|
||||
true => 'Yes',
|
||||
])
|
||||
->icons([
|
||||
false => 'tabler-user-cancel',
|
||||
true => 'tabler-user-bolt',
|
||||
])
|
||||
->colors([
|
||||
false => 'success',
|
||||
true => 'warning',
|
||||
])
|
||||
->default(false)
|
||||
->inline()
|
||||
->required(),
|
||||
Forms\Components\Textarea::make('description')
|
||||
->helperText('A longer description for this mount.')
|
||||
->columnSpanFull(),
|
||||
])->columnSpan(2)->columns([
|
||||
'default' => 1,
|
||||
'lg' => 2,
|
||||
]),
|
||||
Group::make()->schema([
|
||||
Section::make()->schema([
|
||||
Select::make('eggs')->multiple()
|
||||
->relationship('eggs', 'name')
|
||||
->preload(),
|
||||
Select::make('nodes')->multiple()
|
||||
->relationship('nodes', 'name')
|
||||
->searchable(['name', 'fqdn'])
|
||||
->preload(),
|
||||
]),
|
||||
])->columns([
|
||||
'default' => 1,
|
||||
]),
|
||||
])->columns([
|
||||
'default' => 1,
|
||||
'lg' => 3,
|
||||
]);
|
||||
}
|
||||
|
||||
@ -82,8 +103,8 @@ class MountResource extends Resource
|
||||
return $table
|
||||
->searchable(false)
|
||||
->columns([
|
||||
Tables\Columns\TextColumn::make('uuid')
|
||||
->label('UUID')
|
||||
Tables\Columns\TextColumn::make('id')
|
||||
->label('')
|
||||
->searchable(),
|
||||
Tables\Columns\TextColumn::make('name')
|
||||
->searchable(),
|
||||
@ -91,11 +112,14 @@ class MountResource extends Resource
|
||||
->searchable(),
|
||||
Tables\Columns\TextColumn::make('target')
|
||||
->searchable(),
|
||||
Tables\Columns\TextColumn::make('read_only')
|
||||
->numeric()
|
||||
Tables\Columns\IconColumn::make('read_only')
|
||||
->icon(fn (bool $state) => $state ? 'tabler-circle-check-filled' : 'tabler-circle-x-filled')
|
||||
->color(fn (bool $state) => $state ? 'success' : 'danger')
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('user_mountable')
|
||||
->numeric()
|
||||
Tables\Columns\IconColumn::make('user_mountable')
|
||||
->hidden()
|
||||
->icon(fn (bool $state) => $state ? 'tabler-circle-check-filled' : 'tabler-circle-x-filled')
|
||||
->color(fn (bool $state) => $state ? 'success' : 'danger')
|
||||
->sortable(),
|
||||
])
|
||||
->filters([
|
||||
|
@ -3,7 +3,6 @@
|
||||
namespace App\Filament\Resources\MountResource\Pages;
|
||||
|
||||
use App\Filament\Resources\MountResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateMount extends CreateRecord
|
||||
|
@ -3,10 +3,7 @@
|
||||
namespace App\Filament\Resources\NodeResource\Pages;
|
||||
|
||||
use App\Filament\Resources\NodeResource;
|
||||
use App\Models\Node;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Forms;
|
||||
use Filament\Notifications\Notification;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
use Illuminate\Support\HtmlString;
|
||||
|
||||
@ -98,11 +95,11 @@ class CreateNode extends CreateRecord
|
||||
->hintColor('success')
|
||||
->options([
|
||||
true => 'Valid',
|
||||
false => 'Invalid'
|
||||
false => 'Invalid',
|
||||
])
|
||||
->colors([
|
||||
true => 'success',
|
||||
false => 'danger'
|
||||
false => 'danger',
|
||||
]),
|
||||
|
||||
Forms\Components\TextInput::make('daemonListen')
|
||||
@ -115,8 +112,6 @@ class CreateNode extends CreateRecord
|
||||
->required()
|
||||
->integer(),
|
||||
|
||||
|
||||
|
||||
Forms\Components\TextInput::make('name')
|
||||
->label('Display Name')
|
||||
->columnSpan(2)
|
||||
|
@ -64,9 +64,9 @@ class EditNode extends EditRecord
|
||||
->maxValue(65535)
|
||||
->numeric(),
|
||||
Forms\Components\Select::make('server_id')->relationship('server', 'name'),
|
||||
])
|
||||
]),
|
||||
]),
|
||||
])
|
||||
]),
|
||||
]);
|
||||
}
|
||||
|
||||
|
@ -16,7 +16,6 @@ use Filament\Tables;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Illuminate\Support\HtmlString;
|
||||
|
||||
class ServerResource extends Resource
|
||||
{
|
||||
@ -64,7 +63,7 @@ class ServerResource extends Resource
|
||||
Forms\Components\Select::make('node_id')
|
||||
->disabledOn('edit')
|
||||
->prefixIcon('tabler-server-2')
|
||||
->default(fn () => Node::query()->latest()->first()->id)
|
||||
->default(fn () => Node::query()->latest()->first()?->id)
|
||||
->columnSpan(2)
|
||||
->live()
|
||||
->relationship('node', 'name')
|
||||
@ -80,8 +79,9 @@ class ServerResource extends Resource
|
||||
->columnSpan(3)
|
||||
->disabled(fn (Forms\Get $get) => $get('node_id') === null)
|
||||
->searchable(['ip', 'port', 'ip_alias'])
|
||||
->getOptionLabelFromRecordUsing(fn (Allocation $allocation) => "$allocation->ip:$allocation->port" .
|
||||
($allocation->ip_alias ? " ($allocation->ip_alias)" : '')
|
||||
->getOptionLabelFromRecordUsing(
|
||||
fn (Allocation $allocation) => "$allocation->ip:$allocation->port" .
|
||||
($allocation->ip_alias ? " ($allocation->ip_alias)" : '')
|
||||
)
|
||||
->placeholder(function (Forms\Get $get) {
|
||||
$node = Node::find($get('node_id'));
|
||||
@ -340,8 +340,10 @@ class ServerResource extends Resource
|
||||
->required()
|
||||
->live()
|
||||
->rows(function ($state) {
|
||||
return str($state)->explode("\n")->reduce(fn (int $carry, $line) => $carry + floor(strlen($line) / 125),
|
||||
0);
|
||||
return str($state)->explode("\n")->reduce(
|
||||
fn (int $carry, $line) => $carry + floor(strlen($line) / 125),
|
||||
0
|
||||
);
|
||||
})
|
||||
->columnSpanFull(),
|
||||
|
||||
@ -386,7 +388,7 @@ class ServerResource extends Resource
|
||||
->helperText(fn (Forms\Get $get) => empty($get('description')) ? '—' : $get('description'))
|
||||
->maxLength(191),
|
||||
|
||||
Forms\Components\Hidden::make('variable_id')->default(0)
|
||||
Forms\Components\Hidden::make('variable_id')->default(0),
|
||||
])
|
||||
->columnSpanFull(),
|
||||
]),
|
||||
|
@ -3,9 +3,7 @@
|
||||
namespace App\Filament\Resources\ServerResource\Pages;
|
||||
|
||||
use App\Filament\Resources\ServerResource;
|
||||
use App\Models\Allocation;
|
||||
use Filament\Actions;
|
||||
use Filament\Forms;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditServer extends EditRecord
|
||||
|
@ -3,15 +3,12 @@
|
||||
namespace App\Filament\Resources;
|
||||
|
||||
use App\Filament\Resources\UserResource\Pages;
|
||||
use App\Filament\Resources\UserResource\RelationManagers;
|
||||
use App\Models\User;
|
||||
use Filament\Forms;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Tables;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
|
||||
class UserResource extends Resource
|
||||
|
@ -3,7 +3,6 @@
|
||||
namespace App\Filament\Resources\UserResource\Pages;
|
||||
|
||||
use App\Filament\Resources\UserResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateUser extends CreateRecord
|
||||
|
@ -8,7 +8,6 @@ use Filament\Forms\Components\Repeater;
|
||||
use Filament\Forms\Components\Tabs;
|
||||
use Filament\Forms\Components\Tabs\Tab;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Forms\Get;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Support\HtmlString;
|
||||
@ -85,14 +84,14 @@ class EditProfile extends \Filament\Pages\Auth\EditProfile
|
||||
|
||||
->schema([
|
||||
Placeholder::make('activity!')->label('')->content(fn (ActivityLog $log) => new HtmlString($log->htmlable())),
|
||||
])
|
||||
]),
|
||||
]),
|
||||
]),
|
||||
])
|
||||
->operation('edit')
|
||||
->model($this->getUser())
|
||||
->statePath('data')
|
||||
->inlineLabel(! static::isSimple()),
|
||||
->inlineLabel(!static::isSimple()),
|
||||
),
|
||||
];
|
||||
}
|
||||
|
@ -115,4 +115,9 @@ class Mount extends Model
|
||||
{
|
||||
return $this->belongsToMany(Server::class);
|
||||
}
|
||||
|
||||
public function getRouteKeyName(): string
|
||||
{
|
||||
return 'id';
|
||||
}
|
||||
}
|
||||
|
@ -126,7 +126,6 @@ class Node extends Model
|
||||
return 'id';
|
||||
}
|
||||
|
||||
|
||||
protected static function booted(): void
|
||||
{
|
||||
static::creating(function (self $node) {
|
||||
|
@ -83,7 +83,7 @@ use App\Notifications\SendPasswordReset as ResetPasswordNotification;
|
||||
*
|
||||
* @mixin \Eloquent
|
||||
*/
|
||||
class User extends Model implements AuthenticatableContract, AuthorizableContract, CanResetPasswordContract, FilamentUser, HasName, HasAvatar
|
||||
class User extends Model implements AuthenticatableContract, AuthorizableContract, CanResetPasswordContract, FilamentUser, HasAvatar, HasName
|
||||
{
|
||||
use Authenticatable;
|
||||
use Authorizable {can as protected canned; }
|
||||
@ -340,7 +340,7 @@ class User extends Model implements AuthenticatableContract, AuthorizableContrac
|
||||
{
|
||||
$rootAdmins = User::query()->where('root_admin', true)->limit(2)->get();
|
||||
|
||||
return once(fn() => $rootAdmins->count() === 1 && $rootAdmins->first()->is($this));
|
||||
return once(fn () => $rootAdmins->count() === 1 && $rootAdmins->first()->is($this));
|
||||
}
|
||||
|
||||
public function canAccessPanel(Panel $panel): bool
|
||||
|
@ -25,6 +25,7 @@ class EggParserService
|
||||
$parsed = json_decode($file->getContent(), true, 512, JSON_THROW_ON_ERROR);
|
||||
|
||||
$version = $parsed['meta']['version'] ?? '';
|
||||
|
||||
return match ($version) {
|
||||
'PTDL_v1' => $this->convertToV2($parsed),
|
||||
'PTDL_v2' => $parsed,
|
||||
|
Loading…
x
Reference in New Issue
Block a user