diff --git a/app/Http/Controllers/Frontend/DevController.php b/app/Http/Controllers/Frontend/DevController.php new file mode 100644 index 000000000..727d8a05c --- /dev/null +++ b/app/Http/Controllers/Frontend/DevController.php @@ -0,0 +1,88 @@ +user()->getAuthIdentifier(); + + return view('dev.apps', [ + 'apps' => $clients->activeForUser($userId), + ]); + } + + public function renderUpdateApp(int $appId): View { + $clients = new ClientRepository(); + $app = $clients->findForUser($appId, auth()->user()->id); + + if (!$app) { + abort(404); + } + return view('dev.apps-edit', [ + 'title' => 'Anwendung bearbeiten', //ToDo Übersetzen + 'app' => $app, + ]); + } + + public function renderCreateApp(): View { + return view('dev.apps-edit', [ + 'title' => 'Anwendung erstellen', //ToDo Übersetzen + 'app' => null + ]); + } + + public function updateApp(int $appId, Request $request): RedirectResponse { + $validated = $request->validate([ + 'name' => ['required', 'string'], + 'redirect' => ['required', 'string'], + ]); + + $clients = new ClientRepository(); + $app = $clients->findForUser($appId, auth()->user()->id); + + if (!$app) { + abort(404); + } + + $clients->update($app, $validated['name'], $validated['redirect']); + + return redirect(route('dev.apps'))->with('success', __('settings.saved')); + } + + public function createApp(Request $request): RedirectResponse { + $validated = $request->validate([ + 'name' => ['required', 'string'], + 'redirect' => ['required', 'string'], + ]); + + $clients = new ClientRepository(); + $clients->create(auth()->user()->id, $validated['name'], $validated['redirect']); + + return redirect(route('dev.apps'))->with('success', __('settings.saved')); + } + + public function destroyApp(int $appId): RedirectResponse { + $clients = new ClientRepository(); + $app = $clients->findForUser($appId, auth()->user()->id); + + if (!$app) { + abort(404); + } + $clients->delete($app); + + return redirect(route('dev.apps'))->with('success', __('settings.saved')); + } + +} diff --git a/resources/views/dev/apps-edit.blade.php b/resources/views/dev/apps-edit.blade.php new file mode 100644 index 000000000..f250fdc85 --- /dev/null +++ b/resources/views/dev/apps-edit.blade.php @@ -0,0 +1,60 @@ +@extends('layouts.settings') + +@section('title', request()->is('dev.apps.create') ? 'Anwendung erstellen' : 'Anwendung bearbeiten') + +@section('content') +
+
+ @else + action="{{ route('dev.apps.edit', ['appId' => $app->id]) }}"> +
+ + + + + + + + + +
Client Id{{ $app->id }}
Client Secret{{ $app->secret }}
+
+
+ @endif + @csrf +
+ + +
+ +
+
+ +
+ +
+ +
+
+ +
+
+ +
+
+
+
+@endsection diff --git a/resources/views/dev/apps.blade.php b/resources/views/dev/apps.blade.php new file mode 100644 index 000000000..0803f8914 --- /dev/null +++ b/resources/views/dev/apps.blade.php @@ -0,0 +1,126 @@ +@extends('layouts.settings') + +@section('title', 'Deine Anwendungen') + +@section('additional-content-end') + Anwendung erstellen +@endsection + +@section('content') +
+ @if($app) + + + + + + + + + + + @foreach($apps as $app) + + + + + @csrf + + + + @endforeach + +
NameRedirect URL 
{{ $app->name }}{{ $app->redirect }}
+ +
+ @else + Du hast noch keine Apps angelegt + @endif + +
+@endsection diff --git a/resources/views/layouts/settings.blade.php b/resources/views/layouts/settings.blade.php new file mode 100644 index 000000000..94ba1d95b --- /dev/null +++ b/resources/views/layouts/settings.blade.php @@ -0,0 +1,115 @@ + + + + + @yield('title') - {{ config('app.name', 'Träwelling') }} + + @include('layouts.includes.meta') + + + + + + + + + + + + + + + + + @yield('head') + + + @include('includes.message-block') +
+
+ +
+ + {{ config('app.name') }} Logo + + +
+ +
+
+
+
+ + @yield('additional-content-end') + +

@yield('title')

+

@yield('subtitle')

+ +
+ @yield('content') +
+
+
+
+
+ + + @include('includes.modals.notifications-board') + @yield('footer') + diff --git a/routes/web.php b/routes/web.php index 5dee06c46..7a1937991 100644 --- a/routes/web.php +++ b/routes/web.php @@ -12,6 +12,7 @@ */ use App\Http\Controllers\Frontend\AccountController; +use App\Http\Controllers\Frontend\DevController; use App\Http\Controllers\Frontend\EventController; use App\Http\Controllers\Frontend\Export\ExportController; use App\Http\Controllers\Frontend\IcsController; @@ -118,6 +119,7 @@ * All of these routes can only be used by fully registered users. */ Route::middleware(['auth', 'privacy'])->group(function() { + Route::post('/ics/createToken', [IcsController::class, 'createIcsToken']) ->name('ics.createToken'); Route::post('/ics/revokeToken', [IcsController::class, 'revokeIcsToken']) @@ -140,6 +142,16 @@ ->name('events.suggest'); Route::prefix('settings')->group(function() { + + Route::prefix('/applications')->group(function() { + Route::get('/', [DevController::class, 'renderAppList'])->name('dev.apps'); + Route::get('/create', [DevController::class, 'renderCreateApp'])->name('dev.apps.create'); + Route::get('/{appId}', [DevController::class, 'renderUpdateApp'])->name('dev.apps.edit'); + Route::post('/{appId}', [DevController::class, 'updateApp'])->name('dev.apps.update'); + Route::post('/{appId}/destroy', [DevController::class, 'destroyApp'])->name('dev.apps.destroy'); + Route::post('/', [DevController::class, 'createApp'])->name('dev.apps.create.post'); + }); + Route::get('/', [SettingsController::class, 'renderSettings']) ->name('settings'); Route::post('/', [SettingsController::class, 'updateMainSettings']);