From c19c423568dd9de2c1f1daf5aca445b7324a0d8c Mon Sep 17 00:00:00 2001 From: Dane Everitt Date: Sat, 7 Oct 2017 18:08:19 -0500 Subject: [PATCH] More fixes --- app/Http/Controllers/Admin/PackController.php | 15 ++++++--- app/Http/Requests/Admin/ServerFormRequest.php | 2 +- app/Models/Pack.php | 2 +- app/Services/Packs/PackUpdateService.php | 4 +-- app/Services/Packs/TemplateUploadService.php | 14 ++++---- .../Servers/ServerCreationService.php | 2 +- database/factories/ModelFactory.php | 2 +- .../admin/nodes/view/servers.blade.php | 2 +- .../pterodactyl/admin/packs/index.blade.php | 4 +-- .../pterodactyl/admin/packs/modal.blade.php | 14 ++++---- .../pterodactyl/admin/packs/new.blade.php | 18 +++++----- .../pterodactyl/admin/packs/view.blade.php | 14 ++++---- .../pterodactyl/admin/users/view.blade.php | 33 ++++++++++--------- .../themes/pterodactyl/server/index.blade.php | 2 +- 14 files changed, 67 insertions(+), 61 deletions(-) diff --git a/app/Http/Controllers/Admin/PackController.php b/app/Http/Controllers/Admin/PackController.php index e25e3d3b9..742f1ed0a 100644 --- a/app/Http/Controllers/Admin/PackController.php +++ b/app/Http/Controllers/Admin/PackController.php @@ -114,7 +114,7 @@ class PackController extends Controller public function index(Request $request) { return view('admin.packs.index', [ - 'packs' => $this->repository->search($request->input('query'))->paginateWithOptionAndServerCount( + 'packs' => $this->repository->search($request->input('query'))->paginateWithEggAndServerCount( $this->config->get('pterodactyl.paginate.admin.packs') ), ]); @@ -124,11 +124,13 @@ class PackController extends Controller * Display new pack creation form. * * @return \Illuminate\View\View + * + * @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException */ public function create() { return view('admin.packs.new', [ - 'services' => $this->serviceRepository->getWithOptions(), + 'nests' => $this->serviceRepository->getWithEggs(), ]); } @@ -136,11 +138,13 @@ class PackController extends Controller * Display new pack creation modal for use with template upload. * * @return \Illuminate\View\View + * + * @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException */ public function newTemplate() { return view('admin.packs.modal', [ - 'services' => $this->serviceRepository->getWithOptions(), + 'nests' => $this->serviceRepository->getWithEggs(), ]); } @@ -160,7 +164,7 @@ class PackController extends Controller public function store(PackFormRequest $request) { if ($request->has('from_template')) { - $pack = $this->templateUploadService->handle($request->input('option_id'), $request->file('file_upload')); + $pack = $this->templateUploadService->handle($request->input('egg_id'), $request->file('file_upload')); } else { $pack = $this->creationService->handle($request->normalize(), $request->file('file_upload')); } @@ -175,12 +179,13 @@ class PackController extends Controller * * @param int $pack * @return \Illuminate\View\View + * @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException */ public function view($pack) { return view('admin.packs.view', [ 'pack' => $this->repository->getWithServers($pack), - 'services' => $this->serviceRepository->getWithOptions(), + 'nests' => $this->serviceRepository->getWithEggs(), ]); } diff --git a/app/Http/Requests/Admin/ServerFormRequest.php b/app/Http/Requests/Admin/ServerFormRequest.php index 21f0519db..f448a953c 100644 --- a/app/Http/Requests/Admin/ServerFormRequest.php +++ b/app/Http/Requests/Admin/ServerFormRequest.php @@ -63,7 +63,7 @@ class ServerFormRequest extends AdminFormRequest $validator->sometimes('pack_id', [ Rule::exists('packs', 'id')->where(function ($query) { $query->where('selectable', 1); - $query->where('option_id', $this->input('option_id')); + $query->where('egg_id', $this->input('egg_id')); }), ], function ($input) { return $input->pack_id !== 0 && $input->pack_id !== null; diff --git a/app/Models/Pack.php b/app/Models/Pack.php index 960199680..a029b3614 100644 --- a/app/Models/Pack.php +++ b/app/Models/Pack.php @@ -34,7 +34,7 @@ class Pack extends Model implements CleansAttributes, ValidableContract * @var array */ protected $fillable = [ - 'option_id', 'uuid', 'name', 'version', 'description', 'selectable', 'visible', 'locked', + 'egg_id', 'uuid', 'name', 'version', 'description', 'selectable', 'visible', 'locked', ]; /** diff --git a/app/Services/Packs/PackUpdateService.php b/app/Services/Packs/PackUpdateService.php index 6d5555ce5..bb84f7b98 100644 --- a/app/Services/Packs/PackUpdateService.php +++ b/app/Services/Packs/PackUpdateService.php @@ -54,10 +54,10 @@ class PackUpdateService public function handle($pack, array $data) { if (! $pack instanceof Pack) { - $pack = $this->repository->withColumns(['id', 'option_id'])->find($pack); + $pack = $this->repository->withColumns(['id', 'egg_id'])->find($pack); } - if ((int) array_get($data, 'option_id', $pack->option_id) !== $pack->option_id) { + if ((int) array_get($data, 'egg_id', $pack->egg_id) !== $pack->egg_id) { $count = $this->serverRepository->findCountWhere([['pack_id', '=', $pack->id]]); if ($count !== 0) { diff --git a/app/Services/Packs/TemplateUploadService.php b/app/Services/Packs/TemplateUploadService.php index 7007f3bb4..045bfec48 100644 --- a/app/Services/Packs/TemplateUploadService.php +++ b/app/Services/Packs/TemplateUploadService.php @@ -52,7 +52,7 @@ class TemplateUploadService /** * Process an uploaded file to create a new pack from a JSON or ZIP format. * - * @param int $option + * @param int $egg * @param \Illuminate\Http\UploadedFile $file * @return \Pterodactyl\Models\Pack * @@ -63,7 +63,7 @@ class TemplateUploadService * @throws \Pterodactyl\Exceptions\Service\Pack\UnreadableZipArchiveException * @throws \Pterodactyl\Exceptions\Service\Pack\InvalidPackArchiveFormatException */ - public function handle($option, UploadedFile $file) + public function handle($egg, UploadedFile $file) { if (! $file->isValid()) { throw new InvalidFileUploadException(trans('exceptions.packs.invalid_upload')); @@ -76,10 +76,10 @@ class TemplateUploadService } if ($file->getMimeType() === 'application/zip') { - return $this->handleArchive($option, $file); + return $this->handleArchive($egg, $file); } else { $json = json_decode($file->openFile()->fread($file->getSize()), true); - $json['option_id'] = $option; + $json['egg_id'] = $egg; return $this->creationService->handle($json); } @@ -88,7 +88,7 @@ class TemplateUploadService /** * Process a ZIP file to create a pack and stored archive. * - * @param int $option + * @param int $egg * @param \Illuminate\Http\UploadedFile $file * @return \Pterodactyl\Models\Pack * @@ -99,7 +99,7 @@ class TemplateUploadService * @throws \Pterodactyl\Exceptions\Service\Pack\UnreadableZipArchiveException * @throws \Pterodactyl\Exceptions\Service\Pack\InvalidPackArchiveFormatException */ - protected function handleArchive($option, $file) + protected function handleArchive($egg, $file) { if (! $this->archive->open($file->getRealPath())) { throw new UnreadableZipArchiveException(trans('exceptions.packs.unreadable')); @@ -110,7 +110,7 @@ class TemplateUploadService } $json = json_decode($this->archive->getFromName('import.json'), true); - $json['option_id'] = $option; + $json['egg_id'] = $egg; $pack = $this->creationService->handle($json); if (! $this->archive->extractTo(storage_path('app/packs/' . $pack->uuid), 'archive.tar.gz')) { diff --git a/app/Services/Servers/ServerCreationService.php b/app/Services/Servers/ServerCreationService.php index 7760a8edc..0994abe55 100644 --- a/app/Services/Servers/ServerCreationService.php +++ b/app/Services/Servers/ServerCreationService.php @@ -124,7 +124,7 @@ class ServerCreationService public function create(array $data) { // @todo auto-deployment - $validator = $this->validatorService->isAdmin()->setFields($data['environment'])->validate($data['option_id']); + $validator = $this->validatorService->isAdmin()->setFields($data['environment'])->validate($data['egg_id']); $uniqueShort = str_random(8); $this->connection->beginTransaction(); diff --git a/database/factories/ModelFactory.php b/database/factories/ModelFactory.php index 2570d5ab4..f3e4f4093 100644 --- a/database/factories/ModelFactory.php +++ b/database/factories/ModelFactory.php @@ -133,7 +133,7 @@ $factory->state(Pterodactyl\Models\EggVariable::class, 'editable', function () { $factory->define(Pterodactyl\Models\Pack::class, function (Faker\Generator $faker) { return [ 'id' => $faker->unique()->randomNumber(), - 'option_id' => $faker->randomNumber(), + 'egg_id' => $faker->randomNumber(), 'uuid' => $faker->uuid, 'name' => $faker->word, 'description' => null, diff --git a/resources/themes/pterodactyl/admin/nodes/view/servers.blade.php b/resources/themes/pterodactyl/admin/nodes/view/servers.blade.php index ad1944f9a..b648c760c 100644 --- a/resources/themes/pterodactyl/admin/nodes/view/servers.blade.php +++ b/resources/themes/pterodactyl/admin/nodes/view/servers.blade.php @@ -56,7 +56,7 @@ {{ $server->uuidShort }} {{ $server->name }} {{ $server->user->username }} - {{ $server->service->name }} ({{ $server->option->name }}) + {{ $server->nest->name }} ({{ $server->egg->name }}) NaN / {{ $server->memory === 0 ? '∞' : $server->memory }} MB {{ $server->disk }} MB NaN % diff --git a/resources/themes/pterodactyl/admin/packs/index.blade.php b/resources/themes/pterodactyl/admin/packs/index.blade.php index e7b22e0d6..270bea96b 100644 --- a/resources/themes/pterodactyl/admin/packs/index.blade.php +++ b/resources/themes/pterodactyl/admin/packs/index.blade.php @@ -43,7 +43,7 @@ Pack Name Version Description - Option + Egg Servers @foreach ($packs as $pack) @@ -52,7 +52,7 @@ {{ $pack->name }} {{ $pack->version }} {{ str_limit($pack->description, 150) }} - {{ $pack->option->name }} + {{ $pack->egg->name }} {{ $pack->servers_count }} @endforeach diff --git a/resources/themes/pterodactyl/admin/packs/modal.blade.php b/resources/themes/pterodactyl/admin/packs/modal.blade.php index fd4263575..2ce57f2b1 100644 --- a/resources/themes/pterodactyl/admin/packs/modal.blade.php +++ b/resources/themes/pterodactyl/admin/packs/modal.blade.php @@ -10,17 +10,17 @@
- - + @foreach($nests as $nest) + + @foreach($nest->eggs as $egg) + @endforeach @endforeach -

The option that this pack is assocaited with. Only servers that are assigned this option will be able to access this pack.

+

The Egg that this pack is assocaited with. Only servers that are assigned this Egg will be able to access this pack.

diff --git a/resources/themes/pterodactyl/admin/packs/new.blade.php b/resources/themes/pterodactyl/admin/packs/new.blade.php index fe89c904f..35acdb540 100644 --- a/resources/themes/pterodactyl/admin/packs/new.blade.php +++ b/resources/themes/pterodactyl/admin/packs/new.blade.php @@ -52,12 +52,12 @@

The version of this package, or the version of the files contained within the package.

- - + @foreach($nests as $nest) + + @foreach($nest->eggs as $egg) + @endforeach @endforeach @@ -124,7 +124,7 @@ @section('footer-scripts') @parent diff --git a/resources/themes/pterodactyl/admin/packs/view.blade.php b/resources/themes/pterodactyl/admin/packs/view.blade.php index 25a604d09..e9e5804e5 100644 --- a/resources/themes/pterodactyl/admin/packs/view.blade.php +++ b/resources/themes/pterodactyl/admin/packs/view.blade.php @@ -51,12 +51,12 @@
- - + @foreach($nests as $nest) + + @foreach($nest->eggs as $egg) + @endforeach @endforeach @@ -173,6 +173,6 @@ @section('footer-scripts') @parent @endsection diff --git a/resources/themes/pterodactyl/admin/users/view.blade.php b/resources/themes/pterodactyl/admin/users/view.blade.php index 755255505..1c1946ecb 100644 --- a/resources/themes/pterodactyl/admin/users/view.blade.php +++ b/resources/themes/pterodactyl/admin/users/view.blade.php @@ -113,22 +113,23 @@ - @foreach($user->setAccessLevel('subuser')->access()->get() as $server) - - - {{ $server->uuidShort }} - {{ $server->name }} - - @if($server->owner_id === $user->id) - Owner - @else - Subuser - @endif - - {{ $server->node->name }} - @if($server->suspended === 0)Active@elseSuspended@endif - - @endforeach + Oh dear, this hasn't been fixed yet? + {{--@foreach($user->setAccessLevel('subuser')->access()->get() as $server)--}} + {{----}} + {{----}} + {{--{{ $server->uuidShort }}--}} + {{--{{ $server->name }}--}} + {{----}} + {{--@if($server->owner_id === $user->id)--}} + {{--Owner--}} + {{--@else--}} + {{--Subuser--}} + {{--@endif--}} + {{----}} + {{--{{ $server->node->name }}--}} + {{--@if($server->suspended === 0)Active@elseSuspended@endif--}} + {{----}} + {{--@endforeach--}}
diff --git a/resources/themes/pterodactyl/server/index.blade.php b/resources/themes/pterodactyl/server/index.blade.php index be68ffc88..6470a7703 100644 --- a/resources/themes/pterodactyl/server/index.blade.php +++ b/resources/themes/pterodactyl/server/index.blade.php @@ -79,7 +79,7 @@ {!! Theme::js('js/frontend/console.js') !!} {!! Theme::js('vendor/chartjs/chart.min.js') !!} {!! Theme::js('vendor/jquery/date-format.min.js') !!} - @if($server->service->folder === 'minecraft') + @if($server->nest->name === 'Minecraft' && $server->nest->author === 'support@pterodactyl.io') {!! Theme::js('js/plugins/minecraft/eula.js') !!} @endif @endsection