
- Created global.css for styling with a Scandinavian industrial palette. - Added index.ejs as the main entry point for the application, featuring a form creation section and a list of existing forms. - Implemented main.js for dropdown and modal functionalities. - Introduced submissions.ejs to display submissions for each form with pagination and action buttons. - Ensured accessibility features such as skip links and ARIA attributes for better user experience.
177 lines
6.9 KiB
Plaintext
177 lines
6.9 KiB
Plaintext
<!DOCTYPE html>
|
|
<html lang="en">
|
|
|
|
<head>
|
|
<meta charset="UTF-8" />
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
<title>Submissions - <%= formName %>
|
|
</title>
|
|
<link rel="stylesheet" href="/global.css">
|
|
</head>
|
|
|
|
<body>
|
|
<a href="#main-content" class="skip-link">Skip to main content</a>
|
|
|
|
<div class="container">
|
|
<main id="main-content">
|
|
<div class="dashboard-header">
|
|
<h1 class="dashboard-title">Submissions for <%= formName %>
|
|
</h1>
|
|
<div>
|
|
<a href="/admin" class="button button-secondary me-2">
|
|
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none"
|
|
stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"
|
|
aria-hidden="true" focusable="false">
|
|
<line x1="19" y1="12" x2="5" y2="12"></line>
|
|
<polyline points="12 19 5 12 12 5"></polyline>
|
|
</svg>
|
|
Back to Forms
|
|
</a>
|
|
<a href="/admin/submissions/<%= formUuid %>/export" class="button">
|
|
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none"
|
|
stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"
|
|
aria-hidden="true" focusable="false">
|
|
<path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"></path>
|
|
<polyline points="7 10 12 15 17 10"></polyline>
|
|
<line x1="12" y1="15" x2="12" y2="3"></line>
|
|
</svg>
|
|
Export CSV
|
|
</a>
|
|
<form action="/admin/clear-submissions/<%= formUuid %>" method="POST"
|
|
style="display: inline-block; margin-left: 0.5rem;">
|
|
<button type="submit" class="button button-danger"
|
|
onclick="return confirm('Are you sure you want to delete ALL submissions for this form? This action cannot be undone.')">
|
|
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24"
|
|
fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"
|
|
stroke-linejoin="round" aria-hidden="true" focusable="false">
|
|
<polyline points="3 6 5 6 21 6"></polyline>
|
|
<path
|
|
d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2">
|
|
</path>
|
|
<line x1="10" y1="11" x2="10" y2="17"></line>
|
|
<line x1="14" y1="11" x2="14" y2="17"></line>
|
|
</svg>
|
|
Clear All Submissions
|
|
</button>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
|
|
<% if (submissions.length===0) { %>
|
|
<div class="alert-info-custom">No submissions yet for this form.</div>
|
|
<% } else { %>
|
|
<div class="submissions-table-wrapper">
|
|
<table class="submissions-table">
|
|
<caption class="visually-hidden">List of submissions for the form named <%= formName %>.
|
|
</caption>
|
|
<thead>
|
|
<tr>
|
|
<th scope="col">Submitted At</th>
|
|
<th scope="col">IP Address</th>
|
|
<th scope="col">Data</th>
|
|
<th scope="col" style="text-align: right;">Actions</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<% submissions.forEach(submission=> { %>
|
|
<tr>
|
|
<td>
|
|
<%= new Date(submission.submitted_at).toLocaleString() %>
|
|
</td>
|
|
<td>
|
|
<%= submission.ip_address %>
|
|
</td>
|
|
<td>
|
|
<% const data=JSON.parse(submission.data); %>
|
|
<% Object.entries(data).forEach(([key, value])=> { %>
|
|
<% if (key !=='honeypot_field' && key !=='_thankyou' ) { %>
|
|
<div class="submission-data-item">
|
|
<strong>
|
|
<%= key %>:
|
|
</strong>
|
|
<span>
|
|
<%= typeof value==='object' ? JSON.stringify(value) :
|
|
value %>
|
|
</span>
|
|
</div>
|
|
<% } %>
|
|
<% }); %>
|
|
</td>
|
|
<td>
|
|
<div class="table-actions">
|
|
<form action="/admin/delete-submission/<%= submission.id %>"
|
|
method="POST" style="display: inline;">
|
|
<button type="submit" class="table-action delete"
|
|
title="Delete Submission"
|
|
onclick="return confirm('Are you sure you want to delete this submission?')"
|
|
aria-label="Delete submission from <%= submission.ip_address %> at <%= new Date(submission.submitted_at).toLocaleString() %>">
|
|
<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18"
|
|
viewBox="0 0 24 24" fill="none" stroke="currentColor"
|
|
stroke-width="2" stroke-linecap="round"
|
|
stroke-linejoin="round" aria-hidden="true"
|
|
focusable="false">
|
|
<polyline points="3 6 5 6 21 6"></polyline>
|
|
<path
|
|
d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2">
|
|
</path>
|
|
<line x1="10" y1="11" x2="10" y2="17"></line>
|
|
<line x1="14" y1="11" x2="14" y2="17"></line>
|
|
</svg>
|
|
</button>
|
|
</form>
|
|
</div>
|
|
</td>
|
|
</tr>
|
|
<% }); %>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
|
|
<!-- Pagination -->
|
|
<% if (pagination.totalPages> 1) { %>
|
|
<nav aria-label="Submissions pagination">
|
|
<ul class="pagination">
|
|
<% if (pagination.currentPage> 1) { %>
|
|
<li class="page-item">
|
|
<a class="page-link"
|
|
href="/admin/submissions/<%= formUuid %>?page=<%= pagination.currentPage - 1 %>&limit=<%= pagination.limit %>">Previous</a>
|
|
</li>
|
|
<% } else { %>
|
|
<li class="page-item disabled"><span class="page-link"
|
|
aria-disabled="true">Previous</span></li>
|
|
<% } %>
|
|
<% for(let i=1; i <=pagination.totalPages; i++) { %>
|
|
<li
|
|
class="page-item <%= i === pagination.currentPage ? 'active' : '' %>">
|
|
<a class="page-link"
|
|
href="/admin/submissions/<%= formUuid %>?page=<%= i %>&limit=<%= pagination.limit %>"
|
|
<% if (i===pagination.currentPage) { %>
|
|
aria-current="page" <% } %>>
|
|
<%= i %>
|
|
</a>
|
|
</li>
|
|
<% } %>
|
|
<% if (pagination.currentPage < pagination.totalPages) { %>
|
|
<li class="page-item">
|
|
<a class="page-link"
|
|
href="/admin/submissions/<%= formUuid %>?page=<%= pagination.currentPage + 1 %>&limit=<%= pagination.limit %>">Next</a>
|
|
</li>
|
|
<% } else { %>
|
|
<li class="page-item disabled"><span class="page-link"
|
|
aria-disabled="true">Next</span></li>
|
|
<% } %>
|
|
</ul>
|
|
</nav>
|
|
<div class="pagination-info" role="status" aria-live="polite">
|
|
Showing <%= (pagination.currentPage - 1) * pagination.limit + 1 %> to <%=
|
|
Math.min(pagination.currentPage * pagination.limit, pagination.totalSubmissions) %>
|
|
of <%= pagination.totalSubmissions %> submissions
|
|
</div>
|
|
<% } %>
|
|
<% } %>
|
|
</main>
|
|
</div>
|
|
<script src="/main.js"></script>
|
|
</body>
|
|
|
|
</html> |