Compare commits

...

3 Commits

Author SHA1 Message Date
philipp lang 14925f6cb5 --wip-- [skip ci] 2024-08-01 20:28:59 +02:00
philipp lang 5f31489bab --wip-- [skip ci] 2024-08-01 18:25:25 +02:00
philipp lang be57152bea Clear settings view 2024-08-01 17:30:55 +02:00
38 changed files with 331 additions and 444 deletions

View File

@ -1,21 +0,0 @@
<?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));
}
}

View File

@ -21,10 +21,8 @@ class FileshareSettings extends LocalSettings
/**
* @inheritdoc
*/
public function viewData(): array
public function data()
{
return [
'data' => FileshareResource::collection(Fileshare::paginate(15))
];
return FileshareResource::collection(Fileshare::paginate(15));
}
}

View File

@ -2,10 +2,8 @@
namespace App\Form;
use App\Form\Actions\SettingStoreAction;
use App\Setting\Contracts\Storeable;
use App\Setting\LocalSettings;
use Lorisleiva\Actions\ActionRequest;
class FormSettings extends LocalSettings implements Storeable
{
@ -32,23 +30,4 @@ class FormSettings extends LocalSettings implements Storeable
'clearCacheUrl' => 'present|string',
];
}
public function beforeSave(ActionRequest $request): void
{
}
/**
* @inheritdoc
*/
public function viewData(): array
{
return [
'data' => [
'data' => [
'registerUrl' => $this->registerUrl,
'clearCacheUrl' => $this->clearCacheUrl,
]
]
];
}
}

View File

@ -2,6 +2,7 @@
namespace App\Http\Resources;
use App\Lib\HasMeta;
use App\User;
use Illuminate\Http\Resources\Json\JsonResource;
use Storage;
@ -11,6 +12,8 @@ use Storage;
*/
class UserResource extends JsonResource
{
use HasMeta;
/**
* Transform the resource into an array.
*
@ -25,9 +28,21 @@ class UserResource extends JsonResource
'lastname' => $this->lastname,
'avatar_url' => $this->getGravatarUrl(),
'email' => $this->email,
'id' => $this->id,
'avatar' => [
'src' => Storage::url('avatar.png'),
],
];
}
public static function meta(): array
{
return [
'default' => [
'firstname' => '',
'lastname' => '',
],
'links' => []
];
}
}

View File

@ -4,7 +4,6 @@ namespace App\Invoice;
use App\Setting\Contracts\Storeable;
use App\Setting\LocalSettings;
use Lorisleiva\Actions\ActionRequest;
class InvoiceSettings extends LocalSettings implements Storeable
{
@ -35,28 +34,6 @@ class InvoiceSettings extends LocalSettings implements Storeable
return 'bill';
}
/**
* @inheritdoc
*/
public function viewData(): array
{
return [
'data' => [
'from_long' => $this->from_long,
'from' => $this->from,
'mobile' => $this->mobile,
'email' => $this->email,
'website' => $this->website,
'address' => $this->address,
'place' => $this->place,
'zip' => $this->zip,
'iban' => $this->iban,
'bic' => $this->bic,
'rememberWeeks' => $this->rememberWeeks,
]
];
}
/**
* @inheritdoc
*/
@ -77,10 +54,6 @@ class InvoiceSettings extends LocalSettings implements Storeable
];
}
public function beforeSave(ActionRequest $request): void
{
}
public static function title(): string
{
return 'Rechnung';

View File

@ -21,10 +21,8 @@ class MailgatewaySettings extends LocalSettings
/**
* @inheritdoc
*/
public function viewData(): array
public function data()
{
return [
'data' => MailgatewayResource::collection(Mailgateway::paginate(10)),
];
return MailgatewayResource::collection(Mailgateway::paginate(10));
}
}

View File

