Skip to content

Commit

Permalink
Added form submission page
Browse files Browse the repository at this point in the history
  • Loading branch information
BenjaminEHowe committed Jun 23, 2024
1 parent bef48ab commit d36e80c
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 0 deletions.
35 changes: 35 additions & 0 deletions _assets/css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,41 @@ table#professional-experience tr + tr td {
padding-top: 0.75rem;
}

/* spinner used while waiting for fetch, see https://loading.io/css/ */

.loading-spinner {
color: #961c1c;
}
.lds-dual-ring,
.lds-dual-ring:after {
box-sizing: border-box;
}
.lds-dual-ring {
display: inline-block;
width: 80px;
height: 80px;
}
.lds-dual-ring:after {
content: " ";
display: block;
width: 64px;
height: 64px;
margin: 8px;
border-radius: 50%;
border: 6.4px solid currentColor;
border-color: currentColor transparent currentColor transparent;
animation: lds-dual-ring 1.2s linear infinite;
}
@keyframes lds-dual-ring {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}


/* footer */

#main {
Expand Down
36 changes: 36 additions & 0 deletions secure/form-submissions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
---
layout: default
title: Form Submissions
---

This table shows form submissions over the last 30 days:
<div id="form-submissions"><div class="lds-dual-ring"></div></div>

<script>
fetch("/secure/api/form", {
method: "GET",
headers: {
"accept": "application/json",
"content-type": "application/json",
},
})
.then(res => res.json())
.then(submissions => {
const table = document.createElement("table");
const thead = table.createTHead();
const headings = thead.insertRow();
headings.insertCell().innerHTML = "Submission ID";
headings.insertCell().innerHTML = "Form ID";
headings.insertCell().innerHTML = "Submitted";
headings.insertCell().innerHTML = "Spam Reasons";
headings.insertCell().innerHTML = "IP Address";
headings.insertCell().innerHTML = "ASN";
const tbody = table.createTBody();
submissions.forEach(row => {
const tr = table.insertRow();
const td = tr.insertCell();
td.innerHTML = row.submission_id;
});
document.getElementById("form-submissions").innerHTML = table.outerHTML;
});
</script>
1 change: 1 addition & 0 deletions secure/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ layout: default
title: "Secure area: index"
---

- [(Contact) form submissions](form-submissions)
- [Token generator (for urgent contact form)](token-generator)

0 comments on commit d36e80c

Please sign in to comment.