mirror of
https://github.com/usetrmnl/byos_laravel.git
synced 2026-01-14 07:27:47 +00:00
feat: plugins: show markup from blade views
This commit is contained in:
parent
8e47d102c0
commit
2c3747e061
1 changed files with 54 additions and 23 deletions
|
|
@ -6,6 +6,7 @@ use Livewire\Volt\Component;
|
||||||
new class extends Component {
|
new class extends Component {
|
||||||
public Plugin $plugin;
|
public Plugin $plugin;
|
||||||
public string|null $blade_code;
|
public string|null $blade_code;
|
||||||
|
public string|null $view_content;
|
||||||
|
|
||||||
public string $name;
|
public string $name;
|
||||||
public int $data_stale_minutes;
|
public int $data_stale_minutes;
|
||||||
|
|
@ -26,6 +27,15 @@ new class extends Component {
|
||||||
abort_unless(auth()->user()->plugins->contains($this->plugin), 403);
|
abort_unless(auth()->user()->plugins->contains($this->plugin), 403);
|
||||||
$this->blade_code = $this->plugin->render_markup;
|
$this->blade_code = $this->plugin->render_markup;
|
||||||
|
|
||||||
|
if ($this->plugin->render_markup_view) {
|
||||||
|
try {
|
||||||
|
$viewPath = resource_path('views/' . str_replace('.', '/', $this->plugin->render_markup_view) . '.blade.php');
|
||||||
|
$this->view_content = file_get_contents($viewPath);
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
$this->view_content = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$this->fillformFields();
|
$this->fillformFields();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -192,7 +202,8 @@ HTML;
|
||||||
|
|
||||||
@if(count($checked_devices) === 1)
|
@if(count($checked_devices) === 1)
|
||||||
<div class="mb-4">
|
<div class="mb-4">
|
||||||
<flux:radio.group wire:model="selected_playlist" label="Select Playlist" variant="segmented">
|
<flux:radio.group wire:model="selected_playlist" label="Select Playlist"
|
||||||
|
variant="segmented">
|
||||||
<flux:radio value="new" label="Create New"/>
|
<flux:radio value="new" label="Create New"/>
|
||||||
@foreach($this->getDevicePlaylists($checked_devices[0]) as $playlist)
|
@foreach($this->getDevicePlaylists($checked_devices[0]) as $playlist)
|
||||||
<flux:radio value="{{ $playlist->id }}" label="{{ $playlist->name }}"/>
|
<flux:radio value="{{ $playlist->id }}" label="{{ $playlist->name }}"/>
|
||||||
|
|
@ -297,11 +308,30 @@ HTML;
|
||||||
<flux:separator/>
|
<flux:separator/>
|
||||||
<div class="mt-5 mb-5 ">
|
<div class="mt-5 mb-5 ">
|
||||||
<h3 class="text-xl font-semibold dark:text-gray-100">Markup</h3>
|
<h3 class="text-xl font-semibold dark:text-gray-100">Markup</h3>
|
||||||
|
@if($plugin->render_markup_view)
|
||||||
|
<div>
|
||||||
|
Edit view
|
||||||
|
<span class="font-mono text-accent mb-4">{{ $plugin->render_markup_view }}</span> to update.
|
||||||
|
</div>
|
||||||
|
<div class="mb-4 mt-4">
|
||||||
|
<flux:textarea
|
||||||
|
label="File Content"
|
||||||
|
class="font-mono"
|
||||||
|
wire:model="view_content"
|
||||||
|
id="view_content"
|
||||||
|
name="view_content"
|
||||||
|
rows="15"
|
||||||
|
readonly
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
@else
|
||||||
<div class="text-accent">
|
<div class="text-accent">
|
||||||
<a href="#" wire:click="renderExample('layoutTitle')" class="text-xl">Layout with Title Bar</a> |
|
<a href="#" wire:click="renderExample('layoutTitle')" class="text-xl">Layout with Title Bar</a> |
|
||||||
<a href="#" wire:click="renderExample('layout')" class="text-xl">Blank Layout</a>
|
<a href="#" wire:click="renderExample('layout')" class="text-xl">Blank Layout</a>
|
||||||
</div>
|
</div>
|
||||||
|
@endif
|
||||||
</div>
|
</div>
|
||||||
|
@if(!$plugin->render_markup_view)
|
||||||
<form wire:submit="saveMarkup">
|
<form wire:submit="saveMarkup">
|
||||||
<div class="mb-4">
|
<div class="mb-4">
|
||||||
<flux:textarea
|
<flux:textarea
|
||||||
|
|
@ -321,5 +351,6 @@ HTML;
|
||||||
</flux:button>
|
</flux:button>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
@endif
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue