mirror of
https://github.com/usetrmnl/byos_laravel.git
synced 2026-01-14 15:37:53 +00:00
feat: catalog add loading spinner
This commit is contained in:
parent
2045ce9966
commit
4a32132ea9
3 changed files with 44 additions and 24 deletions
|
|
@ -1,6 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
use App\Services\PluginImportService;
|
use App\Services\PluginImportService;
|
||||||
|
use Livewire\Attributes\Lazy;
|
||||||
use Livewire\Volt\Component;
|
use Livewire\Volt\Component;
|
||||||
use Illuminate\Support\Arr;
|
use Illuminate\Support\Arr;
|
||||||
use Illuminate\Support\Facades\Cache;
|
use Illuminate\Support\Facades\Cache;
|
||||||
|
|
@ -8,7 +9,9 @@ use Illuminate\Support\Facades\Http;
|
||||||
use Illuminate\Support\Facades\Log;
|
use Illuminate\Support\Facades\Log;
|
||||||
use Symfony\Component\Yaml\Yaml;
|
use Symfony\Component\Yaml\Yaml;
|
||||||
|
|
||||||
new class extends Component {
|
new
|
||||||
|
#[Lazy]
|
||||||
|
class extends Component {
|
||||||
public array $catalogPlugins = [];
|
public array $catalogPlugins = [];
|
||||||
public string $installingPlugin = '';
|
public string $installingPlugin = '';
|
||||||
|
|
||||||
|
|
@ -17,6 +20,20 @@ new class extends Component {
|
||||||
$this->loadCatalogPlugins();
|
$this->loadCatalogPlugins();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function placeholder()
|
||||||
|
{
|
||||||
|
return <<<'HTML'
|
||||||
|
<div class="space-y-4">
|
||||||
|
<div class="flex items-center justify-center py-12">
|
||||||
|
<div class="flex items-center space-x-2">
|
||||||
|
<flux:icon.loading />
|
||||||
|
<flux:text>Loading recipes...</flux:text>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
HTML;
|
||||||
|
}
|
||||||
|
|
||||||
private function loadCatalogPlugins(): void
|
private function loadCatalogPlugins(): void
|
||||||
{
|
{
|
||||||
$catalogUrl = config('app.catalog_url');
|
$catalogUrl = config('app.catalog_url');
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use Livewire\Attributes\Lazy;
|
||||||
use Livewire\Volt\Component;
|
use Livewire\Volt\Component;
|
||||||
use Illuminate\Support\Facades\Http;
|
use Illuminate\Support\Facades\Http;
|
||||||
use Illuminate\Support\Facades\Log;
|
use Illuminate\Support\Facades\Log;
|
||||||
|
|
@ -7,17 +8,32 @@ use Illuminate\Support\Facades\Cache;
|
||||||
use App\Services\PluginImportService;
|
use App\Services\PluginImportService;
|
||||||
use Illuminate\Support\Facades\Auth;
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
|
||||||
new class extends Component {
|
new
|
||||||
|
#[Lazy]
|
||||||
|
class extends Component {
|
||||||
public array $recipes = [];
|
public array $recipes = [];
|
||||||
public string $search = '';
|
public string $search = '';
|
||||||
public bool $isSearching = false;
|
public bool $isSearching = false;
|
||||||
public string $installingPlugin = '';
|
|
||||||
|
|
||||||
public function mount(): void
|
public function mount(): void
|
||||||
{
|
{
|
||||||
$this->loadNewest();
|
$this->loadNewest();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function placeholder()
|
||||||
|
{
|
||||||
|
return <<<'HTML'
|
||||||
|
<div class="space-y-4">
|
||||||
|
<div class="flex items-center justify-center py-12">
|
||||||
|
<div class="flex items-center space-x-2">
|
||||||
|
<flux:icon.loading />
|
||||||
|
<flux:text>Loading recipes...</flux:text>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
HTML;
|
||||||
|
}
|
||||||
|
|
||||||
private function loadNewest(): void
|
private function loadNewest(): void
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
|
|
@ -87,8 +103,6 @@ new class extends Component {
|
||||||
{
|
{
|
||||||
abort_unless(auth()->user() !== null, 403);
|
abort_unless(auth()->user() !== null, 403);
|
||||||
|
|
||||||
$this->installingPlugin = $recipeId;
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$zipUrl = "https://usetrmnl.com/api/plugin_settings/{$recipeId}/archive";
|
$zipUrl = "https://usetrmnl.com/api/plugin_settings/{$recipeId}/archive";
|
||||||
|
|
||||||
|
|
@ -108,8 +122,6 @@ new class extends Component {
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
Log::error('Plugin installation failed: ' . $e->getMessage());
|
Log::error('Plugin installation failed: ' . $e->getMessage());
|
||||||
$this->addError('installation', 'Error installing plugin: ' . $e->getMessage());
|
$this->addError('installation', 'Error installing plugin: ' . $e->getMessage());
|
||||||
} finally {
|
|
||||||
$this->installingPlugin = '';
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -199,21 +211,12 @@ new class extends Component {
|
||||||
|
|
||||||
<div class="mt-4 flex items-center space-x-3">
|
<div class="mt-4 flex items-center space-x-3">
|
||||||
@if($recipe['id'])
|
@if($recipe['id'])
|
||||||
@if($installingPlugin === $recipe['id'])
|
|
||||||
<flux:button
|
|
||||||
wire:click="installPlugin('{{ $recipe['id'] }}')"
|
|
||||||
variant="primary"
|
|
||||||
disabled>
|
|
||||||
<flux:icon name="arrow-path" class="w-4 h-4 animate-spin" />
|
|
||||||
</flux:button>
|
|
||||||
@else
|
|
||||||
<flux:button
|
<flux:button
|
||||||
wire:click="installPlugin('{{ $recipe['id'] }}')"
|
wire:click="installPlugin('{{ $recipe['id'] }}')"
|
||||||
variant="primary">
|
variant="primary">
|
||||||
Install
|
Install
|
||||||
</flux:button>
|
</flux:button>
|
||||||
@endif
|
@endif
|
||||||
@endif
|
|
||||||
|
|
||||||
@if($recipe['detail_url'])
|
@if($recipe['detail_url'])
|
||||||
<flux:button
|
<flux:button
|
||||||
|
|
|
||||||
|
|
@ -286,7 +286,7 @@ new class extends Component {
|
||||||
</flux:heading>
|
</flux:heading>
|
||||||
<flux:subheading>Browse and install Recipes from the community. Add yours <a href="https://github.com/bnussbau/trmnl-recipe-catalog" class="underline" target="_blank">here</a>.</flux:subheading>
|
<flux:subheading>Browse and install Recipes from the community. Add yours <a href="https://github.com/bnussbau/trmnl-recipe-catalog" class="underline" target="_blank">here</a>.</flux:subheading>
|
||||||
</div>
|
</div>
|
||||||
<livewire:catalog.index lazy />
|
<livewire:catalog.index />
|
||||||
</div>
|
</div>
|
||||||
</flux:modal>
|
</flux:modal>
|
||||||
|
|
||||||
|
|
@ -300,14 +300,14 @@ new class extends Component {
|
||||||
<flux:heading size="sm">Limitations</flux:heading>
|
<flux:heading size="sm">Limitations</flux:heading>
|
||||||
<ul class="list-disc pl-5 mt-2">
|
<ul class="list-disc pl-5 mt-2">
|
||||||
<li><flux:text>Only full view will be imported; shared markup will be prepended</flux:text></li>
|
<li><flux:text>Only full view will be imported; shared markup will be prepended</flux:text></li>
|
||||||
<li><flux:text>Requires <span class="font-mono">trmnl-liquid-cli</span>. (Included in Docker container)</flux:text></li>
|
<li><flux:text>Requires <span class="font-mono">trmnl-liquid-cli</span> executable.</flux:text></li>
|
||||||
<li><flux:text>API responses in formats other than <span class="font-mono">JSON</span> are not yet fully supported.</flux:text></li>
|
<li><flux:text>API responses in formats other than <span class="font-mono">JSON</span> are not yet fully supported.</flux:text></li>
|
||||||
<li><flux:text>There are limitations in payload size (Data Payload, Template).</flux:text></li>
|
<li><flux:text>There are limitations in payload size (Data Payload, Template).</flux:text></li>
|
||||||
</ul>
|
</ul>
|
||||||
<flux:text class="mt-1">Please report issues, aside from the known limitations, on <a href="https://github.com/usetrmnl/byos_laravel/issues/new" target="_blank" class="underline">GitHub</a>. Include the recipe URL.</flux:text></li>
|
<flux:text class="mt-1">Please report issues, aside from the known limitations, on <a href="https://github.com/usetrmnl/byos_laravel/issues/new" target="_blank" class="underline">GitHub</a>. Include the recipe URL.</flux:text></li>
|
||||||
</flux:callout>
|
</flux:callout>
|
||||||
</div>
|
</div>
|
||||||
<livewire:catalog.trmnl lazy />
|
<livewire:catalog.trmnl />
|
||||||
</div>
|
</div>
|
||||||
</flux:modal>
|
</flux:modal>
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue