Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow importing of multiple eggs at once #115

Merged
merged 4 commits into from
Apr 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 15 additions & 14 deletions app/Filament/Resources/EggResource/Pages/ListEggs.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,12 @@ protected function getHeaderActions(): array
Actions\CreateAction::make(),

Actions\Action::make('import')
->label('Import Egg')
->label('Import')
->form([
Forms\Components\FileUpload::make('egg')
->acceptedFileTypes(['application/json'])
->storeFiles(false),
->storeFiles(false)
->multiple(),
])
->action(function (array $data): void {
/** @var TemporaryUploadedFile $eggFile */
Expand All @@ -34,25 +35,25 @@ protected function getHeaderActions(): array
/** @var EggImporterService $eggImportService */
$eggImportService = resolve(EggImporterService::class);

try {
$newEgg = $eggImportService->handle($eggFile);
} catch (Exception $exception) {
Notification::make()
->title('Egg Import Failed')
->danger()
->send();
foreach ($eggFile as $file) {
try {
$eggImportService->handle($file);
} catch (Exception $exception) {
Notification::make()
->title('Import Failed')
->danger()
->send();

report($exception);
report($exception);

return;
return;
}
}

Notification::make()
->title("Egg Import Success: $newEgg->name")
->title('Import Success')
->success()
->send();

redirect()->route('filament.admin.resources.eggs.edit', [$newEgg]);
}),
];
}
Expand Down
12 changes: 2 additions & 10 deletions resources/views/filament/pages/dashboard.blade.php
Original file line number Diff line number Diff line change
@@ -1,39 +1,31 @@
<x-filament-panels::page>

<x-filament::tabs label="Content tabs">
<x-filament::tabs.item disabled>Panel's Resources: </x-filament::tabs.item>
<x-filament::tabs disabled>
<x-filament::tabs.item disabled>Overview: </x-filament::tabs.item>

<x-filament::tabs.item
icon="tabler-server-2"
:active="$activeTab === 'nodes'"
wire:click="$set('activeTab', 'nodes')"
>
Nodes
<x-slot name="badge">{{ $nodesCount }}</x-slot>
</x-filament::tabs.item>

<x-filament::tabs.item
icon="tabler-brand-docker"
:active="$activeTab === 'servers'"
wire:click="$set('activeTab', 'servers')"
>
Servers
<x-slot name="badge">{{ $serversCount }}</x-slot>
</x-filament::tabs.item>

<x-filament::tabs.item
icon="tabler-eggs"
:active="$activeTab === 'eggs'"
wire:click="$set('activeTab', 'eggs')"
>
Eggs
<x-slot name="badge">{{ $eggsCount }}</x-slot>
</x-filament::tabs.item>

<x-filament::tabs.item
icon="tabler-users"
:active="$activeTab === 'users'"
wire:click="$set('activeTab', 'users')"
>
Users
<x-slot name="badge">{{ $usersCount }}</x-slot>
Expand Down
Loading