More fixes

This commit is contained in:
Dane Everitt 2017-10-07 18:08:19 -05:00
parent 17642bffe7
commit c19c423568
No known key found for this signature in database
GPG Key ID: EEA66103B3D71F53
14 changed files with 67 additions and 61 deletions

View File

@ -114,7 +114,7 @@ class PackController extends Controller
public function index(Request $request) public function index(Request $request)
{ {
return view('admin.packs.index', [ 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') $this->config->get('pterodactyl.paginate.admin.packs')
), ),
]); ]);
@ -124,11 +124,13 @@ class PackController extends Controller
* Display new pack creation form. * Display new pack creation form.
* *
* @return \Illuminate\View\View * @return \Illuminate\View\View
*
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
*/ */
public function create() public function create()
{ {
return view('admin.packs.new', [ 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. * Display new pack creation modal for use with template upload.
* *
* @return \Illuminate\View\View * @return \Illuminate\View\View
*
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
*/ */
public function newTemplate() public function newTemplate()
{ {
return view('admin.packs.modal', [ 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) public function store(PackFormRequest $request)
{ {
if ($request->has('from_template')) { 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 { } else {
$pack = $this->creationService->handle($request->normalize(), $request->file('file_upload')); $pack = $this->creationService->handle($request->normalize(), $request->file('file_upload'));
} }
@ -175,12 +179,13 @@ class PackController extends Controller
* *
* @param int $pack * @param int $pack
* @return \Illuminate\View\View * @return \Illuminate\View\View
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
*/ */
public function view($pack) public function view($pack)
{ {
return view('admin.packs.view', [ return view('admin.packs.view', [
'pack' => $this->repository->getWithServers($pack), 'pack' => $this->repository->getWithServers($pack),
'services' => $this->serviceRepository->getWithOptions(), 'nests' => $this->serviceRepository->getWithEggs(),
]); ]);
} }

View File

@ -63,7 +63,7 @@ class ServerFormRequest extends AdminFormRequest
$validator->sometimes('pack_id', [ $validator->sometimes('pack_id', [
Rule::exists('packs', 'id')->where(function ($query) { Rule::exists('packs', 'id')->where(function ($query) {
$query->where('selectable', 1); $query->where('selectable', 1);
$query->where('option_id', $this->input('option_id')); $query->where('egg_id', $this->input('egg_id'));
}), }),
], function ($input) { ], function ($input) {
return $input->pack_id !== 0 && $input->pack_id !== null; return $input->pack_id !== 0 && $input->pack_id !== null;

View File

@ -34,7 +34,7 @@ class Pack extends Model implements CleansAttributes, ValidableContract
* @var array * @var array
*/ */
protected $fillable = [ protected $fillable = [
'option_id', 'uuid', 'name', 'version', 'description', 'selectable', 'visible', 'locked', 'egg_id', 'uuid', 'name', 'version', 'description', 'selectable', 'visible', 'locked',
]; ];
/** /**

View File

@ -54,10 +54,10 @@ class PackUpdateService
public function handle($pack, array $data) public function handle($pack, array $data)
{ {
if (! $pack instanceof Pack) { 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]]); $count = $this->serverRepository->findCountWhere([['pack_id', '=', $pack->id]]);
if ($count !== 0) { if ($count !== 0) {

View File

@ -52,7 +52,7 @@ class TemplateUploadService
/** /**
* Process an uploaded file to create a new pack from a JSON or ZIP format. * 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 * @param \Illuminate\Http\UploadedFile $file
* @return \Pterodactyl\Models\Pack * @return \Pterodactyl\Models\Pack
* *
@ -63,7 +63,7 @@ class TemplateUploadService
* @throws \Pterodactyl\Exceptions\Service\Pack\UnreadableZipArchiveException * @throws \Pterodactyl\Exceptions\Service\Pack\UnreadableZipArchiveException
* @throws \Pterodactyl\Exceptions\Service\Pack\InvalidPackArchiveFormatException * @throws \Pterodactyl\Exceptions\Service\Pack\InvalidPackArchiveFormatException
*/ */
public function handle($option, UploadedFile $file) public function handle($egg, UploadedFile $file)
{ {
if (! $file->isValid()) { if (! $file->isValid()) {
throw new InvalidFileUploadException(trans('exceptions.packs.invalid_upload')); throw new InvalidFileUploadException(trans('exceptions.packs.invalid_upload'));
@ -76,10 +76,10 @@ class TemplateUploadService
} }
if ($file->getMimeType() === 'application/zip') { if ($file->getMimeType() === 'application/zip') {
return $this->handleArchive($option, $file); return $this->handleArchive($egg, $file);
} else { } else {
$json = json_decode($file->openFile()->fread($file->getSize()), true); $json = json_decode($file->openFile()->fread($file->getSize()), true);
$json['option_id'] = $option; $json['egg_id'] = $egg;
return $this->creationService->handle($json); return $this->creationService->handle($json);
} }
@ -88,7 +88,7 @@ class TemplateUploadService
/** /**
* Process a ZIP file to create a pack and stored archive. * Process a ZIP file to create a pack and stored archive.
* *
* @param int $option * @param int $egg
* @param \Illuminate\Http\UploadedFile $file * @param \Illuminate\Http\UploadedFile $file
* @return \Pterodactyl\Models\Pack * @return \Pterodactyl\Models\Pack
* *
@ -99,7 +99,7 @@ class TemplateUploadService
* @throws \Pterodactyl\Exceptions\Service\Pack\UnreadableZipArchiveException * @throws \Pterodactyl\Exceptions\Service\Pack\UnreadableZipArchiveException
* @throws \Pterodactyl\Exceptions\Service\Pack\InvalidPackArchiveFormatException * @throws \Pterodactyl\Exceptions\Service\Pack\InvalidPackArchiveFormatException
*/ */
protected function handleArchive($option, $file) protected function handleArchive($egg, $file)
{ {
if (! $this->archive->open($file->getRealPath())) { if (! $this->archive->open($file->getRealPath())) {
throw new UnreadableZipArchiveException(trans('exceptions.packs.unreadable')); throw new UnreadableZipArchiveException(trans('exceptions.packs.unreadable'));
@ -110,7 +110,7 @@ class TemplateUploadService
} }
$json = json_decode($this->archive->getFromName('import.json'), true); $json = json_decode($this->archive->getFromName('import.json'), true);
$json['option_id'] = $option; $json['egg_id'] = $egg;
$pack = $this->creationService->handle($json); $pack = $this->creationService->handle($json);
if (! $this->archive->extractTo(storage_path('app/packs/' . $pack->uuid), 'archive.tar.gz')) { if (! $this->archive->extractTo(storage_path('app/packs/' . $pack->uuid), 'archive.tar.gz')) {

View File

@ -124,7 +124,7 @@ class ServerCreationService
public function create(array $data) public function create(array $data)
{ {
// @todo auto-deployment // @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); $uniqueShort = str_random(8);
$this->connection->beginTransaction(); $this->connection->beginTransaction();

View File

@ -133,7 +133,7 @@ $factory->state(Pterodactyl\Models\EggVariable::class, 'editable', function () {
$factory->define(Pterodactyl\Models\Pack::class, function (Faker\Generator $faker) { $factory->define(Pterodactyl\Models\Pack::class, function (Faker\Generator $faker) {
return [ return [
'id' => $faker->unique()->randomNumber(), 'id' => $faker->unique()->randomNumber(),
'option_id' => $faker->randomNumber(), 'egg_id' => $faker->randomNumber(),
'uuid' => $faker->uuid, 'uuid' => $faker->uuid,
'name' => $faker->word, 'name' => $faker->word,
'description' => null, 'description' => null,

View File

@ -56,7 +56,7 @@
<td><code>{{ $server->uuidShort }}</code></td> <td><code>{{ $server->uuidShort }}</code></td>
<td><a href="{{ route('admin.servers.view', $server->id) }}">{{ $server->name }}</a></td> <td><a href="{{ route('admin.servers.view', $server->id) }}">{{ $server->name }}</a></td>
<td><a href="{{ route('admin.users.view', $server->owner_id) }}">{{ $server->user->username }}</a></td> <td><a href="{{ route('admin.users.view', $server->owner_id) }}">{{ $server->user->username }}</a></td>
<td>{{ $server->service->name }} ({{ $server->option->name }})</td> <td>{{ $server->nest->name }} ({{ $server->egg->name }})</td>
<td class="text-center"><span data-action="memory">NaN</span> / {{ $server->memory === 0 ? '&infin;' : $server->memory }} MB</td> <td class="text-center"><span data-action="memory">NaN</span> / {{ $server->memory === 0 ? '&infin;' : $server->memory }} MB</td>
<td class="text-center">{{ $server->disk }} MB</td> <td class="text-center">{{ $server->disk }} MB</td>
<td class="text-center"><span data-action="cpu" data-cpumax="{{ $server->cpu }}">NaN</span> %</td> <td class="text-center"><span data-action="cpu" data-cpumax="{{ $server->cpu }}">NaN</span> %</td>

View File

@ -43,7 +43,7 @@
<th>Pack Name</th> <th>Pack Name</th>
<th>Version</th> <th>Version</th>
<th>Description</th> <th>Description</th>
<th>Option</td> <th>Egg</th>
<th class="text-center">Servers</th> <th class="text-center">Servers</th>
</tr> </tr>
@foreach ($packs as $pack) @foreach ($packs as $pack)
@ -52,7 +52,7 @@
<td class="middle"><a href="{{ route('admin.packs.view', $pack->id) }}">{{ $pack->name }}</a></td> <td class="middle"><a href="{{ route('admin.packs.view', $pack->id) }}">{{ $pack->name }}</a></td>
<td class="middle"><code>{{ $pack->version }}</code></td> <td class="middle"><code>{{ $pack->version }}</code></td>
<td class="col-md-6">{{ str_limit($pack->description, 150) }}</td> <td class="col-md-6">{{ str_limit($pack->description, 150) }}</td>
<td class="middle"><a href="{{ route('admin.services.option.view', $pack->option->id) }}">{{ $pack->option->name }}</a></td> <td class="middle"><a href="{{ route('admin.nests.egg.view', $pack->egg->id) }}">{{ $pack->egg->name }}</a></td>
<td class="middle text-center">{{ $pack->servers_count }}</td> <td class="middle text-center">{{ $pack->servers_count }}</td>
</tr> </tr>
@endforeach @endforeach

View File

@ -10,17 +10,17 @@
<div class="well" style="margin-bottom:0"> <div class="well" style="margin-bottom:0">
<div class="row"> <div class="row">
<div class="col-md-12"> <div class="col-md-12">
<label for="pOptionIdModal" class="form-label">Associated Service Option:</label> <label for="pEggIdModal" class="form-label">Associated Egg:</label>
<select id="pOptionIdModal" name="option_id" class="form-control"> <select id="pEggIdModal" name="egg_id" class="form-control">
@foreach($services as $service) @foreach($nests as $nest)
<optgroup label="{{ $service->name }}"> <optgroup label="{{ $nest->name }}">
@foreach($service->options as $option) @foreach($nest->eggs as $egg)
<option value="{{ $option->id }}">{{ $option->name }}</option> <option value="{{ $egg->id }}">{{ $egg->name }}</option>
@endforeach @endforeach
</optgroup> </optgroup>
@endforeach @endforeach
</select> </select>
<p class="text-muted small">The option that this pack is assocaited with. Only servers that are assigned this option will be able to access this pack.</p> <p class="text-muted small">The Egg that this pack is assocaited with. Only servers that are assigned this Egg will be able to access this pack.</p>
</div> </div>
</div> </div>
<div class="row" style="margin-top:15px;"> <div class="row" style="margin-top:15px;">

View File

@ -52,12 +52,12 @@
<p class="text-muted small">The version of this package, or the version of the files contained within the package.</p> <p class="text-muted small">The version of this package, or the version of the files contained within the package.</p>
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="pOptionId" class="form-label">Associated Option</label> <label for="pEggId" class="form-label">Associated Egg</label>
<select id="pOptionId" name="option_id" class="form-control"> <select id="pEggId" name="egg_id" class="form-control">
@foreach($services as $service) @foreach($nests as $nest)
<optgroup label="{{ $service->name }}"> <optgroup label="{{ $nest->name }}">
@foreach($service->options as $option) @foreach($nest->eggs as $egg)
<option value="{{ $option->id }}">{{ $option->name }}</option> <option value="{{ $egg->id }}">{{ $egg->name }}</option>
@endforeach @endforeach
</optgroup> </optgroup>
@endforeach @endforeach
@ -124,7 +124,7 @@
@section('footer-scripts') @section('footer-scripts')
@parent @parent
<script> <script>
$('#pOptionId').select2(); $('#pEggId').select2();
$('#toggleModal').on('click', function (event) { $('#toggleModal').on('click', function (event) {
event.preventDefault(); event.preventDefault();
@ -135,9 +135,9 @@
}).fail(function (jqXhr) { }).fail(function (jqXhr) {
console.error(jqXhr); console.error(jqXhr);
alert('There was an error trying to create the upload modal.'); alert('There was an error trying to create the upload modal.');
}).success(function (data) { }).done(function (data) {
$(data).modal(); $(data).modal();
$('#pOptionIdModal').select2(); $('#pEggIdModal').select2();
}); });
}); });
</script> </script>

View File

@ -51,12 +51,12 @@
</div> </div>
<div class="box-body"> <div class="box-body">
<div class="form-group"> <div class="form-group">
<label for="pOptionId" class="form-label">Associated Option</label> <label for="pEggId" class="form-label">Associated Option</label>
<select id="pOptionId" name="option_id" class="form-control"> <select id="pEggId" name="egg_id" class="form-control">
@foreach($services as $service) @foreach($nests as $nest)
<optgroup label="{{ $service->name }}"> <optgroup label="{{ $nest->name }}">
@foreach($service->options as $option) @foreach($nest->eggs as $egg)
<option value="{{ $option->id }}" {{ $pack->option_id !== $option->id ?: 'selected' }}>{{ $option->name }}</option> <option value="{{ $egg->id }}" {{ $pack->egg_id !== $egg->id ?: 'selected' }}>{{ $egg->name }}</option>
@endforeach @endforeach
</optgroup> </optgroup>
@endforeach @endforeach
@ -173,6 +173,6 @@
@section('footer-scripts') @section('footer-scripts')
@parent @parent
<script> <script>
$('#pOptionId').select2(); $('#pEggId').select2();
</script> </script>
@endsection @endsection

View File

@ -113,22 +113,23 @@
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
@foreach($user->setAccessLevel('subuser')->access()->get() as $server) Oh dear, this hasn't been fixed yet?
<tr> {{--@foreach($user->setAccessLevel('subuser')->access()->get() as $server)--}}
<td><a href="{{ route('server.index', $server->uuidShort) }}/"><i class="fa fa-tachometer"></i></a></td> {{--<tr>--}}
<td><code>{{ $server->uuidShort }}</code></td> {{--<td><a href="{{ route('server.index', $server->uuidShort) }}/"><i class="fa fa-tachometer"></i></a></td>--}}
<td><a href="{{ route('admin.servers.view', $server->id) }}">{{ $server->name }}</a></td> {{--<td><code>{{ $server->uuidShort }}</code></td>--}}
<td> {{--<td><a href="{{ route('admin.servers.view', $server->id) }}">{{ $server->name }}</a></td>--}}
@if($server->owner_id === $user->id) {{--<td>--}}
<span class="label bg-purple">Owner</span> {{--@if($server->owner_id === $user->id)--}}
@else {{--<span class="label bg-purple">Owner</span>--}}
<span class="label bg-blue">Subuser</span> {{--@else--}}
@endif {{--<span class="label bg-blue">Subuser</span>--}}
</td> {{--@endif--}}
<td><a href="{{ route('admin.nodes.view', $server->node->id) }}">{{ $server->node->name }}</a></td> {{--</td>--}}
<td class="centered">@if($server->suspended === 0)<span class="label muted muted-hover label-success">Active</span>@else<span class="label label-warning">Suspended</span>@endif</td> {{--<td><a href="{{ route('admin.nodes.view', $server->node->id) }}">{{ $server->node->name }}</a></td>--}}
</td> {{--<td class="centered">@if($server->suspended === 0)<span class="label muted muted-hover label-success">Active</span>@else<span class="label label-warning">Suspended</span>@endif</td>--}}
@endforeach {{--</td>--}}
{{--@endforeach--}}
</tbody> </tbody>
</table> </table>
</div> </div>

View File

@ -79,7 +79,7 @@
{!! Theme::js('js/frontend/console.js') !!} {!! Theme::js('js/frontend/console.js') !!}
{!! Theme::js('vendor/chartjs/chart.min.js') !!} {!! Theme::js('vendor/chartjs/chart.min.js') !!}
{!! Theme::js('vendor/jquery/date-format.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') !!} {!! Theme::js('js/plugins/minecraft/eula.js') !!}
@endif @endif
@endsection @endsection