Add fileshare api
This commit is contained in:
parent
73633d7628
commit
94cc0147bc
|
@ -0,0 +1,21 @@
|
|||
<?php
|
||||
|
||||
namespace App\Fileshare\Actions;
|
||||
|
||||
use App\Fileshare\Models\Fileshare;
|
||||
use App\Fileshare\Resources\FileshareResource;
|
||||
use Illuminate\Http\Resources\Json\AnonymousResourceCollection;
|
||||
use Lorisleiva\Actions\Concerns\AsAction;
|
||||
|
||||
class FileshareApiIndexAction
|
||||
{
|
||||
use AsAction;
|
||||
|
||||
public function handle(): AnonymousResourceCollection
|
||||
{
|
||||
session()->put('menu', 'setting');
|
||||
session()->put('title', 'Datei-Verbindungen');
|
||||
|
||||
return FileshareResource::collection(Fileshare::paginate(15));
|
||||
}
|
||||
}
|
|
@ -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)),
|
||||
]);
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,18 +7,32 @@
|
|||
<form @submit.prevent="submit">
|
||||
<section class="grid grid-cols-2 gap-3 mt-6">
|
||||
<f-text id="name" v-model="single.name" name="name" label="Bezeichnung" required></f-text>
|
||||
<f-select id="type" :model-value="single.type" label="Typ" name="type" :options="meta.types" required
|
||||
<f-select
|
||||
id="type"
|
||||
:model-value="single.type"
|
||||
label="Typ"
|
||||
name="type"
|
||||
:options="meta.types"
|
||||
required
|
||||
@update:model-value="
|
||||
single = {
|
||||
...single,
|
||||
type: $event,
|
||||
config: { ...getType($event).defaults },
|
||||
config: {...getType($event).defaults},
|
||||
}
|
||||
"></f-select>
|
||||
"
|
||||
></f-select>
|
||||
<template v-for="(field, index) in getType(single.type).fields">
|
||||
<f-text v-if="field.type === 'text' || field.type === 'password' || field.type === 'email'"
|
||||
:id="field.key" :key="index" v-model="single.config[field.key]" :label="field.label"
|
||||
:type="field.type" :name="field.key" required></f-text>
|
||||
<f-text
|
||||
v-if="field.type === 'text' || field.type === 'password' || field.type === 'email'"
|
||||
:id="field.key"
|
||||
:key="index"
|
||||
v-model="single.config[field.key]"
|
||||
:label="field.label"
|
||||
:type="field.type"
|
||||
:name="field.key"
|
||||
required
|
||||
></f-text>
|
||||
</template>
|
||||
</section>
|
||||
<section class="flex mt-4 space-x-2">
|
||||
|
@ -41,12 +55,14 @@
|
|||
<td v-text="connection.name"></td>
|
||||
<td v-text="connection.type_human"></td>
|
||||
<td>
|
||||
<ui-boolean-display :value="connection.is_active" long-label="Verbindungsstatus"
|
||||
:label="connection.is_active ? 'Verbindung erfolgreich' : 'Verbindung fehlgeschlagen'"></ui-boolean-display>
|
||||
<ui-boolean-display
|
||||
:value="connection.is_active"
|
||||
long-label="Verbindungsstatus"
|
||||
:label="connection.is_active ? 'Verbindung erfolgreich' : 'Verbindung fehlgeschlagen'"
|
||||
></ui-boolean-display>
|
||||
</td>
|
||||
<td>
|
||||
<a v-tooltip="`Bearbeiten`" href="#" class="inline-flex btn btn-warning btn-sm"
|
||||
@click.prevent="edit(connection)"><ui-sprite src="pencil"></ui-sprite></a>
|
||||
<a v-tooltip="`Bearbeiten`" href="#" class="inline-flex btn btn-warning btn-sm" @click.prevent="edit(connection)"><ui-sprite src="pencil"></ui-sprite></a>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
@ -60,11 +76,10 @@
|
|||
</template>
|
||||
|
||||
<script setup>
|
||||
import { indexProps, useIndex } from '../../composables/useInertiaApiIndex.js';
|
||||
import {useApiIndex} from '../../composables/useApiIndex.js';
|
||||
import SettingLayout from '../setting/Layout.vue';
|
||||
|
||||
const props = defineProps(indexProps);
|
||||
const { meta, data, create, edit, cancel, single, submit } = useIndex(props.data, 'mailgateway');
|
||||
const {meta, data, reload, create, edit, cancel, single, submit} = useApiIndex('/api/fileshare', 'fileshare');
|
||||
|
||||
function getType(type) {
|
||||
if (!type) {
|
||||
|
@ -74,4 +89,6 @@ function getType(type) {
|
|||
}
|
||||
return meta.value.types.find((t) => t.id === type);
|
||||
}
|
||||
|
||||
reload();
|
||||
</script>
|
|
@ -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');
|
||||
});
|
||||
|
|
|
@ -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');
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue