Compare commits

...

7 Commits

Author SHA1 Message Date
Lance Pioch
2bfc788e13 Allow searching for port when associating allocations (#801) 2024-12-08 16:24:00 -05:00
Lance Pioch
839ff96271 Fix power buttons (#799) 2024-12-08 16:19:15 -05:00
Lance Pioch
5d2b892eab Better IP addresses (#800)
* Unique ip addresses

* Only ipv4 addresses for now

* Switch to selects
2024-12-08 16:19:04 -05:00
MartinOscar
c953b97009 Force width (#798) 2024-12-08 20:27:16 +01:00
MartinOscar
9716b1e64d Only allow one * (#797) 2024-12-08 20:23:37 +01:00
Boy132
8358e410dc Move installer to correct namespace (#795) 2024-12-08 19:57:00 +01:00
Boy132
f6c586bf5b Add persistFiltersInSession to server list (#796) 2024-12-08 19:14:56 +01:00
17 changed files with 57 additions and 32 deletions

View File

@@ -5,6 +5,7 @@ namespace App\Filament\Admin\Resources\NodeResource\RelationManagers;
use App\Models\Allocation;
use App\Models\Node;
use App\Services\Allocations\AssignmentService;
use Filament\Forms\Components\Select;
use Filament\Forms\Components\TagsInput;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Form;
@@ -73,8 +74,8 @@ class AllocationsRelationManager extends RelationManager
->headerActions([
Tables\Actions\Action::make('create new allocation')->label('Create Allocations')
->form(fn () => [
TextInput::make('allocation_ip')
->datalist($this->getOwnerRecord()->ipAddresses())
Select::make('allocation_ip')
->options(collect($this->getOwnerRecord()->ipAddresses())->mapWithKeys(fn (string $ip) => [$ip => $ip]))
->label('IP Address')
->inlineLabel()
->ipv4()

View File

@@ -192,13 +192,12 @@ class CreateServer extends CreateRecord
->whereNull('server_id'),
)
->createOptionForm(fn (Get $get) => [
TextInput::make('allocation_ip')
->datalist(Node::find($get('node_id'))?->ipAddresses() ?? [])
Select::make('allocation_ip')
->options(collect(Node::find($get('node_id'))?->ipAddresses())->mapWithKeys(fn (string $ip) => [$ip => $ip]))
->label('IP Address')
->inlineLabel()
->ipv4()
->helperText("Usually your machine's public IP unless you are port forwarding.")
// ->selectablePlaceholder(false)
->required(),
TextInput::make('allocation_alias')
->label('Alias')

View File

@@ -5,6 +5,7 @@ namespace App\Filament\Admin\Resources\ServerResource\RelationManagers;
use App\Models\Allocation;
use App\Models\Server;
use App\Services\Allocations\AssignmentService;
use Filament\Forms\Components\Select;
use Filament\Forms\Components\TagsInput;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Form;
@@ -71,8 +72,8 @@ class AllocationsRelationManager extends RelationManager
CreateAction::make()->label('Create Allocation')
->createAnother(false)
->form(fn () => [
TextInput::make('allocation_ip')
->datalist($this->getOwnerRecord()->node->ipAddresses())
Select::make('allocation_ip')
->options(collect($this->getOwnerRecord()->node->ipAddresses())->mapWithKeys(fn (string $ip) => [$ip => $ip]))
->label('IP Address')
->inlineLabel()
->ipv4()
@@ -151,6 +152,7 @@ class AllocationsRelationManager extends RelationManager
->associateAnother(false)
->preloadRecordSelect()
->recordSelectOptionsQuery(fn ($query) => $query->whereBelongsTo($this->getOwnerRecord()->node)->whereNull('server_id'))
->recordSelectSearchColumns(['ip', 'port'])
->label('Add Allocation'),
])
->bulkActions([

View File

@@ -42,6 +42,7 @@ class ListServers extends ListRecords
->emptyStateIcon('tabler-brand-docker')
->emptyStateDescription('')
->emptyStateHeading('You don\'t have access to any servers!')
->persistFiltersInSession()
->filters([
TernaryFilter::make('only_my_servers')
->label('Owned by')

View File

@@ -2,6 +2,7 @@
namespace App\Filament\Server\Pages;
use App\Enums\ContainerStatus;
use App\Filament\Server\Widgets\ServerConsole;
use App\Filament\Server\Widgets\ServerCpuChart;
use App\Filament\Server\Widgets\ServerMemoryChart;
@@ -12,6 +13,7 @@ use Filament\Actions\Action;
use Filament\Facades\Filament;
use Filament\Pages\Page;
use Filament\Support\Enums\ActionSize;
use Livewire\Attributes\On;
class Console extends Page
{
@@ -21,6 +23,8 @@ class Console extends Page
protected static string $view = 'filament.server.pages.console';
public ContainerStatus $status = ContainerStatus::Missing;
public function getWidgetData(): array
{
return [
@@ -50,6 +54,16 @@ class Console extends Page
return 3;
}
#[On('powerChanged')]
public function powerChanged(string $state): void
{
$this->status = ContainerStatus::from($state);
$this->cachedHeaderActions = [];
$this->cacheHeaderActions();
}
protected function getHeaderActions(): array
{
/** @var Server $server */
@@ -60,17 +74,18 @@ class Console extends Page
->color('primary')
->size(ActionSize::ExtraLarge)
->action(fn () => $this->dispatch('setServerState', state: 'start'))
->disabled(fn () => $server->isInConflictState()),
->disabled(fn () => $server->isInConflictState() || in_array($this->status, [ContainerStatus::Running, ContainerStatus::Starting, ContainerStatus::Stopping, ContainerStatus::Restarting])),
Action::make('restart')
->color('gray')
->size(ActionSize::ExtraLarge)
->action(fn () => $this->dispatch('setServerState', state: 'restart'))
->disabled(fn () => $server->isInConflictState() || $server->retrieveStatus() == 'offline'),
->disabled(fn () => $server->isInConflictState() || $this->status !== ContainerStatus::Running),
Action::make('stop')
->color('danger')
->size(ActionSize::ExtraLarge)
->action(fn () => $this->dispatch('setServerState', state: 'stop'))
->disabled(fn () => $server->isInConflictState() || $server->retrieveStatus() == 'offline'),
->hidden(fn () => in_array($this->status, [ContainerStatus::Stopping, ContainerStatus::Restarting, ContainerStatus::Starting]))
->disabled(fn () => $server->isInConflictState() || in_array($this->status, [ContainerStatus::Starting, ContainerStatus::Stopping, ContainerStatus::Restarting, ContainerStatus::Exited, ContainerStatus::Offline])),
Action::make('kill')
->color('danger')
->requiresConfirmation()
@@ -79,7 +94,8 @@ class Console extends Page
->modalSubmitActionLabel('Kill Server')
->size(ActionSize::ExtraLarge)
->action(fn () => $this->dispatch('setServerState', state: 'kill'))
->disabled(fn () => $server->isInConflictState() || $server->retrieveStatus() == 'offline'),
->hidden(fn () => $server->isInConflictState() || in_array($this->status, [ContainerStatus::Running, ContainerStatus::Restarting, ContainerStatus::Offline, ContainerStatus::Removing, ContainerStatus::Dead, ContainerStatus::Exited, ContainerStatus::Created]))
->disabled(fn () => $server->isInConflictState() || $this->status === ContainerStatus::Offline),
];
}
}

View File

@@ -545,6 +545,7 @@ class ListFiles extends ListRecords
->form([
TextInput::make('searchTerm')
->placeholder('Enter a search term, e.g. *.txt')
->regex('/^[^*]*\*?[^*]*$/')
->minLength(3),
])
->action(fn ($data) => redirect(SearchFiles::getUrl([

View File

@@ -2,7 +2,7 @@
namespace App\Http\Controllers\Auth;
use App\Filament\Pages\Installer\PanelInstaller;
use App\Livewire\Installer\PanelInstaller;
use Carbon\CarbonImmutable;
use Illuminate\Http\RedirectResponse;
use Illuminate\Support\Str;

View File

@@ -1,14 +1,14 @@
<?php
namespace App\Filament\Pages\Installer;
namespace App\Livewire\Installer;
use App\Filament\Admin\Pages\Dashboard;
use App\Filament\Pages\Installer\Steps\CacheStep;
use App\Filament\Pages\Installer\Steps\DatabaseStep;
use App\Filament\Pages\Installer\Steps\EnvironmentStep;
use App\Filament\Pages\Installer\Steps\QueueStep;
use App\Filament\Pages\Installer\Steps\RequirementsStep;
use App\Filament\Pages\Installer\Steps\SessionStep;
use App\Livewire\Installer\Steps\CacheStep;
use App\Livewire\Installer\Steps\DatabaseStep;
use App\Livewire\Installer\Steps\EnvironmentStep;
use App\Livewire\Installer\Steps\QueueStep;
use App\Livewire\Installer\Steps\RequirementsStep;
use App\Livewire\Installer\Steps\SessionStep;
use App\Models\User;
use App\Services\Users\UserCreationService;
use App\Traits\CheckMigrationsTrait;
@@ -42,7 +42,7 @@ class PanelInstaller extends SimplePage implements HasForms
public function getMaxWidth(): MaxWidth|string
{
return config('panel.filament.display-width', 'screen-2xl');
return MaxWidth::SevenExtraLarge;
}
public static function isInstalled(): bool

View File

@@ -1,8 +1,8 @@
<?php
namespace App\Filament\Pages\Installer\Steps;
namespace App\Livewire\Installer\Steps;
use App\Filament\Pages\Installer\PanelInstaller;
use App\Livewire\Installer\PanelInstaller;
use Exception;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Components\ToggleButtons;

View File

@@ -1,8 +1,8 @@
<?php
namespace App\Filament\Pages\Installer\Steps;
namespace App\Livewire\Installer\Steps;
use App\Filament\Pages\Installer\PanelInstaller;
use App\Livewire\Installer\PanelInstaller;
use Exception;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Components\ToggleButtons;

View File

@@ -1,8 +1,8 @@
<?php
namespace App\Filament\Pages\Installer\Steps;
namespace App\Livewire\Installer\Steps;
use App\Filament\Pages\Installer\PanelInstaller;
use App\Livewire\Installer\PanelInstaller;
use Filament\Forms\Components\Fieldset;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Components\Wizard\Step;

View File

@@ -1,8 +1,8 @@
<?php
namespace App\Filament\Pages\Installer\Steps;
namespace App\Livewire\Installer\Steps;
use App\Filament\Pages\Installer\PanelInstaller;
use App\Livewire\Installer\PanelInstaller;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Components\Toggle;
use Filament\Forms\Components\ToggleButtons;

View File

@@ -1,6 +1,6 @@
<?php
namespace App\Filament\Pages\Installer\Steps;
namespace App\Livewire\Installer\Steps;
use Filament\Forms\Components\Placeholder;
use Filament\Forms\Components\Section;

View File

@@ -1,6 +1,6 @@
<?php
namespace App\Filament\Pages\Installer\Steps;
namespace App\Livewire\Installer\Steps;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Components\ToggleButtons;

View File

@@ -384,7 +384,10 @@ class Node extends Model
// pass
}
return $ips->all();
// Only IPV4
$ips = $ips->filter(fn (string $ip) => filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4) !== false);
return $ips->unique()->all();
});
}
}

View File

@@ -125,6 +125,8 @@
break;
case 'status':
handlePowerChangeEvent(args[0]);
$wire.dispatch('powerChanged', {state: args[0]})
break;
case 'transfer status':
handleTransferStatus(args[0]);

View File

@@ -1,6 +1,6 @@
<?php
use App\Filament\Pages\Installer\PanelInstaller;
use App\Livewire\Installer\PanelInstaller;
use Illuminate\Support\Facades\Route;
use App\Http\Controllers\Base;
use App\Http\Middleware\RequireTwoFactorAuthentication;