From 4f32bf68ca086422c02bb22839c6d7e982d93313 Mon Sep 17 00:00:00 2001 From: Troy Grunt Date: Sat, 7 Feb 2026 16:28:05 +0100 Subject: [PATCH] =?UTF-8?q?feat:=20Dockerfile=20und=20Dashboard-Modul=20hi?= =?UTF-8?q?nzugef=C3=BCgt,=20.htaccess=20angepasst=20und=20SQL-Initialisie?= =?UTF-8?q?rung=20optimiert?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile | 12 +++ app/.htaccess | 6 +- app/assets/js/app.js | 3 + app/assets/js/dashboard.js | 130 +++++++++++++++++++++++++++++++++ app/bootstrap.php | 7 +- app/index.php | 2 +- app/lib/_sql.php | 2 - app/modules/dashboard/list.php | 3 + docker-compose.yml | 2 +- 9 files changed, 154 insertions(+), 13 deletions(-) create mode 100644 Dockerfile create mode 100644 app/assets/js/dashboard.js create mode 100644 app/modules/dashboard/list.php diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..5e9aa10 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,12 @@ +FROM php:8.3-apache + +# Apache Module aktivieren +RUN a2enmod rewrite headers + +# Optional, aber empfehlenswert: +# PHP-Einstellungen oder Extensions +# RUN docker-php-ext-install pdo pdo_mysql +RUN docker-php-ext-install mysqli pdo pdo_mysql + +# Apache soll .htaccess erlauben +RUN sed -i 's/AllowOverride None/AllowOverride All/g' /etc/apache2/apache2.conf diff --git a/app/.htaccess b/app/.htaccess index 76006f3..e34fbe6 100644 --- a/app/.htaccess +++ b/app/.htaccess @@ -41,8 +41,8 @@ DirectoryIndex index.php # ========================= # Upload-Sicherheit # ========================= - - Require all denied - +# +# Require all denied +# # TODO: Optional: Upload-Verzeichnisse (device_types, floorplans) via .htaccess zusätzlich schützen diff --git a/app/assets/js/app.js b/app/assets/js/app.js index a19bcd2..0d2b9ef 100644 --- a/app/assets/js/app.js +++ b/app/assets/js/app.js @@ -120,3 +120,6 @@ function ajaxPost(url, data, callback) { } // TODO: weitere Utility-Funktionen (DOM-Helper, SVG-Helper, etc.) + +// Dashboard initialisieren +if (window.Dashboard) window.Dashboard.init(); diff --git a/app/assets/js/dashboard.js b/app/assets/js/dashboard.js new file mode 100644 index 0000000..f009f70 --- /dev/null +++ b/app/assets/js/dashboard.js @@ -0,0 +1,130 @@ +/** + * app/assets/js/dashboard.js + * + * Dashboard-Modul + * - Zentrale Übersicht aller Grundfunktionen + * - Einstiegspunkt für das Tool + * - Kann später Status, Warnungen, Statistiken anzeigen + */ + +window.Dashboard = (function () { + + // ========================= + // Interne Daten + // ========================= + + const modules = [ + { + id: 'device_types', + label: 'Gerätetypen', + description: 'Gerätetypen, Port-Definitionen, Module', + url: '/app/device_types/list.php', + icon: '🔌' + }, + { + id: 'devices', + label: 'Geräte', + description: 'Physische Geräte in Racks und Räumen', + url: '/app/devices/list.php', + icon: '🖥️' + }, + { + id: 'connections', + label: 'Verbindungen', + description: 'Kabel, Ports, VLANs, Protokolle', + url: '/app/connections/list.php', + icon: '🧵' + }, + { + id: 'floors', + label: 'Standorte & Stockwerke', + description: 'Gebäude, Etagen, Räume, Dosen', + url: '/app/floors/list.php', + icon: '🏢' + }, + { + id: 'racks', + label: 'Serverschränke', + description: 'Racks, Positionierung, Höheneinheiten', + url: '/app/racks/list.php', + icon: '🗄️' + }, + { + id: 'network_view', + label: 'Netzwerk-Ansicht', + description: 'Grafische Netzwerkdarstellung', + url: '/network.php', + icon: '🌐' + }, + { + id: 'svg_editor', + label: 'SVG-Port-Editor', + description: 'Ports auf Gerätetypen definieren', + url: '/svg-editor.php', + icon: '✏️' + } + ]; + + // ========================= + // Public API + // ========================= + + function init() { + console.log('Dashboard initialized'); + + // TODO: Dashboard-Container ermitteln + // const container = document.querySelector('#dashboard'); + + // TODO: Module rendern + // renderModules(container); + + // TODO: Optional: Status-Daten laden (Counts, Warnings) + } + + // ========================= + // Render Functions + // ========================= + + function renderModules(container) { + if (!container) return; + + container.innerHTML = ''; + + modules.forEach(module => { + const el = document.createElement('div'); + el.className = 'dashboard-tile'; + + el.innerHTML = ` +
${module.icon}
+
+

${module.label}

+

${module.description}

+
+ `; + + el.addEventListener('click', () => { + window.location.href = module.url; + }); + + container.appendChild(el); + }); + } + + // ========================= + // Optional Erweiterungen + // ========================= + + // TODO: loadStats() → Anzahl Geräte, offene Ports, unverbundene Dosen + // TODO: showWarnings() → unverbundene Ports, VLAN-Konflikte + // TODO: RecentChanges() → letzte Änderungen + + // ========================= + // Expose Public Methods + // ========================= + + return { + init, + // renderModules // optional öffentlich machen + }; + +})(); diff --git a/app/bootstrap.php b/app/bootstrap.php index aba3307..186a63f 100644 --- a/app/bootstrap.php +++ b/app/bootstrap.php @@ -28,12 +28,7 @@ session_start(); require_once __DIR__ . '/lib/_sql.php'; // TODO: Host, User, Passwort, DB aus config.php nutzen -$sql = new SQL( - DB_HOST, // z.B. localhost - DB_USER, // z.B. netdoc - DB_PASSWORD, // z.B. netdoc - DB_NAME // z.B. netdoc -); +$sql = new SQL(); /* ========================= * Helper laden diff --git a/app/index.php b/app/index.php index c27b318..da8ba2f 100644 --- a/app/index.php +++ b/app/index.php @@ -58,7 +58,7 @@ if (file_exists($modulePath)) { require_once $modulePath; } else { // TODO: Fehlerseite oder 404 - echo "

Die Seite existiert noch nicht.

"; + echo "

Die Seite existiert noch nicht.

".$modulePath; } /* ========================= diff --git a/app/lib/_sql.php b/app/lib/_sql.php index 16c5c8b..474060f 100644 --- a/app/lib/_sql.php +++ b/app/lib/_sql.php @@ -171,6 +171,4 @@ class SQL { // echo 'DESTROY'; } } - -$sql = new SQL(); ?> \ No newline at end of file diff --git a/app/modules/dashboard/list.php b/app/modules/dashboard/list.php new file mode 100644 index 0000000..3045c8c --- /dev/null +++ b/app/modules/dashboard/list.php @@ -0,0 +1,3 @@ +Dashboard

'; \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 1986a38..1f05e54 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,6 +1,6 @@ services: web: - image: php:8.3-apache + build: . container_name: netdoc_web ports: - "80:80"