mirror of
https://github.com/pterodactyl/panel.git
synced 2024-11-22 17:12:30 +01:00
Add base support for definining the number of backups that can be created for a server
This commit is contained in:
parent
bed51b5871
commit
f1c3762f4d
@ -263,7 +263,7 @@ class ServersController extends Controller
|
|||||||
$this->buildModificationService->handle($server, $request->only([
|
$this->buildModificationService->handle($server, $request->only([
|
||||||
'allocation_id', 'add_allocations', 'remove_allocations',
|
'allocation_id', 'add_allocations', 'remove_allocations',
|
||||||
'memory', 'swap', 'io', 'cpu', 'threads', 'disk',
|
'memory', 'swap', 'io', 'cpu', 'threads', 'disk',
|
||||||
'database_limit', 'allocation_limit', 'oom_disabled',
|
'database_limit', 'allocation_limit', 'backup_limit', 'oom_disabled',
|
||||||
]));
|
]));
|
||||||
$this->alert->success(trans('admin/server.alerts.build_updated'))->flash();
|
$this->alert->success(trans('admin/server.alerts.build_updated'))->flash();
|
||||||
|
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
namespace Pterodactyl\Models;
|
namespace Pterodactyl\Models;
|
||||||
|
|
||||||
use Schema;
|
|
||||||
use Illuminate\Notifications\Notifiable;
|
use Illuminate\Notifications\Notifiable;
|
||||||
use Pterodactyl\Models\Traits\Searchable;
|
use Pterodactyl\Models\Traits\Searchable;
|
||||||
use Znck\Eloquent\Traits\BelongsToThrough;
|
use Znck\Eloquent\Traits\BelongsToThrough;
|
||||||
@ -34,6 +33,7 @@ use Znck\Eloquent\Traits\BelongsToThrough;
|
|||||||
* @property int $installed
|
* @property int $installed
|
||||||
* @property int $allocation_limit
|
* @property int $allocation_limit
|
||||||
* @property int $database_limit
|
* @property int $database_limit
|
||||||
|
* @property int $backup_limit
|
||||||
* @property \Carbon\Carbon $created_at
|
* @property \Carbon\Carbon $created_at
|
||||||
* @property \Carbon\Carbon $updated_at
|
* @property \Carbon\Carbon $updated_at
|
||||||
*
|
*
|
||||||
@ -127,6 +127,7 @@ class Server extends Model
|
|||||||
'installed' => 'in:0,1,2',
|
'installed' => 'in:0,1,2',
|
||||||
'database_limit' => 'present|nullable|integer|min:0',
|
'database_limit' => 'present|nullable|integer|min:0',
|
||||||
'allocation_limit' => 'sometimes|nullable|integer|min:0',
|
'allocation_limit' => 'sometimes|nullable|integer|min:0',
|
||||||
|
'backup_limit' => 'present|nullable|integer|min:0',
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -152,6 +153,7 @@ class Server extends Model
|
|||||||
'installed' => 'integer',
|
'installed' => 'integer',
|
||||||
'database_limit' => 'integer',
|
'database_limit' => 'integer',
|
||||||
'allocation_limit' => 'integer',
|
'allocation_limit' => 'integer',
|
||||||
|
'backup_limit' => 'integer',
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -170,16 +172,6 @@ class Server extends Model
|
|||||||
'pack.name' => 10,
|
'pack.name' => 10,
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
|
||||||
* Return the columns available for this table.
|
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public function getTableColumns()
|
|
||||||
{
|
|
||||||
return Schema::getColumnListing($this->getTable());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the format for server allocations when communicating with the Daemon.
|
* Returns the format for server allocations when communicating with the Daemon.
|
||||||
*
|
*
|
||||||
|
@ -101,8 +101,9 @@ class BuildModificationService
|
|||||||
'threads' => array_get($data, 'threads'),
|
'threads' => array_get($data, 'threads'),
|
||||||
'disk' => array_get($data, 'disk'),
|
'disk' => array_get($data, 'disk'),
|
||||||
'allocation_id' => array_get($data, 'allocation_id'),
|
'allocation_id' => array_get($data, 'allocation_id'),
|
||||||
'database_limit' => array_get($data, 'database_limit'),
|
'database_limit' => array_get($data, 'database_limit', 0),
|
||||||
'allocation_limit' => array_get($data, 'allocation_limit'),
|
'allocation_limit' => array_get($data, 'allocation_limit', 0),
|
||||||
|
'backup_limit' => array_get($data, 'backup_limit', 0),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$updateData = $this->structureService->handle($server);
|
$updateData = $this->structureService->handle($server);
|
||||||
|
@ -249,8 +249,9 @@ class ServerCreationService
|
|||||||
'pack_id' => empty($data['pack_id']) ? null : $data['pack_id'],
|
'pack_id' => empty($data['pack_id']) ? null : $data['pack_id'],
|
||||||
'startup' => Arr::get($data, 'startup'),
|
'startup' => Arr::get($data, 'startup'),
|
||||||
'image' => Arr::get($data, 'image'),
|
'image' => Arr::get($data, 'image'),
|
||||||
'database_limit' => Arr::get($data, 'database_limit'),
|
'database_limit' => Arr::get($data, 'database_limit', 0),
|
||||||
'allocation_limit' => Arr::get($data, 'allocation_limit'),
|
'allocation_limit' => Arr::get($data, 'allocation_limit', 0),
|
||||||
|
'backup_limit' => Arr::get($data, 'backup_limit', 0),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return $model;
|
return $model;
|
||||||
|
@ -80,6 +80,7 @@ class ServerTransformer extends BaseTransformer
|
|||||||
'feature_limits' => [
|
'feature_limits' => [
|
||||||
'databases' => $server->database_limit,
|
'databases' => $server->database_limit,
|
||||||
'allocations' => $server->allocation_limit,
|
'allocations' => $server->allocation_limit,
|
||||||
|
'backups' => $server->backup_limit,
|
||||||
],
|
],
|
||||||
'user' => $server->owner_id,
|
'user' => $server->owner_id,
|
||||||
'node' => $server->node_id,
|
'node' => $server->node_id,
|
||||||
|
@ -55,6 +55,7 @@ class ServerTransformer extends BaseClientTransformer
|
|||||||
'feature_limits' => [
|
'feature_limits' => [
|
||||||
'databases' => $server->database_limit,
|
'databases' => $server->database_limit,
|
||||||
'allocations' => $server->allocation_limit,
|
'allocations' => $server->allocation_limit,
|
||||||
|
'backups' => $server->backup_limit,
|
||||||
],
|
],
|
||||||
'is_suspended' => $server->suspended !== 0,
|
'is_suspended' => $server->suspended !== 0,
|
||||||
'is_installing' => $server->installed !== 1,
|
'is_installing' => $server->installed !== 1,
|
||||||
|
@ -0,0 +1,32 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
class AddBackupLimitToServers extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::table('servers', function (Blueprint $table) {
|
||||||
|
$table->unsignedInteger('backup_limit')->default(0)->after('database_limit');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::table('servers', function (Blueprint $table) {
|
||||||
|
$table->dropColumn('backup_limit');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
@ -29,6 +29,7 @@ export interface Server {
|
|||||||
featureLimits: {
|
featureLimits: {
|
||||||
databases: number;
|
databases: number;
|
||||||
allocations: number;
|
allocations: number;
|
||||||
|
backups: number;
|
||||||
};
|
};
|
||||||
isSuspended: boolean;
|
isSuspended: boolean;
|
||||||
isInstalling: boolean;
|
isInstalling: boolean;
|
||||||
|
@ -118,15 +118,21 @@
|
|||||||
<div>
|
<div>
|
||||||
<input type="text" id="pDatabaseLimit" name="database_limit" class="form-control" value="{{ old('database_limit', 0) }}"/>
|
<input type="text" id="pDatabaseLimit" name="database_limit" class="form-control" value="{{ old('database_limit', 0) }}"/>
|
||||||
</div>
|
</div>
|
||||||
<p class="text-muted small">The total number of databases a user is allowed to create for this server. Leave blank to allow unlimited.</p>
|
<p class="text-muted small">The total number of databases a user is allowed to create for this server.</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-group col-xs-6">
|
<div class="form-group col-xs-6">
|
||||||
<label for="pAllocationLimit" class="control-label">Allocation Limit</label>
|
<label for="pAllocationLimit" class="control-label">Allocation Limit</label>
|
||||||
<div>
|
<div>
|
||||||
<input type="text" id="pAllocationLimit" name="allocation_limit" class="form-control" value="{{ old('allocation_limit', 0) }}"/>
|
<input type="text" id="pAllocationLimit" name="allocation_limit" class="form-control" value="{{ old('allocation_limit', 0) }}"/>
|
||||||
</div>
|
</div>
|
||||||
<p class="text-muted small">The total number of allocations a user is allowed to create for this server. Leave blank to allow unlimited.</p>
|
<p class="text-muted small">The total number of allocations a user is allowed to create for this server.</p>
|
||||||
|
</div>
|
||||||
|
<div class="form-group col-xs-6">
|
||||||
|
<label for="pBackupLimit" class="control-label">Backup Limit</label>
|
||||||
|
<div>
|
||||||
|
<input type="text" id="pBackupLimit" name="backup_limit" class="form-control" value="{{ old('backup_limit', 0) }}"/>
|
||||||
|
</div>
|
||||||
|
<p class="text-muted small">The total number of backups that can be created for this server.</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -104,18 +104,25 @@
|
|||||||
<div class="box-body">
|
<div class="box-body">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="form-group col-xs-6">
|
<div class="form-group col-xs-6">
|
||||||
<label for="cpu" class="control-label">Database Limit</label>
|
<label for="database_limit" class="control-label">Database Limit</label>
|
||||||
<div>
|
<div>
|
||||||
<input type="text" name="database_limit" class="form-control" value="{{ old('database_limit', $server->database_limit) }}"/>
|
<input type="text" name="database_limit" class="form-control" value="{{ old('database_limit', $server->database_limit) }}"/>
|
||||||
</div>
|
</div>
|
||||||
<p class="text-muted small">The total number of databases a user is allowed to create for this server. Leave blank to allow unlimited.</p>
|
<p class="text-muted small">The total number of databases a user is allowed to create for this server.</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group col-xs-6">
|
<div class="form-group col-xs-6">
|
||||||
<label for="cpu" class="control-label">Allocation Limit</label>
|
<label for="allocation_limit" class="control-label">Allocation Limit</label>
|
||||||
<div>
|
<div>
|
||||||
<input type="text" name="allocation_limit" class="form-control" value="{{ old('allocation_limit', $server->allocation_limit) }}"/>
|
<input type="text" name="allocation_limit" class="form-control" value="{{ old('allocation_limit', $server->allocation_limit) }}"/>
|
||||||
</div>
|
</div>
|
||||||
<p class="text-muted small"><strong>This feature is not currently implemented.</strong> The total number of allocations a user is allowed to create for this server. Leave blank to allow unlimited.</p>
|
<p class="text-muted small"><strong>This feature is not currently implemented.</strong> The total number of allocations a user is allowed to create for this server.</p>
|
||||||
|
</div>
|
||||||
|
<div class="form-group col-xs-6">
|
||||||
|
<label for="backup_limit" class="control-label">Backup Limit</label>
|
||||||
|
<div>
|
||||||
|
<input type="text" name="backup_limit" class="form-control" value="{{ old('backup_limit', $server->backup_limit) }}"/>
|
||||||
|
</div>
|
||||||
|
<p class="text-muted small">The total number of backups that can be created for this server.</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user