@ -27,10 +27,6 @@ class ModuleSettings extends LocalSettings implements Storeable
return in_array($module, $this->modules);
}
public function beforeSave(ActionRequest $request): void
{
}
/**
* @inheritdoc
*/
@ -45,14 +41,13 @@ class ModuleSettings extends LocalSettings implements Storeable
/**
* @inheritdoc
*/
public function viewData(): array
public function data(): array
{
return [
'data' => [
'data' => [
'modules' => $this->modules,
],
'meta' => ['modules' => Module::forSelect()],
...parent::data(),
'meta' => [
...parent::data()['meta'],
'modules' => Module::forSelect(),
]
];
}

View File

@ -1,19 +0,0 @@
<?php
namespace App\Prevention\Actions;
use App\Prevention\PreventionSettings;
use Illuminate\Http\JsonResponse;
use Lorisleiva\Actions\Concerns\AsAction;
class SettingApiAction
{
use AsAction;
public function handle(): JsonResponse
{
return response()->json([
'data' => app(PreventionSettings::class)->toArray(),
]);
}
}

View File

@ -1,33 +0,0 @@
<?php
namespace App\Prevention\Actions;
use App\Lib\Editor\EditorData;
use App\Lib\Events\Succeeded;
use App\Prevention\PreventionSettings;
use Lorisleiva\Actions\ActionRequest;
use Lorisleiva\Actions\Concerns\AsAction;
class SettingStoreAction
{
use AsAction;
/**
* @return array<string, string>
*/
public function rules(): array
{
return [
'formmail' => 'array',
];
}
public function handle(ActionRequest $request): void
{
$settings = app(PreventionSettings::class);
$settings->formmail = EditorData::from($request->formmail);
$settings->save();
Succeeded::message('Einstellungen gespeichert.')->dispatch();
}
}

View File

@ -3,9 +3,11 @@
namespace App\Prevention;
use App\Lib\Editor\EditorData;
use App\Setting\Contracts\Storeable;
use App\Setting\LocalSettings;
use Lorisleiva\Actions\ActionRequest;
class PreventionSettings extends LocalSettings
class PreventionSettings extends LocalSettings implements Storeable
{
public EditorData $formmail;
@ -23,8 +25,17 @@ class PreventionSettings extends LocalSettings
/**
* @inheritdoc
*/
public function viewData(): array
public function rules(): array
{
return [];
return [
'formmail' => 'required',
];
}
public function saveAttributes(ActionRequest $request): array
{
return [
'formmail' => EditorData::from($request->formmail),
];
}
}

View File

@ -2,7 +2,9 @@
namespace App\Setting\Actions;
use App\Lib\Events\Succeeded;
use App\Setting\Contracts\Storeable;
use GrahamCampbell\ResultType\Success;
use Illuminate\Http\RedirectResponse;
use Lorisleiva\Actions\ActionRequest;
use Lorisleiva\Actions\Concerns\AsAction;
@ -33,7 +35,9 @@ class StoreAction
public function asController(ActionRequest $request, Storeable $settingGroup): RedirectResponse
{
$settingGroup->beforeSave($request);
$this->handle($settingGroup, $request->validated());
$this->handle($settingGroup, $settingGroup->saveAttributes($request));
Succeeded::message('Einstellungen gespeichert')->dispatch();
return redirect()->back();
}

View File

@ -18,8 +18,8 @@ class ViewAction
session()->put('title', $settingGroup::title());
return Inertia::render('setting/' . ucfirst($settingGroup::group()), [
...$settingGroup->viewData(),
'setting_menu' => app(SettingFactory::class)->getShare(),
'data' => $settingGroup->data(),
'settingMenu' => app(SettingFactory::class)->getShare(),
]);
}
}

View File

@ -24,4 +24,6 @@ interface Storeable
public function rules(): array;
public function beforeSave(ActionRequest $request): void;
public function saveAttributes(ActionRequest $request): array;
}

View File

@ -2,6 +2,7 @@
namespace App\Setting;
use Lorisleiva\Actions\ActionRequest;
use Spatie\LaravelSettings\Settings;
abstract class LocalSettings extends Settings
@ -13,8 +14,36 @@ abstract class LocalSettings extends Settings
return route('setting.view', ['settingGroup' => $this->group()]);
}
public function storeUrl(): string
{
return $this->url();
}
/**
* @return mixed
*/
public function data()
{
return [
'data' => $this->toArray(),
'meta' => [
'links' => [
'store' => $this->storeUrl(),
]
]
];
}
public function beforeSave(ActionRequest $request): void
{
return;
}
/**
* @return array<string, mixed>
*/
abstract public function viewData(): array;
public function saveAttributes(ActionRequest $request): array
{
return $request->validated();
}
}

View File

