web/views/admin.njk

134 lines
5.9 KiB
Plaintext

<!doctype html>
<html lang="en" data-bs-core="modern">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>email.radio — profile</title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/holiday.css@0.11.2"/>
<script src="https://js.sentry-cdn.com/41fbed7261ca5017a6aa55e4c9a081a9.min.js" crossorigin="anonymous"></script>
</head>
<body>
<header>
<h1>
email.radio
</h1>
</header>
<nav>
<ul>
<li><a href="/">Home</a></li>
<li><a href="/auth">Profile</a></li>
</ul>
</nav>
<main>
<h1>👋 Hi, {{ profile.displayName }}</h1>
<h2>Applications Pending</h2>
{% for application in applications %}
<br>
<details>
<summary>{{ application.callsign }}
{% if yourSign %}
on behalf of{{ yourSign }}
{% endif %}
</summary>
<p>
<b>Callsign:
</b>
{{ application.callsign }}</p>
<p>
<b>Email:
</b>
{{ application.email }}</p>
<p>
<b>Date:
</b>
{{ application.createdAt }}</p>
<p>
<b>IP Address:
</b>
{% if application.ip %}
{{ application.ip }}{% else %}(none provided){% endif %}
</p>
<h2>Group Accounts</h2>
<p>
<b>Applicant's personal callsign:
</b>
{% if application.yourSign %}
{{ application.yourSign }}{% else %}(none provided){% endif %}
</p>
<p>
<b>Share this account with:
</b>
{% if application.groupEmail %}
{{ application.groupEmail }}{% else %}(none provided){% endif %}
</p>
<button onclick="accept('{{ application.id }}')" class="item{{ application.id }}">Accept</button>
<button onclick="deny('{{ application.id }}')" class="item{{ application.id }}">Deny</button>
<button onclick="del('{{ application.id }}')" class="item{{ application.id }}">Delete</button>
</details>
{% else %}
No applications found. Great job!
{% endfor %}
<script>
async function deny(id) {
document
.querySelectorAll(`.${id}`)
.forEach(e => e.disabled = true)
fetch(`/admin/reject/${id}`, {method: "POST"})
.then(response => response.json())
.then(result => {
if (result.error) {
document.querySelectorAll(`.item${id}`).forEach(e => e.disabled = false)
return alert(result.error)
}
window.location.reload()
})
.catch(error => console.log('error', error));
}
async function accept(id) {
document
.querySelectorAll(`.item${id}`)
.forEach(e => e.disabled = true)
fetch(`/admin/approve/${id}`, {method: "POST"})
.then(response => response.json())
.then(result => {
if (result.error) {
document.querySelectorAll(`.item${id}`).forEach(e => e.disabled = false)
return alert(result.error)
}
window.location.reload()
})
.catch(error => console.log('error', error));
}
async function del(id) {
document
.querySelectorAll(`.item${id}`)
.forEach(e => e.disabled = true)
fetch(`/admin/delete/${id}`, {method: "DELETE"})
.then(response => response.json())
.then(result => {
if (result.error) {
document.querySelectorAll(`.item${id}`).forEach(e => e.disabled = false)
return alert(result.error)
}
window.location.reload()
})
.catch(error => console.log('error', error));
}
</script>
</main>
<footer>
<p>&copy; email.radio {{ date.getFullYear() }}, AGPL. Rendered in
<b>{{ date - startedTime }}ms</b>.
<a href="/terms">Terms of Service</a>
&bull;
<a href="/privacy">Privacy Policy</a>
&bull;
<a href="/donate">Donate</a>
&bull;
<a href="https://git.email.radio/emaildotradio/web/">Source Code</a>. email.radio is fiscally sponsored by
<a href="https://the.hackfoundation.org">The Hack Foundation</a>
(d.b.a.
<a href="https://hackclub.com">Hack Club</a>), a 501(c)(3) nonprofit (EIN: 81-2908499).</p>
</footer>
</body>
</html>