- Added main application entry point (app.jsx) and bootstrap file for React setup. - Created Wiki index page (Index.jsx) for documentation and file management. - Implemented utility functions for formatting and status handling in utils.js. - Set up Blade template (app.blade.php) for Inertia.js integration. - Defined API routes for metrics and terminal access in api.php. - Established console commands for scheduled tasks in console.php. - Created web routes for various application features including authentication, hypervisors, containers, cloud accounts, security, backups, and wiki management in web.php. - Developed setup scripts for Windows (setup.ps1) and Linux (setup.sh) environments. - Configured Tailwind CSS for styling with custom themes and animations in tailwind.config.js. - Set up Vite for asset bundling and development server in vite.config.js.
75 lines
3.2 KiB
PHP
75 lines
3.2 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Middleware;
|
|
|
|
use App\Models\Setting;
|
|
use Illuminate\Http\Request;
|
|
use Inertia\Middleware;
|
|
|
|
class HandleInertiaRequests extends Middleware
|
|
{
|
|
protected $rootView = 'app';
|
|
|
|
public function version(Request $request): ?string
|
|
{
|
|
return parent::version($request);
|
|
}
|
|
|
|
public function share(Request $request): array
|
|
{
|
|
$user = $request->user();
|
|
|
|
return array_merge(parent::share($request), [
|
|
'auth' => [
|
|
'user' => $user ? [
|
|
'id' => $user->id,
|
|
'name' => $user->name,
|
|
'email' => $user->email,
|
|
'avatar' => $user->avatar_url,
|
|
'roles' => $user->getRoleNames(),
|
|
'permissions' => $user->getAllPermissions()->pluck('name'),
|
|
] : null,
|
|
],
|
|
'flash' => [
|
|
'success' => fn() => $request->session()->get('success'),
|
|
'error' => fn() => $request->session()->get('error'),
|
|
'warning' => fn() => $request->session()->get('warning'),
|
|
'info' => fn() => $request->session()->get('info'),
|
|
],
|
|
'app' => [
|
|
'name' => config('app.name'),
|
|
'version' => config('app.version', '1.0.0'),
|
|
'env' => config('app.env'),
|
|
],
|
|
'navigation' => $this->buildNavigation($user),
|
|
]);
|
|
}
|
|
|
|
private function buildNavigation($user): array
|
|
{
|
|
if (!$user) return [];
|
|
|
|
$nav = [
|
|
['name' => 'Dashboard', 'href' => '/', 'icon' => 'LayoutDashboard', 'key' => 'dashboard'],
|
|
['name' => 'Hypervisors', 'href' => '/hypervisors', 'icon' => 'Server', 'key' => 'hypervisors'],
|
|
['name' => 'VMs', 'href' => '/virtual-machines', 'icon' => 'Monitor', 'key' => 'vms'],
|
|
['name' => 'Templates', 'href' => '/templates', 'icon' => 'Layers', 'key' => 'templates'],
|
|
['name' => 'Containers', 'href' => '/containers', 'icon' => 'Box', 'key' => 'containers'],
|
|
['name' => 'Stacks', 'href' => '/stacks', 'icon' => 'Boxes', 'key' => 'stacks'],
|
|
['name' => 'Cloud', 'href' => '/cloud', 'icon' => 'Cloud', 'key' => 'cloud'],
|
|
['name' => 'Security', 'href' => '/security', 'icon' => 'Shield', 'key' => 'security'],
|
|
['name' => 'Backups', 'href' => '/backups', 'icon' => 'HardDrive', 'key' => 'backups'],
|
|
['name' => 'Monitoring', 'href' => '/monitoring', 'icon' => 'Activity', 'key' => 'monitoring'],
|
|
['name' => 'Identity', 'href' => '/identity', 'icon' => 'KeyRound', 'key' => 'identity'],
|
|
['name' => 'Wiki', 'href' => '/wiki', 'icon' => 'BookOpen', 'key' => 'wiki'],
|
|
];
|
|
|
|
if ($user->hasRole(['admin', 'super-admin'])) {
|
|
$nav[] = ['name' => 'ACL', 'href' => '/acl', 'icon' => 'Users', 'key' => 'acl'];
|
|
$nav[] = ['name' => 'Admin', 'href' => '/admin', 'icon' => 'Settings','key' => 'admin'];
|
|
}
|
|
|
|
return $nav;
|
|
}
|
|
}
|