@ -4,7 +4,6 @@ namespace App\Setting;
use App\Group;
use App\Initialize\Actions\NamiLoginCheckAction;
use App\Nami\Actions\SettingSaveAction;
use App\Setting\Contracts\Storeable;
use Lorisleiva\Actions\ActionRequest;
use Zoomyboy\LaravelNami\Api;
@ -64,14 +63,15 @@ class NamiSettings extends LocalSettings implements Storeable
/**
* @inheritdoc
*/
public function viewData(): array
public function data(): array
{
return [
...parent::data(),
'data' => [
'mglnr' => $this->mglnr,
'password' => '',
'default_group_id' => $this->default_group_id,
]
],
];
}
}

View File

@ -2,8 +2,6 @@
namespace App\Setting;
use App\Invoice\InvoiceSettings;
use App\Setting\Contracts\Storeable;
use Illuminate\Routing\Router;
class SettingFactory

View File

@ -10,6 +10,7 @@ use App\Module\ModuleSettings;
use App\Prevention\PreventionSettings;
use App\Setting\Actions\StoreAction;
use App\Setting\Actions\ViewAction;
use App\User\UserSettings;
use Illuminate\Routing\Router;
use Illuminate\Support\ServiceProvider;
@ -43,5 +44,6 @@ class SettingServiceProvider extends ServiceProvider
app(SettingFactory::class)->register(FormSettings::class);
app(SettingFactory::class)->register(FileshareSettings::class);
app(SettingFactory::class)->register(PreventionSettings::class);
app(SettingFactory::class)->register(UserSettings::class);
}
}

28
app/User/UserSettings.php Normal file
View File

@ -0,0 +1,28 @@
<?php
namespace App\User;
use App\Http\Resources\UserResource;
use App\Setting\LocalSettings;
use App\User;
class UserSettings extends LocalSettings
{
public static function group(): string
{
return 'user';
}
public static function title(): string
{
return 'Benutzer';
}
/**
* @inheritdoc
*/
public function data()
{
return UserResource::collection(User::orderByRaw('lastname, firstname')->get());
}
}

5
bin/copydbdk Executable file
View File

@ -0,0 +1,5 @@
#!/bin/bash
ssh dkd 'cd $ADREMA_PATH && docker compose exec db mysqldump -q -udb -p'$ADREMA_DB_PASSWORD' db --ignore-table=db.telescope_entries --ignore-table=db.failed_jobs' > db.tmp
sudo mysql scoutrobot < db.tmp

7
bin/testmigration Executable file
View File

@ -0,0 +1,7 @@
#!/usr/bin/zsh
php artisan migrate:fresh --env=testing
ssh dkd 'cd $ADREMA_PATH && docker compose exec db mysqldump -q -udb -p'$ADREMA_DB_PASSWORD' db --ignore-table=db.telescope_entries --ignore-table=db.failed_jobs' > dddd.sql
sudo mysql scoutrobottest < dddd.sql
php artisan migrate --env=testing

View File

@ -92,6 +92,8 @@ services:
socketi:
image: quay.io/soketi/soketi:89604f268623cf799573178a7ba56b7491416bde-16-debian
ports:
- '6001:6001'
environment:
SOKETI_DEFAULT_APP_ID: adremaid
SOKETI_DEFAULT_APP_KEY: adremakey
@ -104,6 +106,8 @@ services:
meilisearch:
image: getmeili/meilisearch:v1.6
ports:
- '7700:7700'
volumes:
- ./data/meilisearch:/meili_data
env_file:

View File

