diff --git a/app/Fileshare/Data/FileshareResourceData.php b/app/Fileshare/Data/FileshareResourceData.php
new file mode 100644
index 00000000..11ceaa28
--- /dev/null
+++ b/app/Fileshare/Data/FileshareResourceData.php
@@ -0,0 +1,18 @@
+ Level::class
+ 'level' => Level::class,
+ 'fileshare' => FileshareResourceData::class,
];
/**
diff --git a/app/Group/Actions/GroupBulkstoreAction.php b/app/Group/Actions/GroupBulkstoreAction.php
index 3c6c78ec..f940b006 100644
--- a/app/Group/Actions/GroupBulkstoreAction.php
+++ b/app/Group/Actions/GroupBulkstoreAction.php
@@ -22,6 +22,9 @@ class GroupBulkstoreAction
'*.id' => 'required|integer|exists:groups,id',
'*.inner_name' => 'required|string|max:255',
'*.level' => ['required', 'string', Rule::in(Level::values())],
+ '*.fileshare' => 'present|nullable',
+ '*.fileshare.connection_id' => 'nullable|numeric|exists:fileshares,id',
+ '*.fileshare.resource' => 'nullable|string',
];
}
@@ -31,7 +34,7 @@ class GroupBulkstoreAction
public function handle(array $groups): void
{
foreach ($groups as $payload) {
- Group::find($payload['id'])->update(['level' => $payload['level'], 'inner_name' => $payload['inner_name']]);
+ Group::find($payload['id'])->update(['level' => $payload['level'], 'inner_name' => $payload['inner_name'], 'fileshare' => $payload['fileshare']]);
}
}
diff --git a/app/Group/Resources/GroupResource.php b/app/Group/Resources/GroupResource.php
index aedebe24..e9a0b03d 100644
--- a/app/Group/Resources/GroupResource.php
+++ b/app/Group/Resources/GroupResource.php
@@ -30,6 +30,7 @@ class GroupResource extends JsonResource
'id' => $this->id,
'level' => $this->level?->value,
'children_count' => $this->children_count,
+ 'fileshare' => $this->fileshare,
'links' => [
'children' => route('api.group', ['group' => $this->id]),
]
diff --git a/database/migrations/2024_06_29_141316_create_fileshare_column.php b/database/migrations/2024_06_29_141316_create_fileshare_column.php
new file mode 100644
index 00000000..2da2af57
--- /dev/null
+++ b/database/migrations/2024_06_29_141316_create_fileshare_column.php
@@ -0,0 +1,32 @@
+json('fileshare')->after('inner_name')->nullable();
+ });
+ }
+
+ /**
+ * Reverse the migrations.
+ *
+ * @return void
+ */
+ public function down()
+ {
+ Schema::table('groups', function (Blueprint $table) {
+ $table->dropColumn('fileshare');
+ });
+ }
+};
diff --git a/resources/js/views/group/Index.vue b/resources/js/views/group/Index.vue
index 7a3d27d3..7b60267b 100644
--- a/resources/js/views/group/Index.vue
+++ b/resources/js/views/group/Index.vue
@@ -19,6 +19,7 @@
NaMi-Name |
Interner Name |
Ebene |
+ Remote |
@@ -30,6 +31,9 @@
|
|
+
+
+ |
@@ -108,7 +112,8 @@ async function edit(parent) {
async function store() {
await axios.post(meta.value.links.bulkstore, [editing.value.parent, ...editing.value.children]);
- children[editing.value.parent.id] = (await axios.get(editing.value.parent.links.children)).data.data;
+ await toggle(editing.value.parent);
+ await toggle(editing.value.parent);
editing.value = null;
}
diff --git a/tests/Feature/Group/BulkstoreTest.php b/tests/Feature/Group/BulkstoreTest.php
index 65b7fcee..3f593a57 100644
--- a/tests/Feature/Group/BulkstoreTest.php
+++ b/tests/Feature/Group/BulkstoreTest.php
@@ -2,6 +2,8 @@
namespace Tests\Feature\Group;
+use App\Fileshare\ConnectionTypes\OwncloudConnection;
+use App\Fileshare\Models\Fileshare;
use App\Group;
use App\Group\Enums\Level;
use Illuminate\Foundation\Testing\DatabaseTransactions;
@@ -18,13 +20,37 @@ class BulkstoreTest extends TestCase
$group = Group::factory()->for(Group::first(), 'parent')->create(['inner_name' => 'Gruppe', 'level' => Level::REGION]);
$this->postJson(route('group.bulkstore'), [
- ['id' => $group->id, 'inner_name' => 'Abc', 'level' => Level::FEDERATION->value]
+ ['id' => $group->id, 'inner_name' => 'Abc', 'level' => Level::FEDERATION->value, 'fileshare' => null]
])->assertOk();
+ $this->assertNull($group->fresh()->fileshare);
$this->assertDatabaseHas('groups', [
'id' => $group->id,
'inner_name' => 'Abc',
'level' => 'Diƶzese',
+ 'fileshare' => null,
]);
}
+
+ public function testItStoresFileconnection(): void
+ {
+ $this->login()->loginNami()->withoutExceptionHandling();
+
+ $connection = Fileshare::factory()
+ ->type(OwncloudConnection::from(['user' => 'badenpowell', 'password' => 'secret', 'base_url' => env('TEST_OWNCLOUD_DOMAIN')]))
+ ->name('lokaler Server')
+ ->create();
+
+ $group = Group::factory()->for(Group::first(), 'parent')->create(['inner_name' => 'Gruppe', 'level' => Level::REGION]);
+
+ $this->postJson(route('group.bulkstore'), [
+ ['id' => $group->id, 'inner_name' => 'Abc', 'level' => Level::FEDERATION->value, 'fileshare' => [
+ 'connection_id' => $connection->id,
+ 'resource' => '/abc',
+ ]]
+ ])->assertOk();
+
+ $this->assertEquals($connection->id, $group->fresh()->fileshare->connectionId);
+ $this->assertEquals('/abc', $group->fresh()->fileshare->resource);
+ }
}
diff --git a/tests/Feature/Group/IndexTest.php b/tests/Feature/Group/IndexTest.php
index 181556ca..a18a5be8 100644
--- a/tests/Feature/Group/IndexTest.php
+++ b/tests/Feature/Group/IndexTest.php
@@ -2,6 +2,8 @@
namespace Tests\Feature\Group;
+use App\Fileshare\ConnectionTypes\OwncloudConnection;
+use App\Fileshare\Models\Fileshare;
use App\Group;
use App\Group\Enums\Level;
use Illuminate\Foundation\Testing\DatabaseTransactions;
@@ -73,4 +75,21 @@ class IndexTest extends TestCase
$this->get('/api/group/' . Group::first()->id)->assertJsonPath('data.0.id', $group->id);
}
+
+ public function testItDisplaysFileshare(): void
+ {
+ $this->login()->loginNami()->withoutExceptionHandling();
+
+ $connection = Fileshare::factory()
+ ->type(OwncloudConnection::from(['user' => 'badenpowell', 'password' => 'secret', 'base_url' => env('TEST_OWNCLOUD_DOMAIN')]))
+ ->name('lokaler Server')
+ ->create();
+
+ Group::factory()->for(Group::first(), 'parent')->create(['level' => null, 'fileshare' => [
+ 'connection_id' => $connection->id,
+ 'resource' => '/abc',
+ ]]);
+
+ $this->get('/api/group/' . Group::first()->id)->assertJsonPath('data.0.fileshare.resource', '/abc');
+ }
}