mirror of
https://github.com/usetrmnl/byos_laravel.git
synced 2026-01-14 15:37:53 +00:00
feat: add menu item to seed example receipts
This commit is contained in:
parent
8eb0b2ccd7
commit
0c0a3026ce
3 changed files with 74 additions and 24 deletions
20
app/Console/Commands/ExampleReceiptsSeederCommand.php
Normal file
20
app/Console/Commands/ExampleReceiptsSeederCommand.php
Normal file
|
|
@ -0,0 +1,20 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Console\Commands;
|
||||||
|
|
||||||
|
use Database\Seeders\ExampleReceiptsSeeder;
|
||||||
|
use Illuminate\Console\Command;
|
||||||
|
use Illuminate\Contracts\Console\PromptsForMissingInput;
|
||||||
|
|
||||||
|
class ExampleReceiptsSeederCommand extends Command implements PromptsForMissingInput
|
||||||
|
{
|
||||||
|
protected $signature = 'receipts:seed {user_id}';
|
||||||
|
|
||||||
|
protected $description = 'Seed example receipts';
|
||||||
|
|
||||||
|
public function handle(ExampleReceiptsSeeder $seeder): void
|
||||||
|
{
|
||||||
|
$user_id = $this->argument('user_id');
|
||||||
|
$seeder->run($user_id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -10,13 +10,13 @@ class ExampleReceiptsSeeder extends Seeder
|
||||||
/**
|
/**
|
||||||
* Run the database seeds.
|
* Run the database seeds.
|
||||||
*/
|
*/
|
||||||
public function run(): void
|
public function run($user_id = 1): void
|
||||||
{
|
{
|
||||||
Plugin::create(
|
Plugin::updateOrCreate(
|
||||||
[
|
[
|
||||||
'uuid' => '9e46c6cf-358c-4bfe-8998-436b3a207fec',
|
'uuid' => '9e46c6cf-358c-4bfe-8998-436b3a207fec',
|
||||||
'name' => 'ÖBB Departures',
|
'name' => 'ÖBB Departures',
|
||||||
'user_id' => '1',
|
'user_id' => $user_id,
|
||||||
'data_payload' => null,
|
'data_payload' => null,
|
||||||
'data_stale_minutes' => 15,
|
'data_stale_minutes' => 15,
|
||||||
'data_strategy' => 'polling',
|
'data_strategy' => 'polling',
|
||||||
|
|
@ -31,11 +31,11 @@ class ExampleReceiptsSeeder extends Seeder
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
Plugin::create(
|
Plugin::updateOrCreate(
|
||||||
[
|
[
|
||||||
'uuid' => '3b046eda-34e9-4232-b935-c33b989a284b',
|
'uuid' => '3b046eda-34e9-4232-b935-c33b989a284b',
|
||||||
'name' => 'Weather',
|
'name' => 'Weather',
|
||||||
'user_id' => '1',
|
'user_id' => $user_id,
|
||||||
'data_payload' => null,
|
'data_payload' => null,
|
||||||
'data_stale_minutes' => 60,
|
'data_stale_minutes' => 60,
|
||||||
'data_strategy' => 'polling',
|
'data_strategy' => 'polling',
|
||||||
|
|
@ -50,11 +50,11 @@ class ExampleReceiptsSeeder extends Seeder
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
Plugin::create(
|
Plugin::updateOrCreate(
|
||||||
[
|
[
|
||||||
'uuid' => '21464b16-5f5a-4099-a967-f5c915e3da54',
|
'uuid' => '21464b16-5f5a-4099-a967-f5c915e3da54',
|
||||||
'name' => 'Zen Quotes',
|
'name' => 'Zen Quotes',
|
||||||
'user_id' => '1',
|
'user_id' => $user_id,
|
||||||
'data_payload' => null,
|
'data_payload' => null,
|
||||||
'data_stale_minutes' => 720,
|
'data_stale_minutes' => 720,
|
||||||
'data_strategy' => 'polling',
|
'data_strategy' => 'polling',
|
||||||
|
|
@ -69,11 +69,11 @@ class ExampleReceiptsSeeder extends Seeder
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
Plugin::create(
|
Plugin::updateOrCreate(
|
||||||
[
|
[
|
||||||
'uuid' => '8d472959-400f-46ee-afb2-4a9f1cfd521f',
|
'uuid' => '8d472959-400f-46ee-afb2-4a9f1cfd521f',
|
||||||
'name' => 'This Day in History',
|
'name' => 'This Day in History',
|
||||||
'user_id' => '1',
|
'user_id' => $user_id,
|
||||||
'data_payload' => null,
|
'data_payload' => null,
|
||||||
'data_stale_minutes' => 720,
|
'data_stale_minutes' => 720,
|
||||||
'data_strategy' => 'polling',
|
'data_strategy' => 'polling',
|
||||||
|
|
@ -88,11 +88,11 @@ class ExampleReceiptsSeeder extends Seeder
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
Plugin::create(
|
Plugin::updateOrCreate(
|
||||||
[
|
[
|
||||||
'uuid' => '4349fdad-a273-450b-aa00-3d32f2de788d',
|
'uuid' => '4349fdad-a273-450b-aa00-3d32f2de788d',
|
||||||
'name' => 'Home Assistant',
|
'name' => 'Home Assistant',
|
||||||
'user_id' => '1',
|
'user_id' => $user_id,
|
||||||
'data_payload' => null,
|
'data_payload' => null,
|
||||||
'data_stale_minutes' => 30,
|
'data_stale_minutes' => 30,
|
||||||
'data_strategy' => 'polling',
|
'data_strategy' => 'polling',
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ new class extends Component {
|
||||||
public int $data_stale_minutes = 60;
|
public int $data_stale_minutes = 60;
|
||||||
public string $data_strategy = "polling";
|
public string $data_strategy = "polling";
|
||||||
public string $polling_url;
|
public string $polling_url;
|
||||||
public string $polling_verb ="get";
|
public string $polling_verb = "get";
|
||||||
public $polling_header;
|
public $polling_header;
|
||||||
public array $plugins;
|
public array $plugins;
|
||||||
|
|
||||||
|
|
@ -49,16 +49,22 @@ new class extends Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public function mount(): void
|
public function mount(): void
|
||||||
{
|
{
|
||||||
$userPlugins =auth()->user()?->plugins?->map(function ($plugin) {
|
$userPlugins = auth()->user()?->plugins?->map(function ($plugin) {
|
||||||
return $plugin->toArray();
|
return $plugin->toArray();
|
||||||
})->toArray();
|
})->toArray();
|
||||||
|
|
||||||
$this->plugins = array_merge($this->native_plugins, $userPlugins ?? []);
|
$this->plugins = array_merge($this->native_plugins, $userPlugins ?? []);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function seedExamplePlugins(): void
|
||||||
|
{
|
||||||
|
// \Artisan::call('db:seed', ['--class' => 'ExampleReceiptsSeeder']);
|
||||||
|
\Artisan::call(\App\Console\Commands\ExampleReceiptsSeederCommand::class, ['user_id' => auth()->id()]);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
?>
|
?>
|
||||||
|
|
||||||
|
|
@ -66,9 +72,29 @@ new class extends Component {
|
||||||
<div class="max-w-7xl mx-auto sm:px-6 lg:px-8">
|
<div class="max-w-7xl mx-auto sm:px-6 lg:px-8">
|
||||||
<div class="flex justify-between items-center mb-6">
|
<div class="flex justify-between items-center mb-6">
|
||||||
<h2 class="text-2xl font-semibold dark:text-gray-100">Plugins</h2>
|
<h2 class="text-2xl font-semibold dark:text-gray-100">Plugins</h2>
|
||||||
|
|
||||||
|
<flux:button.group>
|
||||||
<flux:modal.trigger name="add-plugin">
|
<flux:modal.trigger name="add-plugin">
|
||||||
<flux:button icon="plus" variant="primary">Add Plugin</flux:button>
|
<flux:button icon="plus" variant="primary">Add Plugin</flux:button>
|
||||||
</flux:modal.trigger>
|
</flux:modal.trigger>
|
||||||
|
|
||||||
|
<flux:dropdown>
|
||||||
|
<flux:button icon="chevron-down" variant="primary"></flux:button>
|
||||||
|
<flux:menu>
|
||||||
|
<flux:menu.item icon="beaker" wire:click="seedExamplePlugins">Seed Example Plugins</flux:menu.item>
|
||||||
|
{{-- <flux:menu.separator/>--}}
|
||||||
|
{{-- <flux:modal.trigger name="import-receipt">--}}
|
||||||
|
{{-- <flux:menu.item icon="paper-clip">Import Receipt ZIP File</flux:menu.item>--}}
|
||||||
|
{{-- </flux:modal.trigger>--}}
|
||||||
|
{{-- <flux:menu.separator/>--}}
|
||||||
|
{{-- <flux:modal.trigger name="add-native-plugin">--}}
|
||||||
|
{{-- <flux:menu.item icon="code-bracket">New Native Plugin</flux:menu.item>--}}
|
||||||
|
{{-- </flux:modal.trigger>--}}
|
||||||
|
</flux:menu>
|
||||||
|
</flux:dropdown>
|
||||||
|
</flux:button.group>
|
||||||
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<flux:modal name="add-plugin" class="md:w-96">
|
<flux:modal name="add-plugin" class="md:w-96">
|
||||||
|
|
@ -84,26 +110,28 @@ new class extends Component {
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="mb-4">
|
<div class="mb-4">
|
||||||
<flux:input label="Data is stale after minutes" wire:model="data_stale_minutes" id="data_stale_minutes"
|
<flux:input label="Data is stale after minutes" wire:model="data_stale_minutes"
|
||||||
|
id="data_stale_minutes"
|
||||||
class="block mt-1 w-full" type="number" name="data_stale_minutes" autofocus/>
|
class="block mt-1 w-full" type="number" name="data_stale_minutes" autofocus/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="mb-4">
|
<div class="mb-4">
|
||||||
<flux:radio.group wire:model="data_strategy" label="Data Strategy" variant="segmented">
|
<flux:radio.group wire:model="data_strategy" label="Data Strategy" variant="segmented">
|
||||||
<flux:radio value="polling" label="Polling"/>
|
<flux:radio value="polling" label="Polling"/>
|
||||||
<flux:radio value="webhook" label="Webhook" />
|
<flux:radio value="webhook" label="Webhook"/>
|
||||||
</flux:radio.group>
|
</flux:radio.group>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="mb-4">
|
<div class="mb-4">
|
||||||
<flux:input label="Polling URL" wire:model="polling_url" id="polling_url" placeholder="https://example.com/api"
|
<flux:input label="Polling URL" wire:model="polling_url" id="polling_url"
|
||||||
|
placeholder="https://example.com/api"
|
||||||
class="block mt-1 w-full" type="text" name="polling_url" autofocus/>
|
class="block mt-1 w-full" type="text" name="polling_url" autofocus/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="mb-4">
|
<div class="mb-4">
|
||||||
<flux:radio.group wire:model="polling_verb" label="Polling Verb" variant="segmented">
|
<flux:radio.group wire:model="polling_verb" label="Polling Verb" variant="segmented">
|
||||||
<flux:radio value="get" label="GET"/>
|
<flux:radio value="get" label="GET"/>
|
||||||
<flux:radio value="post" label="POST" />
|
<flux:radio value="post" label="POST"/>
|
||||||
</flux:radio.group>
|
</flux:radio.group>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
@ -124,9 +152,11 @@ new class extends Component {
|
||||||
@foreach($plugins as $plugin)
|
@foreach($plugins as $plugin)
|
||||||
<div
|
<div
|
||||||
class="rounded-xl border bg-white dark:bg-stone-950 dark:border-stone-800 text-stone-800 shadow-xs">
|
class="rounded-xl border bg-white dark:bg-stone-950 dark:border-stone-800 text-stone-800 shadow-xs">
|
||||||
<a href="{{ ($plugin['detail_view_route']) ? route($plugin['detail_view_route']) : route('plugins.receipt', ['plugin' => $plugin['id']]) }}" class="block">
|
<a href="{{ ($plugin['detail_view_route']) ? route($plugin['detail_view_route']) : route('plugins.receipt', ['plugin' => $plugin['id']]) }}"
|
||||||
|
class="block">
|
||||||
<div class="flex items-center space-x-4 px-10 py-8">
|
<div class="flex items-center space-x-4 px-10 py-8">
|
||||||
<flux:icon name="{{$plugin['flux_icon_name'] ?? 'puzzle-piece'}}" class="text-4xl text-accent"/>
|
<flux:icon name="{{$plugin['flux_icon_name'] ?? 'puzzle-piece'}}"
|
||||||
|
class="text-4xl text-accent"/>
|
||||||
<h3 class="text-lg font-medium dark:text-zinc-200">{{$plugin['name']}}</h3>
|
<h3 class="text-lg font-medium dark:text-zinc-200">{{$plugin['name']}}</h3>
|
||||||
</div>
|
</div>
|
||||||
</a>
|
</a>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue