Skip to content

Commit

Permalink
Implement notification api for BlueprintExtensionLibrary
Browse files Browse the repository at this point in the history
  • Loading branch information
prplwtf committed Apr 24, 2023
1 parent 054ed35 commit fa5e375
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use Pterodactyl\Services\Helpers\SoftwareVersionService;
use Pterodactyl\Services\Helpers\BlueprintVariableService;
use Pterodactyl\Services\Helpers\BlueprintTelemetryService;
use Pterodactyl\Services\Helpers\BlueprintExtensionLibrary;
use Pterodactyl\Contracts\Repository\SettingsRepositoryInterface;
use Illuminate\Contracts\Config\Repository as ConfigRepository;
use Pterodactyl\Http\Requests\Admin\Extensions\Blueprint\BlueprintSettingsFormRequest;
Expand All @@ -24,6 +25,7 @@ class BlueprintExtensionController extends Controller
public function __construct(
private BlueprintVariableService $bp,
private BlueprintTelemetryService $telemetry,
private BlueprintExtensionLibrary $bplib,

private SoftwareVersionService $version,
private ViewFactory $view,
Expand All @@ -45,8 +47,11 @@ public function index(): View
return $this->view->make(
'admin.extensions.blueprint.index', [
'version' => $this->version,

'bp' => $this->bp,
'bplib' => $this->bplib,
'telemetry' => $this->telemetry,

'root' => "/admin/extensions/blueprint",
]
);
Expand Down
11 changes: 11 additions & 0 deletions app/Services/Helpers/BlueprintExtensionLibrary.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,15 @@ public function dbGet($table, $record) {
public function dbSet($table, $record, $value) {
return $this->settings->set($table."::".$record, $value);
}

/*
| Notifications
|
| notify("text");
*/
public function notify($text) {
$this->dbSet("blueprint", "notification:text", $text);
shell_exec("cd /var/www/pterodactyl;echo \"$text\" > .blueprint/.storage/notification;");
return;
}
}
Empty file added blueprint/.storage/notification
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ public function up()
$table->string('telemetry')->nullable();
$table->string('telemetry:id')->nullable();

$table->string('notification:text')->nullable();

$table->timestamp('timestamp')->useCurrent()->onUpdate(null);
});
}
Expand Down
23 changes: 17 additions & 6 deletions resources/views/layouts/admin.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -157,13 +157,24 @@
</div>
@yield('content')
<?php
if(shell_exec("cd /var/www/pterodactyl;cat .blueprint/.flags/onboarding.md") == "*blueprint*") {
echo "
<div class=\"notification\">
if(shell_exec("cd /var/www/pterodactyl;cat .blueprint/.flags/onboarding.md") == "*blueprint*") {
echo "
<div class=\"notification\">
<p>Blueprint has now been installed, click the extension icon to take a look.</p>
</div>";
`cd /var/www/pterodactyl;rm .blueprint/.flags/onboarding.md;`;
}
</div>";
`cd /var/www/pterodactyl;rm .blueprint/.flags/onboarding.md;`;
}
$notification = shell_exec("cd /var/www/pterodactyl;cat .blueprint/.storage/notification");
if($notification != null) {
echo "<div class=\"notification\">
<p>".$notification."</p>
</div>
";
shell_exec("cd /var/www/pterodactyl;rm .blueprint/.storage/notification;touch .blueprint/.storage/notification;");
}
?>
</section>
</div>
Expand Down

0 comments on commit fa5e375

Please sign in to comment.