Misc fixes
This commit is contained in:
parent
864513c44b
commit
aaf96669d4
|
@ -47,11 +47,11 @@ class EggRetrievalController extends Controller
|
|||
*/
|
||||
public function index(): JsonResponse
|
||||
{
|
||||
$options = $this->repository->getAllWithCopyAttributes();
|
||||
$eggs = $this->repository->getAllWithCopyAttributes();
|
||||
|
||||
$response = [];
|
||||
$options->each(function ($option) use (&$response) {
|
||||
$response[$option->uuid] = sha1(json_encode($this->configurationFileService->handle($option)));
|
||||
$eggs->each(function ($egg) use (&$response) {
|
||||
$response[$egg->uuid] = sha1(json_encode($this->configurationFileService->handle($egg)));
|
||||
});
|
||||
|
||||
return response()->json($response);
|
||||
|
|
|
@ -11,14 +11,20 @@ namespace Pterodactyl\Http\Controllers\Admin\Nests;
|
|||
|
||||
use Pterodactyl\Models\Egg;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Prologue\Alerts\AlertsMessageBag;
|
||||
use Pterodactyl\Http\Controllers\Controller;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Pterodactyl\Services\Eggs\Sharing\EggExporterService;
|
||||
use Pterodactyl\Services\Eggs\Sharing\EggImporterService;
|
||||
use Pterodactyl\Http\Requests\Admin\Service\OptionImportFormRequest;
|
||||
use Pterodactyl\Http\Requests\Admin\Egg\EggImportFormRequest;
|
||||
|
||||
class EggShareController extends Controller
|
||||
{
|
||||
/**
|
||||
* @var \Prologue\Alerts\AlertsMessageBag
|
||||
*/
|
||||
protected $alert;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Services\Eggs\Sharing\EggExporterService
|
||||
*/
|
||||
|
@ -32,13 +38,16 @@ class EggShareController extends Controller
|
|||
/**
|
||||
* OptionShareController constructor.
|
||||
*
|
||||
* @param \Prologue\Alerts\AlertsMessageBag $alert
|
||||
* @param \Pterodactyl\Services\Eggs\Sharing\EggExporterService $exporterService
|
||||
* @param \Pterodactyl\Services\Eggs\Sharing\EggImporterService $importerService
|
||||
*/
|
||||
public function __construct(
|
||||
AlertsMessageBag $alert,
|
||||
EggExporterService $exporterService,
|
||||
EggImporterService $importerService
|
||||
) {
|
||||
$this->alert = $alert;
|
||||
$this->exporterService = $exporterService;
|
||||
$this->importerService = $importerService;
|
||||
}
|
||||
|
@ -62,16 +71,17 @@ class EggShareController extends Controller
|
|||
/**
|
||||
* Import a new service option using an XML file.
|
||||
*
|
||||
* @param \Pterodactyl\Http\Requests\Admin\Service\OptionImportFormRequest $request
|
||||
* @param \Pterodactyl\Http\Requests\Admin\Egg\EggImportFormRequest $request
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
|
||||
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
||||
* @throws \Pterodactyl\Exceptions\Service\Pack\InvalidFileUploadException
|
||||
*/
|
||||
public function import(OptionImportFormRequest $request): RedirectResponse
|
||||
public function import(EggImportFormRequest $request): RedirectResponse
|
||||
{
|
||||
$egg = $this->importerService->handle($request->file('import_file'), $request->input('import_to_nest'));
|
||||
$this->alert->success(trans('admin/nests.eggs.notices.imported'))->flash();
|
||||
|
||||
return redirect()->route('admin.nests.egg.view', ['egg' => $egg->id]);
|
||||
}
|
||||
|
|
|
@ -7,11 +7,11 @@
|
|||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Http\Requests\Admin\Service;
|
||||
namespace Pterodactyl\Http\Requests\Admin\Egg;
|
||||
|
||||
use Pterodactyl\Http\Requests\Admin\AdminFormRequest;
|
||||
|
||||
class OptionImportFormRequest extends AdminFormRequest
|
||||
class EggImportFormRequest extends AdminFormRequest
|
||||
{
|
||||
/**
|
||||
* @return array
|
||||
|
@ -20,7 +20,7 @@ class OptionImportFormRequest extends AdminFormRequest
|
|||
{
|
||||
return [
|
||||
'import_file' => 'bail|required|file|max:1000|mimetypes:application/json,text/plain',
|
||||
'import_to_service' => 'bail|required|integer|exists:services,id',
|
||||
'import_to_nest' => 'bail|required|integer|exists:nests,id',
|
||||
];
|
||||
}
|
||||
}
|
|
@ -1,25 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Pterodactyl - Panel
|
||||
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
|
||||
*
|
||||
* This software is licensed under the terms of the MIT license.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Http\Requests\Admin\Service;
|
||||
|
||||
use Pterodactyl\Http\Requests\Admin\AdminFormRequest;
|
||||
|
||||
class ServiceFunctionsFormRequest extends AdminFormRequest
|
||||
{
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
'index_file' => 'required|nullable|string',
|
||||
];
|
||||
}
|
||||
}
|
|
@ -65,8 +65,10 @@ class Egg extends Model implements CleansAttributes, ValidableContract
|
|||
*/
|
||||
protected static $applicationRules = [
|
||||
'nest_id' => 'required',
|
||||
'uuid' => 'required',
|
||||
'name' => 'required',
|
||||
'description' => 'required',
|
||||
'author' => 'required',
|
||||
'docker_image' => 'required',
|
||||
'startup' => 'required',
|
||||
'config_from' => 'sometimes',
|
||||
|
@ -84,6 +86,7 @@ class Egg extends Model implements CleansAttributes, ValidableContract
|
|||
'uuid' => 'string|size:36',
|
||||
'name' => 'string|max:255',
|
||||
'description' => 'string',
|
||||
'author' => 'string|email',
|
||||
'docker_image' => 'string|max:255',
|
||||
'startup' => 'nullable|string',
|
||||
'config_from' => 'bail|nullable|numeric|exists:eggs,id',
|
||||
|
|
|
@ -49,7 +49,7 @@ class Nest extends Model implements CleansAttributes, ValidableContract
|
|||
* @var array
|
||||
*/
|
||||
protected static $dataIntegrityRules = [
|
||||
'author' => 'email',
|
||||
'author' => 'string|email',
|
||||
'name' => 'string|max:255',
|
||||
'description' => 'nullable|string',
|
||||
];
|
||||
|
|
|
@ -32,22 +32,22 @@ class EggConfigurationService
|
|||
/**
|
||||
* Return an Egg file to be used by the Daemon.
|
||||
*
|
||||
* @param int|\Pterodactyl\Models\Egg $option
|
||||
* @param int|\Pterodactyl\Models\Egg $egg
|
||||
* @return array
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
||||
*/
|
||||
public function handle($option): array
|
||||
public function handle($egg): array
|
||||
{
|
||||
if (! $option instanceof Egg) {
|
||||
$option = $this->repository->getWithCopyAttributes($option);
|
||||
if (! $egg instanceof Egg) {
|
||||
$egg = $this->repository->getWithCopyAttributes($egg);
|
||||
}
|
||||
|
||||
return [
|
||||
'startup' => json_decode($option->inherit_config_startup),
|
||||
'stop' => $option->inherit_config_stop,
|
||||
'configs' => json_decode($option->inherit_config_files),
|
||||
'log' => json_decode($option->inherit_config_logs),
|
||||
'startup' => json_decode($egg->inherit_config_startup),
|
||||
'stop' => $egg->inherit_config_stop,
|
||||
'configs' => json_decode($egg->inherit_config_files),
|
||||
'log' => json_decode($egg->inherit_config_logs),
|
||||
'query' => 'none',
|
||||
];
|
||||
}
|
||||
|
|
|
@ -51,6 +51,7 @@ class EggExporterService
|
|||
'author' => $egg->author,
|
||||
'description' => $egg->description,
|
||||
'image' => $egg->docker_image,
|
||||
'startup' => $egg->startup,
|
||||
'config' => [
|
||||
'files' => $egg->inherit_config_files,
|
||||
'startup' => $egg->inherit_config_startup,
|
||||
|
|
|
@ -89,6 +89,7 @@ class EggImporterService
|
|||
$egg = $this->repository->create([
|
||||
'uuid' => Uuid::uuid4()->toString(),
|
||||
'nest_id' => $nest->id,
|
||||
'author' => object_get($parsed, 'author'),
|
||||
'name' => object_get($parsed, 'name'),
|
||||
'description' => object_get($parsed, 'description'),
|
||||
'docker_image' => object_get($parsed, 'image'),
|
||||
|
|
|
@ -72,7 +72,7 @@ class ServerConfigurationStructureService
|
|||
],
|
||||
'keys' => [],
|
||||
'service' => [
|
||||
'option' => $server->option->uuid,
|
||||
'egg' => $server->egg->uuid,
|
||||
'pack' => object_get($server, 'pack.uuid'),
|
||||
'skip_scripts' => $server->skip_scripts,
|
||||
],
|
||||
|
|
|
@ -15,6 +15,7 @@ return [
|
|||
],
|
||||
'eggs' => [
|
||||
'notices' => [
|
||||
'imported' => 'Successfully imported this Egg and its associated variables.',
|
||||
'deleted' => 'Successfully deleted the requested egg from the Panel.',
|
||||
'updated' => 'Egg configuration has been updated successfully.',
|
||||
'script_updated' => 'Egg install script has been updated and will run whenever servers are installed.',
|
||||
|
|
|
@ -52,20 +52,30 @@
|
|||
<p class="text-muted small">A simple, human-readable name to use as an identifier for this Egg.</p>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="pDescription" class="control-label">Description <span class="field-required"></span></label>
|
||||
<textarea id="pDescription" name="description" class="form-control" rows="10">{{ $egg->description }}</textarea>
|
||||
<p class="text-muted small">A description of this Egg that will be displayed throughout the Panel as needed.</p>
|
||||
<label for="pUuid" class="control-label">UUID</label>
|
||||
<input type="text" id="pUuid" readonly value="{{ $egg->uuid }}" class="form-control" />
|
||||
<p class="text-muted small">This is the globally unique identifier for this Egg which the Daemon uses as an identifier.</p>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="pAuthor" class="control-label">Author</label>
|
||||
<input type="text" id="pAuthor" readonly value="{{ $egg->author }}" class="form-control" />
|
||||
<p class="text-muted small">The author of this version of the Egg. Uploading a new Egg configuration from a different author will change this.</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-6">
|
||||
<div class="form-group">
|
||||
<label for="pDockerImage" class="control-label">Docker Image <span class="field-required"></span></label>
|
||||
<input type="text" id="pDockerImage" name="docker_image" value="{{ $egg->docker_image }}" class="form-control" />
|
||||
<p class="text-muted small">The default docker image that should be used for new servers using this Egg. This can be changed per-server as needed.</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-6">
|
||||
<div class="form-group">
|
||||
<label for="pDescription" class="control-label">Description <span class="field-required"></span></label>
|
||||
<textarea id="pDescription" name="description" class="form-control" rows="6">{{ $egg->description }}</textarea>
|
||||
<p class="text-muted small">A description of this Egg that will be displayed throughout the Panel as needed.</p>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="pStartup" class="control-label">Startup Command <span class="field-required"></span></label>
|
||||
<textarea id="pStartup" name="startup" class="form-control" rows="9">{{ $egg->startup }}</textarea>
|
||||
<textarea id="pStartup" name="startup" class="form-control" rows="6">{{ $egg->startup }}</textarea>
|
||||
<p class="text-muted small">The default statup command that should be used for new servers using this Egg.</p>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -141,7 +151,7 @@
|
|||
<script>
|
||||
$('#pConfigFrom').select2();
|
||||
$('#deleteButton').on('mouseenter', function (event) {
|
||||
$(this).find('i').html(' Delete Option');
|
||||
$(this).find('i').html(' Delete Egg');
|
||||
}).on('mouseleave', function (event) {
|
||||
$(this).find('i').html('');
|
||||
});
|
||||
|
|
|
@ -75,9 +75,9 @@
|
|||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label" for="pImportToService">Associated Nest <span class="field-required"></span></label>
|
||||
<label class="control-label" for="pImportToNest">Associated Nest <span class="field-required"></span></label>
|
||||
<div>
|
||||
<select id="pImportToService" name="import_to_service">
|
||||
<select id="pImportToNest" name="import_to_nest">
|
||||
@foreach($nests as $nest)
|
||||
<option value="{{ $nest->id }}">{{ $nest->name }} <{{ $nest->author }}></option>
|
||||
@endforeach
|
||||
|
@ -101,7 +101,7 @@
|
|||
@parent
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
$('#pImportToService').select2();
|
||||
$('#pImportToNest').select2();
|
||||
});
|
||||
</script>
|
||||
@endsection
|
||||
|
|
|
@ -83,7 +83,7 @@
|
|||
</tr>
|
||||
@foreach($nest->eggs as $egg)
|
||||
<tr>
|
||||
<td class="align-middle"><a href="{{ route('admin.nests.egg.view', $egg->id) }}">{{ $egg->name }}</a></td>
|
||||
<td class="align-middle"><a href="{{ route('admin.nests.egg.view', $egg->id) }}" data-toggle="tooltip" data-placement="right" title="{{ $egg->author }}">{{ $egg->name }}</a></td>
|
||||
<td class="col-xs-8 align-middle">{!! $egg->description !!}</td>
|
||||
<td class="text-center align-middle"><code>{{ $egg->servers->count() }}</code></td>
|
||||
<td class="align-middle">
|
||||
|
@ -105,7 +105,7 @@
|
|||
@parent
|
||||
<script>
|
||||
$('#deleteButton').on('mouseenter', function (event) {
|
||||
$(this).find('i').html(' Delete Service');
|
||||
$(this).find('i').html(' Delete Nest');
|
||||
}).on('mouseleave', function (event) {
|
||||
$(this).find('i').html('');
|
||||
});
|
||||
|
|
|
@ -9,6 +9,6 @@
|
|||
Route::get('/authenticate/{token}', 'ValidateKeyController@index')->name('api.remote.authenticate');
|
||||
|
||||
Route::group(['prefix' => '/eggs'], function () {
|
||||
Route::get('/', 'EggRetrievalController@download@index')->name('api.remote.eggs');
|
||||
Route::get('/', 'EggRetrievalController@index')->name('api.remote.eggs');
|
||||
Route::get('/{uuid}', 'EggRetrievalController@download')->name('api.remote.eggs.download');
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue