Skip to content

Commit

Permalink
feat: add total domain and aliases into respective admin pages
Browse files Browse the repository at this point in the history
  • Loading branch information
shaunwarman committed Aug 29, 2024
1 parent 2505e34 commit b059abb
Show file tree
Hide file tree
Showing 29 changed files with 87 additions and 27 deletions.
11 changes: 10 additions & 1 deletion app/controllers/web/admin/domains.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const { isEmail } = require('validator');
const config = require('#config');
const emailHelper = require('#helpers/email');
const i18n = require('#helpers/i18n');
const { Users, Domains } = require('#models');
const { Aliases, Users, Domains } = require('#models');

async function list(ctx) {
let query = {};
Expand Down Expand Up @@ -70,6 +70,15 @@ async function list(ctx) {
Domains.countDocuments(query)
]);

// add total alias count to each domain
await Promise.all(
domains.map(async (domain) => {
domain.totalAliases = await Aliases.countDocuments({
domain: domain._id
});
})
);

const pageCount = Math.ceil(itemCount / ctx.query.limit);

if (ctx.accepts('html'))
Expand Down
11 changes: 10 additions & 1 deletion app/controllers/web/admin/users.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const paginate = require('koa-ctx-paginate');
const parser = require('mongodb-query-parser');
const { boolean } = require('boolean');

const { Users } = require('#models');
const { Domains, Users } = require('#models');
const config = require('#config');

const USER_SEARCH_PATHS = [
Expand Down Expand Up @@ -59,6 +59,15 @@ async function list(ctx) {
Users.countDocuments(query)
]);

// add total domain count to each user
await Promise.all(
users.map(async (user) => {
user.totalDomains = await Domains.countDocuments({
'members.user': user._id
});
})
);

const pageCount = Math.ceil(itemCount / ctx.query.limit);

