Improvements, fixes
This commit is contained in:
parent
6c391e8c0a
commit
c17cace17c
3 changed files with 95 additions and 27 deletions
64
index.html
64
index.html
|
@ -5,12 +5,19 @@
|
|||
<style>
|
||||
.status_online {
|
||||
background-color: lawngreen;
|
||||
color: black;
|
||||
}
|
||||
.status_offline {
|
||||
background-color: orangered;
|
||||
color: black;
|
||||
}
|
||||
.status_free {
|
||||
background-color: dimgray;
|
||||
color: black;
|
||||
}
|
||||
body {
|
||||
background-color: black;
|
||||
color: white;
|
||||
}
|
||||
</style>
|
||||
<script>
|
||||
|
@ -53,16 +60,20 @@
|
|||
alert(`Error ${xhr.status}: ${xhr.statusText}`); // e.g. 404: Not Found
|
||||
} else { // show the result
|
||||
data = JSON.parse(xhr.responseText)
|
||||
let last=""
|
||||
for (const subnet in data.Subnets) {
|
||||
document.getElementById("subnetscontainer").innerHTML+="<button onClick=viewSubnet(this)>"+subnet+"</button>"
|
||||
document.getElementById("subnetscontainer").innerHTML+="<button onClick=viewSubnet(this.innerText)>"+subnet+"</button>"
|
||||
last=subnet
|
||||
}
|
||||
if(last != "") {
|
||||
viewSubnet(last)
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
xhr.send();
|
||||
}
|
||||
function viewSubnet(elem) {
|
||||
subnet = elem.innerText
|
||||
function viewSubnet(subnet) {
|
||||
|
||||
usedAddresses = data.Subnets[subnet].used_addresses
|
||||
totalAddresses = data.Subnets[subnet].total_addresses
|
||||
|
@ -75,33 +86,33 @@
|
|||
|
||||
let tableHTML = '<table border="1"><thead><tr><th>IP Address</th><th>RevDNS</th><th>First seen</th><th>Last seen</th></tr></thead><tbody>';
|
||||
|
||||
for (const subnet in data.Subnets) {
|
||||
const hosts = data.Subnets[subnet].hosts;
|
||||
|
||||
// Iterate over IPs in the subnet
|
||||
data.Subnets[subnet].host_list.forEach(ip => {
|
||||
const hostDetails = hosts[ip] || {}; // Get host details if available
|
||||
const hosts = data.Subnets[subnet].hosts;
|
||||
|
||||
// Determine the status based on the presence in hosts and online status
|
||||
let revdns="";
|
||||
let ls=""
|
||||
let fs=""
|
||||
let status;
|
||||
if (ip in hosts) {
|
||||
status = hostDetails.online ? 'online' : 'offline';
|
||||
revdns = hostDetails.rev_dns;
|
||||
ls = formatHumanFriendlyTime(hostDetails.last_seen)
|
||||
fs = formatHumanFriendlyTime(hostDetails.first_seen)
|
||||
// Iterate over IPs in the subnet
|
||||
data.Subnets[subnet].host_list.forEach(ip => {
|
||||
const hostDetails = hosts[ip] || {}; // Get host details if available
|
||||
|
||||
} else {
|
||||
status = 'free';
|
||||
}
|
||||
// Add a row to the HTML table
|
||||
tableHTML += `<tr class="status_${status}"><td>${ip}</td><td>${revdns}</td><td>${fs}</td><td>${ls}</td></tr>`;
|
||||
});
|
||||
}
|
||||
// Determine the status based on the presence in hosts and online status
|
||||
let revdns="";
|
||||
let ls=""
|
||||
let fs=""
|
||||
let status;
|
||||
if (ip in hosts) {
|
||||
status = hostDetails.online ? 'online' : 'offline';
|
||||
revdns = hostDetails.rev_dns;
|
||||
ls = formatHumanFriendlyTime(hostDetails.last_seen)
|
||||
fs = formatHumanFriendlyTime(hostDetails.first_seen)
|
||||
|
||||
} else {
|
||||
status = 'free';
|
||||
}
|
||||
// Add a row to the HTML table
|
||||
tableHTML += `<tr class="status_${status}"><td>${ip}</td><td>${revdns}</td><td>${fs}</td><td>${ls}</td></tr>`;
|
||||
});
|
||||
|
||||
tableHTML += '</tbody></table>';
|
||||
document.getElementById("subnetview").innerHTML=""
|
||||
document.getElementById("subnetview").innerHTML=tableHTML
|
||||
|
||||
}
|
||||
|
@ -112,7 +123,8 @@
|
|||
<div id="subnetscontainer"></div>
|
||||
<hr>
|
||||
<p>Subnet <span id="subnetCidrField"></span></p>
|
||||
<p>Space usage <span id="subnetUsedField"></span><progress id="subnetUsageBar"></progress></p>
|
||||
<p>Space usage <span id="subnetUsedField"></span></p>
|
||||
<progress id="subnetUsageBar"></progress><br>
|
||||
<div id="subnetview"></div>
|
||||
</body>
|
||||
</html>
|
Loading…
Add table
Add a link
Reference in a new issue