Skip to content

High performance, self-hosted, newsletter and mailing list manager with a modern dashboard. Single binary app.

Restyle subscriber stats in the lists table.

Kailash Nadha090dbe6b045
diff --git a/static/admin/assets/css/style.css b/static/admin/assets/css/style.css
index ed9d73fe..47c9f8f6 100644
--- a/static/admin/assets/css/style.css
+++ b/static/admin/assets/css/style.css
@@ -1025,9 +1025,65 @@ section.dashboard {
/* Lists */
section.lists {
+ .subscriber-breakdown {
+ margin-top: var(--space-2);
+
+ .status-confirmed { --meter-color: rgb(66, 169, 138); }
+ .status-unconfirmed { --meter-color: rgb(232, 180, 88); }
+ .status-unsubscribed { --meter-color: rgb(213, 105, 105); }
+
+ .status-icon {
+ color: var(--meter-color);
+ }
+ }
+
+ .subscriber-meters {
+ display: flex;
+ align-items: flex-start;
+ overflow: hidden;
+ border-radius: var(--radius-small);
+ max-width: 90%;
+
+ &::after {
+ content: "";
+ flex: 1;
+ border-top: 2px solid var(--border);
+ }
+
+ meter {
+ appearance: none;
+ box-sizing: content-box;
+ flex: 0 0 auto;
+ min-width: 0;
+ height: 0;
+ overflow: hidden;
+ margin: 0;
+ padding: 0;
+ border: 0;
+ border-top: 2px solid var(--meter-color);
+ border-radius: 0;
+ }
+ }
+
+ .subscriber-legend {
+ display: flex;
+ gap: var(--space-4);
+ margin-top: var(--space-2);
+
+ .text-grey {
+ color: var(--muted-foreground);
+ white-space: nowrap;
+ }
+
+ .dot {
+ font-size: 0.6em;
+ vertical-align: middle;
+ }
+ }
+
th, td {
&.subscribers {
- text-align: center;
+ text-align: left;
}
}
@@ -1039,6 +1095,10 @@ section.lists {
/* Subscribers */
.subscribers {
+ .list-names {
+ row-gap: var(--space-1);
+ }
+
.blocklisted {
td > a,
td .name-stack > div > a {
@@ -1800,6 +1860,21 @@ section.users {
}
}
+ section.lists {
+ .subscriber-breakdown {
+ flex: 0 0 100%;
+ min-width: 0;
+ }
+
+ .subscriber-meters {
+ max-width: 100%;
+ }
+
+ .subscriber-legend {
+ flex-wrap: wrap;
+ }
+ }
+
section.campaign {
[role="tablist"] {
max-width: 100%;
diff --git a/static/admin/assets/static/icons.svg b/static/admin/assets/static/icons.svg
index 46b83ac1..26718671 100644
--- a/static/admin/assets/static/icons.svg
+++ b/static/admin/assets/static/icons.svg
@@ -39,6 +39,10 @@
<rect x="3" y="4" width="18" height="18" rx="2" ry="2" /><line x1="16" y1="2" x2="16" y2="6" /><line x1="8" y1="2" x2="8" y2="6" /><line x1="3" y1="10" x2="21" y2="10" />
</symbol>
+ <symbol id="icon-check" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
+ <polyline points="20 6 9 17 4 12" />
+ </symbol>
+
<symbol id="icon-check-circle" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<path d="M22 11.08V12a10 10 0 1 1-5.93-9.14" /><polyline points="22 4 12 14.01 9 11.01" />
</symbol>
diff --git a/static/admin/icons.txt b/static/admin/icons.txt
index 809c32a0..a23fbb23 100644
--- a/static/admin/icons.txt
+++ b/static/admin/icons.txt
@@ -9,6 +9,7 @@ archive
at-sign
bar-chart-2
calendar
+check
check-circle
check-square
chevron-down
@@ -60,4 +61,4 @@ user-check
user-x
users
x-circle
-x
\ No newline at end of file
+x
diff --git a/static/admin/views/lists.html b/static/admin/views/lists.html
index d55bdd2d..8bd0fc9d 100644
--- a/static/admin/views/lists.html
+++ b/static/admin/views/lists.html
@@ -2,6 +2,7 @@
{{ template "admin-header" . }}
{{- $d := .Data -}}
{{- $base := URI "/admin/lists" -}}
+{{- $statusIcons := dict "confirmed" "check" "unsubscribed" "x" -}}
{{- $status := $d.Page.Param "status" -}}
{{- $type := $d.Page.Param "type" -}}
{{- $optin := $d.Page.Param "optin" -}}
@@ -70,8 +71,7 @@
<th width="5%"><input type="checkbox" aria-label="{{ .L.T "globals.buttons.toggleSelect" }}"></th>
<th width="27%">{{ $d.Page.SortLink (URI "/admin/lists") "name" (.L.T "globals.fields.name") }}</th>
<th width="22%">{{ $d.Page.SortLink (URI "/admin/lists") "type" (.L.T "globals.fields.type") }}</th>
- <th width="10%" class="subscribers">{{ $d.Page.SortLink (URI "/admin/lists") "subscriber_count" (.L.T "globals.terms.subscribers") }}</th>
- <th width="18%"></th>
+ <th width="20%" class="subscribers">{{ $d.Page.SortLink (URI "/admin/lists") "subscriber_count" (.L.T "globals.terms.subscribers") }}</th>
<th width="12%">{{ $d.Page.SortLink (URI "/admin/lists") "created_at" (.L.T "globals.fields.createdAt") }}</th>
<th width="5%" class="align-right"></th>
</tr>
@@ -101,37 +101,37 @@
</td>
<td class="subscribers" data-label="{{ $.L.T "globals.terms.subscribers" }}">
{{- if $d.Can "subscribers:get" "subscribers:get_all" }}
- <a class="subscriber-total align-center" href="{{ URI "/admin/subscribers/lists" }}/{{ .ID }}" title="{{ $.L.T "globals.buttons.filter" }} {{ .Name }}">{{ FormatNumber .SubscriberCount }}<br /><span class="view">{{ $.L.T "globals.buttons.view" }}</span></a>
+ <a class="subscriber-total" href="{{ URI "/admin/subscribers/lists" }}/{{ .ID }}" title="{{ $.L.T "globals.buttons.filter" }} {{ .Name }}">{{ FormatNumber .SubscriberCount }}</a>
{{- else }}
<span class="subscriber-total">{{ FormatNumber .SubscriberCount }}</span>
{{- end }}
- </td>
- <td class="stats">
- <dl class="text-8">
- {{- $counts := .SubscriberCounts -}}
- {{- $subscribed := index $counts "subscribed" -}}
- {{- $unsubscribed := index $counts "unsubscribed" -}}
- {{- $blocklisted := index $counts "blocklisted" }}
- {{- if gt $subscribed 0 }}
- <div><dt>{{ $.L.T "subscribers.status.subscribed" }}</dt><dd><a href="{{ URI "/admin/subscribers/lists" }}/{{ .ID }}?subscription_status=subscribed" class="unstyled" title="{{ $.L.T "globals.buttons.filter" }} {{ $.L.T "subscribers.status.subscribed" }}">{{ FormatNumber $subscribed }}</a></dd></div>
- {{- end }}
- {{- if gt $unsubscribed 0 }}
- <div><dt>{{ $.L.T "subscribers.status.unsubscribed" }}</dt><dd><a href="{{ URI "/admin/subscribers/lists" }}/{{ .ID }}?subscription_status=unsubscribed" class="unstyled" title="{{ $.L.T "globals.buttons.filter" }} {{ $.L.T "subscribers.status.unsubscribed" }}">{{ FormatNumber $unsubscribed }}</a></dd></div>
- {{- end }}
- {{- if gt $blocklisted 0 }}
- <div><dt>{{ $.L.T "subscribers.status.blocklisted" }}</dt><dd><a href="{{ URI "/admin/subscribers/lists" }}/{{ .ID }}?subscription_status=blocklisted" class="unstyled blocklisted" title="{{ $.L.T "globals.buttons.filter" }} {{ $.L.T "subscribers.status.blocklisted" }}">{{ FormatNumber $blocklisted }}</a></dd></div>
- {{- end }}
- {{- if eq .Optin "double" }}
- {{- $confirmed := index $counts "confirmed" -}}
- {{- $unconfirmed := index $counts "unconfirmed" }}
- {{- if gt $confirmed 0 }}
- <div><dt>{{ $.L.T "subscribers.status.confirmed" }}</dt><dd><a href="{{ URI "/admin/subscribers/lists" }}/{{ .ID }}?subscription_status=confirmed" class="unstyled confirmed" title="{{ $.L.T "globals.buttons.filter" }} {{ $.L.T "subscribers.status.confirmed" }}">{{ FormatNumber $confirmed }}</a></dd></div>
+ {{- $listID := .ID -}}
+ {{- $total := max .SubscriberCount 1 -}}
+ {{- $counts := .SubscriberCounts -}}
+ {{- $stats := list -}}
+ {{- $statuses := list "unsubscribed" -}}
+ {{- if eq .Optin "double" -}}
+ {{- $statuses = list "confirmed" "unconfirmed" "unsubscribed" -}}
+ {{- end -}}
+ {{- range $statuses -}}
+ {{- $count := index $counts . -}}
+ {{- $label := $.L.T (printf "subscribers.status.%s" .) -}}
+ {{- $percent := mulf (divf $count $total) 100 -}}
+ {{- $title := printf "%s %s (%.2f%%)" $label (FormatNumber $count) $percent -}}
+ {{- $stats = append $stats (dict "Status" . "Count" $count "Label" $label "Percent" $percent "Title" $title) -}}
+ {{- end }}
+ <div class="subscriber-breakdown">
+ <div class="subscriber-meters" role="group" aria-label="{{ $.L.T "globals.terms.subscribers" }}: {{ .Name }} — {{ $.L.T "globals.fields.status" }}">
+ {{- range $stats }}
+ <meter class="status-{{ .Status }}" min="0" max="{{ $total }}" value="{{ .Count }}" style="width: {{ .Percent }}%" aria-label="{{ .Label }}" aria-valuetext="{{ .Title }}" title="{{ .Title }}">{{ .Title }}</meter>
{{- end }}
- {{- if gt $unconfirmed 0 }}
- <div><dt>{{ $.L.T "subscribers.status.unconfirmed" }}</dt><dd><a href="{{ URI "/admin/subscribers/lists" }}/{{ .ID }}?subscription_status=unconfirmed" class="unstyled unconfirmed" title="{{ $.L.T "globals.buttons.filter" }} {{ $.L.T "subscribers.status.unconfirmed" }}">{{ FormatNumber $unconfirmed }}</a></dd></div>
+ </div>
+ <div class="subscriber-legend text-8">
+ {{- range $stats }}
+ <a class="unstyled text-grey" href="{{ URI "/admin/subscribers/lists" }}/{{ $listID }}?subscription_status={{ .Status }}" title="{{ .Title }}" aria-label="{{ .Title }}"><span class="status-icon status-{{ .Status }}" aria-hidden="true">{{ if eq .Status "unconfirmed" }}?{{ else }}{{ Icon (index $statusIcons .Status) }}{{ end }}</span> {{ printf "%.2f%%" .Percent }}</a>
{{- end }}
- {{- end }}
- </dl>
+ </div>
+ </div>
</td>
<td class="date-stack" data-label="{{ $.L.T "globals.fields.createdAt" }}">
{{ NiceDate .CreatedAt }}
diff --git a/static/admin/views/subscribers.html b/static/admin/views/subscribers.html
index bb1e5e37..7c4a44d4 100644
--- a/static/admin/views/subscribers.html
+++ b/static/admin/views/subscribers.html
@@ -4,7 +4,7 @@
{{- $subStatus := $d.Page.Param "subscription_status" -}}
{{- $status := $d.Page.Param "status" -}}
{{- $base := URI "/admin/subscribers" -}}
-{{- $statusIcons := dict "confirmed" "check-circle" "blocklisted" "x-circle" "disabled" "pause-circle" "unsubscribed" "minus-circle" "unconfirmed" "help-circle" -}}
+{{- $statusIcons := dict "confirmed" "check" "blocklisted" "x-circle" "disabled" "pause-circle" "unsubscribed" "x" "unconfirmed" "help-circle" -}}
{{- if $d.CurrentList }}{{ $base = printf "%s/lists/%d" (URI "/admin/subscribers") $d.CurrentList.ID }}{{ end -}}
<script>
@@ -113,14 +113,14 @@
{{- end }}
{{- if .ParsedLists }}
<div class="mt-2">
- <div class="hstack">
+ <div class="hstack list-names">
{{- range $i, $l := .ParsedLists }}
{{- if lt $i 2 }}
<span>
<a class="unstyled text-light" href="{{ URI "/admin/subscribers/lists" }}/{{ $l.ID }}" title="{{ $.L.T "globals.buttons.filter" }} {{ $l.Name }}">{{ $l.Name }}
{{- if or (eq $l.Optin "double") (eq $l.SubscriptionStatus "unsubscribed") }}
{{- $label := $.L.T (printf "subscribers.status.%s" $l.SubscriptionStatus) }}
- <span class="status-icon status-{{ $l.SubscriptionStatus }}" title="{{ $label }}" aria-label="{{ $label }}">{{ Icon (or (index $statusIcons $l.SubscriptionStatus) "help-circle") }}</span>
+ <span class="status-icon status-{{ $l.SubscriptionStatus }}" title="{{ $label }}" aria-label="{{ $label }}">{{ if eq $l.SubscriptionStatus "unconfirmed" }}?{{ else }}{{ Icon (or (index $statusIcons $l.SubscriptionStatus) "help-circle") }}{{ end }}</span>
{{- end }}
</a>
</span>