Started working on Admin Dashboard, setup layout and the nav-bar

This commit is contained in:
Vari 2024-03-16 04:31:11 +01:00
parent cd9d96d421
commit fceab708aa
15 changed files with 248 additions and 11 deletions

View File

@ -0,0 +1,16 @@
<?php
namespace App\Http\Controllers\Web\Admin;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\View;
class DashboardController extends Controller
{
public function dashboard()
{
View::share('title', 'Dashboard');
return view('admin.dashboard');
}
}

View File

@ -48,6 +48,10 @@ public function boot(): void
Route::middleware(['api', 'api.session'])
->prefix('metrics')
->group(base_path('routes/metrics.php'));
Route::middleware(['web', 'auth'])
->prefix('admin')
->group(base_path('routes/admin.php'));
});
}
}

View File

@ -0,0 +1,29 @@
<?php
namespace App\View\Components\Admin;
use App\Models\User\User;
use Auth;
use Closure;
use Illuminate\Contracts\View\View;
use Illuminate\View\Component;
class Navbar extends Component
{
public User $user;
/**
* Create a new component instance.
*/
public function __construct()
{
$this->user = Auth::user();
}
/**
* Get the view / contents that represent the component.
*/
public function render(): View|Closure|string
{
return view('components.admin.navbar');
}
}

46
dist/app/View/Components/Auth/User.php vendored Normal file
View File

@ -0,0 +1,46 @@
<?php
namespace App\View\Components\Auth;
use Closure;
use Illuminate\Contracts\View\View;
use Illuminate\View\Component;
class User extends Component
{
public string $profileUrl;
/**
* Create a new component instance.
*/
public function __construct(
public \App\Models\User\User $user,
public bool $showAvatar = true,
public bool $showName = true,
)
{
$this->profileUrl = 'https://steamcommunity.com/profiles/'.$user->steam_id;
}
public function avatarFull(): string
{
return $this->user->avatar_full ?? $this->user->avatar_medium ?? $this->user->avatar_small;
}
public function avatarMedium(): string
{
return $this->user->avatar_medium ?? $this->user->avatar_small ?? $this->user->avatar_full ?? '';
}
public function avatarSmall(): string {
return $this->user->avatar_small ?? $this->user->avatar_medium ?? $this->user->avatar_full ?? '';
}
/**
* Get the view / contents that represent the component.
*/
public function render(): View|Closure|string
{
return view('components.auth.user');
}
}

View File

@ -0,0 +1,26 @@
<?php
namespace App\View\Components\Layouts;
use Closure;
use Illuminate\Contracts\View\View;
use Illuminate\View\Component;
class App extends Component
{
/**
* Create a new component instance.
*/
public function __construct()
{
//
}
/**
* Get the view / contents that represent the component.
*/
public function render(): View|Closure|string
{
return view('components.layouts.app');
}
}

View File

@ -0,0 +1,26 @@
<?php
namespace App\View\Components\Layouts;
use Closure;
use Illuminate\Contracts\View\View;
use Illuminate\View\Component;
class admin extends Component
{
/**
* Create a new component instance.
*/
public function __construct()
{
//
}
/**
* Get the view / contents that represent the component.
*/
public function render(): View|Closure|string
{
return view('components.layouts.admin');
}
}

View File

@ -0,0 +1,3 @@
<x-layouts.admin>
Dashboard
</x-layouts.admin>

View File

@ -1,12 +1,17 @@
<!DOCTYPE html>
<html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0" />
<meta name="csrf-token" content="{{ csrf_token() }}">
<title>{{ $title ?? 'Deathgarden Rebirth' }}</title>
@vite(['resources/css/app.css', 'resources/js/app.js'])
@inertiaHead
@stack('head')
</head>
<body>
@inertia
<body class="bg-gray-950 font-sans text-white antialiased">
{{ $slot }}
</body>
<footer>
@stack('footer')
</footer>
</html>

View File

@ -0,0 +1,21 @@
<?php
/** @var \App\Models\User\User $user */
?>
<nav class="bg-gray-800 flex flex-row p-3 w-full items-center align-middle">
<a href="{{ route('admin.dashboard') }}">
<span class="font-bold text-lg mr-4">
Administration
</span>
</a>
@isset($title)
<span class="italic">
{{ $title }}
</span>
@endisset
<div class="ml-auto max-h-10 object-scale-down">
<x-auth.user :$user/>
</div>
</nav>

View File

@ -0,0 +1,24 @@
<?php
/** @var \App\Models\User\User $user */
/** @var string $profileUrl */
/** @var bool $showAvatar */
/** @var bool $showName */
?>
<div class="flex items-center" style="max-height: inherit">
@if($showName)
<a href="{{ $profileUrl }}" target="_blank">
<span class="mx-1">
{{ $user->last_known_username }}
</span>
</a>
@endif
@if($showAvatar)
<a href="{{ $profileUrl }}" target="_blank" style="max-height: inherit">
<img src="{{ $avatarFull }}"
alt="Avatar"
class="rounded-lg mx-1" style="max-height: inherit">
</a>
@endif
</div>

View File

@ -0,0 +1,8 @@
<x-layouts.app>
<div class="grid grid-cols-1 grid-rows-2">
<x-admin.navbar class="row-span-1"/>
<div class="row-span-2">
{{ $slot }}
</div>
</div>
</x-layouts.app>

View File

@ -0,0 +1,17 @@
<!DOCTYPE html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0" />
<meta name="csrf-token" content="{{ csrf_token() }}">
<title>{{ $title ?? 'Deathgarden Rebirth' }}</title>
@vite(['resources/css/app.css', 'resources/js/app.js'])
@stack('head')
</head>
<body class="bg-gray-950 font-sans text-white antialiased">
{{ $slot }}
</body>
<footer>
@stack('footer')
</footer>
</html>

View File

@ -4,11 +4,14 @@
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0" />
<meta name="csrf-token" content="{{ csrf_token() }}">
<title>{{ $title ?? 'Deathgarden Rebirth' }}</title>
@vite(['resources/css/app.css', 'resources/js/app.js'])
@stack('head')
</head>
<body class="bg-gray-950 font-sans text-white antialiased">
{{ $slot }}
</body>
@stack('js')
<footer>
@stack('js')
</footer>
</html>

14
dist/routes/admin.php vendored Normal file
View File

@ -0,0 +1,14 @@
<?php
use App\Http\Controllers\Web\Admin\DashboardController;
use App\Http\Controllers\Web\GameFileController;
Route::redirect('', 'admin/dashboard');
Route::get('dashboard', [DashboardController::class, 'dashboard'])->name('admin.dashboard');
Route::get('file-manager', [GameFileController::class, 'index']);
Route::post('file-manager', [GameFileController::class, 'store'])->name('file.store');
Route::fallback(function () {
return redirect(route('admin.dashboard'));
});

5
dist/routes/web.php vendored
View File

@ -33,11 +33,6 @@
return \Inertia\Inertia::render('Dashboard');
});
Route::middleware('auth')->group(function () {
Route::get('/admin/file-manager', [\App\Http\Controllers\Web\GameFileController::class, 'index']);
Route::post('/admin/file-manager', [\App\Http\Controllers\Web\GameFileController::class, 'store'])->name('file.store');
});
Route::middleware('verify_migration_key')->get('/migrate-database', function () {
Artisan::call('migrate --no-interaction');
print Artisan::output();