added IMAP, LetsEncrypt, update layout
This commit is contained in:
@@ -0,0 +1,58 @@
|
||||
package webui
|
||||
|
||||
import "net/http"
|
||||
|
||||
// navCounts are the small per-resource counts shown as sidebar badges on every page
|
||||
// (and reused by the dashboard's own stat tiles, which use the same numbers) — scoped
|
||||
// to the current admin exactly like every list page already is.
|
||||
type navCounts struct {
|
||||
DomainCount, SenderCount, MailboxCount, IPCount, DKIMCount int
|
||||
}
|
||||
|
||||
func (a *App) computeNavCounts(r *http.Request) navCounts {
|
||||
scope := scopeFromContext(r)
|
||||
var c navCounts
|
||||
|
||||
if scope.Global {
|
||||
c.DomainCount, _ = a.DB.CountActiveDomains()
|
||||
c.SenderCount, _ = a.DB.CountActiveSenders()
|
||||
c.DKIMCount, _ = a.DB.CountActiveDKIMKeys()
|
||||
} else {
|
||||
domains, _ := a.DB.ListDomains()
|
||||
for _, d := range domains {
|
||||
if d.IsActive && scope.Allowed(d.ID) {
|
||||
c.DomainCount++
|
||||
}
|
||||
}
|
||||
senders, _ := a.DB.ListSenders()
|
||||
for _, s := range senders {
|
||||
if s.IsActive && scope.Allowed(s.DomainID) {
|
||||
c.SenderCount++
|
||||
}
|
||||
}
|
||||
keys, _ := a.DB.ListActiveDKIMKeysWithDomain()
|
||||
for _, k := range keys {
|
||||
if scope.Allowed(k.DomainID) {
|
||||
c.DKIMCount++
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Mailboxes and IPs always need a per-row pass regardless of scope.Global (no
|
||||
// dedicated CountActive* helpers exist for them), same as dashboard.go already did
|
||||
// for mailboxes before this was centralized.
|
||||
mailboxes, _ := a.DB.ListMailboxes()
|
||||
for _, m := range mailboxes {
|
||||
if m.IsActive && (scope.Global || scope.Allowed(m.DomainID)) {
|
||||
c.MailboxCount++
|
||||
}
|
||||
}
|
||||
ips, _ := a.DB.ListWhitelistedIPs()
|
||||
for _, ip := range ips {
|
||||
if ip.IsActive && (scope.Global || scope.Allowed(ip.DomainID)) {
|
||||
c.IPCount++
|
||||
}
|
||||
}
|
||||
|
||||
return c
|
||||
}
|
||||
Reference in New Issue
Block a user