diff options
author | Niall Sheridan <nsheridan@gmail.com> | 2016-09-10 20:16:28 +0100 |
---|---|---|
committer | Niall Sheridan <nsheridan@gmail.com> | 2016-09-11 20:41:32 +0100 |
commit | 65151dd29dc01c6d1f6ff79ab6f8e049e925ce25 (patch) | |
tree | 2db5267b573f2a58ffff94de7f9b9af5f9767d82 /server/static/js | |
parent | 2e7c8c2f521c9e50bb3aea4df16771c22fe70e58 (diff) |
Add a toggle for unexpired certs
Diffstat (limited to 'server/static/js')
-rw-r--r-- | server/static/js/table.js | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/server/static/js/table.js b/server/static/js/table.js new file mode 100644 index 0000000..da0da39 --- /dev/null +++ b/server/static/js/table.js @@ -0,0 +1,49 @@ +function reqListener() { + var recs = JSON.parse(this.responseText); + var table = document.querySelector('#cert-table'); + var tbody = table.querySelector("#list"); + while (tbody.rows.length > 0) { + tbody.deleteRow(0); + } + issuedList.clear(); + recs.forEach(function makeTable(el, i, arr) { + var row = tbody.insertRow(-1); + row.insertCell(0).innerHTML = el.key_id; + row.insertCell(1).innerHTML = el.created_at; + row.insertCell(2).innerHTML = el.expires; + row.insertCell(3).innerHTML = el.principals; + row.insertCell(4).innerHTML = el.revoked; + // Index keyid and principals. + row.cells[0].classList = ["keyid"]; + row.cells[3].classList = ["principals"]; + if (el.revoked) { + row.insertCell(5).innerHTML = '<input style="margin:0;" type="checkbox" value="'+ el.key_id + '" name="cert_id" id="cert_id" />'; + } + tbody.appendChild(row); + }); + issuedList.reIndex(); +} + +function loadCerts(all) { + var r = new XMLHttpRequest(); + var endpoint = '/admin/certs.json'; + if (all) { + endpoint += '?all=true'; + } + r.open('GET', endpoint); + r.addEventListener('load', reqListener); + r.send() +} + +var SHOW_ALL = false; + +function toggleExpired() { + var button = document.querySelector("#toggle-certs"); + SHOW_ALL = !SHOW_ALL; + loadCerts(SHOW_ALL); + if (SHOW_ALL == false) { + button.innerHTML = "Show Expired"; + } else { + button.innerHTML = "Hide Expired"; + } +} |