RFID erstellung raugeflogen
This commit is contained in:
242
data/rfid.css
242
data/rfid.css
@@ -1,242 +0,0 @@
|
|||||||
* {
|
|
||||||
margin: 0;
|
|
||||||
padding: 0;
|
|
||||||
box-sizing: border-box;
|
|
||||||
}
|
|
||||||
|
|
||||||
body {
|
|
||||||
font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
|
|
||||||
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
|
||||||
min-height: 100vh;
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
padding: 20px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.container {
|
|
||||||
background: rgba(255, 255, 255, 0.95);
|
|
||||||
padding: 40px;
|
|
||||||
border-radius: 20px;
|
|
||||||
box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
|
|
||||||
backdrop-filter: blur(10px);
|
|
||||||
width: 100%;
|
|
||||||
max-width: 500px;
|
|
||||||
animation: slideIn 0.5s ease-out;
|
|
||||||
}
|
|
||||||
|
|
||||||
@keyframes slideIn {
|
|
||||||
from {
|
|
||||||
opacity: 0;
|
|
||||||
transform: translateY(30px);
|
|
||||||
}
|
|
||||||
to {
|
|
||||||
opacity: 1;
|
|
||||||
transform: translateY(0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.header {
|
|
||||||
text-align: center;
|
|
||||||
margin-bottom: 30px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.header h1 {
|
|
||||||
color: #333;
|
|
||||||
font-size: 2em;
|
|
||||||
margin-bottom: 10px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.header p {
|
|
||||||
color: #666;
|
|
||||||
font-size: 1.1em;
|
|
||||||
}
|
|
||||||
|
|
||||||
.form-group {
|
|
||||||
margin-bottom: 25px;
|
|
||||||
position: relative;
|
|
||||||
}
|
|
||||||
|
|
||||||
.form-group label {
|
|
||||||
display: block;
|
|
||||||
margin-bottom: 8px;
|
|
||||||
color: #333;
|
|
||||||
font-weight: 600;
|
|
||||||
font-size: 1em;
|
|
||||||
}
|
|
||||||
|
|
||||||
.form-group input {
|
|
||||||
width: 100%;
|
|
||||||
padding: 15px;
|
|
||||||
border: 2px solid #e1e5e9;
|
|
||||||
border-radius: 10px;
|
|
||||||
font-size: 1em;
|
|
||||||
transition: all 0.3s ease;
|
|
||||||
background: #fff;
|
|
||||||
}
|
|
||||||
|
|
||||||
.form-group input:focus {
|
|
||||||
outline: none;
|
|
||||||
border-color: #667eea;
|
|
||||||
box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
|
|
||||||
transform: translateY(-2px);
|
|
||||||
}
|
|
||||||
|
|
||||||
.form-group input:hover {
|
|
||||||
border-color: #667eea;
|
|
||||||
}
|
|
||||||
|
|
||||||
.required {
|
|
||||||
color: #e74c3c;
|
|
||||||
}
|
|
||||||
|
|
||||||
.btn-container {
|
|
||||||
display: flex;
|
|
||||||
gap: 15px;
|
|
||||||
margin-top: 30px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.btn {
|
|
||||||
flex: 1;
|
|
||||||
padding: 15px 25px;
|
|
||||||
border: none;
|
|
||||||
border-radius: 10px;
|
|
||||||
font-size: 1.1em;
|
|
||||||
font-weight: 600;
|
|
||||||
cursor: pointer;
|
|
||||||
transition: all 0.3s ease;
|
|
||||||
text-transform: uppercase;
|
|
||||||
letter-spacing: 0.5px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.btn-primary {
|
|
||||||
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
|
||||||
color: white;
|
|
||||||
}
|
|
||||||
|
|
||||||
.btn-primary:hover {
|
|
||||||
transform: translateY(-2px);
|
|
||||||
box-shadow: 0 10px 20px rgba(102, 126, 234, 0.3);
|
|
||||||
}
|
|
||||||
|
|
||||||
.btn-secondary {
|
|
||||||
background: #f8f9fa;
|
|
||||||
color: #666;
|
|
||||||
border: 2px solid #e1e5e9;
|
|
||||||
}
|
|
||||||
|
|
||||||
.btn-secondary:hover {
|
|
||||||
background: #e9ecef;
|
|
||||||
transform: translateY(-2px);
|
|
||||||
}
|
|
||||||
|
|
||||||
.success-message {
|
|
||||||
background: #d4edda;
|
|
||||||
color: #155724;
|
|
||||||
padding: 15px;
|
|
||||||
border-radius: 8px;
|
|
||||||
margin-bottom: 20px;
|
|
||||||
border: 1px solid #c3e6cb;
|
|
||||||
animation: fadeIn 0.3s ease-out;
|
|
||||||
}
|
|
||||||
|
|
||||||
.read-uid-btn {
|
|
||||||
background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
|
|
||||||
color: white;
|
|
||||||
border: none;
|
|
||||||
padding: 15px 20px;
|
|
||||||
border-radius: 10px;
|
|
||||||
font-size: 0.9em;
|
|
||||||
font-weight: 600;
|
|
||||||
cursor: pointer;
|
|
||||||
transition: all 0.3s ease;
|
|
||||||
text-transform: uppercase;
|
|
||||||
letter-spacing: 0.5px;
|
|
||||||
white-space: nowrap;
|
|
||||||
min-width: 120px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.read-uid-btn:hover {
|
|
||||||
transform: translateY(-2px);
|
|
||||||
box-shadow: 0 8px 16px rgba(40, 167, 69, 0.3);
|
|
||||||
}
|
|
||||||
|
|
||||||
.read-uid-btn:disabled {
|
|
||||||
background: #6c757d;
|
|
||||||
cursor: not-allowed;
|
|
||||||
transform: none;
|
|
||||||
box-shadow: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
.read-uid-btn.reading {
|
|
||||||
background: linear-gradient(135deg, #fd7e14 0%, #e83e8c 100%);
|
|
||||||
animation: pulse 1.5s infinite;
|
|
||||||
}
|
|
||||||
|
|
||||||
@keyframes pulse {
|
|
||||||
0% {
|
|
||||||
transform: scale(1);
|
|
||||||
}
|
|
||||||
50% {
|
|
||||||
transform: scale(1.05);
|
|
||||||
}
|
|
||||||
100% {
|
|
||||||
transform: scale(1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@keyframes fadeIn {
|
|
||||||
from {
|
|
||||||
opacity: 0;
|
|
||||||
transform: translateX(-20px);
|
|
||||||
}
|
|
||||||
to {
|
|
||||||
opacity: 1;
|
|
||||||
transform: translateX(0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Geburtsdatum Styling */
|
|
||||||
.date-input-group {
|
|
||||||
position: relative;
|
|
||||||
}
|
|
||||||
|
|
||||||
.date-input-group input[type="date"] {
|
|
||||||
position: relative;
|
|
||||||
color-scheme: light;
|
|
||||||
}
|
|
||||||
|
|
||||||
.date-input-group input[type="date"]::-webkit-calendar-picker-indicator {
|
|
||||||
background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="%23667eea" viewBox="0 0 16 16"><path d="M3.5 0a.5.5 0 0 1 .5.5V1h8V.5a.5.5 0 0 1 1 0V1h1a2 2 0 0 1 2 2v11a2 2 0 0 1-2 2H2a2 2 0 0 1-2-2V3a2 2 0 0 1 2-2h1V.5a.5.5 0 0 1 .5-.5zM1 4v10a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1V4H1z"/></svg>')
|
|
||||||
no-repeat;
|
|
||||||
background-size: contain;
|
|
||||||
width: 20px;
|
|
||||||
height: 20px;
|
|
||||||
cursor: pointer;
|
|
||||||
}
|
|
||||||
|
|
||||||
.age-display {
|
|
||||||
position: absolute;
|
|
||||||
right: 15px;
|
|
||||||
top: 50%;
|
|
||||||
transform: translateY(-50%);
|
|
||||||
color: #667eea;
|
|
||||||
font-weight: 600;
|
|
||||||
font-size: 0.9em;
|
|
||||||
pointer-events: none;
|
|
||||||
background: rgba(255, 255, 255, 0.9);
|
|
||||||
padding: 2px 8px;
|
|
||||||
border-radius: 4px;
|
|
||||||
border: 1px solid #e1e5e9;
|
|
||||||
}
|
|
||||||
|
|
||||||
@media (max-width: 600px) {
|
|
||||||
.container {
|
|
||||||
padding: 30px 20px;
|
|
||||||
margin: 10px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.btn-container {
|
|
||||||
flex-direction: column;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
451
data/rfid.html
451
data/rfid.html
@@ -1,451 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html lang="de">
|
|
||||||
<head>
|
|
||||||
<meta charset="UTF-8" />
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
||||||
<link rel="stylesheet" href="rfid.css" />
|
|
||||||
<link rel="icon" type="image/x-icon" href="/pictures/favicon.ico" />
|
|
||||||
|
|
||||||
<title>RFID Daten Eingabe</title>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<div class="container">
|
|
||||||
<div class="header">
|
|
||||||
<div
|
|
||||||
style="
|
|
||||||
display: flex;
|
|
||||||
justify-content: space-between;
|
|
||||||
align-items: center;
|
|
||||||
margin-bottom: 10px;
|
|
||||||
"
|
|
||||||
>
|
|
||||||
<button
|
|
||||||
onclick="window.location.href='/settings'"
|
|
||||||
class="back-btn"
|
|
||||||
style="
|
|
||||||
background: #6c757d;
|
|
||||||
color: white;
|
|
||||||
border: none;
|
|
||||||
padding: 8px 15px;
|
|
||||||
border-radius: 5px;
|
|
||||||
cursor: pointer;
|
|
||||||
font-size: 14px;
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
gap: 5px;
|
|
||||||
"
|
|
||||||
>
|
|
||||||
← Zurück zu Einstellungen
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
<h1>🏷️ RFID Daten Eingabe</h1>
|
|
||||||
<p>Erfassen Sie RFID-Tag Informationen</p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div id="successMessage" class="success-message" style="display: none">
|
|
||||||
✅ Daten erfolgreich gespeichert!
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<form id="rfidForm">
|
|
||||||
<div class="form-group">
|
|
||||||
<label for="uid">RFID UID <span class="required">*</span></label>
|
|
||||||
<div style="display: flex; gap: 10px; align-items: stretch">
|
|
||||||
<input
|
|
||||||
type="text"
|
|
||||||
id="uid"
|
|
||||||
name="uid"
|
|
||||||
placeholder="z.B. A1:B2:C3:D4"
|
|
||||||
required
|
|
||||||
style="flex: 1"
|
|
||||||
/>
|
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
id="readUidBtn"
|
|
||||||
class="read-uid-btn"
|
|
||||||
onclick="readRFIDUID()"
|
|
||||||
>
|
|
||||||
📡 Read Chip
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="form-group">
|
|
||||||
<label for="vorname">Vorname <span class="required">*</span></label>
|
|
||||||
<input
|
|
||||||
type="text"
|
|
||||||
id="vorname"
|
|
||||||
name="vorname"
|
|
||||||
placeholder="Vorname eingeben"
|
|
||||||
required
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="form-group">
|
|
||||||
<label for="nachname">Nachname <span class="required">*</span></label>
|
|
||||||
<input
|
|
||||||
type="text"
|
|
||||||
id="nachname"
|
|
||||||
name="nachname"
|
|
||||||
placeholder="Nachname eingeben"
|
|
||||||
required
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="form-group">
|
|
||||||
<label for="geburtsdatum"
|
|
||||||
>Geburtsdatum <span class="required">*</span></label
|
|
||||||
>
|
|
||||||
<div class="date-input-group">
|
|
||||||
<input
|
|
||||||
type="date"
|
|
||||||
id="geburtsdatum"
|
|
||||||
name="geburtsdatum"
|
|
||||||
required
|
|
||||||
max=""
|
|
||||||
/>
|
|
||||||
<div
|
|
||||||
id="ageDisplay"
|
|
||||||
class="age-display"
|
|
||||||
style="display: none"
|
|
||||||
></div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="btn-container">
|
|
||||||
<button type="submit" class="btn btn-primary">💾 Speichern</button>
|
|
||||||
<button type="button" class="btn btn-secondary" onclick="clearForm()">
|
|
||||||
🗑️ Zurücksetzen
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
// Globale Variablen
|
|
||||||
let rfidData = [];
|
|
||||||
let isLoading = false;
|
|
||||||
let DBUrl = "ninja.reptilfpv.de:3000";
|
|
||||||
var APIKey;
|
|
||||||
|
|
||||||
// Maximales Datum auf heute setzen
|
|
||||||
document.addEventListener("DOMContentLoaded", function () {
|
|
||||||
const today = new Date().toISOString().split("T")[0];
|
|
||||||
document.getElementById("geburtsdatum").setAttribute("max", today);
|
|
||||||
});
|
|
||||||
|
|
||||||
// Alter berechnen und anzeigen
|
|
||||||
function calculateAge(birthDate) {
|
|
||||||
const today = new Date();
|
|
||||||
const birth = new Date(birthDate);
|
|
||||||
let age = today.getFullYear() - birth.getFullYear();
|
|
||||||
const monthDiff = today.getMonth() - birth.getMonth();
|
|
||||||
|
|
||||||
if (
|
|
||||||
monthDiff < 0 ||
|
|
||||||
(monthDiff === 0 && today.getDate() < birth.getDate())
|
|
||||||
) {
|
|
||||||
age--;
|
|
||||||
}
|
|
||||||
|
|
||||||
return age;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Geburtsdatum Change Event
|
|
||||||
document
|
|
||||||
.getElementById("geburtsdatum")
|
|
||||||
.addEventListener("change", function (e) {
|
|
||||||
const birthDate = e.target.value;
|
|
||||||
const ageDisplay = document.getElementById("ageDisplay");
|
|
||||||
|
|
||||||
if (birthDate) {
|
|
||||||
const age = calculateAge(birthDate);
|
|
||||||
if (age >= 0 && age <= 150) {
|
|
||||||
ageDisplay.textContent = `${age} Jahre`;
|
|
||||||
ageDisplay.style.display = "block";
|
|
||||||
} else {
|
|
||||||
ageDisplay.style.display = "none";
|
|
||||||
if (age < 0) {
|
|
||||||
showErrorMessage(
|
|
||||||
"Das Geburtsdatum kann nicht in der Zukunft liegen!"
|
|
||||||
);
|
|
||||||
e.target.value = "";
|
|
||||||
} else {
|
|
||||||
showErrorMessage("Bitte überprüfen Sie das Geburtsdatum!");
|
|
||||||
e.target.value = "";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
ageDisplay.style.display = "none";
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// Form Submit Handler
|
|
||||||
document
|
|
||||||
.getElementById("rfidForm")
|
|
||||||
.addEventListener("submit", async function (e) {
|
|
||||||
e.preventDefault();
|
|
||||||
|
|
||||||
if (isLoading) return;
|
|
||||||
|
|
||||||
// Daten aus dem Formular holen
|
|
||||||
const uid = document.getElementById("uid").value.trim();
|
|
||||||
const vorname = document.getElementById("vorname").value.trim();
|
|
||||||
const nachname = document.getElementById("nachname").value.trim();
|
|
||||||
const geburtsdatum = document.getElementById("geburtsdatum").value;
|
|
||||||
|
|
||||||
// Validierung
|
|
||||||
if (!uid || !vorname || !nachname || !geburtsdatum) {
|
|
||||||
showErrorMessage("Bitte füllen Sie alle Pflichtfelder aus!");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Alter berechnen
|
|
||||||
const alter = calculateAge(geburtsdatum);
|
|
||||||
if (alter < 0) {
|
|
||||||
showErrorMessage(
|
|
||||||
"Das Geburtsdatum kann nicht in der Zukunft liegen!"
|
|
||||||
);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Loading State
|
|
||||||
setLoadingState(true);
|
|
||||||
|
|
||||||
try {
|
|
||||||
// API Aufruf zum Erstellen des Benutzers
|
|
||||||
const response = await fetch(`/api/users/insert`, {
|
|
||||||
method: "POST",
|
|
||||||
headers: {
|
|
||||||
"Content-Type": "application/json",
|
|
||||||
...(APIKey && { Authorization: `Bearer ${APIKey}` }),
|
|
||||||
},
|
|
||||||
body: JSON.stringify({
|
|
||||||
uid: uid,
|
|
||||||
vorname: vorname,
|
|
||||||
nachname: nachname,
|
|
||||||
geburtsdatum: geburtsdatum,
|
|
||||||
alter: alter, // Berechnetes Alter wird mit gesendet
|
|
||||||
}),
|
|
||||||
});
|
|
||||||
|
|
||||||
const result = await response.json();
|
|
||||||
|
|
||||||
if (result.success) {
|
|
||||||
// Erfolg anzeigen
|
|
||||||
showSuccessMessage("Benutzer erfolgreich gespeichert!");
|
|
||||||
|
|
||||||
// Formular zurücksetzen
|
|
||||||
clearForm();
|
|
||||||
|
|
||||||
// UID Feld fokussieren für nächsten Eintrag
|
|
||||||
setTimeout(() => {
|
|
||||||
document.getElementById("uid").focus();
|
|
||||||
}, 100);
|
|
||||||
} else {
|
|
||||||
// Fehler anzeigen
|
|
||||||
showErrorMessage(
|
|
||||||
result.error || "Fehler beim Speichern der Daten"
|
|
||||||
);
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
console.error("Fehler beim Speichern:", error);
|
|
||||||
showErrorMessage(
|
|
||||||
"Verbindungsfehler zum Server. Bitte versuchen Sie es später erneut."
|
|
||||||
);
|
|
||||||
} finally {
|
|
||||||
setLoadingState(false);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
function showSuccessMessage(message = "Daten erfolgreich gespeichert!") {
|
|
||||||
const successMsg = document.getElementById("successMessage");
|
|
||||||
successMsg.textContent = `✅ ${message}`;
|
|
||||||
successMsg.style.display = "block";
|
|
||||||
setTimeout(() => {
|
|
||||||
successMsg.style.display = "none";
|
|
||||||
}, 3000);
|
|
||||||
}
|
|
||||||
|
|
||||||
function showErrorMessage(message) {
|
|
||||||
// Fehlermeldung dynamisch erstellen
|
|
||||||
let errorDiv = document.getElementById("errorMessage");
|
|
||||||
if (!errorDiv) {
|
|
||||||
errorDiv = document.createElement("div");
|
|
||||||
errorDiv.id = "errorMessage";
|
|
||||||
errorDiv.className = "error-message";
|
|
||||||
errorDiv.style.cssText = `
|
|
||||||
background: #f8d7da;
|
|
||||||
color: #721c24;
|
|
||||||
padding: 15px;
|
|
||||||
border-radius: 8px;
|
|
||||||
margin-bottom: 20px;
|
|
||||||
border: 1px solid #f5c6cb;
|
|
||||||
animation: fadeIn 0.3s ease-out;
|
|
||||||
display: none;
|
|
||||||
`;
|
|
||||||
document
|
|
||||||
.querySelector(".container")
|
|
||||||
.insertBefore(errorDiv, document.getElementById("rfidForm"));
|
|
||||||
}
|
|
||||||
|
|
||||||
errorDiv.textContent = `❌ ${message}`;
|
|
||||||
errorDiv.style.display = "block";
|
|
||||||
setTimeout(() => {
|
|
||||||
errorDiv.style.display = "none";
|
|
||||||
}, 10000);
|
|
||||||
}
|
|
||||||
|
|
||||||
function setLoadingState(loading) {
|
|
||||||
isLoading = loading;
|
|
||||||
const submitBtn = document.querySelector(".btn-primary");
|
|
||||||
const form = document.getElementById("rfidForm");
|
|
||||||
|
|
||||||
if (loading) {
|
|
||||||
submitBtn.textContent = "⏳ Speichern...";
|
|
||||||
submitBtn.disabled = true;
|
|
||||||
form.style.opacity = "0.7";
|
|
||||||
} else {
|
|
||||||
submitBtn.textContent = "💾 Speichern";
|
|
||||||
submitBtn.disabled = false;
|
|
||||||
form.style.opacity = "1";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function clearForm() {
|
|
||||||
document.getElementById("rfidForm").reset();
|
|
||||||
document.getElementById("ageDisplay").style.display = "none";
|
|
||||||
document.getElementById("uid").focus();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Beim Laden der Seite
|
|
||||||
window.addEventListener("load", function () {
|
|
||||||
document.getElementById("uid").focus();
|
|
||||||
checkServerStatus();
|
|
||||||
loadLicence();
|
|
||||||
});
|
|
||||||
|
|
||||||
// Enter-Taste in UID Feld zum nächsten Feld springen
|
|
||||||
document.getElementById("uid").addEventListener("keydown", function (e) {
|
|
||||||
if (e.key === "Enter") {
|
|
||||||
e.preventDefault();
|
|
||||||
document.getElementById("vorname").focus();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// Automatische UID Formatierung
|
|
||||||
document.getElementById("uid").addEventListener("input", function (e) {
|
|
||||||
let value = e.target.value.toUpperCase();
|
|
||||||
// Entfernen aller nicht-hexadezimalen Zeichen außer Doppelpunkt
|
|
||||||
value = value.replace(/[^0-9A-F:]/g, "");
|
|
||||||
e.target.value = value;
|
|
||||||
});
|
|
||||||
|
|
||||||
// RFID UID lesen
|
|
||||||
async function readRFIDUID() {
|
|
||||||
const readBtn = document.getElementById("readUidBtn");
|
|
||||||
const uidInput = document.getElementById("uid");
|
|
||||||
|
|
||||||
// Button Status ändern
|
|
||||||
readBtn.disabled = true;
|
|
||||||
readBtn.className = "read-uid-btn reading";
|
|
||||||
readBtn.innerHTML = "📡 Lese UID...";
|
|
||||||
|
|
||||||
try {
|
|
||||||
// API Aufruf zum RFID Reader
|
|
||||||
const response = await fetch(`/api/rfid/read`, {
|
|
||||||
method: "GET",
|
|
||||||
headers: {
|
|
||||||
"Content-Type": "application/json",
|
|
||||||
...(APIKey && { Authorization: `Bearer ${APIKey}` }),
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const result = await response.json();
|
|
||||||
|
|
||||||
if (result.success && result.uid) {
|
|
||||||
// UID in das Eingabefeld setzen
|
|
||||||
uidInput.value = result.uid
|
|
||||||
.match(/.{1,2}/g)
|
|
||||||
.join(":")
|
|
||||||
.toUpperCase();
|
|
||||||
uidInput.focus();
|
|
||||||
|
|
||||||
// Visuelles Feedback
|
|
||||||
uidInput.style.borderColor = "#28a745";
|
|
||||||
setTimeout(() => {
|
|
||||||
uidInput.style.borderColor = "#e1e5e9";
|
|
||||||
}, 2000);
|
|
||||||
|
|
||||||
showSuccessMessage("UID erfolgreich gelesen!");
|
|
||||||
|
|
||||||
// Automatisch zum nächsten Feld springen
|
|
||||||
setTimeout(() => {
|
|
||||||
document.getElementById("vorname").focus();
|
|
||||||
}, 500);
|
|
||||||
} else {
|
|
||||||
// Fehler beim Lesen
|
|
||||||
const errorMsg = result.error || "Keine UID gefunden";
|
|
||||||
showErrorMessage(`RFID Fehler: ${errorMsg}`);
|
|
||||||
|
|
||||||
// UID Feld rot markieren
|
|
||||||
uidInput.style.borderColor = "#dc3545";
|
|
||||||
setTimeout(() => {
|
|
||||||
uidInput.style.borderColor = "#e1e5e9";
|
|
||||||
}, 10000);
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
console.error("Fehler beim Lesen der UID:", error);
|
|
||||||
showErrorMessage(
|
|
||||||
"Verbindungsfehler zum RFID Reader. Bitte prüfen Sie die Verbindung."
|
|
||||||
);
|
|
||||||
|
|
||||||
// UID Feld rot markieren
|
|
||||||
uidInput.style.borderColor = "#dc3545";
|
|
||||||
setTimeout(() => {
|
|
||||||
uidInput.style.borderColor = "#e1e5e9";
|
|
||||||
}, 3000);
|
|
||||||
} finally {
|
|
||||||
// Button Status zurücksetzen
|
|
||||||
readBtn.disabled = false;
|
|
||||||
readBtn.className = "read-uid-btn";
|
|
||||||
readBtn.innerHTML = "📡 Read Chip";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async function checkServerStatus() {
|
|
||||||
try {
|
|
||||||
const response = await fetch("/api/health", {
|
|
||||||
headers: {
|
|
||||||
...(APIKey && { Authorization: `Bearer ${APIKey}` }),
|
|
||||||
},
|
|
||||||
});
|
|
||||||
const data = await response.json();
|
|
||||||
|
|
||||||
if (!data.status || data.status !== "connected") {
|
|
||||||
showErrorMessage(
|
|
||||||
"Server nicht verbunden. Einige Funktionen könnten eingeschränkt sein."
|
|
||||||
);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
} catch (error) {
|
|
||||||
console.error("Server Status Check fehlgeschlagen:", error);
|
|
||||||
showErrorMessage("Verbindung zum Server nicht möglich.");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function loadLicence() {
|
|
||||||
fetch("/api/get-licence")
|
|
||||||
.then((response) => response.json())
|
|
||||||
.then((data) => {
|
|
||||||
APIKey = data.licence || "";
|
|
||||||
})
|
|
||||||
.catch((error) =>
|
|
||||||
showMessage("Fehler beim Laden der Lizenz", "error")
|
|
||||||
);
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -38,7 +38,6 @@
|
|||||||
<!-- Navigation Buttons -->
|
<!-- Navigation Buttons -->
|
||||||
<div class="nav-buttons">
|
<div class="nav-buttons">
|
||||||
<a href="/" class="nav-button">🏠 Hauptseite</a>
|
<a href="/" class="nav-button">🏠 Hauptseite</a>
|
||||||
<a href="/rfid" class="nav-button">📡 RFID</a>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Date & Time Section -->
|
<!-- Date & Time Section -->
|
||||||
|
|||||||
@@ -33,9 +33,6 @@ void setupRoutes() {
|
|||||||
request->send(SPIFFS, "/settings.html", "text/html");
|
request->send(SPIFFS, "/settings.html", "text/html");
|
||||||
});
|
});
|
||||||
|
|
||||||
server.on("/rfid", HTTP_GET, [](AsyncWebServerRequest *request) {
|
|
||||||
request->send(SPIFFS, "/rfid.html", "text/html");
|
|
||||||
});
|
|
||||||
|
|
||||||
server.on("/firmware.bin", HTTP_GET, [](AsyncWebServerRequest *request) {
|
server.on("/firmware.bin", HTTP_GET, [](AsyncWebServerRequest *request) {
|
||||||
if (SPIFFS.exists("/firmware.bin")) {
|
if (SPIFFS.exists("/firmware.bin")) {
|
||||||
|
|||||||
Reference in New Issue
Block a user