mirror of
https://github.com/MrUnknownDE/utools.git
synced 2026-04-10 18:23:46 +02:00
add version on footer
This commit is contained in:
@@ -57,6 +57,10 @@ ENV PING_COUNT=4
|
||||
ENV GEOIP_CITY_DB=./data/GeoLite2-City.mmdb
|
||||
ENV GEOIP_ASN_DB=./data/GeoLite2-ASN.mmdb
|
||||
|
||||
# Define build argument and environment variable for Git commit SHA
|
||||
ARG GIT_COMMIT_SHA=unknown
|
||||
ENV GIT_COMMIT_SHA=${GIT_COMMIT_SHA}
|
||||
|
||||
|
||||
# Run the app when the container launches
|
||||
CMD ["node", "server.js"]
|
||||
@@ -611,6 +611,14 @@ app.get('/api/lookup', async (req, res) => {
|
||||
}
|
||||
});
|
||||
|
||||
// Version Endpunkt
|
||||
app.get('/api/version', (req, res) => {
|
||||
const commitSha = process.env.GIT_COMMIT_SHA || 'unknown';
|
||||
logger.info({ commitSha }, 'Version request received');
|
||||
res.json({ commitSha });
|
||||
});
|
||||
|
||||
|
||||
// --- Server starten ---
|
||||
initialize().then(() => {
|
||||
app.listen(PORT, () => {
|
||||
@@ -620,6 +628,7 @@ initialize().then(() => {
|
||||
logger.info(` http://localhost:${PORT}/api/ping?targetIp=<ip>`);
|
||||
logger.info(` http://localhost:${PORT}/api/traceroute?targetIp=<ip>`);
|
||||
logger.info(` http://localhost:${PORT}/api/lookup?targetIp=<ip>`);
|
||||
logger.info(` http://localhost:${PORT}/api/version`);
|
||||
});
|
||||
}).catch(error => {
|
||||
// Fehler bei der Initialisierung wurde bereits geloggt.
|
||||
|
||||
@@ -1,7 +1,12 @@
|
||||
services:
|
||||
# Backend Service (Node.js App)
|
||||
backend:
|
||||
build: ./backend # Pfad zum Verzeichnis mit dem Backend-Dockerfile
|
||||
build:
|
||||
context: ./backend # Pfad zum Verzeichnis mit dem Backend-Dockerfile
|
||||
args:
|
||||
# Übergibt den Git Commit Hash als Build-Argument.
|
||||
# Erwartet, dass GIT_COMMIT_SHA in der Shell-Umgebung gesetzt ist (z.B. export GIT_COMMIT_SHA=$(git rev-parse --short HEAD))
|
||||
- GIT_COMMIT_SHA=${GIT_COMMIT_SHA:-unknown}
|
||||
container_name: utools_backend # Eindeutiger Name für den Container
|
||||
restart: unless-stopped
|
||||
environment:
|
||||
|
||||
@@ -207,6 +207,12 @@
|
||||
<!-- Globaler Fehlerbereich -->
|
||||
<div id="global-error" class="mt-6 p-4 bg-red-800 text-red-100 rounded hidden"></div>
|
||||
|
||||
<!-- Footer für Version -->
|
||||
<footer class="mt-8 pt-4 border-t border-gray-600 text-center text-xs text-gray-500">
|
||||
<p>Version: <span id="commit-sha" class="font-mono">loading...</span></p>
|
||||
</footer>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<!-- Leaflet JS -->
|
||||
|
||||
@@ -66,6 +66,9 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
const tracerouteLoader = document.getElementById('traceroute-loader');
|
||||
const tracerouteMessage = document.getElementById('traceroute-message');
|
||||
|
||||
// --- DOM Elements (Footer) ---
|
||||
const commitShaEl = document.getElementById('commit-sha');
|
||||
|
||||
// --- Configuration ---
|
||||
const API_BASE_URL = '/api'; // Anpassen, falls nötig
|
||||
|
||||
@@ -260,6 +263,22 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
}
|
||||
}
|
||||
|
||||
/** Ruft die Versionsinformationen (Commit SHA) ab */
|
||||
async function fetchVersionInfo() {
|
||||
try {
|
||||
const response = await fetch(`${API_BASE_URL}/version`);
|
||||
if (!response.ok) throw new Error(`Network response: ${response.statusText} (${response.status})`);
|
||||
const data = await response.json();
|
||||
console.log('Received Version Info:', data);
|
||||
if (commitShaEl) {
|
||||
commitShaEl.textContent = data.commitSha || 'unknown';
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Failed to fetch version info:', error);
|
||||
if (commitShaEl) commitShaEl.textContent = 'error';
|
||||
}
|
||||
}
|
||||
|
||||
// --- Lookup Functions ---
|
||||
|
||||
/** Zeigt Fehler im Lookup-Bereich an */
|
||||
@@ -562,6 +581,7 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
|
||||
// --- Initial Load & Event Listeners ---
|
||||
fetchIpInfo(); // Lade Infos zur eigenen IP
|
||||
fetchVersionInfo(); // Lade Versionsinfo für Footer
|
||||
|
||||
lookupButton.addEventListener('click', handleLookupClick);
|
||||
lookupIpInput.addEventListener('keypress', (event) => {
|
||||
|
||||
Reference in New Issue
Block a user