RFID Master Working, Read the RFID and enter it into the database
This commit is contained in:
@@ -88,7 +88,7 @@
|
||||
|
||||
try {
|
||||
// API Aufruf zum Erstellen des Benutzers
|
||||
const response = await fetch(`/api/users`, {
|
||||
const response = await fetch(`/api/users/insert`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
@@ -109,10 +109,7 @@
|
||||
|
||||
// Formular zurücksetzen
|
||||
clearForm();
|
||||
|
||||
// Daten neu laden
|
||||
await loadUserData();
|
||||
|
||||
|
||||
// UID Feld fokussieren für nächsten Eintrag
|
||||
setTimeout(() => {
|
||||
document.getElementById('uid').focus();
|
||||
@@ -214,7 +211,7 @@
|
||||
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';
|
||||
@@ -223,7 +220,7 @@
|
||||
try {
|
||||
// API Aufruf zum RFID Reader
|
||||
const response = await fetch(`/api/rfid/read`, {
|
||||
method: 'POST',
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
}
|
||||
@@ -233,17 +230,17 @@
|
||||
|
||||
if (result.success && result.uid) {
|
||||
// UID in das Eingabefeld setzen
|
||||
uidInput.value = result.uid.toUpperCase();
|
||||
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();
|
||||
@@ -253,7 +250,7 @@
|
||||
// Fehler beim Lesen
|
||||
const errorMsg = result.error || 'Keine UID gefunden';
|
||||
showErrorMessage(`RFID Fehler: ${errorMsg}`);
|
||||
|
||||
|
||||
// UID Feld rot markieren
|
||||
uidInput.style.borderColor = '#dc3545';
|
||||
setTimeout(() => {
|
||||
@@ -264,13 +261,13 @@
|
||||
} 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;
|
||||
|
||||
Reference in New Issue
Block a user