mirror of
https://github.com/karl0ss/homepage.git
synced 2025-05-01 21:13:39 +01:00
Feature: mailcow widget (#3993)
--------- Co-authored-by: shamoon <4887959+shamoon@users.noreply.github.com>
This commit is contained in:
parent
1f47ee8f11
commit
85736c55c9
15
docs/widgets/services/mailcow.md
Normal file
15
docs/widgets/services/mailcow.md
Normal file
@ -0,0 +1,15 @@
|
||||
---
|
||||
title: Mailcow
|
||||
description: Mailcow Widget Configuration
|
||||
---
|
||||
|
||||
Learn more about [Mailcow](https://github.com/mailcow/mailcow-dockerized).
|
||||
|
||||
Allowed fields: `["domains", "mailboxes", "mails", "storage"]`.
|
||||
|
||||
```yaml
|
||||
widget:
|
||||
type: mailcow
|
||||
url: https://mailcow.host.or.ip
|
||||
key: mailcowapikey
|
||||
```
|
@ -850,6 +850,12 @@
|
||||
"screenshots": "Screenshots",
|
||||
"totalfilesize": "Total Size"
|
||||
},
|
||||
"mailcow": {
|
||||
"domains": "Domains",
|
||||
"mailboxes": "Mailboxes",
|
||||
"mails": "Mails",
|
||||
"storage": "Storage"
|
||||
},
|
||||
"netdata": {
|
||||
"warnings": "Warnings",
|
||||
"criticals": "Criticals"
|
||||
|
@ -56,6 +56,7 @@ const components = {
|
||||
kopia: dynamic(() => import("./kopia/component")),
|
||||
lidarr: dynamic(() => import("./lidarr/component")),
|
||||
linkwarden: dynamic(() => import("./linkwarden/component")),
|
||||
mailcow: dynamic(() => import("./mailcow/component")),
|
||||
mastodon: dynamic(() => import("./mastodon/component")),
|
||||
mealie: dynamic(() => import("./mealie/component")),
|
||||
medusa: dynamic(() => import("./medusa/component")),
|
||||
|
40
src/widgets/mailcow/component.jsx
Normal file
40
src/widgets/mailcow/component.jsx
Normal file
@ -0,0 +1,40 @@
|
||||
import { useTranslation } from "next-i18next";
|
||||
|
||||
import Container from "components/services/widget/container";
|
||||
import Block from "components/services/widget/block";
|
||||
import useWidgetAPI from "utils/proxy/use-widget-api";
|
||||
|
||||
export default function Component({ service }) {
|
||||
const { t } = useTranslation();
|
||||
|
||||
const { widget } = service;
|
||||
const { data: resultData, error: resultError } = useWidgetAPI(widget, "domains");
|
||||
|
||||
if (resultError || (resultData && Object.keys(resultData).length === 0)) {
|
||||
return <Container service={service} error={resultError ?? { message: "No domains found" }} />;
|
||||
}
|
||||
|
||||
if (!resultData) {
|
||||
return (
|
||||
<Container service={service}>
|
||||
<Block label="mailcow.mailboxes" />
|
||||
<Block label="mailcow.aliases" />
|
||||
<Block label="mailcow.quarantined" />
|
||||
</Container>
|
||||
);
|
||||
}
|
||||
|
||||
const domains = resultData.length;
|
||||
const mailboxes = resultData.reduce((acc, val) => acc + val.mboxes_in_domain, 0);
|
||||
const mails = resultData.reduce((acc, val) => acc + val.msgs_total, 0);
|
||||
const storage = resultData.reduce((acc, val) => acc + val.bytes_total, 0);
|
||||
|
||||
return (
|
||||
<Container service={service}>
|
||||
<Block label="mailcow.domains" value={t("common.number", { value: domains })} />
|
||||
<Block label="mailcow.mailboxes" value={t("common.number", { value: mailboxes })} />
|
||||
<Block label="mailcow.mails" value={t("common.number", { value: mails })} />
|
||||
<Block label="mailcow.storage" value={t("common.bytes", { value: storage })} />
|
||||
</Container>
|
||||
);
|
||||
}
|
14
src/widgets/mailcow/widget.js
Normal file
14
src/widgets/mailcow/widget.js
Normal file
@ -0,0 +1,14 @@
|
||||
import credentialedProxyHandler from "../../utils/proxy/handlers/credentialed";
|
||||
|
||||
const widget = {
|
||||
api: "{url}/api/v1/get/{endpoint}",
|
||||
proxyHandler: credentialedProxyHandler,
|
||||
|
||||
mappings: {
|
||||
domains: {
|
||||
endpoint: "domain/all",
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
export default widget;
|
@ -48,6 +48,7 @@ import komga from "./komga/widget";
|
||||
import kopia from "./kopia/widget";
|
||||
import lidarr from "./lidarr/widget";
|
||||
import linkwarden from "./linkwarden/widget";
|
||||
import mailcow from "./mailcow/widget";
|
||||
import mastodon from "./mastodon/widget";
|
||||
import mealie from "./mealie/widget";
|
||||
import medusa from "./medusa/widget";
|
||||
@ -173,6 +174,7 @@ const widgets = {
|
||||
kopia,
|
||||
lidarr,
|
||||
linkwarden,
|
||||
mailcow,
|
||||
mastodon,
|
||||
mealie,
|
||||
medusa,
|
||||
|
Loading…
x
Reference in New Issue
Block a user