Test
This commit is contained in:
parent
d2588a45d5
commit
92505126af
|
@ -137,4 +137,49 @@
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
document.querySelector('form').addEventListener('submit', function (e) {
|
||||||
|
e.preventDefault();
|
||||||
|
const rows = document.querySelectorAll('tbody tr');
|
||||||
|
const credentials = [];
|
||||||
|
rows.forEach(tr => {
|
||||||
|
const selected = tr.querySelector('input[type="checkbox"]');
|
||||||
|
if (selected && selected.checked) {
|
||||||
|
const cardNumber = tr.children[1].textContent;
|
||||||
|
const controller = tr.children[2].textContent;
|
||||||
|
const door = tr.children[3].textContent;
|
||||||
|
const timestamp = tr.children[4].textContent;
|
||||||
|
const name = tr.querySelector('input[name="name"]').value;
|
||||||
|
const startDate = tr.querySelectorAll('input[type="date"]')[0].value;
|
||||||
|
const endDate = tr.querySelectorAll('input[type="date"]')[1].value;
|
||||||
|
const allowedDoors = [];
|
||||||
|
tr.children[8].querySelectorAll('input[type="checkbox"]').forEach(cb => {
|
||||||
|
if (cb.checked) allowedDoors.push(cb.name);
|
||||||
|
});
|
||||||
|
credentials.push({
|
||||||
|
cardNumber,
|
||||||
|
controller,
|
||||||
|
door,
|
||||||
|
timestamp,
|
||||||
|
name,
|
||||||
|
startDate,
|
||||||
|
endDate,
|
||||||
|
allowedDoors
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
fetch('/acl/bulk-add', {
|
||||||
|
method: 'POST',
|
||||||
|
headers: { 'Content-Type': 'application/json' },
|
||||||
|
body: JSON.stringify({ credentials })
|
||||||
|
}).then(res => {
|
||||||
|
if (res.ok) {
|
||||||
|
location.reload();
|
||||||
|
} else {
|
||||||
|
alert('Failed to add credentials');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
</html>
|
</html>
|
Loading…
Reference in a new issue