More fixes
This commit is contained in:
parent
17642bffe7
commit
c19c423568
14 changed files with 67 additions and 61 deletions
|
@ -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(),
|
||||
]);
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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',
|
||||
];
|
||||
|
||||
/**
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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')) {
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -56,7 +56,7 @@
|
|||
<td><code>{{ $server->uuidShort }}</code></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>{{ $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 ? '∞' : $server->memory }} 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>
|
||||
|
|
|
@ -43,7 +43,7 @@
|
|||
<th>Pack Name</th>
|
||||
<th>Version</th>
|
||||
<th>Description</th>
|
||||
<th>Option</td>
|
||||
<th>Egg</th>
|
||||
<th class="text-center">Servers</th>
|
||||
</tr>
|
||||
@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"><code>{{ $pack->version }}</code></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>
|
||||
</tr>
|
||||
@endforeach
|
||||
|
|
|
@ -10,17 +10,17 @@
|
|||
<div class="well" style="margin-bottom:0">
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<label for="pOptionIdModal" class="form-label">Associated Service Option:</label>
|
||||
<select id="pOptionIdModal" name="option_id" class="form-control">
|
||||
@foreach($services as $service)
|
||||
<optgroup label="{{ $service->name }}">
|
||||
@foreach($service->options as $option)
|
||||
<option value="{{ $option->id }}">{{ $option->name }}</option>
|
||||
<label for="pEggIdModal" class="form-label">Associated Egg:</label>
|
||||
<select id="pEggIdModal" name="egg_id" class="form-control">
|
||||
@foreach($nests as $nest)
|
||||
<optgroup label="{{ $nest->name }}">
|
||||
@foreach($nest->eggs as $egg)
|
||||
<option value="{{ $egg->id }}">{{ $egg->name }}</option>
|
||||
@endforeach
|
||||
</optgroup>
|
||||
@endforeach
|
||||
</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 class="row" style="margin-top:15px;">
|
||||
|
|
|
@ -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>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="pOptionId" class="form-label">Associated Option</label>
|
||||
<select id="pOptionId" name="option_id" class="form-control">
|
||||
@foreach($services as $service)
|
||||
<optgroup label="{{ $service->name }}">
|
||||
@foreach($service->options as $option)
|
||||
<option value="{{ $option->id }}">{{ $option->name }}</option>
|
||||
<label for="pEggId" class="form-label">Associated Egg</label>
|
||||
<select id="pEggId" name="egg_id" class="form-control">
|
||||
@foreach($nests as $nest)
|
||||
<optgroup label="{{ $nest->name }}">
|
||||
@foreach($nest->eggs as $egg)
|
||||
<option value="{{ $egg->id }}">{{ $egg->name }}</option>
|
||||
@endforeach
|
||||
</optgroup>
|
||||
@endforeach
|
||||
|
@ -124,7 +124,7 @@
|
|||
@section('footer-scripts')
|
||||
@parent
|
||||
<script>
|
||||
$('#pOptionId').select2();
|
||||
$('#pEggId').select2();
|
||||
$('#toggleModal').on('click', function (event) {
|
||||
event.preventDefault();
|
||||
|
||||
|
@ -135,9 +135,9 @@
|
|||
}).fail(function (jqXhr) {
|
||||
console.error(jqXhr);
|
||||
alert('There was an error trying to create the upload modal.');
|
||||
}).success(function (data) {
|
||||
}).done(function (data) {
|
||||
$(data).modal();
|
||||
$('#pOptionIdModal').select2();
|
||||
$('#pEggIdModal').select2();
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
|
|
@ -51,12 +51,12 @@
|
|||
</div>
|
||||
<div class="box-body">
|
||||
<div class="form-group">
|
||||
<label for="pOptionId" class="form-label">Associated Option</label>
|
||||
<select id="pOptionId" name="option_id" class="form-control">
|
||||
@foreach($services as $service)
|
||||
<optgroup label="{{ $service->name }}">
|
||||
@foreach($service->options as $option)
|
||||
<option value="{{ $option->id }}" {{ $pack->option_id !== $option->id ?: 'selected' }}>{{ $option->name }}</option>
|
||||
<label for="pEggId" class="form-label">Associated Option</label>
|
||||
<select id="pEggId" name="egg_id" class="form-control">
|
||||
@foreach($nests as $nest)
|
||||
<optgroup label="{{ $nest->name }}">
|
||||
@foreach($nest->eggs as $egg)
|
||||
<option value="{{ $egg->id }}" {{ $pack->egg_id !== $egg->id ?: 'selected' }}>{{ $egg->name }}</option>
|
||||
@endforeach
|
||||
</optgroup>
|
||||
@endforeach
|
||||
|
@ -173,6 +173,6 @@
|
|||
@section('footer-scripts')
|
||||
@parent
|
||||
<script>
|
||||
$('#pOptionId').select2();
|
||||
$('#pEggId').select2();
|
||||
</script>
|
||||
@endsection
|
||||
|
|
|
@ -113,22 +113,23 @@
|
|||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach($user->setAccessLevel('subuser')->access()->get() as $server)
|
||||
<tr>
|
||||
<td><a href="{{ route('server.index', $server->uuidShort) }}/"><i class="fa fa-tachometer"></i></a></td>
|
||||
<td><code>{{ $server->uuidShort }}</code></td>
|
||||
<td><a href="{{ route('admin.servers.view', $server->id) }}">{{ $server->name }}</a></td>
|
||||
<td>
|
||||
@if($server->owner_id === $user->id)
|
||||
<span class="label bg-purple">Owner</span>
|
||||
@else
|
||||
<span class="label bg-blue">Subuser</span>
|
||||
@endif
|
||||
</td>
|
||||
<td><a href="{{ route('admin.nodes.view', $server->node->id) }}">{{ $server->node->name }}</a></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>
|
||||
@endforeach
|
||||
Oh dear, this hasn't been fixed yet?
|
||||
{{--@foreach($user->setAccessLevel('subuser')->access()->get() as $server)--}}
|
||||
{{--<tr>--}}
|
||||
{{--<td><a href="{{ route('server.index', $server->uuidShort) }}/"><i class="fa fa-tachometer"></i></a></td>--}}
|
||||
{{--<td><code>{{ $server->uuidShort }}</code></td>--}}
|
||||
{{--<td><a href="{{ route('admin.servers.view', $server->id) }}">{{ $server->name }}</a></td>--}}
|
||||
{{--<td>--}}
|
||||
{{--@if($server->owner_id === $user->id)--}}
|
||||
{{--<span class="label bg-purple">Owner</span>--}}
|
||||
{{--@else--}}
|
||||
{{--<span class="label bg-blue">Subuser</span>--}}
|
||||
{{--@endif--}}
|
||||
{{--</td>--}}
|
||||
{{--<td><a href="{{ route('admin.nodes.view', $server->node->id) }}">{{ $server->node->name }}</a></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>--}}
|
||||
{{--@endforeach--}}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue