diff --git a/public/js/pages/Cpeprovisioning/Cpeprovisioning.js b/public/js/pages/Cpeprovisioning/Cpeprovisioning.js index 63e1ad23e..6cf017632 100644 --- a/public/js/pages/Cpeprovisioning/Cpeprovisioning.js +++ b/public/js/pages/Cpeprovisioning/Cpeprovisioning.js @@ -380,26 +380,29 @@ Vue.component('Cpeprovisioning', { if (val !== undefined) { item.cpe_data.mac = val; } - + const itemKey = item.orderproduct_id; - this.markDirty(item); - + + // Clear existing timer if (this.macInputTimers[itemKey]) { clearTimeout(this.macInputTimers[itemKey]); } - - // Immediate check if it LOOKS like it contains our pattern - const isPotentialScan = item.cpe_data.mac && item.cpe_data.mac.includes('-'); - - if (isPotentialScan) { - // If it has a dash, we process immediately to see if it matches our strict pattern - this.processMacAddress(item); - } else { - // Otherwise debounce (typing manual address) + + // Check if input matches QR code pattern (XXXXXX-XXXXXXXXXXXX) + const qrPattern = /[0-9A-Fa-f]{6}-[0-9A-Fa-f]{12}/; + const hasCompleteQr = qrPattern.test(item.cpe_data.mac || ''); + + if (hasCompleteQr) { + // Complete QR code detected - short delay to ensure full scan is received this.macInputTimers[itemKey] = setTimeout(() => { this.processMacAddress(item); - }, 300); + }, 150); + } else { + // Manual entry or incomplete scan - longer debounce + this.macInputTimers[itemKey] = setTimeout(() => { + this.processMacAddress(item); + }, 600); } }, @@ -416,14 +419,12 @@ Vue.component('Cpeprovisioning', { if (!inputValue) return; - // 1. Try to detect and parse QR code format - // This will ONLY return a value if the XXXXXX-XXXXXXXXXXXX pattern exists - const parsedMac = this.parseMacFromQrCode(inputValue); - - if (parsedMac) { - // A QR-like pattern (XXXXXX-XXXXXXXXXXXX) was found - if (routerType === 'FritzBox 4050' || routerType === 'FritzBox 7690') { - // Perform calculation and full formatting for specific routers + // Only process QR codes for FritzBox 4050 and 7690 + if (routerType === 'FritzBox 4050' || routerType === 'FritzBox 7690') { + const parsedMac = this.parseMacFromQrCode(inputValue); + + if (parsedMac) { + // QR code pattern found, calculate offset and format let offset = 0; if (routerType === 'FritzBox 4050') offset = -3; else if (routerType === 'FritzBox 7690') offset = 2; @@ -439,25 +440,18 @@ Vue.component('Cpeprovisioning', { } } catch (e) { console.error('MAC Calculation error', e); + window.notify('error', 'Fehler bei MAC Berechnung'); } - } else { - // For other routers, just extract the 12-char MAC from QR, but don't apply offset. - // The 'formatting' part (AA:BB:CC...) should only happen for 4050/7690 - // So for other types, we'll just put the raw 12-char MAC from the QR. - if (item.cpe_data.mac !== parsedMac) { - this.$set(item.cpe_data, 'mac', parsedMac); // Store raw 12-char MAC - window.notify('info', 'MAC aus QR extrahiert (keine Berechnung für diesen Routertyp).'); - } + return; // Exit after QR processing } - } else { - // No QR pattern found, apply general manual entry formatting if it's a valid 12-char hex string - const cleanInput = inputValue.replace(/[:-]/g, '').replace(/\s/g, ''); - if (cleanInput.length === 12 && /^[0-9A-Fa-f]{12}$/.test(cleanInput)) { - const formatted = this.formatMacAddress(cleanInput); - if (item.cpe_data.mac !== formatted) { - this.$set(item.cpe_data, 'mac', formatted); - window.notify('info', 'MAC formatiert.'); - } + } + + // For all router types (including 4050/7690 without QR): format manual entry + const cleanInput = inputValue.replace(/[:-]/g, '').replace(/\s/g, ''); + if (cleanInput.length === 12 && /^[0-9A-Fa-f]{12}$/.test(cleanInput)) { + const formatted = this.formatMacAddress(cleanInput); + if (item.cpe_data.mac !== formatted) { + this.$set(item.cpe_data, 'mac', formatted); } } }, @@ -517,6 +511,7 @@ Vue.component('Cpeprovisioning', { ont_sn: item.ont_sn, vlans: item.vlans, ...item.cpe_data, + routertype: item.cpe_data.routertype || '', // Ensure empty string instead of null shipping: item.cpe_data.shipping ? 1 : 0, routerconfig_finished: item.cpe_data.routerconfig_finished ? 1 : 0, };