diff --git a/resources/views/livewire/plugins/recipe.blade.php b/resources/views/livewire/plugins/recipe.blade.php index 83d464f..08ee441 100644 --- a/resources/views/livewire/plugins/recipe.blade.php +++ b/resources/views/livewire/plugins/recipe.blade.php @@ -2,6 +2,7 @@ use App\Models\Plugin; use Livewire\Volt\Component; +use Illuminate\Support\Facades\Blade; new class extends Component { public Plugin $plugin; @@ -11,7 +12,7 @@ new class extends Component { public string $name; public int $data_stale_minutes; public string $data_strategy; - public string $polling_url; + public string|null $polling_url; public string $polling_verb; public string|null $polling_header; public $data_payload; @@ -72,7 +73,7 @@ new class extends Component { 'name' => 'required|string|max:255', 'data_stale_minutes' => 'required|integer|min:1', 'data_strategy' => 'required|string|in:polling,webhook', - 'polling_url' => 'required|url', + 'polling_url' => 'required_if:data_strategy,polling|nullable|url', 'polling_verb' => 'required|string|in:get,post', 'polling_header' => 'nullable|string|max:255', 'blade_code' => 'nullable|string', @@ -199,6 +200,22 @@ HTML; HTML; } + public function renderPreview(): void + { + abort_unless(auth()->user()->plugins->contains($this->plugin), 403); + + try { + if ($this->plugin->render_markup_view) { + $previewMarkup = view($this->plugin->render_markup_view, ['data' => $this->plugin->data_payload])->render(); + } else { + $previewMarkup = Blade::render($this->plugin->render_markup, ['data' => $this->plugin->data_payload]); + } + $this->dispatch('preview-updated', preview: $previewMarkup); + } catch (\Exception $e) { + $this->dispatch('preview-error', message: $e->getMessage()); + } + } + public function deletePlugin(): void { abort_unless(auth()->user()->plugins->contains($this->plugin), 403); @@ -217,6 +234,9 @@ HTML; + + Preview + Add to Playlist @@ -309,6 +329,16 @@ HTML; + +
+ Preview {{ $plugin->name }} +
+ +
+ +
+
+

Settings

@@ -442,3 +472,19 @@ HTML; @endif + +@script + +@endscript