feat ScreenGeneratorCommand, fix render endpoint

* feat: signature var `view` added to ScreenGeneratorCommand
* fix: /display endpoint responds current screen image from db
This commit is contained in:
Benjamin Nussbaum 2025-02-13 13:06:04 +01:00
parent 17e5dfd70e
commit 309450e1b3
2 changed files with 6 additions and 3 deletions

View file

@ -15,7 +15,7 @@ class ScreenGeneratorCommand extends Command
*
* @var string
*/
protected $signature = 'trmnl:screen:generate {deviceId=1}';
protected $signature = 'trmnl:screen:generate {deviceId=1} {view=trmnl}';
/**
* The console command description.
@ -31,6 +31,7 @@ class ScreenGeneratorCommand extends Command
{
$deviceId = $this->argument('deviceId');
$view = $this->argument('view');
$uuid = Uuid::uuid4()->toString();
$pngPath = public_path('storage/images/generated/').$uuid.'.png';
@ -38,7 +39,7 @@ class ScreenGeneratorCommand extends Command
// Generate PNG
try {
Browsershot::html(view('trmnl')->render())
Browsershot::html(view($view)->render())
->windowSize(800, 480)
->save($pngPath);
} catch (\Exception $e) {