aboutsummaryrefslogtreecommitdiff
path: root/templates
diff options
context:
space:
mode:
authorBobby <[email protected]>2026-03-07 18:42:40 +0530
committerBobby <[email protected]>2026-03-07 18:42:40 +0530
commit96c136f046d78c51210927e61483a36a220fedcb (patch)
tree8f5baf294d92ec3bc503bd02f4a08871874f048d /templates
parent6bc2ef7a8972547f10a5a8f50269b0e6b487a580 (diff)
downloaddove-96c136f046d78c51210927e61483a36a220fedcb.tar.xz
dove-96c136f046d78c51210927e61483a36a220fedcb.zip
Refactor dashboard and mailboxes pages to integrate services for data retrieval
- Updated `Dashboard` function to use `services.Overview()` for rendering overview data. - Enhanced `Mailboxes` function to include pagination, sorting, and search functionality using `services.ListMailboxes()`. - Modified `Users` function to implement pagination, sorting, and search with `services.ListUsers()`. Revamped templates for mailboxes and users - Updated `mailboxes.htmx.django` to display mailbox items dynamically with total count. - Enhanced `users.htmx.django` to show user details and total count, with improved layout for user information. Introduced new response types and constants - Added `PaginatedResponse` type in `types/response.go` for consistent pagination responses. - Introduced constants for pagination in `utils/meta/constants.go`. Implemented email processing and storage services - Created `services/email.go` for processing incoming emails and storing them in the database. - Added email parsing utilities in `utils/email` for handling email content and attachments. Established repository functions for mailboxes, users, and emails - Created repository functions in `repositories` for managing mailboxes, users, and emails, including listing and searching capabilities. Refactored SMTP server functions - Updated SMTP server handling in `utils/smtp` to streamline session management and message processing. - Removed obsolete storage functions and integrated email processing directly into the SMTP session. Added new message constants for better logging and error handling - Introduced message constants in `messages/email.go` and `messages/mailbox.go` for improved clarity in logs.
Diffstat (limited to 'templates')
-rw-r--r--templates/dashboard/htmx/mailboxes.htmx.django25
-rw-r--r--templates/dashboard/htmx/overview.htmx.django6
-rw-r--r--templates/dashboard/htmx/users.htmx.django34
3 files changed, 48 insertions, 17 deletions
diff --git a/templates/dashboard/htmx/mailboxes.htmx.django b/templates/dashboard/htmx/mailboxes.htmx.django
index 57fdf04..9ccedb1 100644
--- a/templates/dashboard/htmx/mailboxes.htmx.django
+++ b/templates/dashboard/htmx/mailboxes.htmx.django
@@ -3,8 +3,28 @@
<div class="glass rounded-xl glow-border">
<div class="flex items-center justify-between px-5 py-4 border-b border-white/[0.04]">
<h2 class="text-sm font-medium text-zinc-200">All Mailboxes</h2>
- <span class="text-xs text-zinc-600">Mailboxes are created automatically when emails are received</span>
+ <span class="text-xs text-zinc-600">{{ total }} total</span>
</div>
+ {% if items %}
+ <div class="divide-y divide-white/[0.04]">
+ {% for mailbox in items %}
+ {% url "dashboard.mailbox" address=mailbox.Address as mailbox_path %}
+ <a href="{{ mailbox_path }}" hx-get="{{ mailbox_path }}" hx-target="#content" hx-swap="innerHTML" hx-push-url="true" class="flex items-center justify-between px-5 py-3 hover:bg-white/[0.02] transition-colors duration-150">
+ <div class="flex items-center gap-3">
+ <div class="flex items-center justify-center w-8 h-8 rounded-lg bg-accent-500/10">
+ <svg class="w-4 h-4 text-accent-400" fill="none" stroke="currentColor" viewBox="0 0 24 24" stroke-width="1.5">
+ <path stroke-linecap="round" stroke-linejoin="round" d="M2.25 13.5h3.86a2.25 2.25 0 0 1 2.012 1.244l.256.512a2.25 2.25 0 0 0 2.013 1.244h2.21a2.25 2.25 0 0 0 2.013-1.244l.256-.512a2.25 2.25 0 0 1 2.013-1.244h3.859m-19.5.338V18a2.25 2.25 0 0 0 2.25 2.25h15A2.25 2.25 0 0 0 21.75 18v-4.162c0-.224-.034-.447-.1-.661L19.24 5.338a2.25 2.25 0 0 0-2.15-1.588H6.911a2.25 2.25 0 0 0-2.15 1.588L2.35 13.177a2.25 2.25 0 0 0-.1.661Z" />
+ </svg>
+ </div>
+ <div>
+ <p class="text-sm text-zinc-200">{{ mailbox.Address }}</p>
+ <p class="text-xs text-zinc-600">{{ mailbox.User.DisplayName }}</p>
+ </div>
+ </div>
+ </a>
+ {% endfor %}
+ </div>
+ {% else %}
<div class="flex flex-col items-center justify-center py-16 text-center">
<div class="flex items-center justify-center w-12 h-12 rounded-2xl bg-surface-800 mb-4">
<svg class="w-6 h-6 text-zinc-600" fill="none" stroke="currentColor" viewBox="0 0 24 24" stroke-width="1.5">
@@ -14,5 +34,6 @@
<p class="text-sm text-zinc-400">No mailboxes yet</p>
<p class="mt-1 text-xs text-zinc-600">Send an email to start receiving mail</p>
</div>
+ {% endif %}
</div>
-</div> \ No newline at end of file
+</div>
diff --git a/templates/dashboard/htmx/overview.htmx.django b/templates/dashboard/htmx/overview.htmx.django
index 8d9e88a..c5a7b4d 100644
--- a/templates/dashboard/htmx/overview.htmx.django
+++ b/templates/dashboard/htmx/overview.htmx.django
@@ -10,7 +10,7 @@
</div>
<span class="text-xs font-medium text-zinc-500 uppercase tracking-wider">Mailboxes</span>
</div>
- <p class="text-3xl font-bold text-zinc-100 tracking-tight">0</p>
+ <p class="text-3xl font-bold text-zinc-100 tracking-tight">{{ MailboxCount }}</p>
<p class="mt-1 text-xs text-zinc-600">Active inboxes</p>
</div>
@@ -23,7 +23,7 @@
</div>
<span class="text-xs font-medium text-zinc-500 uppercase tracking-wider">Emails</span>
</div>
- <p class="text-3xl font-bold text-zinc-100 tracking-tight">0</p>
+ <p class="text-3xl font-bold text-zinc-100 tracking-tight">{{ EmailCount }}</p>
<p class="mt-1 text-xs text-zinc-600">Total received</p>
</div>
@@ -37,7 +37,7 @@
<span class="text-xs font-medium text-zinc-500 uppercase tracking-wider">Server</span>
</div>
<p class="text-3xl font-bold text-emerald-400 tracking-tight">Online</p>
- <p class="mt-1 text-xs text-zinc-600">SMTP listening on :1025</p>
+ <p class="mt-1 text-xs text-zinc-600">SMTP listening on {{ SMTPAddress }}</p>
</div>
</div>
diff --git a/templates/dashboard/htmx/users.htmx.django b/templates/dashboard/htmx/users.htmx.django
index 7a36fe8..6578ba2 100644
--- a/templates/dashboard/htmx/users.htmx.django
+++ b/templates/dashboard/htmx/users.htmx.django
@@ -3,27 +3,37 @@
<div class="glass rounded-xl glow-border">
<div class="flex items-center justify-between px-5 py-4 border-b border-white/[0.04]">
<h2 class="text-sm font-medium text-zinc-200">All Users</h2>
+ <span class="text-xs text-zinc-600">{{ total }} total</span>
</div>
- {% if AuthEnabled %}
- <div class="flex flex-col items-center justify-center py-16 text-center">
- <div class="flex items-center justify-center w-12 h-12 rounded-2xl bg-surface-800 mb-4">
- <svg class="w-6 h-6 text-zinc-600" fill="none" stroke="currentColor" viewBox="0 0 24 24" stroke-width="1.5">
- <path stroke-linecap="round" stroke-linejoin="round" d="M15 19.128a9.38 9.38 0 0 0 2.625.372 9.337 9.337 0 0 0 4.121-.952 4.125 4.125 0 0 0-7.533-2.493M15 19.128v-.003c0-1.113-.285-2.16-.786-3.07M15 19.128v.106A12.318 12.318 0 0 1 8.624 21c-2.331 0-4.512-.645-6.374-1.766l-.001-.109a6.375 6.375 0 0 1 11.964-3.07M12 6.375a3.375 3.375 0 1 1-6.75 0 3.375 3.375 0 0 1 6.75 0Zm8.25 2.25a2.625 2.625 0 1 1-5.25 0 2.625 2.625 0 0 1 5.25 0Z" />
- </svg>
+ {% if items %}
+ <div class="divide-y divide-white/[0.04]">
+ {% for user in items %}
+ <div class="flex items-center justify-between px-5 py-3">
+ <div class="flex items-center gap-3">
+ <div class="flex items-center justify-center w-8 h-8 rounded-lg bg-accent-500/10">
+ <svg class="w-4 h-4 text-accent-400" fill="none" stroke="currentColor" viewBox="0 0 24 24" stroke-width="1.5">
+ <path stroke-linecap="round" stroke-linejoin="round" d="M15.75 6a3.75 3.75 0 1 1-7.5 0 3.75 3.75 0 0 1 7.5 0ZM4.501 20.118a7.5 7.5 0 0 1 14.998 0A17.933 17.933 0 0 1 12 21.75c-2.676 0-5.216-.584-7.499-1.632Z" />
+ </svg>
+ </div>
+ <div>
+ <p class="text-sm text-zinc-200">{{ user.DisplayName }}</p>
+ <p class="text-xs text-zinc-600">{{ user.Username }}</p>
+ </div>
+ </div>
+ <span class="text-xs text-zinc-600">{{ user.Mailboxes|length }} mailbox{{ user.Mailboxes|length|pluralize:"es" }}</span>
</div>
- <p class="text-sm text-zinc-400">No additional users</p>
- <p class="mt-1 text-xs text-zinc-600">Users are configured in config.toml</p>
+ {% endfor %}
</div>
{% else %}
<div class="flex flex-col items-center justify-center py-16 text-center">
<div class="flex items-center justify-center w-12 h-12 rounded-2xl bg-surface-800 mb-4">
<svg class="w-6 h-6 text-zinc-600" fill="none" stroke="currentColor" viewBox="0 0 24 24" stroke-width="1.5">
- <path stroke-linecap="round" stroke-linejoin="round" d="M16.5 10.5V6.75a4.5 4.5 0 1 0-9 0v3.75m-.75 11.25h10.5a2.25 2.25 0 0 0 2.25-2.25v-6.75a2.25 2.25 0 0 0-2.25-2.25H6.75a2.25 2.25 0 0 0-2.25 2.25v6.75a2.25 2.25 0 0 0 2.25 2.25Z" />
+ <path stroke-linecap="round" stroke-linejoin="round" d="M15 19.128a9.38 9.38 0 0 0 2.625.372 9.337 9.337 0 0 0 4.121-.952 4.125 4.125 0 0 0-7.533-2.493M15 19.128v-.003c0-1.113-.285-2.16-.786-3.07M15 19.128v.106A12.318 12.318 0 0 1 8.624 21c-2.331 0-4.512-.645-6.374-1.766l-.001-.109a6.375 6.375 0 0 1 11.964-3.07M12 6.375a3.375 3.375 0 1 1-6.75 0 3.375 3.375 0 0 1 6.75 0Zm8.25 2.25a2.625 2.625 0 1 1-5.25 0 2.625 2.625 0 0 1 5.25 0Z" />
</svg>
</div>
- <p class="text-sm text-zinc-400">Authentication is disabled</p>
- <p class="mt-1 text-xs text-zinc-600">Enable authentication in config.toml to manage users</p>
+ <p class="text-sm text-zinc-400">No users yet</p>
+ <p class="mt-1 text-xs text-zinc-600">Users are created when emails are received</p>
</div>
{% endif %}
</div>
-</div> \ No newline at end of file
+</div>