Add initial pack creation and overview pages

This commit is contained in:
Dane Everitt 2017-03-14 21:18:36 -04:00
parent 2d90187c83
commit 50558db7c3
No known key found for this signature in database
GPG key ID: EEA66103B3D71F53
21 changed files with 944 additions and 487 deletions

100
app/Models/Pack.php Normal file
View file

@ -0,0 +1,100 @@
<?php
/**
* Pterodactyl - Panel
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
namespace Pterodactyl\Models;
use Illuminate\Database\Eloquent\Model;
use Nicolaslopezj\Searchable\SearchableTrait;
class Pack extends Model
{
use SearchableTrait;
/**
* The table associated with the model.
*
* @var string
*/
protected $table = 'packs';
/**
* Fields that are mass assignable.
*
* @var array
*/
protected $fillable = [
'option_id', 'name', 'version', 'description', 'selectable', 'visible', 'locked',
];
/**
* Cast values to correct type.
*
* @var array
*/
protected $casts = [
'option_id' => 'integer',
'selectable' => 'boolean',
'visible' => 'boolean',
'locked' => 'boolean',
];
/**
* Parameters for search querying.
*
* @var array
*/
protected $searchable = [
'columns' => [
'packs.name' => 10,
'packs.uuid' => 8,
'service_options.name' => 6,
'service_options.tag' => 5,
'service_options.docker_image' => 5,
'packs.version' => 2,
],
'joins' => [
'service_options' => ['packs.option_id', 'service_options.id'],
],
];
/**
* Gets option associated with a service pack.
*
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/
public function option()
{
return $this->belongsTo(ServiceOption::class);
}
/**
* Gets servers associated with a pack.
*
* @return \Illuminate\Database\Eloquent\Relations\HasMany
*/
public function servers()
{
return $this->hasMany(Server::class);
}
}

View file

@ -65,43 +65,50 @@ class Server extends Model
*/
protected $guarded = ['id', 'installed', 'created_at', 'updated_at', 'deleted_at'];
/**
* Cast values to correct type.
*
* @var array
*/
protected $casts = [
'node_id' => 'integer',
'suspended' => 'integer',
'owner_id' => 'integer',
'memory' => 'integer',
'swap' => 'integer',
'disk' => 'integer',
'io' => 'integer',
'cpu' => 'integer',
'oom_disabled' => 'integer',
'allocation_id' => 'integer',
'service_id' => 'integer',
'option_id' => 'integer',
'pack_id' => 'integer',
'installed' => 'integer',
];
/**
* Cast values to correct type.
*
* @var array
*/
protected $casts = [
'node_id' => 'integer',
'suspended' => 'integer',
'owner_id' => 'integer',
'memory' => 'integer',
'swap' => 'integer',
'disk' => 'integer',
'io' => 'integer',
'cpu' => 'integer',
'oom_disabled' => 'integer',
'allocation_id' => 'integer',
'service_id' => 'integer',
'option_id' => 'integer',
'pack_id' => 'integer',
'installed' => 'integer',
];
/**
* Parameters for search querying.
*
* @var array
*/
protected $searchable = [
'columns' => [
'servers.name' => 10,
'servers.username' => 10,
'servers.uuidShort' => 9,
'servers.uuid' => 8,
'users.email' => 6,
'users.username' => 6,
'nodes.name' => 2,
],
'joins' => [
'columns' => [
'servers.name' => 10,
'servers.username' => 10,
'servers.uuidShort' => 9,
'servers.uuid' => 8,
'packs.name' => 7,
'users.email' => 6,
'users.username' => 6,
'nodes.name' => 2,
],
'joins' => [
'packs' => ['packs.id', 'servers.pack_id'],
'users' => ['users.id', 'servers.owner_id'],
'nodes' => ['nodes.id', 'servers.node_id'],
],
];
],
];
/**
* Returns a single server specified by UUID.
@ -236,11 +243,11 @@ class Server extends Model
/**
* Gets information for the pack associated with this server.
*
* @return \Illuminate\Database\Eloquent\Relations\HasOne
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/
public function pack()
{
return $this->hasOne(ServicePack::class, 'id', 'pack_id');
return $this->belongsTo(Pack::class);
}
/**

View file

@ -105,7 +105,7 @@ EOF;
public function packs()
{
return $this->hasManyThrough(
'Pterodactyl\Models\ServicePack', 'Pterodactyl\Models\ServiceOption',
'Pterodactyl\Models\Pack', 'Pterodactyl\Models\ServiceOption',
'service_id', 'option_id'
);
}

View file

@ -99,6 +99,6 @@ class ServiceOption extends Model
*/
public function packs()
{
return $this->hasMany(ServicePack::class, 'option_id');
return $this->hasMany(Pack::class, 'option_id');
}
}

View file

@ -1,69 +0,0 @@
<?php
/**
* Pterodactyl - Panel
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
namespace Pterodactyl\Models;
use Illuminate\Database\Eloquent\Model;
class ServicePack extends Model
{
/**
* The table associated with the model.
*
* @var string
*/
protected $table = 'service_packs';
/**
* Fields that are not mass assignable.
*
* @var array
*/
protected $guarded = ['id', 'created_at', 'updated_at'];
/**
* Cast values to correct type.
*
* @var array
*/
protected $casts = [
'option' => 'integer',
'build_memory' => 'integer',
'build_swap' => 'integer',
'build_cpu' => 'integer',
'build_io' => 'integer',
'selectable' => 'boolean',
'visible' => 'boolean',
];
/**
* Gets option associated with a service pack.
*
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/
public function option()
{
return $this->belongsTo(ServiceOption::class);
}
}

View file

@ -88,6 +88,11 @@ class User extends Model implements AuthenticatableContract, AuthorizableContrac
*/
protected $hidden = ['password', 'remember_token', 'totp_secret'];
/**
* Parameters for search querying.
*
* @var array
*/
protected $searchable = [
'columns' => [
'email' => 10,