50 lines
1.4 KiB
Plaintext
50 lines
1.4 KiB
Plaintext
<%
|
|
// Helper function to format date
|
|
function formatDate(dateString) {
|
|
let date = new Date(dateString);
|
|
return date.toLocaleString('en-CA', {
|
|
year: 'numeric',
|
|
month: 'long',
|
|
day: 'numeric',
|
|
hour: 'numeric',
|
|
minute: '2-digit'
|
|
});
|
|
}
|
|
|
|
// Group data by unique domain_name
|
|
let groupedDomains = {};
|
|
data.forEach(item => {
|
|
let domain = item.domain_name?.trim();
|
|
if (!domain) return;
|
|
if (!groupedDomains[domain]) {
|
|
groupedDomains[domain] = [];
|
|
}
|
|
groupedDomains[domain].push(item);
|
|
});
|
|
%>
|
|
|
|
<div class="card-container grid gap-6 grid-cols-1 md:grid-cols-3 lg:grid-cols-4">
|
|
<% Object.keys(groupedDomains).forEach(domain => { %>
|
|
<%
|
|
// Sort entries by created_at descending and limit to 5
|
|
let sortedEntries=groupedDomains[domain]
|
|
.sort((a, b) => new Date(b.created_at) - new Date(a.created_at))
|
|
.slice(0, 5);
|
|
%>
|
|
<div class="card w-full bg-base-100 card-lg shadow-sm">
|
|
<div class="card-body">
|
|
<h2 class="card-title"><%= domain %></h2>
|
|
<% sortedEntries.forEach(entry => { %>
|
|
<div class="flex font-normal">
|
|
<p class="w-fit"><%= entry.id %></p>
|
|
<p class="flex-grow-1"><%= formatDate(entry.created_at) %></p>
|
|
</div>
|
|
<% }) %>
|
|
<div class="card-actions justify-end">
|
|
<a href="/sites/<%= domain %>" class="btn btn-info hover:text-white!">View All Tests</a>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<% }) %>
|
|
</div>
|