Merge pull request #225 from Boy132/update/gb-to-gib

Update GB to GiB + minValues for resources + other stuff
This commit is contained in:
Charles 2024-05-14 18:59:33 -04:00 committed by GitHub
commit 2d643ec79f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 36 additions and 25 deletions

View File

@ -91,7 +91,7 @@ class EditNode extends EditRecord
Forms\Components\ToggleButtons::make('unlimited_mem')
->label('Memory')->inlineLabel()->inline()
->afterStateUpdated(fn (Forms\Set $set) => $set('memory', 0))
->afterStateUpdated(fn (Forms\Set $set) => $set('memory_overallocate', -1))
->afterStateUpdated(fn (Forms\Set $set) => $set('memory_overallocate', 0))
->formatStateUsing(fn (Forms\Get $get) => $get('memory') == 0)
->live()
->options([
@ -110,7 +110,8 @@ class EditNode extends EditRecord
->suffix('MiB')
->required()
->columnSpan(2)
->numeric(),
->numeric()
->minValue(0),
Forms\Components\TextInput::make('memory_overallocate')
->dehydratedWhenHidden()
->label('Overallocate')->inlineLabel()
@ -120,6 +121,7 @@ class EditNode extends EditRecord
->hintIconTooltip('The % allowable to go over the set limit.')
->columnSpan(2)
->numeric()
->minValue(-1)
->maxValue(100)
->suffix('%'),
]),
@ -131,7 +133,7 @@ class EditNode extends EditRecord
->label('Disk')->inlineLabel()->inline()
->live()
->afterStateUpdated(fn (Forms\Set $set) => $set('disk', 0))
->afterStateUpdated(fn (Forms\Set $set) => $set('disk_overallocate', -1))
->afterStateUpdated(fn (Forms\Set $set) => $set('disk_overallocate', 0))
->formatStateUsing(fn (Forms\Get $get) => $get('disk') == 0)
->options([
true => 'Unlimited',
@ -146,10 +148,11 @@ class EditNode extends EditRecord
->dehydratedWhenHidden()
->hidden(fn (Forms\Get $get) => $get('unlimited_disk'))
->label('Disk Limit')->inlineLabel()
->suffix('MB')
->suffix('MiB')
->required()
->columnSpan(2)
->numeric(),
->numeric()
->minValue(0),
Forms\Components\TextInput::make('disk_overallocate')
->dehydratedWhenHidden()
->hidden(fn (Forms\Get $get) => $get('unlimited_disk'))
@ -159,6 +162,7 @@ class EditNode extends EditRecord
->columnSpan(2)
->required()
->numeric()
->minValue(-1)
->maxValue(100)
->suffix('%'),
]),

View File

@ -42,15 +42,15 @@ class ListNodes extends ListRecords
->visibleFrom('sm')
->icon('tabler-device-desktop-analytics')
->numeric()
->suffix(' GB')
->formatStateUsing(fn ($state) => number_format($state / 1000, 2))
->suffix(' GiB')
->formatStateUsing(fn ($state) => number_format($state / 1024, 2))
->sortable(),
Tables\Columns\TextColumn::make('disk')
->visibleFrom('sm')
->icon('tabler-file')
->numeric()
->suffix(' GB')
->formatStateUsing(fn ($state) => number_format($state / 1000, 2))
->suffix(' GiB')
->formatStateUsing(fn ($state) => number_format($state / 1024, 2))
->sortable(),
Tables\Columns\IconColumn::make('scheme')
->visibleFrom('xl')

View File

@ -40,8 +40,8 @@ class NodeMemoryChart extends ChartWidget
/** @var Node $node */
$node = $this->record;
$total = $node->statistics()['memory_total'] ?? 0;
$used = $node->statistics()['memory_used'] ?? 0;
$total = ($node->statistics()['memory_total'] ?? 0) / 1024 / 1024 / 1024;
$used = ($node->statistics()['memory_used'] ?? 0) / 1024 / 1024 / 1024;
$unused = $total - $used;
return [

View File

@ -40,8 +40,8 @@ class NodeStorageChart extends ChartWidget
/** @var Node $node */
$node = $this->record;
$total = $node->statistics()['disk_total'] ?? 0;
$used = $node->statistics()['disk_used'] ?? 0;
$total = ($node->statistics()['disk_total'] ?? 0) / 1024 / 1024 / 1024;
$used = ($node->statistics()['disk_used'] ?? 0) / 1024 / 1024 / 1024;
$unused = $total - $used;
return [

View File

@ -487,11 +487,12 @@ class CreateServer extends CreateRecord
->dehydratedWhenHidden()
->hidden(fn (Forms\Get $get) => $get('unlimited_mem'))
->label('Memory Limit')->inlineLabel()
->suffix('MB')
->suffix('MiB')
->default(0)
->required()
->columnSpan(2)
->numeric(),
->numeric()
->minValue(0),
]),
Forms\Components\Grid::make()
@ -517,11 +518,12 @@ class CreateServer extends CreateRecord
->dehydratedWhenHidden()
->hidden(fn (Forms\Get $get) => $get('unlimited_disk'))
->label('Disk Space Limit')->inlineLabel()
->suffix('MB')
->suffix('MiB')
->default(0)
->required()
->columnSpan(2)
->numeric(),
->numeric()
->minValue(0),
]),
Forms\Components\Grid::make()
@ -551,7 +553,9 @@ class CreateServer extends CreateRecord
->default(0)
->required()
->columnSpan(2)
->numeric(),
->numeric()
->minValue(0)
->helperText('100% equals one logical thread'),
]),
Forms\Components\Grid::make()
@ -593,7 +597,7 @@ class CreateServer extends CreateRecord
})
->label('Swap Memory')
->default(0)
->suffix('MB')
->suffix('MiB')
->minValue(-1)
->columnSpan(2)
->inlineLabel()

View File

@ -333,10 +333,11 @@ class EditServer extends EditRecord
->dehydratedWhenHidden()
->hidden(fn (Forms\Get $get) => $get('unlimited_mem'))
->label('Memory Limit')->inlineLabel()
->suffix('MB')
->suffix('MiB')
->required()
->columnSpan(2)
->numeric(),
->numeric()
->minValue(0),
]),
Forms\Components\Grid::make()
@ -362,10 +363,11 @@ class EditServer extends EditRecord
->dehydratedWhenHidden()
->hidden(fn (Forms\Get $get) => $get('unlimited_disk'))
->label('Disk Space Limit')->inlineLabel()
->suffix('MB')
->suffix('MiB')
->required()
->columnSpan(2)
->numeric(),
->numeric()
->minValue(0),
]),
Forms\Components\Grid::make()
@ -394,7 +396,8 @@ class EditServer extends EditRecord
->suffix('%')
->required()
->columnSpan(2)
->numeric(),
->numeric()
->minValue(0),
]),
Forms\Components\Grid::make()
@ -439,7 +442,7 @@ class EditServer extends EditRecord
'limited', false => false,
})
->label('Swap Memory')->inlineLabel()
->suffix('MB')
->suffix('MiB')
->minValue(-1)
->columnSpan(2)
->required()