From a7679663ccfa7e330c9642b5ab080a47aab1f5a8 Mon Sep 17 00:00:00 2001 From: Simon Cloutier Date: Fri, 28 Mar 2025 16:47:54 -0400 Subject: [PATCH] add user button fixed --- app/templates/user_list_inline_edit.html | 51 ++++++++++++++++-------- 1 file changed, 35 insertions(+), 16 deletions(-) diff --git a/app/templates/user_list_inline_edit.html b/app/templates/user_list_inline_edit.html index 259b7e3..1287913 100644 --- a/app/templates/user_list_inline_edit.html +++ b/app/templates/user_list_inline_edit.html @@ -20,7 +20,13 @@ - + @@ -120,14 +126,14 @@ function updateUser(mac_address) { const description = document.getElementById('description-' + mac_address).value; const vlan_id = document.getElementById('vlan_id-' + mac_address).value; - const mac_address_input = document.getElementById('mac_address-' + mac_address).value; + const mac_address_input = document.getElementById('mac_address-' + mac_address).value; //added fetch('/update_user', { method: 'POST', headers: { 'Content-Type': 'application/x-www-form-urlencoded', }, - body: `mac_address=${mac_address}&description=${description}&vlan_id=${vlan_id}&new_mac_address=${mac_address_input}` + body: `mac_address=${mac_address}&description=${description}&vlan_id=${vlan_id}&new_mac_address=${mac_address_input}` //added new param }) .then(response => response.text()) .then(data => { @@ -151,6 +157,8 @@ } } + + function duplicateUser(mac_address) { fetch('/duplicate_user', { method: 'POST', @@ -185,6 +193,8 @@ `; + + newTable += ` @@ -206,18 +216,20 @@ function saveDuplicatedUser() { let rows = document.querySelectorAll('#duplicate-dialog-content table tbody tr'); - let new_mac_address = rows[0].querySelector('#new-mac').value; + let new_mac_address = rows[0].querySelector('#new-mac').value; //changed let attributes = []; for (let i = 1; i < rows.length - 1; i++) { const descriptionInput = rows[i].querySelector(`.new-description`); const vlanIdInput = rows[i].querySelector(`.new-vlan_id`); + if (descriptionInput && vlanIdInput) { attributes.push({ description: descriptionInput.value, vlan_id: vlanIdInput.value, }); } else { + console.warn(`Input elements not found for row ${i}`); return; } @@ -228,7 +240,7 @@ headers: { 'Content-Type': 'application/json', }, - body: JSON.stringify({ mac_address: new_mac_address, attributes: attributes }) + body: JSON.stringify({ mac_address: new_mac_address, attributes: attributes }) //changed }) .then(response => response.text()) .then(data => { @@ -242,14 +254,18 @@ } function addDuplicatedUserRow(button) { - const table = button.parentNode.parentNode.parentNode; + const table = button.parentNode.parentNode.parentNode; //get the table const newRow = table.insertRow(table.rows.length - 1); + + const cell1 = newRow.insertCell(0); const cell2 = newRow.insertCell(1); const cell3 = newRow.insertCell(2); const cell4 = newRow.insertCell(3); + + cell1.classList.add('merged-cell'); cell2.innerHTML = ``; cell3.innerHTML = `