init
This commit is contained in:
+111
@@ -0,0 +1,111 @@
|
||||
<?php
|
||||
require '../config.php';
|
||||
require '../auth.php';
|
||||
require '../includes/user_background.php';
|
||||
|
||||
if (!isset($_SESSION['username'])) {
|
||||
header('Location: /login.php');
|
||||
exit;
|
||||
}
|
||||
|
||||
$username = (string)($_SESSION['username'] ?? '');
|
||||
$userId = (int)($_SESSION['user_id'] ?? 0);
|
||||
$userId = resolveUserId($pdo, $userId, $username);
|
||||
$userBackgroundPref = userBackgroundLoadPreference($userId);
|
||||
|
||||
if (
|
||||
!hasPermission($pdo, $userId, 'page.visu.viewer.view') &&
|
||||
!hasPermission($pdo, $userId, 'page.visu.designer.view')
|
||||
) {
|
||||
http_response_code(403);
|
||||
exit('Kein Zugriff auf SE-Cloud Vis.');
|
||||
}
|
||||
|
||||
require '../includes/nav.php';
|
||||
render_navbar($config = null, $title = 'SE-Cloud Vis');
|
||||
|
||||
$manifestPath = __DIR__ . '/dist/.vite/manifest.json';
|
||||
$jsFile = null;
|
||||
$cssFiles = [];
|
||||
|
||||
if (is_file($manifestPath)) {
|
||||
$manifest = json_decode((string)file_get_contents($manifestPath), true);
|
||||
|
||||
if (isset($manifest['index.html'])) {
|
||||
$entry = $manifest['index.html'];
|
||||
$jsFile = $entry['file'] ?? null;
|
||||
$cssFiles = $entry['css'] ?? [];
|
||||
} elseif (isset($manifest['src/main.jsx'])) {
|
||||
$entry = $manifest['src/main.jsx'];
|
||||
$jsFile = $entry['file'] ?? null;
|
||||
$cssFiles = $entry['css'] ?? [];
|
||||
}
|
||||
}
|
||||
|
||||
function visuAssetUrl(string $file): string
|
||||
{
|
||||
return '/visu/dist/' . ltrim($file, '/');
|
||||
}
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="de">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>SE-Cloud Vis</title>
|
||||
<script src="https://cdn.tailwindcss.com"></script>
|
||||
|
||||
<?php foreach ($cssFiles as $css): ?>
|
||||
<link rel="stylesheet" href="<?= htmlspecialchars(visuAssetUrl((string)$css), ENT_QUOTES, 'UTF-8') ?>">
|
||||
<?php endforeach; ?>
|
||||
|
||||
<style>
|
||||
body {
|
||||
background:
|
||||
linear-gradient(rgba(17, 24, 39, 0.38), rgba(17, 24, 39, 0.72)),
|
||||
url('/images/green-building-investmentmarkt.jpg') center center / cover fixed no-repeat;
|
||||
}
|
||||
|
||||
.visu-page-wrap {
|
||||
width: 100%;
|
||||
max-width: none;
|
||||
margin: 0;
|
||||
padding: 12px 16px;
|
||||
}
|
||||
|
||||
.visu-build-missing {
|
||||
padding: 18px;
|
||||
border-radius: 18px;
|
||||
background: rgba(127, 29, 29, 0.55);
|
||||
border: 1px solid rgba(248, 113, 113, 0.55);
|
||||
color: #fecaca;
|
||||
font-weight: 700;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body class="bg-gray-900 text-white p-4 md:p-6 min-h-screen" style="<?= htmlspecialchars(userBackgroundInlineStyle($userBackgroundPref), ENT_QUOTES, 'UTF-8') ?>">
|
||||
|
||||
|
||||
<?php
|
||||
if (function_exists('render_dashboard_nav')) {
|
||||
render_dashboard_nav($pdo, $userId, '/visu/');
|
||||
}
|
||||
?>
|
||||
|
||||
<div class="visu-page-wrap">
|
||||
<div id="root"></div>
|
||||
|
||||
<?php if (!$jsFile): ?>
|
||||
<div class="visu-build-missing">
|
||||
React-Build nicht gefunden. Bitte im Ordner <code>visu-src</code> einmal
|
||||
<code>npm run build</code> ausführen.
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<?php if ($jsFile): ?>
|
||||
<script type="module" src="<?= htmlspecialchars(visuAssetUrl((string)$jsFile), ENT_QUOTES, 'UTF-8') ?>"></script>
|
||||
<?php endif; ?>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user