feat(artisan, bpview, bpcontroller): Update formatting on bpview and add new artisan command.
This commit is contained in:
parent
ef6866446c
commit
8097ec517a
4 changed files with 153 additions and 59 deletions
|
@ -15,15 +15,47 @@ class BlueprintVariableService
|
|||
|
||||
|
||||
// $bp->serve()
|
||||
// $bp->latestVersion()
|
||||
// $bp->isInstalled()
|
||||
// $bp->version()
|
||||
// $bp->dbGet('db::record')
|
||||
// $bp->dbSet('db::record', 'value')
|
||||
// $bp->config('item', value);
|
||||
|
||||
public function serve(): void {
|
||||
return;
|
||||
}
|
||||
|
||||
public function latestVersion(): string {
|
||||
$github_user = 'teamblueprint';
|
||||
$github_repo = 'main';
|
||||
|
||||
$api_url = "https://api.github.com/repos/{$github_user}/{$github_repo}/releases/latest";
|
||||
|
||||
$context = stream_context_create([
|
||||
'http' => [
|
||||
'method' => 'GET',
|
||||
'header' => 'User-Agent: BlueprintFramework',
|
||||
],
|
||||
]);
|
||||
|
||||
$response = file_get_contents($api_url, false, $context);
|
||||
|
||||
if ($response) {
|
||||
$cleaned_response = preg_replace('/[[:^print:]]/', '', $response);
|
||||
|
||||
$data = json_decode($cleaned_response, true);
|
||||
if (isset($data['tag_name'])) {
|
||||
$latest_version = $data['tag_name'];
|
||||
return "$latest_version";
|
||||
} else {
|
||||
return "Error: Unable to fetch the latest release version.";
|
||||
}
|
||||
} else {
|
||||
return "Error: Failed to make the API request.";
|
||||
}
|
||||
}
|
||||
|
||||
public function version(): string {
|
||||
return $this->blueprintplaceholderservice->version();
|
||||
}
|
||||
|
|
58
app/Console/Commands/BlueprintFramework/LatestCommand.php
Normal file
58
app/Console/Commands/BlueprintFramework/LatestCommand.php
Normal file
|
@ -0,0 +1,58 @@
|
|||
<?php
|
||||
|
||||
namespace Pterodactyl\Console\Commands\BlueprintFramework;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Pterodactyl\BlueprintFramework\Services\VariableService\BlueprintVariableService;
|
||||
use Pterodactyl\BlueprintFramework\Libraries\ExtensionLibrary\Admin\BlueprintAdminLibrary as BlueprintExtensionLibrary;
|
||||
use Pterodactyl\Contracts\Repository\SettingsRepositoryInterface;
|
||||
|
||||
class LatestCommand extends Command
|
||||
{
|
||||
protected $description = 'Fetch the latest version name of Blueprint.';
|
||||
protected $signature = 'bp:latest';
|
||||
|
||||
/**
|
||||
* TelemetryCommand constructor.
|
||||
*/
|
||||
public function __construct(
|
||||
private BlueprintVariableService $bp,
|
||||
private BlueprintExtensionLibrary $blueprint,
|
||||
private SettingsRepositoryInterface $settings,
|
||||
) { parent::__construct(); }
|
||||
|
||||
/**
|
||||
* Handle execution of command.
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$github_user = 'teamblueprint';
|
||||
$github_repo = 'main';
|
||||
|
||||
$api_url = "https://api.github.com/repos/{$github_user}/{$github_repo}/releases/latest";
|
||||
|
||||
$context = stream_context_create([
|
||||
'http' => [
|
||||
'method' => 'GET',
|
||||
'header' => 'User-Agent: BlueprintFramework',
|
||||
],
|
||||
]);
|
||||
|
||||
$response = file_get_contents($api_url, false, $context);
|
||||
|
||||
if ($response) {
|
||||
$cleaned_response = preg_replace('/[[:^print:]]/', '', $response);
|
||||
|
||||
$data = json_decode($cleaned_response, true);
|
||||
if (isset($data['tag_name'])) {
|
||||
$latest_version = $data['tag_name'];
|
||||
echo "$latest_version";
|
||||
} else {
|
||||
echo "Error: Unable to fetch the latest release version.";
|
||||
}
|
||||
} else {
|
||||
echo "Error: Failed to make the API request.";
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -45,6 +45,9 @@ class BlueprintExtensionController extends Controller
|
|||
public function index(): View
|
||||
{
|
||||
Artisan::call("bp:sync");
|
||||
$verlatest = Artisan::call("bp:latest");
|
||||
|
||||
if($this->bp->version() != $verlatest) { $outdated = true; }
|
||||
return $this->view->make(
|
||||
'admin.extensions.blueprint.index', [
|
||||
'version' => $this->version,
|
||||
|
@ -52,6 +55,8 @@ class BlueprintExtensionController extends Controller
|
|||
'bp' => $this->bp,
|
||||
'bplib' => $this->bplib,
|
||||
'telemetry' => $this->telemetry,
|
||||
'verlatest' => $verlatest,
|
||||
'veroutdated' => $outdated,
|
||||
|
||||
'root' => "/admin/extensions/blueprint",
|
||||
]
|
||||
|
|
|
@ -1,72 +1,71 @@
|
|||
@extends('layouts.admin')
|
||||
|
||||
@section('title')
|
||||
Blueprint
|
||||
Blueprint
|
||||
@endsection
|
||||
|
||||
@section('content-header')
|
||||
<img src="/assets/extensions/blueprint/logo.jpg" alt="logo" style="float:left;width:30px;height:30px;border-radius:3px;margin-right:5px;">
|
||||
<a href="https://ptero.shop" target="_blank">
|
||||
<button class="btn btn-gray-alt pull-right" style="padding: 5px 10px;"><i class="bx bx-link-external"></i></button>
|
||||
</a>
|
||||
<h1 ext-title>Blueprint<tag mg-left blue>{{ $bp->version() }}</tag></h1>
|
||||
<img src="/assets/extensions/blueprint/logo.jpg" alt="logo" style="float:left;width:30px;height:30px;border-radius:3px;margin-right:5px;">
|
||||
<a href="https://ptero.shop" target="_blank">
|
||||
<button class="btn btn-gray-alt pull-right" style="padding: 5px 10px;"><i class="bx bx-link-external"></i></button>
|
||||
</a>
|
||||
<h1 ext-title>Blueprint<tag mg-left blue>{{ $bp->version() }}</tag></h1>
|
||||
@endsection
|
||||
|
||||
@section('content')
|
||||
{{ $bp->serve() }}
|
||||
{{ $telemetry->send("SERVE_BLUEPRINT_ADMIN") }}
|
||||
<p>Blueprint is the framework that powers all Blueprint-compatible extensions, enabling multiple extensions to be installed and used simultaneously.</p>
|
||||
<div class="row">
|
||||
<div class="col-lg-3 col-md-3 col-sm-12 col-xs-12">
|
||||
{{ $bp->serve() }}
|
||||
{{ $telemetry->send("SERVE_BLUEPRINT_ADMIN") }}
|
||||
<p>Blueprint is the framework that powers all Blueprint-compatible extensions, enabling multiple extensions to be installed and used simultaneously.</p>
|
||||
<div class="row">
|
||||
<div class="col-lg-3 col-md-3 col-sm-12 col-xs-12">
|
||||
|
||||
<!-- Overview -->
|
||||
<div class="box">
|
||||
<div class="box-header with-border">
|
||||
<h3 class="box-title"><i class='bx bxs-shapes' style='margin-right:5px;'></i></i>Overview</h3>
|
||||
</div>
|
||||
<div class="box-body">
|
||||
<p>You are currently using version <code>{{ $bp->version() }}</code>.</p>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Overview -->
|
||||
<div class="box @if($veroutdated) box-danger @endif">
|
||||
<div class="box-header with-border">
|
||||
<h3 class="box-title"><i class='bx bxs-shapes' style='margin-right:5px;'></i></i>Overview</h3>
|
||||
</div>
|
||||
<div class="box-body">
|
||||
<p>You are currently using version <code>{{ $bp->version() }}</code>.</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="col-lg-9 col-md-9 col-sm-12 col-xs-12">
|
||||
<form action="" method="POST">
|
||||
<div class="box">
|
||||
<div class="box-header with-border">
|
||||
<h3 class="box-title"><i class='bx bxs-cog' style='margin-right:5px;'></i>Configuration</h3>
|
||||
</div>
|
||||
<div class="box-body">
|
||||
<div class="row">
|
||||
<div class="col-lg-4 col-md-4 col-sm-4 col-xs-12">
|
||||
<label class="control-label">Telemetry</label>
|
||||
<select class="form-control" name="telemetry">
|
||||
<option value="true">Enabled</option>
|
||||
<option value="false" @if($bp->dbGet('telemetry') != "true") selected @endif>Disabled</option>
|
||||
</select>
|
||||
<p class="text-muted small">Automatically share anonymous usage data with Blueprint.</p>
|
||||
</div>
|
||||
<div class="col-lg-4 col-md-4 col-sm-4 col-xs-12">
|
||||
<label class="control-label">ID</label>
|
||||
<input type="text" required name="panel:id" id="panel:id" value="{{ $bp->dbGet('panel:id') }}" class="form-control" readonly/>
|
||||
<p class="text-muted small">Randomly generated string with your version that is used as a panel identifier.</p>
|
||||
</div>
|
||||
<div class="col-lg-4 col-md-4 col-sm-4 col-xs-12">
|
||||
<label class="control-label">Developer Mode</label>
|
||||
<select class="form-control" name="developer">
|
||||
<option value="true">Enabled</option>
|
||||
<option value="false" @if($bp->dbGet('developer') != "true") selected @endif>Disabled</option>
|
||||
</select>
|
||||
<p class="text-muted small">Enable or disable developer-oriented features.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="box-footer">
|
||||
{{ csrf_field() }}
|
||||
<button type="submit" name="_method" value="PATCH" class="btn btn-gray-alt btn-sm pull-right">Save</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-9 col-md-9 col-sm-12 col-xs-12">
|
||||
<form action="" method="POST">
|
||||
<div class="box">
|
||||
<div class="box-header with-border">
|
||||
<h3 class="box-title"><i class='bx bxs-cog' style='margin-right:5px;'></i>Configuration</h3>
|
||||
</div>
|
||||
<div class="box-body">
|
||||
<div class="row">
|
||||
<div class="col-lg-4 col-md-4 col-sm-4 col-xs-12">
|
||||
<label class="control-label">Telemetry</label>
|
||||
<select class="form-control" name="telemetry">
|
||||
<option value="true">Enabled</option>
|
||||
<option value="false" @if($bp->dbGet('telemetry') != "true") selected @endif>Disabled</option>
|
||||
</select>
|
||||
<p class="text-muted small">Automatically share anonymous usage data with Blueprint.</p>
|
||||
</div>
|
||||
<div class="col-lg-4 col-md-4 col-sm-4 col-xs-12">
|
||||
<label class="control-label">ID</label>
|
||||
<input type="text" required name="panel:id" id="panel:id" value="{{ $bp->dbGet('panel:id') }}" class="form-control" readonly/>
|
||||
<p class="text-muted small">Randomly generated string with your version that is used as a panel identifier.</p>
|
||||
</div>
|
||||
<div class="col-lg-4 col-md-4 col-sm-4 col-xs-12">
|
||||
<label class="control-label">Developer Mode</label>
|
||||
<select class="form-control" name="developer">
|
||||
<option value="true">Enabled</option>
|
||||
<option value="false" @if($bp->dbGet('developer') != "true") selected @endif>Disabled</option>
|
||||
</select>
|
||||
<p class="text-muted small">Enable or disable developer-oriented features.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="box-footer">
|
||||
{{ csrf_field() }}
|
||||
<button type="submit" name="_method" value="PATCH" class="btn btn-gray-alt btn-sm pull-right">Save</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
|
|
Loading…
Reference in a new issue