Support creating/updating docker images on eggs
This commit is contained in:
parent
78c4ac80bc
commit
638ea2e815
4 changed files with 26 additions and 12 deletions
|
@ -78,7 +78,14 @@ class EggController extends Controller
|
||||||
*/
|
*/
|
||||||
public function store(EggFormRequest $request): RedirectResponse
|
public function store(EggFormRequest $request): RedirectResponse
|
||||||
{
|
{
|
||||||
$egg = $this->creationService->handle($request->normalize());
|
$data = $request->normalize();
|
||||||
|
if (!empty($data['docker_images']) && !is_array($data['docker_images'])) {
|
||||||
|
$data['docker_images'] = array_map(function ($value) {
|
||||||
|
return trim($value);
|
||||||
|
}, explode("\n", $data['docker_images']));
|
||||||
|
}
|
||||||
|
|
||||||
|
$egg = $this->creationService->handle($data);
|
||||||
$this->alert->success(trans('admin/nests.eggs.notices.egg_created'))->flash();
|
$this->alert->success(trans('admin/nests.eggs.notices.egg_created'))->flash();
|
||||||
|
|
||||||
return redirect()->route('admin.nests.egg.view', $egg->id);
|
return redirect()->route('admin.nests.egg.view', $egg->id);
|
||||||
|
@ -108,7 +115,14 @@ class EggController extends Controller
|
||||||
*/
|
*/
|
||||||
public function update(EggFormRequest $request, Egg $egg): RedirectResponse
|
public function update(EggFormRequest $request, Egg $egg): RedirectResponse
|
||||||
{
|
{
|
||||||
$this->updateService->handle($egg, $request->normalize());
|
$data = $request->normalize();
|
||||||
|
if (!empty($data['docker_images']) && !is_array($data['docker_images'])) {
|
||||||
|
$data['docker_images'] = array_map(function ($value) {
|
||||||
|
return trim($value);
|
||||||
|
}, explode("\n", $data['docker_images']));
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->updateService->handle($egg, $data);
|
||||||
$this->alert->success(trans('admin/nests.eggs.notices.updated'))->flash();
|
$this->alert->success(trans('admin/nests.eggs.notices.updated'))->flash();
|
||||||
|
|
||||||
return redirect()->route('admin.nests.egg.view', $egg->id);
|
return redirect()->route('admin.nests.egg.view', $egg->id);
|
||||||
|
|
|
@ -21,7 +21,7 @@ class EggFormRequest extends AdminFormRequest
|
||||||
$rules = [
|
$rules = [
|
||||||
'name' => 'required|string|max:191',
|
'name' => 'required|string|max:191',
|
||||||
'description' => 'nullable|string',
|
'description' => 'nullable|string',
|
||||||
'docker_image' => 'required|string|max:191',
|
'docker_images' => 'required|string',
|
||||||
'startup' => 'required|string',
|
'startup' => 'required|string',
|
||||||
'config_from' => 'sometimes|bail|nullable|numeric',
|
'config_from' => 'sometimes|bail|nullable|numeric',
|
||||||
'config_stop' => 'required_without:config_from|nullable|string|max:191',
|
'config_stop' => 'required_without:config_from|nullable|string|max:191',
|
||||||
|
|
|
@ -53,13 +53,13 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="col-sm-6">
|
<div class="col-sm-6">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="pDockerImage" class="control-label">Docker Image</label>
|
<label for="pDockerImage" class="control-label">Docker Images</label>
|
||||||
<input type="text" id="pDockerImage" name="docker_image" value="{{ old('docker_image') }}" placeholder="quay.io/pterodactyl/service" class="form-control" />
|
<textarea id="pDockerImages" name="docker_images" rows="4" placeholder="quay.io/pterodactyl/service" class="form-control">{{ old('docker_images') }}</textarea>
|
||||||
<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.</p>
|
<p class="text-muted small">The docker images available to servers using this egg. Enter one per line. Users will be able to select from this list of images if more than one value is provided.</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="pStartup" class="control-label">Startup Command</label>
|
<label for="pStartup" class="control-label">Startup Command</label>
|
||||||
<textarea id="pStartup" name="startup" class="form-control" rows="14">{{ old('startup') }}</textarea>
|
<textarea id="pStartup" name="startup" class="form-control" rows="10">{{ old('startup') }}</textarea>
|
||||||
<p class="text-muted small">The default startup command that should be used for new servers created with this Egg. You can change this per-server as needed.</p>
|
<p class="text-muted small">The default startup command that should be used for new servers created with this Egg. You can change this per-server as needed.</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -82,20 +82,20 @@
|
||||||
<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>
|
<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="form-group">
|
<div class="form-group">
|
||||||
<label for="pDockerImage" class="control-label">Docker Image <span class="field-required"></span></label>
|
<label for="pDockerImage" class="control-label">Docker Images <span class="field-required"></span></label>
|
||||||
<input type="text" id="pDockerImage" name="docker_image" value="{{ $egg->docker_image }}" class="form-control" />
|
<textarea id="pDockerImages" name="docker_images" class="form-control" rows="4">{{ implode("\n", $egg->docker_images) }}</textarea>
|
||||||
<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>
|
<p class="text-muted small">The docker images available to servers using this egg. Enter one per line. Users will be able to select from this list of images if more than one value is provided.</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-sm-6">
|
<div class="col-sm-6">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="pDescription" class="control-label">Description</label>
|
<label for="pDescription" class="control-label">Description</label>
|
||||||
<textarea id="pDescription" name="description" class="form-control" rows="6">{{ $egg->description }}</textarea>
|
<textarea id="pDescription" name="description" class="form-control" rows="8">{{ $egg->description }}</textarea>
|
||||||
<p class="text-muted small">A description of this Egg that will be displayed throughout the Panel as needed.</p>
|
<p class="text-muted small">A description of this Egg that will be displayed throughout the Panel as needed.</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="pStartup" class="control-label">Startup Command <span class="field-required"></span></label>
|
<label for="pStartup" class="control-label">Startup Command <span class="field-required"></span></label>
|
||||||
<textarea id="pStartup" name="startup" class="form-control" rows="6">{{ $egg->startup }}</textarea>
|
<textarea id="pStartup" name="startup" class="form-control" rows="8">{{ $egg->startup }}</textarea>
|
||||||
<p class="text-muted small">The default startup command that should be used for new servers using this Egg.</p>
|
<p class="text-muted small">The default startup command that should be used for new servers using this Egg.</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in a new issue