Added config for js

This commit is contained in:
2025-10-23 00:52:27 +01:00
parent 0352fffabe
commit 0a5637f12a

View File

@@ -1,6 +1,7 @@
<?php <?php
// index.php
// Start session and include config
session_start(); session_start();
// index.php - SPA
require_once __DIR__ . '/includes/config.php'; require_once __DIR__ . '/includes/config.php';
// Replicate what admin_auth.php does for the "check" action // Replicate what admin_auth.php does for the "check" action
@@ -17,7 +18,7 @@ $nav_bar_admin = [];
if (is_dir($pages_dir)) { if (is_dir($pages_dir)) {
foreach (glob($pages_dir . '/*.php') as $file) { foreach (glob($pages_dir . '/*.php') as $file) {
$base = strtolower(basename($file, '.php')); $base = strtolower(basename($file, '.php'));
if (in_array($base, ['_template', 'error'])) continue; // skip special files if (in_array($base, ['_template', 'error', 'log'])) continue; // skip special files
if (in_array($base, array_map('strtolower', $nav_hidden))) continue; if (in_array($base, array_map('strtolower', $nav_hidden))) continue;
$label = ucfirst($base); $label = ucfirst($base);
@@ -30,7 +31,7 @@ if (is_dir($pages_dir)) {
} }
} }
} }
// Optional: order nav_bar according to $nav_order // Order nav_bar according to $nav_order
$ordered = []; $ordered = [];
foreach ($nav_order as $o) { foreach ($nav_order as $o) {
foreach ($nav_bar as $key => $label) { foreach ($nav_bar as $key => $label) {
@@ -51,6 +52,16 @@ unset($nav_order,$nav_admin,$nav_hidden);
<meta name="viewport" content="width=device-width,initial-scale=1"> <meta name="viewport" content="width=device-width,initial-scale=1">
<title><?= htmlspecialchars($CONFIG['site_name']) ?></title> <title><?= htmlspecialchars($CONFIG['site_name']) ?></title>
<link rel="stylesheet" href="css/style.css"> <link rel="stylesheet" href="css/style.css">
<script>
const CONFIG = {
options_status_interval: <?= ($CONFIG['options_status_interval'] ?? 30000) ?>,
options_status_services: <?= ($CONFIG['options_status_services'] ?? []) ?>,
shell_print_howto_to_logconsole: <?= ($CONFIG['shell_print_howto_to_logconsole'] ?? false) ?>,
home_chart_color_threshold_high: <?= ($CONFIG['home_chart_color_threshold_high'] ?? 70) ?>,
home_chart_color_threshold_medium: <?= ($CONFIG['home_chart_color_threshold_medium'] ?? 50) ?>,
index_admin_status_update_interval: <?= ($CONFIG['index_admin_status_update_interval'] ?? 50) ?>,
};
</script>
</head> </head>
<body> <body>
<header class="site-header"> <header class="site-header">
@@ -94,10 +105,7 @@ unset($nav_order,$nav_admin,$nav_hidden);
<!-- GLightbox --> <!-- GLightbox -->
<link rel="stylesheet" href="dist/css/glightbox.min.css"> <link rel="stylesheet" href="dist/css/glightbox.min.css">
<script src="dist/js/glightbox.min.js"></script> <script src="dist/js/glightbox.min.js" defer></script>
<script src="js/app.js" defer></script> <script src="js/app.js" defer></script>
</body> </body>
</html> </html>