feat: DnsHole feature parity with oldmarr (#1145)

* feat: DnsHole feature parity with oldmarr
feat: advanced control management
feat: disconnected state
fix: summary widget sizing
feat: summary text flash on update

* feat: dnshole summary integrations disconnected error page

* fix: classnaming

* refactor: small rename, console to logger and unnecessary as conversion changes

---------

Co-authored-by: Meier Lukas <meierschlumpf@gmail.com>
This commit is contained in:
SeDemal
2024-09-24 23:25:13 +02:00
committed by GitHub
parent 07f72f7367
commit 36915d95fe
16 changed files with 467 additions and 145 deletions
@@ -0,0 +1,28 @@
import { EVERY_5_SECONDS } from "@homarr/cron-jobs-core/expressions";
import { db } from "@homarr/db";
import { getItemsWithIntegrationsAsync } from "@homarr/db/queries";
import { integrationCreatorFromSecrets } from "@homarr/integrations";
import type { DnsHoleSummary } from "@homarr/integrations/types";
import { logger } from "@homarr/log";
import { createItemAndIntegrationChannel } from "@homarr/redis";
import { createCronJob } from "../../lib";
export const dnsHoleJob = createCronJob("dnsHole", EVERY_5_SECONDS).withCallback(async () => {
const itemsForIntegration = await getItemsWithIntegrationsAsync(db, {
kinds: ["dnsHoleSummary", "dnsHoleControls"],
});
for (const itemForIntegration of itemsForIntegration) {
for (const { integration } of itemForIntegration.integrations) {
const integrationInstance = integrationCreatorFromSecrets(integration);
await integrationInstance
.getSummaryAsync()
.then(async (data) => {
const channel = createItemAndIntegrationChannel<DnsHoleSummary>(itemForIntegration.kind, integration.id);
await channel.publishAndUpdateLastStateAsync(data);
})
.catch((error) => logger.error(`Could not retrieve data for ${integration.name}: "${error}"`));
}
}
});