Very basic implemention of frontend logic required to display backups and create a new one

This commit is contained in:
Dane Everitt 2020-04-04 10:59:25 -07:00
parent 17ec4efd3b
commit 9991989f89
No known key found for this signature in database
GPG key ID: EEA66103B3D71F53
16 changed files with 431 additions and 2 deletions

View file

@ -6,9 +6,10 @@ use Illuminate\Database\Eloquent\SoftDeletes;
/**
* @property int $id
* @property int $server_id
* @property int $uuid
* @property string $name
* @property string $contents
* @property string $ignore
* @property string $disk
* @property string|null $sha256_hash
* @property int $bytes
@ -16,11 +17,15 @@ use Illuminate\Database\Eloquent\SoftDeletes;
* @property \Carbon\CarbonImmutable $created_at
* @property \Carbon\CarbonImmutable $updated_at
* @property \Carbon\CarbonImmutable|null $deleted_at
*
* @property \Pterodactyl\Models\Server $server
*/
class Backup extends Model
{
use SoftDeletes;
const RESOURCE_NAME = 'backup';
/**
* @var string
*/
@ -56,4 +61,12 @@ class Backup extends Model
{
return $this->asImmutableDateTime($value);
}
/**
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/
public function server()
{
return $this->belongsTo(Server::class);
}
}

View file

@ -37,6 +37,12 @@ class Permission extends Model
const ACTION_USER_UPDATE = 'user.update';
const ACTION_USER_DELETE = 'user.delete';
const ACTION_BACKUP_READ = 'backup.read';
const ACTION_BACKUP_CREATE = 'backup.create';
const ACTION_BACKUP_UPDATE = 'backup.update';
const ACTION_BACKUP_DELETE = 'backup.delete';
const ACTION_BACKUP_DOWNLOAD = 'backup.download';
const ACTION_ALLOCATION_READ = 'allocation.read';
const ACTION_ALLOCIATION_UPDATE = 'allocation.update';
@ -135,6 +141,17 @@ class Permission extends Model
],
],
'backup' => [
'description' => 'Permissions that control a user\'s ability to generate and manage server backups.',
'keys' => [
'create' => 'Allows a user to create new backups for this server.',
'read' => 'Allows a user to view all backups that exist for this server.',
'update' => '',
'delete' => 'Allows a user to remove backups from the system.',
'download' => 'Allows a user to download backups.',
],
],
// Controls permissions for editing or viewing a server's allocations.
'allocation' => [
'description' => 'Permissions that control a user\'s ability to modify the port allocations for this server.',

View file

@ -51,6 +51,7 @@ use Znck\Eloquent\Traits\BelongsToThrough;
* @property \Pterodactyl\Models\Location $location
* @property \Pterodactyl\Models\DaemonKey $key
* @property \Pterodactyl\Models\DaemonKey[]|\Illuminate\Database\Eloquent\Collection $keys
* @property \Pterodactyl\Models\Backup[]|\Illuminate\Database\Eloquent\Collection $backups
*/
class Server extends Model
{
@ -339,4 +340,12 @@ class Server extends Model
{
return $this->hasMany(DaemonKey::class);
}
/**
* @return \Illuminate\Database\Eloquent\Relations\HasMany
*/
public function backups()
{
return $this->hasMany(Backup::class);
}
}