@ -2,9 +2,11 @@ import {ref, inject, computed, onBeforeUnmount} from 'vue';
import {router} from '@inertiajs/vue3';
import useQueueEvents from './useQueueEvents.js';
export function useIndex(props, siteName) {
export function useIndex(props, siteName = null) {
const axios = inject('axios');
const {startListener, stopListener} = useQueueEvents(siteName, () => reload(false));
if (siteName !== null) {
var {startListener, stopListener} = useQueueEvents(siteName, () => reload(false));
}
const rawProps = JSON.parse(JSON.stringify(props));
const inner = {
data: ref(rawProps.data),
@ -56,8 +58,10 @@ export function useIndex(props, siteName) {
reload(true);
}
if (siteName !== null) {
startListener();
onBeforeUnmount(() => stopListener());
}
return {
data: inner.data,

View File

@ -2,9 +2,11 @@ import {computed, ref, inject, onBeforeUnmount} from 'vue';
import {router} from '@inertiajs/vue3';
import useQueueEvents from './useQueueEvents.js';
export function useIndex(props, siteName) {
export function useIndex(props, siteName = null) {
const axios = inject('axios');
const {startListener, stopListener} = useQueueEvents(siteName, () => reload(false));
if (siteName !== null) {
var {startListener, stopListener} = useQueueEvents(siteName, () => reload(false));
}
const single = ref(null);
const rawProps = JSON.parse(JSON.stringify(props));
const inner = {
@ -86,8 +88,10 @@ export function useIndex(props, siteName) {
reload(true);
}
if (siteName !== null) {
startListener();
onBeforeUnmount(() => stopListener());
}
return {
data: inner.data,

View File

@ -5,45 +5,26 @@
</template>
<setting-layout>
<form id="billsettingform" class="grow p-6 grid grid-cols-2 gap-3 items-start content-start" @submit.prevent="submit">
<f-text id="from" v-model="inner.from" label="Absender" hint="Absender-Name in Kurzform, i.d.R. der kurze Stammesname"></f-text>
<f-text id="from_long" v-model="inner.from_long" label="Absender (lang)" hint="Absender-Name in Langform, i.d.R. der Stammesname"></f-text>
<f-text id="from" v-model="data.from" label="Absender" hint="Absender-Name in Kurzform, i.d.R. der kurze Stammesname"></f-text>
<f-text id="from_long" v-model="data.from_long" label="Absender (lang)" hint="Absender-Name in Langform, i.d.R. der Stammesname"></f-text>
<h2 class="text-lg font-semibold text-gray-300 col-span-2 mt-5">Kontaktdaten</h2>
<div class="col-span-2 text-gray-300 text-sm">Diese Kontaktdaten stehen im Absender-Bereich auf der Rechnung.</div>
<f-text id="address" v-model="inner.address" label="Straße"></f-text>
<f-text id="zip" v-model="inner.zip" label="PLZ"></f-text>
<f-text id="place" v-model="inner.place" label="Ort"></f-text>
<f-text id="email" v-model="inner.email" label="E-Mail-Adresse"></f-text>
<f-text id="mobile" v-model="inner.mobile" label="Telefonnummer"></f-text>
<f-text id="website" v-model="inner.website" label="Webseite"></f-text>
<f-text id="iban" v-model="inner.iban" label="IBAN"></f-text>
<f-text id="bic" v-model="inner.bic" label="BIC"></f-text>
<f-text id="remember_weeks" v-model="inner.rememberWeeks" type="number" label="Erinnerung alle X Wochen versenden"></f-text>
<f-text id="address" v-model="data.address" label="Straße"></f-text>
<f-text id="zip" v-model="data.zip" label="PLZ"></f-text>
<f-text id="place" v-model="data.place" label="Ort"></f-text>
<f-text id="email" v-model="data.email" label="E-Mail-Adresse"></f-text>
<f-text id="mobile" v-model="data.mobile" label="Telefonnummer"></f-text>
<f-text id="website" v-model="data.website" label="Webseite"></f-text>
<f-text id="iban" v-model="data.iban" label="IBAN"></f-text>
<f-text id="bic" v-model="data.bic" label="BIC"></f-text>
<f-text id="remember_weeks" v-model="data.rememberWeeks" type="number" label="Erinnerung alle X Wochen versenden"></f-text>
</form>
</setting-layout>
</page-layout>
</template>
<script>
import SettingLayout from './Layout.vue';
export default {
components: {
SettingLayout,
},
props: {
data: {},
},
data: function () {
return {
inner: {...this.data},
};
},
methods: {
submit() {
this.$inertia.post('/setting/bill', this.inner, {
onSuccess: () => this.$success('Einstellungen gespeichert.'),
});
},
},
};
<script setup>
import {props, useSettings} from './useSettings.js';
const innerProps = defineProps(props);
const {submit, data, meta, SettingLayout} = useSettings(innerProps);
</script>

View File

@ -76,10 +76,12 @@
</template>
<script lang="js" setup>
import { useApiIndex } from '../../composables/useApiIndex.js';
import { useIndex, indexProps } from '../../composables/useInertiaApiIndex.js';
import SettingLayout from '../setting/Layout.vue';
const { meta, data, reload, create, edit, cancel, single, submit } = useApiIndex('/api/fileshare', 'fileshare');
const props = defineProps(indexProps);
const { meta, data, reload, create, edit, cancel, single, submit } = useIndex(props.data, 'fileshare');
function getType(type) {
if (!type) {
@ -89,6 +91,4 @@ function getType(type) {
}
return meta.value.types.find((t) => t.id === type);
}
reload();
</script>

View File

@ -9,40 +9,16 @@
<p class="text-sm">Hier kannst du Einstellungen für Anmeldeformulare setzen.</p>
</div>
<div class="grid grid-cols-2 gap-4">
<f-text id="register_url" v-model="inner.registerUrl" label="Formular-Link"></f-text>
<f-text id="clear_cache_url" v-model="inner.clearCacheUrl" label="Frontend-Cache-Url"></f-text>
<f-text id="register_url" v-model="data.registerUrl" label="Formular-Link"></f-text>
<f-text id="clear_cache_url" v-model="data.clearCacheUrl" label="Frontend-Cache-Url"></f-text>
</div>
</form>
</setting-layout>
</page-layout>
</template>
<script>
import SettingLayout from './Layout.vue';
export default {
components: {
SettingLayout,
},
props: {
data: {
type: Object,
default: () => {
return {};
},
},
},
data: function () {
return {
inner: {...this.data.data},
};
},
methods: {
submit() {
this.$inertia.post('/setting/form', this.inner, {
onSuccess: () => this.$success('Einstellungen gespeichert.'),
});
},
},
};
<script setup>
import {props, useSettings} from './useSettings.js';
const innerProps = defineProps(props);
const {submit, data, meta, SettingLayout} = useSettings(innerProps);
</script>

View File

@ -1,6 +1,6 @@
<template>
<div class="flex grow relative">
<ui-menulist v-model="active" :entries="$page.props.setting_menu"></ui-menulist>
<ui-menulist v-model="active" :entries="$page.props.settingMenu"></ui-menulist>
<slot></slot>
</div>
</template>
@ -9,7 +9,7 @@
export default {
data: function () {
return {
innerActive: this.$page.props.setting_menu.findIndex((menu) => menu.is_active),
innerActive: this.$page.props.settingMenu.findIndex((menu) => menu.is_active),
};
},
computed: {
@ -19,7 +19,7 @@ export default {
},
set(v) {
var _self = this;
this.$inertia.visit(this.$page.props.setting_menu[v].url, {
this.$inertia.visit(this.$page.props.settingMenu[v].url, {
onSuccess() {
_self.innerActive = v;
},

View File

@ -1,87 +0,0 @@
<template>
<page-layout>
<template #right>
<f-save-button form="mailmansettingform"></f-save-button>
</template>
<setting-layout>
<form id="mailmansettingform" class="grow p-6 grid grid-cols-2 gap-3 items-start content-start" @submit.prevent="submit">
<div class="col-span-full text-gray-100 mb-3">
<p class="text-sm">
Scoutrobot kann automatisch Mailinglisten erstellen, wenn es mit einem existierenden
<a href="https://docs.mailman3.org/en/latest/">Mailman Server</a> verbunden wird. Mailman ist ein OpenSource-Mailinglisten-System, um E-Mails an mehrere Leute zu senden.
</p>
<p class="text-sm mt-1">Scoutrobot wird nach der Ersteinrichtung deine Mitglieder zu bestehenden E-Mail-Verteilern hinzufügen.</p>
</div>
<div>
<f-switch id="is_active" v-model="inner.is_active" label="Mailman-Synchronisation aktiv"></f-switch>
</div>
<div class="flex h-full items-center">
<ui-sprite :src="stateDisplay.icon" :class="stateDisplay.text" class="w-5 h-5"></ui-sprite>
<span class="ml-3" :class="stateDisplay.text" v-text="stateDisplay.label"></span>
</div>
<f-text id="base_url" v-model="inner.base_url" label="URL" hint="URL der Mailman Api"></f-text>
<f-text id="username" v-model="inner.username" label="Benutzername"></f-text>
<f-text id="password" v-model="inner.password" type="password" label="Passwort"></f-text>
<f-select id="all_list" v-model="inner.all_list" label="Liste für alle Mitglieder" name="all_list" :options="lists"></f-select>
<f-select id="all_parents_list" v-model="inner.all_parents_list" label="Liste für Eltern" name="all_parents_list" :options="lists"></f-select>
<f-select id="active_leaders_list" v-model="inner.active_leaders_list" label="Liste für aktive Leiter" name="active_leaders_list" :options="lists"></f-select>
<f-select id="passive_leaders_list" v-model="inner.passive_leaders_list" label="Liste für passive Leiter" name="passive_leaders_list" :options="lists"></f-select>
<div></div>
</form>
</setting-layout>
</page-layout>
</template>
<script>
import SettingLayout from './Layout.vue';
export default {
components: {
SettingLayout,
},
props: {
data: {},
state: {},
lists: {},
},
data: function () {
return {
inner: {...this.data},
};
},
computed: {
stateDisplay() {
if (this.state === null) {
return {
text: 'text-gray-500',
icon: 'disabled',
label: 'Deaktiviert',
};
}
return this.state
? {
text: 'text-green-500',
icon: 'check',
label: 'Verbindung erfolgreich.',
}
: {
text: 'text-red-500',
icon: 'close',
label: 'Verbindung fehlgeschlagen.',
};
},
},
methods: {
submit() {
this.$inertia.post('/setting/mailman', this.inner, {
onSuccess: (page) => {
this.$success('Einstellungen gespeichert.');
this.inner = page.props.data;
},
});
},
},
};
</script>

View File

@ -4,48 +4,20 @@
<f-save-button form="modulesettingform"></f-save-button>
</template>
<setting-layout>
<form id="modulesettingform" class="grow p-6 grid grid-cols-2 gap-3 items-start content-start"
@submit.prevent="submit">
<form id="modulesettingform" class="grow p-6 grid grid-cols-2 gap-3 items-start content-start" @submit.prevent="submit">
<div class="col-span-full text-gray-100 mb-3">
<p class="text-sm">Hier kannst du Funktionen innerhalb von Adrema (Module) aktivieren oder deaktivieren
und so den Funktionsumfang auf deine Bedürfnisse anpassen.</p>
<p class="text-sm">Hier kannst du Funktionen innerhalb von Adrema (Module) aktivieren oder deaktivieren und so den Funktionsumfang auf deine Bedürfnisse anpassen.</p>
</div>
<div class="grid grid-cols-2 gap-4">
<f-switch v-for="module in meta.modules" :id="module.id" v-model="inner.modules" :value="module.id"
size="sm" name="modules" :label="module.name"></f-switch>
<f-switch v-for="module in meta.modules" :id="module.id" v-model="data.modules" :value="module.id" size="sm" name="modules" :label="module.name"></f-switch>
</div>
</form>
</setting-layout>
</page-layout>
</template>
<script>
import SettingLayout from './Layout.vue';
export default {
components: {
SettingLayout,
},
props: {
data: {
type: Object,
default: () => {
return {};
},
},
},
data: function () {
return {
inner: { ...this.data.data },
meta: { ...this.data.meta },
};
},
methods: {
submit() {
this.$inertia.post('/setting/module', this.inner, {
onSuccess: () => this.$success('Einstellungen gespeichert.'),
});
},
},
};
<script setup>
import {props, useSettings} from './useSettings.js';
const innerProps = defineProps(props);
const {submit, data, meta, SettingLayout} = useSettings(innerProps);
</script>

View File

@ -8,40 +8,16 @@
<div class="col-span-full text-gray-100 mb-3">
<p class="text-sm">Hier kannst du deine Zugangsdaten zu NaMi anpassen, falls sich z.B. dein Passwort geändert hat.</p>
</div>
<f-text id="mglnr" v-model="inner.mglnr" label="Mitgliedsnummer"></f-text>
<f-text id="default_group_id" v-model="inner.default_group_id" label="Standard-Gruppierung"></f-text>
<f-text id="password" v-model="inner.password" label="Passwort" name="password" type="password"></f-text>
<f-text id="mglnr" v-model="data.mglnr" label="Mitgliedsnummer"></f-text>
<f-text id="default_group_id" v-model="data.default_group_id" label="Standard-Gruppierung"></f-text>
<f-text id="password" v-model="data.password" label="Passwort" name="password" type="password"></f-text>
</form>
</setting-layout>
</page-layout>
</template>
<script>
import SettingLayout from './Layout.vue';
export default {
components: {
SettingLayout,
},
props: {
data: {
type: Object,
default: () => {
return {};
},
},
},
data: function () {
return {
inner: {...this.data},
};
},
methods: {
submit() {
this.$inertia.post('/setting/nami', this.inner, {
onSuccess: () => this.$success('Einstellungen gespeichert.'),
});
},
},
};
<script setup>
import {props, useSettings} from './useSettings.js';
const innerProps = defineProps(props);
const {submit, data, meta, SettingLayout} = useSettings(innerProps);
</script>

View File

@ -3,7 +3,7 @@
<template #right>
<f-save-button form="preventionform"></f-save-button>
</template>
<setting-layout v-if="loaded">
<setting-layout>
<form id="preventionform" class="grow p-6" @submit.prevent="submit">
<div class="col-span-full text-gray-100 mb-3">
<p class="text-sm">Hier kannst du Einstellungen zu Prävention setzen.</p>
@ -16,22 +16,8 @@
</page-layout>
</template>
<script lang="js" setup>
import { ref } from 'vue';
import { useApiIndex } from '../../composables/useApiIndex.js';
import SettingLayout from '../setting/Layout.vue';
const { axios, data, reload } = useApiIndex('/api/prevention', 'prevention');
const loaded = ref(false);
async function load() {
await reload();
loaded.value = true;
}
async function submit() {
await axios.post('/api/prevention', { ...data.value });
}
load();
<script setup>
import {props, useSettings} from './useSettings.js';
const innerProps = defineProps(props);
const {submit, data, meta, SettingLayout} = useSettings(innerProps);
</script>

View File

@ -0,0 +1,53 @@
<template>
<page-layout>
<template #toolbar>
<page-toolbar-button color="primary" icon="plus" @click.prevent="create">Neuer Benutzer</page-toolbar-button>
</template>
<ui-popup v-if="single !== null" :heading="single.id ? 'Benutzer bearbeiten' : 'Neuer Benutzer'" @close="cancel">
<form @submit.prevent="submit">
<section class="grid grid-cols-2 gap-3 mt-6">
<f-text id="firstname" v-model="single.firstname" name="firstname" label="Vorname" required></f-text>
<f-text id="lastname" v-model="single.lastname" name="lastname" label="Nachname" required></f-text>
</section>
<section class="flex mt-4 space-x-2">
<ui-button type="submit" class="btn-danger">Speichern</ui-button>
<ui-button class="btn-primary" @click.prevent="single = null">Abbrechen</ui-button>
</section>
</form>
</ui-popup>
<setting-layout>
<div class="w-full h-full pb-6">
<table cellspacing="0" cellpadding="0" border="0" class="custom-table custom-table-sm hidden md:table">
<thead>
<th>Nachname</th>
<th>Vorname</th>
<th>Aktion</th>
</thead>
<tr v-for="(user, index) in data" :key="index">
<td v-text="user.lastname"></td>
<td v-text="user.firstname"></td>
<td>
<a v-tooltip="`Bearbeiten`" href="#" class="inline-flex btn btn-warning btn-sm" @click.prevent="edit(user)"><ui-sprite src="pencil"></ui-sprite></a>
<a v-tooltip="`Löschen`" href="#" class="inline-flex btn btn-danger btn-sm" @click.prevent="remove(user)"><ui-sprite src="pencil"></ui-sprite></a>
</td>
</tr>
</table>
<div class="px-6">
<ui-pagination class="mt-4" :value="meta" :only="['data']"></ui-pagination>
</div>
</div>
</setting-layout>
</page-layout>
</template>
<script lang="js" setup>
import SettingLayout from '../setting/Layout.vue';
import {indexProps, useIndex} from '../../composables/useInertiaApiIndex.js';
const props = defineProps(indexProps);
const {data, cancel, meta, single, create, edit} = useIndex(props.data);
</script>

View File

@ -0,0 +1,29 @@
import {useIndex} from '../../composables/useInertiaApiIndex.js';
import SettingLayout from './Layout.vue';
export function useSettings(props) {
const {data, meta, router} = useIndex(props.data);
function submit() {
router.post(meta.value.links.store, {...data.value});
}
return {
submit,
data,
meta,
props,
SettingLayout,
};
}
const props = {
data: {
default: () => {
return {data: [], meta: {}};
},
type: Object,
},
};
export {props};

View File

@ -3,13 +3,9 @@
use App\Contribution\Actions\GenerateApiAction as ContributionGenerateApiAction;
use App\Form\Actions\FormApiListAction;
use App\Form\Actions\RegisterAction;
use App\Prevention\Actions\SettingStoreAction as PreventionStoreAction;
use App\Group\Actions\GroupApiIndexAction;
use App\Prevention\Actions\SettingApiAction;
Route::post('/contribution-generate', ContributionGenerateApiAction::class)->name('api.contribution.generate')->middleware('client:contribution-generate');
Route::post('/form/{form}/register', RegisterAction::class)->name('form.register');
Route::get('/group/{group?}', GroupApiIndexAction::class)->name('api.group');
Route::get('/form', FormApiListAction::class)->name('api.form.index');
Route::get('/prevention', SettingApiAction::class)->name('api.prevention.index');
Route::post('/prevention', PreventionStoreAction::class)->name('api.prevention.store');

View File

@ -19,7 +19,6 @@ 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\Fileshare\Actions\ListFilesAction;
@ -182,6 +181,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');
Route::post('/api/fileshare/{fileshare}/files', ListFilesAction::class)->name('api.fileshare.files');
});

View File

@ -0,0 +1,30 @@
<?php
namespace Tests\Feature\Permission;
use App\User;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Tests\TestCase;
class UserIndexTest extends TestCase
{
use DatabaseTransactions;
public function testItOpensSettingsPage(): void
{
$this->login()->loginNami();
auth()->user()->update(['firstname' => 'Jane', 'lastname' => 'Doe']);
User::factory()->create(['firstname' => 'John', 'lastname' => 'Doe']);
$anna = User::factory()->create(['firstname' => 'Anna', 'lastname' => 'Doe']);
$this->get(route('setting.view', ['settingGroup' => 'user']))
->assertOk()
->assertComponent('setting/User')
->assertInertiaPath('data.data.0.firstname', 'Anna')
->assertInertiaPath('data.data.0.lastname', 'Doe')
->assertInertiaPath('data.data.0.id', $anna->id)
->assertInertiaPath('data.data.1.firstname', 'Jane')
->assertInertiaPath('data.data.2.firstname', 'John')
->assertInertiaPath('data.meta.default.firstname', '');
}
}

View File

@ -16,25 +16,25 @@ class SettingTest extends TestCase
{
$this->login()->loginNami();
$this->get('/setting/prevention')->assertComponent('setting/Prevention')->assertOk();
}
public function testItReceivesSettings(): void
{
$this->login()->loginNami();
$text = EditorRequestFactory::new()->text(50, 'lorem ipsum')->toData();
app(PreventionSettings::class)->fill(['formmail' => $text])->save();
$this->get('/api/prevention')
->assertJsonPath('data.formmail.blocks.0.data.text', 'lorem ipsum');
$this->get(route('setting.view', ['settingGroup' => 'prevention']))
->assertOk()
->assertComponent('setting/Prevention')
->assertInertiaPath('data.formmail.blocks.0.data.text', 'lorem ipsum')
->assertInertiaPath('store_url', route('setting.store', ['settingGroup' => 'prevention']));
}
public function testItStoresSettings(): void
{
$this->login()->loginNami();
$this->post('/api/prevention', ['formmail' => EditorRequestFactory::new()->text(50, 'new lorem')->create()])->assertOk();
$route = route('setting.store', ['settingGroup' => 'prevention']);
$this
->from($route)
->post($route, ['formmail' => EditorRequestFactory::new()->text(50, 'new lorem')->create()])
->assertRedirect($route);
$this->assertTrue(app(PreventionSettings::class)->formmail->hasAll(['new lorem']));
}
}

View File

@ -17,31 +17,25 @@ class FileshareIndexActionTest extends FileshareTestCase
->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');
$this->get(route('setting.view', ['settingGroup' => 'fileshare']))
->assertComponent('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', NextcloudConnection::class)
->assertInertiaPath('data.meta.types.0.name', 'Nextcloud')
->assertInertiaPath('data.meta.types.0.defaults.base_url', '')
->assertInertiaPath('data.meta.types.1.id', OwncloudConnection::class)
->assertInertiaPath('data.meta.types.1.name', 'Owncloud')
->assertInertiaPath('data.meta.types.1.defaults.base_url', '')
->assertInertiaPath('data.meta.types.0.fields.1', ['label' => 'Benutzer', 'key' => 'user', 'type' => 'text']);
}
}