if (ctx.accepts('html'))
Expand Down
3 changes: 3 additions & 0 deletions app/views/admin/domains/_table.pug
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ include ../../_pagination
th(scope="col")
+sortHeader('is_global', 'Global', '#table-domains')
th.align-middle(scope="col")= t("Members")
th(scope="col")
+sortHeader('aliases', 'Aliases', '#table-domains')
th(scope="col")
+sortHeader('plan', 'Plan', '#table-domains')
th(scope="col")
Expand Down Expand Up @@ -52,6 +54,7 @@ include ../../_pagination
= "("
code.text-muted= member.user.id
= ")"
td.align-middle.text-center= domain.totalAliases
td.align-middle.text-center
= t(titleize(humanize(domain.plan)))
td.align-middle.text-center
Expand Down
3 changes: 3 additions & 0 deletions app/views/admin/users/_table.pug
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ include ../../_pagination
+sortHeader(config.passport.fields.familyName, 'Last Name', '#table-users')
th(scope="col")
+sortHeader('email', null, '#table-users')
th(scope="col")
+sortHeader('domains', null, '#table-users')
th(scope="col")
+sortHeader('plan', null, '#table-users')
th(scope="col")
Expand Down Expand Up @@ -43,6 +45,7 @@ include ../../_pagination
= "("
code.text-muted= user.id
= ")"
td.align-middle= user.totalDomains
td.align-middle= titleize(humanize(user.plan))
td.align-middle= titleize(humanize(user.group))
td.align-middle.dayjs(
Expand Down
3 changes: 2 additions & 1 deletion locales/ar.json
Original file line number Diff line number Diff line change
Expand Up @@ -10310,5 +10310,6 @@
"Open-source Email Hosting Service": "خدمة استضافة البريد الإلكتروني مفتوحة المصدر",
"Custom Domain Email Forwarding": "إعادة توجيه البريد الإلكتروني إلى نطاق مخصص",
"Suggested": "مقترح",
"Its description from its website is:": "وصفه من موقعه على الإنترنت هو:"
"Its description from its website is:": "وصفه من موقعه على الإنترنت هو:",
"domains": "domains"
}
3 changes: 2 additions & 1 deletion locales/cs.json
Original file line number Diff line number Diff line change
Expand Up @@ -10310,5 +10310,6 @@
"Open-source Email Hosting Service": "Open-source e-mailová hostingová služba",
"Custom Domain Email Forwarding": "Přeposílání e-mailů na vlastní doménu",
"Suggested": "Doporučeno",
"Its description from its website is:": "Jeho popis z jeho webu je:"
"Its description from its website is:": "Jeho popis z jeho webu je:",
"domains": "domains"
}
3 changes: 2 additions & 1 deletion locales/da.json
Original file line number Diff line number Diff line change
Expand Up @@ -7297,5 +7297,6 @@
"Legacy Free Guide": "Legacy gratis guide",
"Suggested": "Foreslået",
"Its description from its website is:": "Beskrivelsen fra dens hjemmeside er:",
"Compare <span class=\"notranslate\">%s</span> with <span class=\"notranslate\">%d</span> email services": "Sammenlign <span class=\"notranslate\">%s</span> med <span class=\"notranslate\">%d</span> e-mail-tjenester"
"Compare <span class=\"notranslate\">%s</span> with <span class=\"notranslate\">%d</span> email services": "Sammenlign <span class=\"notranslate\">%s</span> med <span class=\"notranslate\">%d</span> e-mail-tjenester",
"domains": "domains"
}
3 changes: 2 additions & 1 deletion locales/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -9349,5 +9349,6 @@
"Open-source Email Hosting Service": "Open-Source-E-Mail-Hosting-Dienst",
"Custom Domain Email Forwarding": "Benutzerdefinierte Domänen-E-Mail-Weiterleitung",
"Suggested": "Empfohlen",
"Its description from its website is:": "Die Beschreibung auf der Website lautet:"
"Its description from its website is:": "Die Beschreibung auf der Website lautet:",
"domains": "domains"
}
14 changes: 13 additions & 1 deletion locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -6693,5 +6693,17 @@
"If your ISP blocks outbound port 25, then you will have to find an alternate solution or contact them.": "If your ISP blocks outbound port 25, then you will have to find an alternate solution or contact them.",
"You can run": "You can run",
"from command line or terminal to see if your outbound port 25 connection is blocked.": "from command line or terminal to see if your outbound port 25 connection is blocked.",
"Español": "Español"
"Español": "Español",
"You do not belong to the administrative user group.": "You do not belong to the administrative user group.",
"Admin - Users": "Admin - Users",
"Search for users": "Search for users",
"Search by first name, last name, or email": "Search by first name, last name, or email",
"First Name": "First Name",
"Last Name": "Last Name",
"email": "email",
"domains": "domains",
"plan": "plan",
"group": "group",
"Last Login": "Last Login",
"Log in as user": "Log in as user"
}
3 changes: 2 additions & 1 deletion locales/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -10308,5 +10308,6 @@
"Open-source Email Hosting Service": "Servicio de alojamiento de correo electrónico de código abierto",
"Custom Domain Email Forwarding": "Reenvío de correo electrónico de dominio personalizado",
"Suggested": "Sugerido",
"Its description from its website is:": "Su descripción desde su sitio web es:"
"Its description from its website is:": "Su descripción desde su sitio web es:",
"domains": "domains"
}
3 changes: 2 additions & 1 deletion locales/fi.json
Original file line number Diff line number Diff line change
Expand Up @@ -10157,5 +10157,6 @@
"Open-source Email Hosting Service": "Avoimen lähdekoodin sähköpostipalvelu",
"Custom Domain Email Forwarding": "Mukautetun verkkotunnuksen sähköpostin edelleenlähetys",
"Suggested": "Ehdotettu",
"Its description from its website is:": "Sen kuvaus sen verkkosivuilta on:"
"Its description from its website is:": "Sen kuvaus sen verkkosivuilta on:",
"domains": "domains"
}
3 changes: 2 additions & 1 deletion locales/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -7834,5 +7834,6 @@
"Custom Domain Email Forwarding": "Transfert d'e-mails de domaine personnalisé",
"Legacy Free Guide": "Guide gratuit sur l'héritage",
"Suggested": "Suggéré",
"Its description from its website is:": "Sa description sur son site Web est :"
"Its description from its website is:": "Sa description sur son site Web est :",
"domains": "domains"
}
3 changes: 2 additions & 1 deletion locales/he.json
Original file line number Diff line number Diff line change
Expand Up @@ -8330,5 +8330,6 @@
"Custom Domain Email Forwarding": "העברת דואר אלקטרוני בדומיין מותאם אישית",
"Legacy Free Guide": "מדריך חינם מדור קודם",
"Suggested": "מוּצָע",
"Its description from its website is:": "התיאור שלו מהאתר שלו הוא:"
"Its description from its website is:": "התיאור שלו מהאתר שלו הוא:",
"domains": "domains"
}
3 changes: 2 additions & 1 deletion locales/hu.json
Original file line number Diff line number Diff line change
Expand Up @@ -10310,5 +10310,6 @@
"Open-source Email Hosting Service": "Nyílt forráskódú e-mail hosting szolgáltatás",
"Custom Domain Email Forwarding": "Egyéni domain e-mail továbbítása",
"Suggested": "Javasolt",
"Its description from its website is:": "Leírása a honlapjáról a következő:"
"Its description from its website is:": "Leírása a honlapjáról a következő:",
"domains": "domains"
}
3 changes: 2 additions & 1 deletion locales/id.json
Original file line number Diff line number Diff line change
Expand Up @@ -10310,5 +10310,6 @@
"Open-source Email Hosting Service": "Layanan Hosting Email Sumber Terbuka",
"Custom Domain Email Forwarding": "Penerusan Email Domain Kustom",
"Suggested": "Disarankan",
"Its description from its website is:": "Uraian dari situs webnya adalah:"
"Its description from its website is:": "Uraian dari situs webnya adalah:",
"domains": "domains"
}
3 changes: 2 additions & 1 deletion locales/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -10310,5 +10310,6 @@
"Open-source Email Hosting Service": "Servizio di hosting di posta elettronica open source",
"Custom Domain Email Forwarding": "Inoltro e-mail di dominio personalizzato",
"Suggested": "Suggerito",
"Its description from its website is:": "La descrizione dal suo sito web è:"
"Its description from its website is:": "La descrizione dal suo sito web è:",
"domains": "domains"
}
3 changes: 2 additions & 1 deletion locales/ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -10310,5 +10310,6 @@
"Open-source Email Hosting Service": "オープンソースのメールホスティングサービス",
"Custom Domain Email Forwarding": "カスタムドメインメール転送",
"Suggested": "提案",
"Its description from its website is:": "ウェブサイトからの説明は次のとおりです。"
"Its description from its website is:": "ウェブサイトからの説明は次のとおりです。",
"domains": "domains"
}
3 changes: 2 additions & 1 deletion locales/ko.json
Original file line number Diff line number Diff line change
Expand Up @@ -10310,5 +10310,6 @@
"Open-source Email Hosting Service": "오픈소스 이메일 호스팅 서비스",
"Custom Domain Email Forwarding": "사용자 정의 도메인 이메일 전달",
"Suggested": "제안된",
"Its description from its website is:": "해당 웹사이트의 설명은 다음과 같습니다."
"Its description from its website is:": "해당 웹사이트의 설명은 다음과 같습니다.",
"domains": "domains"
}
3 changes: 2 additions & 1 deletion locales/nl.json
Original file line number Diff line number Diff line change
Expand Up @@ -10310,5 +10310,6 @@
"Open-source Email Hosting Service": "Open-source e-mailhostingservice",
"Custom Domain Email Forwarding": "E-mail doorsturen naar aangepast domein",
"Suggested": "Voorgesteld",
"Its description from its website is:": "De beschrijving op de website is:"
"Its description from its website is:": "De beschrijving op de website is:",
"domains": "domains"
}
3 changes: 2 additions & 1 deletion locales/no.json
Original file line number Diff line number Diff line change
Expand Up @@ -10315,5 +10315,6 @@
"Open-source Email Hosting Service": "Åpen kildekode e-postvertstjeneste",
"Custom Domain Email Forwarding": "Egendefinert domene-e-postvideresending",
"Suggested": "Foreslått",
"Its description from its website is:": "Beskrivelsen fra nettstedet er:"
"Its description from its website is:": "Beskrivelsen fra nettstedet er:",
"domains": "domains"
}
3 changes: 2 additions & 1 deletion locales/pl.json
Original file line number Diff line number Diff line change
Expand Up @@ -10310,5 +10310,6 @@
"Open-source Email Hosting Service": "Usługa hostingu poczty e-mail typu open source",
"Custom Domain Email Forwarding": "Przekierowanie poczty e-mail na domenę niestandardową",
"Suggested": "Sugerowane",
"Its description from its website is:": "Opis na stronie internetowej brzmi następująco:"
"Its description from its website is:": "Opis na stronie internetowej brzmi następująco:",
"domains": "domains"
}
3 changes: 2 additions & 1 deletion locales/pt.json
Original file line number Diff line number Diff line change
Expand Up @@ -10310,5 +10310,6 @@
"Open-source Email Hosting Service": "Serviço de hospedagem de e-mail de código aberto",
"Custom Domain Email Forwarding": "Encaminhamento de e-mail de domínio personalizado",
"Suggested": "Sugerido",
"Its description from its website is:": "A descrição no seu site é:"
"Its description from its website is:": "A descrição no seu site é:",
"domains": "domains"
}
3 changes: 2 additions & 1 deletion locales/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -10310,5 +10310,6 @@
"Open-source Email Hosting Service": "Служба хостинга электронной почты с открытым исходным кодом",
"Custom Domain Email Forwarding": "Пересылка электронной почты на пользовательский домен",
"Suggested": "Предложенный",
"Its description from its website is:": "Описание на сайте:"
"Its description from its website is:": "Описание на сайте:",
"domains": "domains"
}
3 changes: 2 additions & 1 deletion locales/sv.json
Original file line number Diff line number Diff line change
Expand Up @@ -10310,5 +10310,6 @@
"Open-source Email Hosting Service": "E-postvärdtjänst med öppen källkod",
"Custom Domain Email Forwarding": "Anpassad vidarebefordran av e-post på domän",
"Suggested": "Föreslog",
"Its description from its website is:": "Dess beskrivning från dess hemsida är:"
"Its description from its website is:": "Dess beskrivning från dess hemsida är:",
"domains": "domains"
}
3 changes: 2 additions & 1 deletion locales/th.json
Original file line number Diff line number Diff line change
Expand Up @@ -10310,5 +10310,6 @@
"Open-source Email Hosting Service": "บริการโฮสติ้งอีเมล์โอเพ่นซอร์ส",
"Custom Domain Email Forwarding": "การส่งต่ออีเมลโดเมนที่กำหนดเอง",
"Suggested": "ข้อเสนอแนะ",
"Its description from its website is:": "คำอธิบายจากเว็บไซต์มีดังนี้:"
"Its description from its website is:": "คำอธิบายจากเว็บไซต์มีดังนี้:",
"domains": "domains"
}
3 changes: 2 additions & 1 deletion locales/tr.json
Original file line number Diff line number Diff line change
Expand Up @@ -10310,5 +10310,6 @@
"Open-source Email Hosting Service": "Açık Kaynaklı E-posta Barındırma Hizmeti",
"Custom Domain Email Forwarding": "Özel Alan Adı E-posta Yönlendirme",
"Suggested": "Önerilen",
"Its description from its website is:": "Web sitesindeki açıklaması şöyle:"
"Its description from its website is:": "Web sitesindeki açıklaması şöyle:",
"domains": "domains"
}
3 changes: 2 additions & 1 deletion locales/uk.json
Original file line number Diff line number Diff line change
Expand Up @@ -10310,5 +10310,6 @@
"Open-source Email Hosting Service": "Служба хостингу електронної пошти з відкритим кодом",
"Custom Domain Email Forwarding": "Переадресація електронної пошти власного домену",
"Suggested": "Запропоновано",
"Its description from its website is:": "Його опис на веб-сайті:"
"Its description from its website is:": "Його опис на веб-сайті:",
"domains": "domains"
}
3 changes: 2 additions & 1 deletion locales/vi.json
Original file line number Diff line number Diff line change
Expand Up @@ -7839,5 +7839,6 @@
"Custom Domain Email Forwarding": "Chuyển tiếp Email theo tên miền tùy chỉnh",
"Legacy Free Guide": "Hướng dẫn miễn phí Legacy",
"Suggested": "Đề xuất",
"Its description from its website is:": "Mô tả từ trang web của nó như sau:"
"Its description from its website is:": "Mô tả từ trang web của nó như sau:",
"domains": "domains"
}
3 changes: 2 additions & 1 deletion locales/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -10003,5 +10003,6 @@
"Open-source Email Hosting Service": "开源电子邮件托管服务",
"Custom Domain Email Forwarding": "自定义域名电子邮件转发",
"Suggested": "建议",
"Its description from its website is:": "其网站上的描述是:"
"Its description from its website is:": "其网站上的描述是:",
"domains": "domains"
}

0 comments on commit b059abb

Please sign in to comment.