Add fileshare index
continuous-integration/drone/push Build is failing
Details
continuous-integration/drone/push Build is failing
Details
This commit is contained in:
parent
291e69e68c
commit
e9c5b1d789
|
@ -2,8 +2,6 @@
|
|||
|
||||
namespace App\Setting;
|
||||
|
||||
use App\Fileshare\FileshareSettings;
|
||||
use App\Form\FormSettings;
|
||||
use Modules\Module\ModuleSettings;
|
||||
use App\Prevention\PreventionSettings;
|
||||
use App\Setting\Data\SettingSynthesizer;
|
||||
|
@ -35,7 +33,6 @@ class SettingServiceProvider extends ServiceProvider
|
|||
app(SettingFactory::class)->register(ModuleSettings::class);
|
||||
app(SettingFactory::class)->register(InvoiceSettings::class);
|
||||
app(SettingFactory::class)->register(NamiSettings::class);
|
||||
app(SettingFactory::class)->register(FileshareSettings::class);
|
||||
app(SettingFactory::class)->register(PreventionSettings::class);
|
||||
|
||||
Livewire::propertySynthesizer(SettingSynthesizer::class);
|
||||
|
|
|
@ -185,6 +185,7 @@ return [
|
|||
Modules\Nami\NamiServiceProvider::class,
|
||||
Modules\Auth\AuthServiceProvider::class,
|
||||
Modules\Form\FormServiceProvider::class,
|
||||
Modules\Fileshare\FileshareServiceProvider::class,
|
||||
],
|
||||
|
||||
/*
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
<?php
|
||||
|
||||
namespace Modules\Fileshare\Components;
|
||||
|
||||
use App\Fileshare\FileshareSettings;
|
||||
use App\Fileshare\Models\Fileshare;
|
||||
use Livewire\Component;
|
||||
|
||||
class SettingView extends Component
|
||||
{
|
||||
|
||||
public $settingClass = FileshareSettings::class;
|
||||
|
||||
public function render()
|
||||
{
|
||||
return view('fileshare::setting-view', [
|
||||
'data' => Fileshare::get(),
|
||||
]);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,63 @@
|
|||
<?php
|
||||
|
||||
namespace Modules\Fileshare\Components;
|
||||
|
||||
use App\Fileshare\ConnectionTypes\OwncloudConnection;
|
||||
use App\Fileshare\Models\Fileshare;
|
||||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||
use Livewire\Livewire;
|
||||
use Modules\Fileshare\Components\SettingView;
|
||||
use Tests\FileshareTestCase;
|
||||
use Tests\TestCase;
|
||||
|
||||
uses(FileshareTestCase::class);
|
||||
uses(DatabaseTransactions::class);
|
||||
|
||||
it('it renders page', function () {
|
||||
test()->withoutExceptionHandling()->login()->loginNami();
|
||||
|
||||
test()->get('/setting/fileshare')->assertSeeLivewire(SettingView::class);
|
||||
});
|
||||
|
||||
it('displays overview', function () {
|
||||
$this->withoutExceptionHandling()->login()->loginNami()->withUser('badenpowell', 'secret');
|
||||
Fileshare::factory()
|
||||
->type(OwncloudConnection::from(['user' => 'badenpowell', 'password' => 'secret', 'base_url' => env('TEST_OWNCLOUD_DOMAIN')]))
|
||||
->name('lokaler Server')
|
||||
->create();
|
||||
|
||||
Livewire::test(SettingView::class)
|
||||
->assertSee('lokaler Server')
|
||||
->assertSee('Verbindung erfolgreich')
|
||||
->assertSee('Owncloud');
|
||||
// ->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', NextcloudConnection::class)
|
||||
// ->assertJsonPath('meta.types.0.name', 'Nextcloud')
|
||||
// ->assertJsonPath('meta.types.0.defaults.base_url', '')
|
||||
// ->assertJsonPath('meta.types.1.id', OwncloudConnection::class)
|
||||
// ->assertJsonPath('meta.types.1.name', 'Owncloud')
|
||||
// ->assertJsonPath('meta.types.1.defaults.base_url', '')
|
||||
// ->assertJsonPath('meta.types.0.fields.1', ['label' => 'Benutzer', 'key' => 'user', 'type' => 'text']);
|
||||
});
|
||||
|
||||
it('displays wrong connection', function () {
|
||||
$this->withoutExceptionHandling()->login()->loginNami()->withUser('badenpowell', 'secret');
|
||||
Fileshare::factory()
|
||||
->type(OwncloudConnection::from(['user' => 'badenpowell', 'password' => 'wrong', 'base_url' => env('TEST_OWNCLOUD_DOMAIN')]))
|
||||
->name('lokaler Server')
|
||||
->create();
|
||||
|
||||
Livewire::test(SettingView::class)
|
||||
->assertSee('lokaler Server')
|
||||
->assertSee('Verbindung fehlgeschlagen');
|
||||
});
|
|
@ -0,0 +1,36 @@
|
|||
<x-page::setting-layout :active="$settingClass">
|
||||
<x-slot:toolbar>
|
||||
<x-ui::badge wire:click.prevent="$dispatch('openModal', {component: 'modules.fileshare.components.form', props: {}, title: 'Neue Verbindung'})" icon="plus">Neue Verbindung</x-ui::badge>
|
||||
</x-slot:toolbar>
|
||||
<div>
|
||||
<x-ui::table>
|
||||
<thead>
|
||||
<th>Bezeichnung</th>
|
||||
<th>Typ</th>
|
||||
<th>Prüfung</th>
|
||||
<th>Aktion</th>
|
||||
</thead>
|
||||
|
||||
@foreach ($data as $index => $share)
|
||||
<tr wire:key="$index">
|
||||
<td>{{ $share->name }}</td>
|
||||
<td>{{ $share->type::title() }}</td>
|
||||
<td>
|
||||
<x-ui::boolean-display :value="$share->type->check()"
|
||||
hint="Verbindungsstatus"
|
||||
right="Verbindung erfolgreich"
|
||||
wrong="Verbindung fehlgeschlagen"
|
||||
></x-ui::boolean-display>
|
||||
</td>
|
||||
<td>
|
||||
<x-ui::action wire:click="$dispatch('openModal', {
|
||||
component: 'modules.fileshare.components.form',
|
||||
props: {id: '{{$share->id}}'},
|
||||
title: 'Verbindung {{$share->name}} bearbeiten'}
|
||||
)" icon="pencil" variant="warning">Bearbeiten</x-ui::action>
|
||||
</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</x-ui::table>
|
||||
</div>
|
||||
</x-page::setting-layout>
|
|
@ -0,0 +1,38 @@
|
|||
<?php
|
||||
|
||||
namespace Modules\Fileshare;
|
||||
|
||||
use App\Fileshare\FileshareSettings;
|
||||
use App\Setting\SettingFactory;
|
||||
use Illuminate\Routing\Router;
|
||||
use Illuminate\Support\Facades\View;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use Modules\Fileshare\Components\SettingView;
|
||||
|
||||
class FileshareServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* Register services.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function register()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Bootstrap services.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
app(SettingFactory::class)->register(FileshareSettings::class);
|
||||
|
||||
app(Router::class)->middleware(['web', 'auth:web'])->group(function ($router) {
|
||||
$router->get('/setting/fileshare', SettingView::class)->name('setting.fileshare');
|
||||
});
|
||||
|
||||
View::addNamespace('fileshare', __DIR__ . '/Components');
|
||||
}
|
||||
}
|
|
@ -1,47 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Tests\Fileshare;
|
||||
|
||||
use App\Fileshare\ConnectionTypes\NextcloudConnection;
|
||||
use App\Fileshare\ConnectionTypes\OwncloudConnection;
|
||||
use App\Fileshare\Models\Fileshare;
|
||||
use Tests\FileshareTestCase;
|
||||
|
||||
class FileshareIndexActionTest extends FileshareTestCase
|
||||
{
|
||||
public function testItListsOwncloudConnectionsThatAreActive(): void
|
||||
{
|
||||
$this->withoutExceptionHandling()->login()->loginNami()->withUser('badenpowell', 'secret');
|
||||
$connection = Fileshare::factory()
|
||||
->type(OwncloudConnection::from(['user' => 'badenpowell', 'password' => 'secret', 'base_url' => env('TEST_OWNCLOUD_DOMAIN')]))
|
||||
->name('lokaler Server')
|
||||
->create();
|
||||
|
||||
$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', NextcloudConnection::class)
|
||||
->assertJsonPath('meta.types.0.name', 'Nextcloud')
|
||||
->assertJsonPath('meta.types.0.defaults.base_url', '')
|
||||
->assertJsonPath('meta.types.1.id', OwncloudConnection::class)
|
||||
->assertJsonPath('meta.types.1.name', 'Owncloud')
|
||||
->assertJsonPath('meta.types.1.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('setting/Fileshare');
|
||||
}
|
||||
}
|
|
@ -25,7 +25,7 @@ abstract class FileshareTestCase extends TestCase
|
|||
*/
|
||||
protected array $passwords = [];
|
||||
|
||||
public function setUp(): void
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
|
|
Loading…
Reference in New Issue