Add NaMi Settings to change NaMi Login
This commit is contained in:
parent
fafac446c3
commit
e3d581626c
|
@ -0,0 +1,35 @@
|
|||
<?php
|
||||
|
||||
namespace App\Nami\Actions;
|
||||
|
||||
use App\Setting\NamiSettings;
|
||||
use Inertia\Inertia;
|
||||
use Inertia\Response;
|
||||
use Lorisleiva\Actions\Concerns\AsAction;
|
||||
|
||||
class SettingIndexAction
|
||||
{
|
||||
use AsAction;
|
||||
|
||||
/**
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public function handle(NamiSettings $settings): array
|
||||
{
|
||||
return [
|
||||
'mglnr' => $settings->mglnr,
|
||||
'password' => '',
|
||||
'default_group_id' => $settings->default_group_id,
|
||||
];
|
||||
}
|
||||
|
||||
public function asController(NamiSettings $settings): Response
|
||||
{
|
||||
session()->put('menu', 'setting');
|
||||
session()->put('title', 'NaMi-Settings');
|
||||
|
||||
return Inertia::render('setting/Nami', [
|
||||
'data' => $this->handle($settings),
|
||||
]);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,42 @@
|
|||
<?php
|
||||
|
||||
namespace App\Nami\Actions;
|
||||
|
||||
use App\Initialize\Actions\NamiLoginCheckAction;
|
||||
use App\Setting\NamiSettings;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Lorisleiva\Actions\ActionRequest;
|
||||
use Lorisleiva\Actions\Concerns\AsAction;
|
||||
|
||||
class SettingSaveAction
|
||||
{
|
||||
use AsAction;
|
||||
|
||||
/**
|
||||
* @param array<string, string> $input
|
||||
*/
|
||||
public function handle(array $input): void
|
||||
{
|
||||
$settings = app(NamiSettings::class);
|
||||
|
||||
$settings->fill([
|
||||
'mglnr' => $input['mglnr'] ?? '',
|
||||
'password' => $input['password'] ?? '',
|
||||
'default_group_id' => $input['default_group_id'] ?? '',
|
||||
]);
|
||||
|
||||
$settings->save();
|
||||
}
|
||||
|
||||
public function asController(ActionRequest $request): RedirectResponse
|
||||
{
|
||||
NamiLoginCheckAction::run([
|
||||
'mglnr' => $request->mglnr,
|
||||
'password' => $request->password,
|
||||
]);
|
||||
|
||||
$this->handle($request->all());
|
||||
|
||||
return redirect()->back();
|
||||
}
|
||||
}
|
|
@ -3,11 +3,14 @@
|
|||
namespace App\Setting;
|
||||
|
||||
use App\Group;
|
||||
use Spatie\LaravelSettings\Settings;
|
||||
use App\Nami\Actions\SettingIndexAction;
|
||||
use App\Nami\Actions\SettingSaveAction;
|
||||
use App\Setting\Contracts\Indexable;
|
||||
use App\Setting\Contracts\Storeable;
|
||||
use Zoomyboy\LaravelNami\Api;
|
||||
use Zoomyboy\LaravelNami\Nami;
|
||||
|
||||
class NamiSettings extends Settings
|
||||
class NamiSettings extends LocalSettings implements Indexable, Storeable
|
||||
{
|
||||
public int $mglnr;
|
||||
|
||||
|
@ -32,4 +35,24 @@ class NamiSettings extends Settings
|
|||
{
|
||||
return Group::firstWhere('nami_id', $this->default_group_id);
|
||||
}
|
||||
|
||||
public static function slug(): string
|
||||
{
|
||||
return 'nami';
|
||||
}
|
||||
|
||||
public static function indexAction(): string
|
||||
{
|
||||
return SettingIndexAction::class;
|
||||
}
|
||||
|
||||
public static function storeAction(): string
|
||||
{
|
||||
return SettingSaveAction::class;
|
||||
}
|
||||
|
||||
public static function title(): string
|
||||
{
|
||||
return 'NaMi-Login';
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,5 +27,6 @@ class SettingServiceProvider extends ServiceProvider
|
|||
{
|
||||
app(SettingFactory::class)->register(InvoiceSettings::class);
|
||||
app(SettingFactory::class)->register(MailgatewaySettings::class);
|
||||
app(SettingFactory::class)->register(NamiSettings::class);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,50 @@
|
|||
<template>
|
||||
<page-layout>
|
||||
<template #right>
|
||||
<f-save-button form="namisettingform"></f-save-button>
|
||||
</template>
|
||||
<setting-layout>
|
||||
<form id="namisettingform" 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 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" name="mglnr"></f-text>
|
||||
<f-text id="default_group_id" v-model="inner.default_group_id" label="Standard-Gruppierung"
|
||||
name="default_group_id"></f-text>
|
||||
<f-text id="password" v-model="inner.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>
|
Loading…
Reference in New Issue