Update templates/arp.html
This commit is contained in:
parent
202359c9f6
commit
9cb38fbab1
1 changed files with 7 additions and 157 deletions
|
|
@ -1,40 +1,9 @@
|
||||||
<!DOCTYPE html>
|
{% extends "base.html" %}
|
||||||
<html lang="en">
|
|
||||||
<head>
|
{% block title %}AS215085 - Router tools | ARP table{% endblock %}
|
||||||
<meta charset="UTF-8">
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
{% block content %}
|
||||||
<title>AS215085 - Router tools | ARP table</title>
|
<script src="../static/js/pages/arp.js"></script>
|
||||||
<link rel="icon" type="image/png" href="../static/img/cropped-Pixelhosting-logo-favicon-32x32.png">
|
|
||||||
<script src="../static/js/bootstrap.bundle.min.js"></script>
|
|
||||||
<link href="../static/css/bootstrap.min.css" rel="stylesheet">
|
|
||||||
<link href="../static/css/style.css" rel="stylesheet">
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<header>
|
|
||||||
<div class="header-content">
|
|
||||||
<a href="/"> <img src="../static/img/as215085-logo.png" alt="AS215085 Logo" style="height: 120px; opacity: 1;!important"> </a>
|
|
||||||
<h2><b>core1.doet.pixelhosting.nl</b></h2>
|
|
||||||
<p><b>Proudly delivering the backbone for PixelHosting’s services</b></p>
|
|
||||||
</div>
|
|
||||||
</header>
|
|
||||||
<nav class="navbar navbar-expand-lg navbar-light" style="background-color: #07AAF9;">
|
|
||||||
<div class="container-fluid">
|
|
||||||
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav">
|
|
||||||
<span class="navbar-toggler-icon"></span>
|
|
||||||
</button>
|
|
||||||
<div class="collapse navbar-collapse" id="navbarNav">
|
|
||||||
<ul class="navbar-nav justify-content-center w-100">
|
|
||||||
<li class="nav-item"><a class="nav-link text-white" href="/">Home</a></li>
|
|
||||||
<li class="nav-item"><a class="nav-link text-white" href="/bgp">BGP summary</a></li>
|
|
||||||
<li class="nav-item"><a class="nav-link text-white" href="/bgp-route">BGP route</a></li>
|
|
||||||
<li class="nav-item"><a class="nav-link text-white" href="/arp">ARP table</a></li>
|
|
||||||
<li class="nav-item"><a class="nav-link text-white" href="/neighbors">Neighbors table</a></li>
|
|
||||||
<li class="nav-item"><a class="nav-link text-white" href="/interfaces">Interfaces table</a></li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</nav>
|
|
||||||
<main>
|
|
||||||
<section id="arp">
|
<section id="arp">
|
||||||
<div class="input-group mb-3">
|
<div class="input-group mb-3">
|
||||||
<input type="text" id="arpSearch" class="form-control" placeholder="Search in ARP table..." onkeyup="filterTable('arpSearch', 'arpTable')">
|
<input type="text" id="arpSearch" class="form-control" placeholder="Search in ARP table..." onkeyup="filterTable('arpSearch', 'arpTable')">
|
||||||
|
|
@ -65,123 +34,4 @@
|
||||||
</table>
|
</table>
|
||||||
<p><a href="/arp/json">JSON version</a></p>
|
<p><a href="/arp/json">JSON version</a></p>
|
||||||
</section>
|
</section>
|
||||||
</main>
|
{% endblock %}
|
||||||
<footer>
|
|
||||||
<p>© 2020 – <span id="year"></span> AS215085 (PixelHosting). All rights reserved.</p>
|
|
||||||
<script> document.getElementById("year").textContent = new Date().getFullYear(); </script>
|
|
||||||
</footer>
|
|
||||||
<script src="../static/js/materialize.min.js"></script>
|
|
||||||
<script>
|
|
||||||
function filterTable(searchInputId, tableId) {
|
|
||||||
const input = document.getElementById(searchInputId);
|
|
||||||
const filter = input.value.toUpperCase();
|
|
||||||
const table = document.getElementById(tableId);
|
|
||||||
const tr = table.getElementsByTagName("tr");
|
|
||||||
|
|
||||||
for (let i = 1; i < tr.length; i++) {
|
|
||||||
tr[i].style.display = "none";
|
|
||||||
const td = tr[i].getElementsByTagName("td");
|
|
||||||
for (let j = 0; j < td.length; j++) {
|
|
||||||
if (td[j]) {
|
|
||||||
const txtValue = td[j].textContent || td[j].innerText;
|
|
||||||
if (txtValue.toUpperCase().indexOf(filter) > -1) {
|
|
||||||
tr[i].style.display = "";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function sortTable(tableId, columnIndex, th) {
|
|
||||||
const table = document.getElementById(tableId);
|
|
||||||
const tbody = table.tBodies[0];
|
|
||||||
const rows = Array.from(tbody.rows);
|
|
||||||
const headers = Array.from(th.parentNode.children);
|
|
||||||
|
|
||||||
headers.forEach(header => {
|
|
||||||
if (header !== th) {
|
|
||||||
header.classList.remove('asc', 'desc');
|
|
||||||
header.setAttribute('data-sort-state', 'none');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
let currentState = th.getAttribute('data-sort-state') || 'none';
|
|
||||||
let newState = currentState === 'none' ? 'asc' : currentState === 'asc' ? 'desc' : 'none';
|
|
||||||
|
|
||||||
th.classList.remove('asc', 'desc');
|
|
||||||
if (newState !== 'none') th.classList.add(newState);
|
|
||||||
th.setAttribute('data-sort-state', newState);
|
|
||||||
|
|
||||||
if (newState === 'none') {
|
|
||||||
rows.sort((a, b) => parseInt(a.getAttribute('data-index')) - parseInt(b.getAttribute('data-index')));
|
|
||||||
} else {
|
|
||||||
rows.sort((a, b) => {
|
|
||||||
const aText = a.cells[columnIndex].textContent.trim();
|
|
||||||
const bText = b.cells[columnIndex].textContent.trim();
|
|
||||||
|
|
||||||
const aNum = parseFloat(aText.replace(/[^0-9.-]/g, ''));
|
|
||||||
const bNum = parseFloat(bText.replace(/[^0-9.-]/g, ''));
|
|
||||||
const isNumeric = !isNaN(aNum) && !isNaN(bNum);
|
|
||||||
|
|
||||||
return newState === 'asc'
|
|
||||||
? (isNumeric ? aNum - bNum : aText.localeCompare(bText))
|
|
||||||
: (isNumeric ? bNum - aNum : bText.localeCompare(aText));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
rows.forEach(row => tbody.appendChild(row));
|
|
||||||
}
|
|
||||||
|
|
||||||
async function loadArpTable() {
|
|
||||||
const tableBody = document.getElementById("arpTableBody");
|
|
||||||
|
|
||||||
try {
|
|
||||||
const response = await fetch("/arp/json");
|
|
||||||
const data = await response.json();
|
|
||||||
|
|
||||||
tableBody.innerHTML = "";
|
|
||||||
|
|
||||||
if (!data.arp_table || data.arp_table.length === 0) {
|
|
||||||
tableBody.innerHTML = "<tr><td colspan='4' class='text-center'>Geen data beschikbaar.</td></tr>";
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
data.arp_table.forEach((entry, index) => {
|
|
||||||
const row = document.createElement("tr");
|
|
||||||
row.setAttribute("data-index", index);
|
|
||||||
row.innerHTML = `
|
|
||||||
<td>${entry.address}</td>
|
|
||||||
<td>${entry.interface}</td>
|
|
||||||
<td>${entry.link_layer_address}</td>
|
|
||||||
<td>${entry.state}</td>
|
|
||||||
`;
|
|
||||||
tableBody.appendChild(row);
|
|
||||||
});
|
|
||||||
} catch (err) {
|
|
||||||
tableBody.innerHTML = "<tr><td colspan='4' class='text-center text-danger'>Fout bij ophalen van data.</td></tr>";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
window.addEventListener("DOMContentLoaded", () => {
|
|
||||||
loadArpTable();
|
|
||||||
});
|
|
||||||
|
|
||||||
function refreshArpTable() {
|
|
||||||
const searchInput = document.getElementById("arpSearch");
|
|
||||||
const refreshIcon = document.getElementById("refreshIcon");
|
|
||||||
const refreshSpinner = document.getElementById("refreshSpinner");
|
|
||||||
|
|
||||||
searchInput.value = ""; // Leegmaken van het zoekveld
|
|
||||||
|
|
||||||
refreshIcon.classList.add("d-none");
|
|
||||||
refreshSpinner.classList.remove("d-none");
|
|
||||||
|
|
||||||
loadArpTable().then(() => {
|
|
||||||
refreshIcon.classList.remove("d-none");
|
|
||||||
refreshSpinner.classList.add("d-none");
|
|
||||||
});
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue