diff --git a/app/Fileshare/Actions/FileshareApiIndexAction.php b/app/Fileshare/Actions/FileshareApiIndexAction.php new file mode 100644 index 00000000..4ee530e1 --- /dev/null +++ b/app/Fileshare/Actions/FileshareApiIndexAction.php @@ -0,0 +1,21 @@ +put('menu', 'setting'); + session()->put('title', 'Datei-Verbindungen'); + + return FileshareResource::collection(Fileshare::paginate(15)); + } +} diff --git a/app/Fileshare/Actions/FileshareIndexAction.php b/app/Fileshare/Actions/FileshareIndexAction.php index 4aa80e13..53874994 100644 --- a/app/Fileshare/Actions/FileshareIndexAction.php +++ b/app/Fileshare/Actions/FileshareIndexAction.php @@ -17,7 +17,7 @@ class FileshareIndexAction session()->put('menu', 'setting'); session()->put('title', 'Datei-Verbindungen'); - return Inertia::render('fileshareconnection/Index', [ + return Inertia::render('fileshare/Index', [ 'data' => FileshareResource::collection(Fileshare::paginate(15)), ]); } diff --git a/app/Fileshare/Actions/FileshareStoreAction.php b/app/Fileshare/Actions/FileshareStoreAction.php index 54a59463..86608b4b 100644 --- a/app/Fileshare/Actions/FileshareStoreAction.php +++ b/app/Fileshare/Actions/FileshareStoreAction.php @@ -3,6 +3,7 @@ namespace App\Fileshare\Actions; use App\Fileshare\Models\Fileshare; +use App\Lib\Events\Succeeded; use Illuminate\Validation\ValidationException; use Lorisleiva\Actions\ActionRequest; use Lorisleiva\Actions\Concerns\AsAction; @@ -35,5 +36,7 @@ class FileshareStoreAction ...$request->validated(), 'type' => $type, ]); + + Succeeded::message('Verbindung erstellt.')->dispatch(); } } diff --git a/app/Fileshare/Actions/FileshareUpdateAction.php b/app/Fileshare/Actions/FileshareUpdateAction.php index d0f77b13..a4e456d1 100644 --- a/app/Fileshare/Actions/FileshareUpdateAction.php +++ b/app/Fileshare/Actions/FileshareUpdateAction.php @@ -3,6 +3,7 @@ namespace App\Fileshare\Actions; use App\Fileshare\Models\Fileshare; +use App\Lib\Events\Succeeded; use Illuminate\Validation\ValidationException; use Lorisleiva\Actions\ActionRequest; use Lorisleiva\Actions\Concerns\AsAction; @@ -35,5 +36,7 @@ class FileshareUpdateAction ...$request->validated(), 'type' => $type, ]); + + Succeeded::message('Verbindung bearbeitet.')->dispatch(); } } diff --git a/resources/js/views/fileshareconnection/Index.vue b/resources/js/views/fileshare/Index.vue similarity index 63% rename from resources/js/views/fileshareconnection/Index.vue rename to resources/js/views/fileshare/Index.vue index ffef24af..c6740b71 100644 --- a/resources/js/views/fileshareconnection/Index.vue +++ b/resources/js/views/fileshare/Index.vue @@ -7,18 +7,32 @@
- + " + >
@@ -41,12 +55,14 @@ - + - + @@ -60,11 +76,10 @@ diff --git a/routes/web.php b/routes/web.php index d0f6dcf5..a5b64ff0 100644 --- a/routes/web.php +++ b/routes/web.php @@ -19,6 +19,7 @@ use App\Invoice\Actions\InvoiceStoreAction; use App\Course\Actions\CourseUpdateAction; use App\Dashboard\Actions\IndexAction as DashboardIndexAction; use App\Efz\ShowEfzDocumentAction; +use App\Fileshare\Actions\FileshareApiIndexAction; use App\Fileshare\Actions\FileshareStoreAction; use App\Fileshare\Actions\FileshareUpdateAction; use App\Form\Actions\ExportAction as ActionsExportAction; @@ -172,4 +173,5 @@ Route::group(['middleware' => 'auth:web'], function (): void { // ------------------------------------ fileshare ----------------------------------- Route::post('/fileshare', FileshareStoreAction::class)->name('fileshare.store'); Route::patch('/fileshare/{fileshare}', FileshareUpdateAction::class)->name('fileshare.update'); + Route::get('/api/fileshare', FileshareApiIndexAction::class)->name('api.fileshare.index'); }); diff --git a/tests/Fileshare/FileshareIndexActionTest.php b/tests/Fileshare/FileshareIndexActionTest.php index b5e24e44..8cfee9af 100644 --- a/tests/Fileshare/FileshareIndexActionTest.php +++ b/tests/Fileshare/FileshareIndexActionTest.php @@ -16,28 +16,28 @@ class FileshareIndexActionTest extends FileshareTestCase ->name('lokaler Server') ->create(); - $this->get('/setting/fileshare') - ->assertInertiaPath('data.data.0.name', 'lokaler Server') - ->assertInertiaPath('data.data.0.type', OwncloudConnection::class) - ->assertInertiaPath('data.data.0.config.user', 'badenpowell') - ->assertInertiaPath('data.data.0.config.password', 'secret') - ->assertInertiaPath('data.data.0.config.base_url', env('TEST_OWNCLOUD_DOMAIN')) - ->assertInertiaPath('data.data.0.id', $connection->id) - ->assertInertiaPath('data.data.0.is_active', true) - ->assertInertiaPath('data.data.0.type_human', 'Owncloud') - ->assertInertiaPath('data.data.0.links.update', route('fileshare.update', ['fileshare' => $connection])) - ->assertInertiaPath('data.meta.default.name', '') - ->assertInertiaPath('data.meta.links.store', route('fileshare.store')) - ->assertInertiaPath('data.meta.types.0.id', OwncloudConnection::class) - ->assertInertiaPath('data.meta.types.0.name', 'Owncloud') - ->assertInertiaPath('data.meta.types.0.defaults.base_url', '') - ->assertInertiaPath('data.meta.types.0.fields.1', ['label' => 'Benutzer', 'key' => 'user', 'type' => 'text']); + $this->get('/api/fileshare') + ->assertJsonPath('data.0.name', 'lokaler Server') + ->assertJsonPath('data.0.type', OwncloudConnection::class) + ->assertJsonPath('data.0.config.user', 'badenpowell') + ->assertJsonPath('data.0.config.password', 'secret') + ->assertJsonPath('data.0.config.base_url', env('TEST_OWNCLOUD_DOMAIN')) + ->assertJsonPath('data.0.id', $connection->id) + ->assertJsonPath('data.0.is_active', true) + ->assertJsonPath('data.0.type_human', 'Owncloud') + ->assertJsonPath('data.0.links.update', route('fileshare.update', ['fileshare' => $connection])) + ->assertJsonPath('meta.default.name', '') + ->assertJsonPath('meta.links.store', route('fileshare.store')) + ->assertJsonPath('meta.types.0.id', OwncloudConnection::class) + ->assertJsonPath('meta.types.0.name', 'Owncloud') + ->assertJsonPath('meta.types.0.defaults.base_url', '') + ->assertJsonPath('meta.types.0.fields.1', ['label' => 'Benutzer', 'key' => 'user', 'type' => 'text']); } public function testItRendersComponent(): void { $this->withoutExceptionHandling()->login()->loginNami(); - $this->get('/setting/fileshare')->assertComponent('fileshareconnection/Index'); + $this->get('/setting/fileshare')->assertComponent('fileshare/Index'); } }