2023-04-05 15:29:58 -04:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Pterodactyl\Http\Controllers\Admin\Extensions\Blueprint;
|
|
|
|
|
|
|
|
use Illuminate\View\View;
|
|
|
|
use Illuminate\View\Factory as ViewFactory;
|
|
|
|
use Prologue\Alerts\AlertsMessageBag;
|
|
|
|
use Illuminate\Contracts\Console\Kernel;
|
|
|
|
use Pterodactyl\Http\Controllers\Controller;
|
|
|
|
use Pterodactyl\Services\Helpers\SoftwareVersionService;
|
|
|
|
use Pterodactyl\Services\Helpers\BlueprintVariableService;
|
2023-04-11 15:54:57 -04:00
|
|
|
use Pterodactyl\Services\Helpers\BlueprintTelemetryService;
|
2023-04-24 11:34:02 -04:00
|
|
|
use Pterodactyl\Services\Helpers\BlueprintExtensionLibrary;
|
2023-05-06 10:21:22 -04:00
|
|
|
use Pterodactyl\Services\Helpers\BlueprintPlaceholderService;
|
2023-04-05 15:29:58 -04:00
|
|
|
use Pterodactyl\Contracts\Repository\SettingsRepositoryInterface;
|
|
|
|
use Illuminate\Contracts\Config\Repository as ConfigRepository;
|
|
|
|
use Illuminate\Http\RedirectResponse;
|
2023-06-28 09:48:44 -04:00
|
|
|
use Pterodactyl\Http\Requests\Admin\AdminFormRequest;
|
2023-04-05 15:29:58 -04:00
|
|
|
|
|
|
|
class BlueprintExtensionController extends Controller
|
|
|
|
{
|
|
|
|
|
2023-06-02 10:37:38 -04:00
|
|
|
/**
|
|
|
|
* BlueprintExtensionController constructor.
|
|
|
|
*/
|
|
|
|
public function __construct(
|
|
|
|
private BlueprintVariableService $bp,
|
|
|
|
private BlueprintTelemetryService $telemetry,
|
|
|
|
private BlueprintExtensionLibrary $bplib,
|
|
|
|
private BlueprintPlaceholderService $placeholderservice,
|
2023-04-05 15:29:58 -04:00
|
|
|
|
2023-06-02 10:37:38 -04:00
|
|
|
private SoftwareVersionService $version,
|
|
|
|
private ViewFactory $view,
|
|
|
|
private Kernel $kernel,
|
|
|
|
private AlertsMessageBag $alert,
|
|
|
|
private ConfigRepository $config,
|
|
|
|
private SettingsRepositoryInterface $settings,
|
|
|
|
) {
|
|
|
|
}
|
2023-05-31 04:40:03 -04:00
|
|
|
|
2023-06-02 10:37:38 -04:00
|
|
|
/**
|
|
|
|
* Return the admin index view.
|
|
|
|
*/
|
|
|
|
public function index(): View
|
|
|
|
{
|
|
|
|
if ($this->settings->get('blueprint::panel:id') == "" || $this->bp->version() != $this->settings->get('blueprint::version:cache')) {
|
|
|
|
$this->settings->set('blueprint::panel:id', uniqid(rand())."@".$this->bp->version());
|
|
|
|
$this->settings->set('blueprint::version:cache', $this->bp->version());
|
2023-07-17 07:29:32 -04:00
|
|
|
$this->bp->config('TELEMETRY_ID',$this->settings->get("blueprint::panel:id"));
|
2023-06-02 10:37:38 -04:00
|
|
|
};
|
2023-08-07 09:50:54 -04:00
|
|
|
$this->bp->config('DEVELOPER', $this->settings->get('blueprint::developer'));
|
2023-06-02 10:37:38 -04:00
|
|
|
return $this->view->make(
|
|
|
|
'admin.extensions.blueprint.index', [
|
|
|
|
'version' => $this->version,
|
2023-04-24 11:34:02 -04:00
|
|
|
|
2023-06-02 10:37:38 -04:00
|
|
|
'bp' => $this->bp,
|
|
|
|
'bplib' => $this->bplib,
|
|
|
|
'telemetry' => $this->telemetry,
|
2023-04-05 15:29:58 -04:00
|
|
|
|
2023-06-02 10:37:38 -04:00
|
|
|
'root' => "/admin/extensions/blueprint",
|
|
|
|
]
|
|
|
|
);
|
|
|
|
}
|
2023-04-05 15:29:58 -04:00
|
|
|
|
2023-06-02 10:37:38 -04:00
|
|
|
/**
|
|
|
|
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
|
|
|
|
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
|
|
|
*/
|
2023-06-28 10:57:05 -04:00
|
|
|
public function update(BlueprintAdminFormRequest $request): RedirectResponse
|
2023-06-02 10:37:38 -04:00
|
|
|
{
|
|
|
|
foreach ($request->normalize() as $key => $value) {
|
|
|
|
$this->settings->set('blueprint::' . $key, $value);
|
2023-04-05 15:29:58 -04:00
|
|
|
}
|
2023-06-02 10:37:38 -04:00
|
|
|
|
|
|
|
$this->bplib->notify("Your changes have been saved.");
|
|
|
|
return redirect()->route('admin.extensions.blueprint.index');
|
|
|
|
}
|
2023-06-18 12:32:02 -04:00
|
|
|
}
|
2023-06-28 09:48:44 -04:00
|
|
|
|
2023-06-28 10:57:05 -04:00
|
|
|
class BlueprintAdminFormRequest extends AdminFormRequest
|
2023-06-28 09:48:44 -04:00
|
|
|
{
|
|
|
|
public function rules(): array {
|
|
|
|
return [
|
|
|
|
'placeholder' => 'string',
|
|
|
|
'developer' => 'string',
|
|
|
|
'telemetry' => 'string',
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
public function attributes(): array {
|
|
|
|
return [
|
|
|
|
'placeholder' => 'Placeholder Value',
|
|
|
|
'developer' => 'Developer Mode',
|
|
|
|
'telemetry' => 'Telemetry',
|
|
|
|
];
|
|
|
|
}
|
|
|
|
}
|