Refactor MAC address debouncing logic and add local settings configuration

This commit is contained in:
2025-12-01 12:20:47 +01:00
parent 902bd03664
commit 489a67cda8

View File

@@ -175,7 +175,7 @@ Vue.component('Cpeprovisioning', {
page: 1,
pagination: {},
debouncedFetchData: null,
debouncedMacHandlers: {}, // Store debounced handlers per item
macInputTimers: {}, // Store timers for debouncing MAC input
extensionId: 'jglijfiddilckddlmbnlojmmlahboffh',
showExtensionIdModal: false,
processingMacItems: new Set() // Track items currently being processed
@@ -200,6 +200,10 @@ Vue.component('Cpeprovisioning', {
},
beforeDestroy() {
window.removeEventListener('keydown', this.handleKeydown);
// Clear all pending MAC input timers
Object.keys(this.macInputTimers).forEach(key => {
clearTimeout(this.macInputTimers[key]);
});
},
methods: {
copyToClipboard(text) {
@@ -355,18 +359,18 @@ Vue.component('Cpeprovisioning', {
this.markDirty(item);
// Create a debounced handler for this item if it doesn't exist
if (!this.debouncedMacHandlers[itemKey]) {
console.log('[MAC Input] Creating debounced handler for item:', itemKey);
this.debouncedMacHandlers[itemKey] = _.debounce((itm) => {
console.log('[MAC Input] Debounced handler executing for item:', itemKey);
this.processMacAddress(itm);
}, 300); // 300ms delay to wait for barcode scanner to finish
// Clear existing timer for this item
if (this.macInputTimers[itemKey]) {
console.log('[MAC Input] Clearing existing timer for item:', itemKey);
clearTimeout(this.macInputTimers[itemKey]);
}
// Call the debounced handler
console.log('[MAC Input] Calling debounced handler');
this.debouncedMacHandlers[itemKey](item);
// Create new timer (debounce with 300ms delay)
console.log('[MAC Input] Creating new debounce timer for item:', itemKey);
this.macInputTimers[itemKey] = setTimeout(() => {
console.log('[MAC Input] Debounce timer fired for item:', itemKey);
this.processMacAddress(item);
}, 300); // 300ms delay to wait for barcode scanner to finish
},
handleRouterTypeChange(item) {
console.log('[Router Type Change] Router type changed, checking if MAC needs processing');