Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change limits section on front end #853

Merged
merged 2 commits into from
Jan 4, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 38 additions & 6 deletions app/Filament/Server/Pages/Settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
use Filament\Support\Enums\Alignment;
use GuzzleHttp\Exception\TransferException;
use Illuminate\Support\Facades\Http;
use Illuminate\Support\Number;

class Settings extends ServerFormPage
{
Expand Down Expand Up @@ -99,21 +100,52 @@ public function form(Form $form): Form
'lg' => 3,
])
->schema([
TextInput::make('cpu')
->label('')
->prefix('CPU')
->prefixIcon('tabler-cpu')
->columnSpan(1)
->disabled()
->formatStateUsing(fn ($state, Server $server) => !$state ? 'Unlimited' : Number::format($server->cpu, locale: auth()->user()->language) . '%'),
TextInput::make('memory')
->label('')
->prefix('Memory')
->prefixIcon('tabler-device-desktop-analytics')
->columnSpan(1)
->disabled()
->formatStateUsing(fn ($state, Server $server) => !$state ? 'Unlimited' : (config('panel.use_binary_prefix')
? Number::format($server->memory / 1024, maxPrecision: 2, locale: auth()->user()->language) .' GiB'
: Number::format($server->memory / 1000, maxPrecision: 2, locale: auth()->user()->language) . ' GB')),
notAreYouScared marked this conversation as resolved.
Show resolved Hide resolved
TextInput::make('disk')
->label('')
->prefix('Disk Space')
->prefixIcon('tabler-device-sd-card')
->columnSpan(1)
->disabled()
->formatStateUsing(fn ($state, Server $server) => !$state ? 'Unlimited' : (config('panel.use_binary_prefix')
? Number::format($server->disk / 1024, maxPrecision: 2, locale: auth()->user()->language) .' GiB'
: Number::format($server->disk / 1000, maxPrecision: 2, locale: auth()->user()->language) . ' GB')),
TextInput::make('backup_limit')
->label('Backup Limit')
->label('')
->prefix('Backups')
->prefixIcon('tabler-file-zip')
->columnSpan(1)
->disabled()
->formatStateUsing(fn ($state, Server $server) => !$state ? 'No Backups can be created' : $server->backups->count() . ' of ' . $state),
->formatStateUsing(fn ($state, Server $server) => !$state ? 'No Backups' : $server->backups->count() . ' of ' . $state),
TextInput::make('database_limit')
->label('Database Limit')
->label('')
->prefix('Databases')
->prefixIcon('tabler-database')
->columnSpan(1)
->disabled()
->formatStateUsing(fn ($state, Server $server) => !$state ? 'No Databases can be created' : $server->databases->count() . ' of ' . $state),
->formatStateUsing(fn ($state, Server $server) => !$state ? 'No Databases' : $server->databases->count() . ' of ' . $state),
TextInput::make('allocation_limit')
->label('Allocation Limit')
->label('')
->prefix('Allocations')
->prefixIcon('tabler-network')
->columnSpan(1)
->disabled()
->formatStateUsing(fn ($state, Server $server) => !$state ? 'No additional Allocations can be created' : $server->allocations->count() . ' of ' . $state),
->formatStateUsing(fn ($state, Server $server) => !$state ? 'No Additional Allocations' : $server->allocations->count() . ' of ' . $state),
]),
]),
Section::make('Node Information')
Expand Down
Loading