Skip to content

Commit

Permalink
Merge pull request #115 from pelican-dev/feature/mult-egg-upload
Browse files Browse the repository at this point in the history
Allow importing of multiple eggs at once
  • Loading branch information
notAreYouScared authored Apr 21, 2024
2 parents 7de4cf1 + db67c64 commit 6ff9568
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 24 deletions.
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

0 comments on commit 6ff9568

Please sign in to comment.