lib/osa/views/index.erb in osa-0.2.0 vs lib/osa/views/index.erb in osa-0.2.1
- old
+ new
@@ -136,20 +136,17 @@
<script>
let totalReportCount = 0;
function sec2time(timeInSeconds) {
- const pad = function (num, size) {
- return ('000' + num).slice(size * -1);
- }
const time = parseFloat(timeInSeconds).toFixed(3);
const hours = Math.floor(time / 60 / 60);
const minutes = Math.floor(time / 60) % 60;
const units = [{value: hours, unit: 'h'}, {value: minutes, unit: 'm'}].filter((value) => value.value > 0 );
- return units.map((value) => `${pad(value.value, 2)}${value.unit}`).join(' ');
+ return units.map((value) => `${value.value}${value.unit}`).join(' ');
}
async function updateStats() {
const response = await fetch('/api/stats/summary');
if (response.ok) {
@@ -192,11 +189,14 @@
const indexTd = document.createElement("td");
indexTd.innerText = index + 1;
tr.appendChild(indexTd);
const domainTd = document.createElement("td");
- domainTd.innerText = spammer['domain'];
+ const domainRef = document.createElement("a");
+ domainRef.setAttribute("href", `/spammers/${encodeURI(spammer['domain'])}`);
+ domainRef.innerText = spammer['domain']
+ domainTd.appendChild(domainRef);
tr.appendChild(domainTd);
const reportCountTd = document.createElement("td");
reportCountTd.innerText = spammer['count'];
tr.appendChild(reportCountTd);
@@ -206,10 +206,10 @@
const spamRatioProgressTd = document.createElement("td");
spamRatioProgressTd.append(createProgressDiv(spamRatio));
tr.appendChild(spamRatioProgressTd);
const spamRatioTd = document.createElement("td");
- spamRatioTd.innerText = `${spamRatio}%`;
+ spamRatioTd.innerText = `${spamRatio.toFixed(1)}%`;
tr.appendChild(spamRatioTd);
return tr;
});
const tableBody = document.getElementById("top-spammers-table-body")