in webui/js/blocky4.js [103:152]
async function prime_frontpage() {
let all = await GET("all?short=true");
let main = document.getElementById('main');
main.innerHTML = "";
let block_count = all.total_block.pretty();
let h1 = _h1(`Recent activity (${block_count} blocks in total)`);
main.appendChild(h1);
all.block.sort((a,b) => b.timestamp - a.timestamp); // sort desc by timestamp
// Recent blocks
let activity_table = _table();
activity_table.style.tableLayout = 'fixed';
main.appendChild(activity_table);
let theader = _tr();
theader.appendChild(_th('Source IP', 300));
theader.appendChild(_th('Added', 120));
theader.appendChild(_th('Expires', 120));
theader.appendChild(_th('Reason', 500));
theader.appendChild(_th('Actions', 100));
activity_table.appendChild(theader);
let results_shown = 0;
for (const entry of all.block) {
let tr = _tr();
let td_ip = _td(entry.ip);
td_ip.style.fontFamily = "monospace";
if (entry.ip.length > 16) td_ip.style.fontSize = "0.8rem";
let td_added = _td(moment(entry.timestamp*1000.0).fromNow());
let td_expires = _td(entry.expires > 0 ? moment(entry.expires*1000.0).fromNow() : 'Never');
let td_reason = _td(entry.reason);
let td_action = _td();
td_action.appendChild(unblock_link(entry));
tr.appendChild(td_ip);
tr.appendChild(td_added);
tr.appendChild(td_expires);
tr.appendChild(td_reason);
tr.appendChild(td_action);
activity_table.appendChild(tr);
results_shown++;
}
if (results_shown === 0) {
let tr = _tr();
tr.innerText = "No activity found...";
activity_table.appendChild(_tr);
}
}