From f04e50eebf505a608475e87d9e4814bcd3f7cdaa Mon Sep 17 00:00:00 2001 From: hillaliy Date: Fri, 26 Apr 2024 19:52:16 +0300 Subject: [PATCH 1/9] Feature: Add dns disable timer --- src/server/api/routers/dns-hole/router.ts | 13 ++- src/tools/server/sdk/adGuard/adGuard.ts | 8 +- src/tools/server/sdk/pihole/piHole.ts | 11 +- src/widgets/dnshole/DnsHoleControls.tsx | 130 ++++++++++++++++++++-- 4 files changed, 141 insertions(+), 21 deletions(-) diff --git a/src/server/api/routers/dns-hole/router.ts b/src/server/api/routers/dns-hole/router.ts index 8f02ea981b5..d58039a5319 100644 --- a/src/server/api/routers/dns-hole/router.ts +++ b/src/server/api/routers/dns-hole/router.ts @@ -14,6 +14,7 @@ export const dnsHoleRouter = createTRPCRouter({ .input( z.object({ action: z.enum(['enable', 'disable']), + duration: z.number(), configName: z.string(), appsToChange: z.optional(z.array(z.string())), }) @@ -32,12 +33,12 @@ export const dnsHoleRouter = createTRPCRouter({ await Promise.all( applicableApps.map(async (app) => { if (app.integration?.type === 'pihole') { - await processPiHole(app, input.action === 'enable'); + await processPiHole(app, input.action === 'enable', input.duration); return; } - await processAdGuard(app, input.action === 'enable'); + await processAdGuard(app, input.action === 'enable', input.duration); }) ); }), @@ -89,7 +90,7 @@ export const dnsHoleRouter = createTRPCRouter({ }), }); -const processAdGuard = async (app: ConfigAppType, enable: boolean) => { +const processAdGuard = async (app: ConfigAppType, enable: boolean, duration: number = 0) => { const adGuard = new AdGuard( app.url, findAppProperty(app, 'username'), @@ -106,13 +107,13 @@ const processAdGuard = async (app: ConfigAppType, enable: boolean) => { } try { - await adGuard.disable(); + await adGuard.disable(duration); } catch (error) { Consola.error((error as Error).message); } }; -const processPiHole = async (app: ConfigAppType, enable: boolean) => { +const processPiHole = async (app: ConfigAppType, enable: boolean, duration: number = 0) => { const pihole = new PiHoleClient(app.url, findAppProperty(app, 'apiKey')); if (enable) { @@ -125,7 +126,7 @@ const processPiHole = async (app: ConfigAppType, enable: boolean) => { } try { - await pihole.disable(); + await pihole.disable(duration); } catch (error) { Consola.error((error as Error).message); } diff --git a/src/tools/server/sdk/adGuard/adGuard.ts b/src/tools/server/sdk/adGuard/adGuard.ts index 461b06f64aa..f1c631c29e1 100644 --- a/src/tools/server/sdk/adGuard/adGuard.ts +++ b/src/tools/server/sdk/adGuard/adGuard.ts @@ -59,8 +59,8 @@ export class AdGuard { .reduce((sum, filter) => filter.rules_count + sum, 0); } - async disable() { - await this.changeProtectionStatus(false); + async disable(duration: number) { + await this.changeProtectionStatus(false, duration); } async enable() { await this.changeProtectionStatus(true); @@ -69,7 +69,7 @@ export class AdGuard { /** * Make a post request to the AdGuard API to change the protection status based on the value of newStatus * @param {boolean} newStatus - The new status of the protection - * @param {number} duration - Duration of a pause, in milliseconds. Enabled should be false. + * @param {number} duration - Duration of a pause, in seconds. Enabled should be false. * @returns {string} - The response from the AdGuard API */ private async changeProtectionStatus(newStatus: boolean, duration = 0) { @@ -78,7 +78,7 @@ export class AdGuard { `${this.baseHostName}/control/protection`, { enabled: newStatus, - duration, + duration: duration * 1000, }, { headers: { diff --git a/src/tools/server/sdk/pihole/piHole.ts b/src/tools/server/sdk/pihole/piHole.ts index 76ed4517c2f..52c55867f81 100644 --- a/src/tools/server/sdk/pihole/piHole.ts +++ b/src/tools/server/sdk/pihole/piHole.ts @@ -37,16 +37,19 @@ export class PiHoleClient { return response.status === 'enabled'; } - async disable() { - const response = await this.sendStatusChangeRequest('disable'); + async disable(duration: number) { + const response = await this.sendStatusChangeRequest('disable', duration); return response.status === 'disabled'; } private async sendStatusChangeRequest( - action: 'enable' | 'disable' + action: 'enable' | 'disable', + duration = 0 ): Promise { const response = await fetch( - `${this.baseHostName}/admin/api.php?${action}&auth=${this.apiToken}` + duration !== 0 + ? `${this.baseHostName}/admin/api.php?${action}=${duration}&auth=${this.apiToken}` + : `${this.baseHostName}/admin/api.php?${action}&auth=${this.apiToken}` ); if (response.status !== 200) { diff --git a/src/widgets/dnshole/DnsHoleControls.tsx b/src/widgets/dnshole/DnsHoleControls.tsx index 872f891c375..6379b3c8396 100644 --- a/src/widgets/dnshole/DnsHoleControls.tsx +++ b/src/widgets/dnshole/DnsHoleControls.tsx @@ -1,21 +1,33 @@ import { + ActionIcon, Badge, Box, Button, Card, Center, + Flex, Group, Image, + Modal, + NumberInput, + NumberInputHandlers, SimpleGrid, Stack, Text, Title, UnstyledButton, + rem, } from '@mantine/core'; -import { useElementSize } from '@mantine/hooks'; -import { IconDeviceGamepad, IconPlayerPlay, IconPlayerStop } from '@tabler/icons-react'; +import { useDisclosure, useElementSize } from '@mantine/hooks'; +import { + IconClockPause, + IconDeviceGamepad, + IconPlayerPlay, + IconPlayerStop, +} from '@tabler/icons-react'; import { useSession } from 'next-auth/react'; import { useTranslation } from 'next-i18next'; +import { useRef, useState } from 'react'; import { useConfigContext } from '~/config/provider'; import { api } from '~/utils/api'; @@ -69,6 +81,11 @@ const dnsLightStatus = ( function DnsHoleControlsWidgetTile({ widget }: DnsHoleControlsWidgetProps) { const { data: sessionData } = useSession(); + const [opened, { close, open }] = useDisclosure(false); + const [hours, setHours] = useState(0); + const [minutes, setMinutes] = useState(0); + const hoursHandlers = useRef(); + const minutesHandlers = useRef(); const { isInitialLoading, data, isFetching: fetchingDnsSummary } = useDnsHoleSummeryQuery(); const { mutateAsync, isLoading: changingStatus } = useDnsHoleControlMutation(); const { width, ref } = useElementSize(); @@ -124,10 +141,17 @@ function DnsHoleControlsWidgetTile({ widget }: DnsHoleControlsWidgetProps) { return dnsList; }; - const toggleDns = async (action: 'enable' | 'disable', appsToChange?: string[]) => { + const toggleDns = async ( + action: 'enable' | 'disable', + appsToChange?: string[], + hours: number = 0, + minutes: number = 0 + ) => { + const duration = hours * 3600 + minutes * 60; await mutateAsync( { action, + duration, configName, appsToChange, }, @@ -158,8 +182,100 @@ function DnsHoleControlsWidgetTile({ widget }: DnsHoleControlsWidgetProps) { > {t('enableAll')} + + + + + + Hours + hoursHandlers.current?.decrement()} + > + – + + + setHours(Number(val))} + handlersRef={hoursHandlers} + max={23} + min={0} + step={1} + styles={{ input: { width: rem(54), textAlign: 'center' } }} + /> + + hoursHandlers.current?.increment()} + > + + + + + + Minutes + minutesHandlers.current?.decrement()} + > + – + + + setMinutes(Number(val))} + handlersRef={minutesHandlers} + max={59} + min={0} + step={1} + styles={{ input: { width: rem(54), textAlign: 'center' } }} + /> + + minutesHandlers.current?.increment()} + > + + + + + + + leave empty for unlimited + + + + + From 40fdfe218368e2497525f6a8fe505c8a4370c17b Mon Sep 17 00:00:00 2001 From: hillaliy Date: Sat, 27 Apr 2024 20:18:01 +0300 Subject: [PATCH 3/9] Fix: translation, disable individual integration --- public/locales/en/modules/dns-hole-controls.json | 14 +++++++------- src/widgets/dnshole/DnsHoleControls.tsx | 15 ++++++++------- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/public/locales/en/modules/dns-hole-controls.json b/public/locales/en/modules/dns-hole-controls.json index 275df36297d..562bf62afb9 100644 --- a/public/locales/en/modules/dns-hole-controls.json +++ b/public/locales/en/modules/dns-hole-controls.json @@ -8,18 +8,18 @@ "label": "Show 'Enable/Disable All' Buttons" } }, - "durationModal": { - "title": "Set disable duration time", - "hours": "Hours", - "minutes": "Minutes", - "unlimited": "leave empty for unlimited", - "set": "Set" - }, "errors": { "general": { "title": "Unable to find a DNS hole", "text": "There was a problem connecting to your DNS Hole(s). Please verify your configuration/integration(s)." } } + }, + "durationModal": { + "title": "Set disable duration time", + "hours": "Hours", + "minutes": "Minutes", + "unlimited": "leave empty for unlimited", + "set": "Set" } } \ No newline at end of file diff --git a/src/widgets/dnshole/DnsHoleControls.tsx b/src/widgets/dnshole/DnsHoleControls.tsx index 74c8cb34a36..dc5113e942f 100644 --- a/src/widgets/dnshole/DnsHoleControls.tsx +++ b/src/widgets/dnshole/DnsHoleControls.tsx @@ -86,6 +86,7 @@ function DnsHoleControlsWidgetTile({ widget }: DnsHoleControlsWidgetProps) { const [minutes, setMinutes] = useState(0); const hoursHandlers = useRef(); const minutesHandlers = useRef(); + const [appId, setAppId] = useState(''); const { isInitialLoading, data, isFetching: fetchingDnsSummary } = useDnsHoleSummeryQuery(); const { mutateAsync, isLoading: changingStatus } = useDnsHoleControlMutation(); const { width, ref } = useElementSize(); @@ -161,6 +162,9 @@ function DnsHoleControlsWidgetTile({ widget }: DnsHoleControlsWidgetProps) { }, } ); + setHours(0); + setMinutes(0); + setAppId(''); }; return ( @@ -203,7 +207,6 @@ function DnsHoleControlsWidgetTile({ widget }: DnsHoleControlsWidgetProps) { > – - - - - { - toggleDns('disable', getDnsStatus()?.enabled, hours, minutes); - setHours(0); - setMinutes(0); + appId === '' + ? toggleDns('disable', getDnsStatus()?.enabled, hours, minutes) + : toggleDns('disable', [appId], hours, minutes); close(); }} > @@ -321,6 +321,7 @@ function DnsHoleControlsWidgetTile({ widget }: DnsHoleControlsWidgetProps) { {app.name} { + setAppId(app.id); dnsHole.status === 'enabled' ? open() : toggleDns('enable', [app.id]); }} disabled={fetchingDnsSummary || changingStatus} From f047c2aa30ae7e7889a4993363b1d03c188de15f Mon Sep 17 00:00:00 2001 From: hillaliy Date: Sun, 28 Apr 2024 17:38:47 +0300 Subject: [PATCH 4/9] Fix: summary refresh --- src/widgets/dnshole/DnsHoleControls.tsx | 37 +++++++++++++++++++------ 1 file changed, 29 insertions(+), 8 deletions(-) diff --git a/src/widgets/dnshole/DnsHoleControls.tsx b/src/widgets/dnshole/DnsHoleControls.tsx index dc5113e942f..d36aa8c3ad7 100644 --- a/src/widgets/dnshole/DnsHoleControls.tsx +++ b/src/widgets/dnshole/DnsHoleControls.tsx @@ -159,6 +159,13 @@ function DnsHoleControlsWidgetTile({ widget }: DnsHoleControlsWidgetProps) { { onSettled: () => { trpcUtils.dnsHole.summary.invalidate(); + + setTimeout( + () => { + trpcUtils.dnsHole.summary.invalidate(); + }, + (duration + 3) * 1000 + ); }, } ); @@ -263,9 +270,12 @@ function DnsHoleControlsWidgetTile({ widget }: DnsHoleControlsWidgetProps) { h="2rem" w="12rem" onClick={() => { - appId === '' - ? toggleDns('disable', getDnsStatus()?.enabled, hours, minutes) - : toggleDns('disable', [appId], hours, minutes); + toggleDns( + 'disable', + appId !== '' ? [appId] : getDnsStatus()?.enabled, + hours, + minutes + ); close(); }} > @@ -317,13 +327,12 @@ function DnsHoleControlsWidgetTile({ widget }: DnsHoleControlsWidgetProps) { > - + {app.name} { - setAppId(app.id); - dnsHole.status === 'enabled' ? open() : toggleDns('enable', [app.id]); - }} + onClick={() => + toggleDns(dnsHole.status === 'enabled' ? 'disable' : 'enable', [app.id]) + } disabled={fetchingDnsSummary || changingStatus} style={{ pointerEvents: enableControls ? 'auto' : 'none' }} > @@ -350,6 +359,18 @@ function DnsHoleControlsWidgetTile({ widget }: DnsHoleControlsWidgetProps) { {t(dnsHole.status)} + { + setAppId(app.id); + open(); + }} + > + + From 6b5c9ada1141f817bdae5b975d931817b669e51f Mon Sep 17 00:00:00 2001 From: hillaliy Date: Tue, 30 Apr 2024 20:23:42 +0300 Subject: [PATCH 5/9] New design --- public/locales/en/common.json | 1 + src/widgets/dnshole/DnsHoleControls.tsx | 325 +++++++++++++----------- 2 files changed, 173 insertions(+), 153 deletions(-) diff --git a/public/locales/en/common.json b/public/locales/en/common.json index bebc69de876..3f3b569225a 100644 --- a/public/locales/en/common.json +++ b/public/locales/en/common.json @@ -17,6 +17,7 @@ "disabled": "Disabled", "enableAll": "Enable all", "disableAll": "Disable all", + "setTimer": "Set timer", "version": "Version", "changePosition": "Change position", "remove": "Remove", diff --git a/src/widgets/dnshole/DnsHoleControls.tsx b/src/widgets/dnshole/DnsHoleControls.tsx index d36aa8c3ad7..f407a348ab2 100644 --- a/src/widgets/dnshole/DnsHoleControls.tsx +++ b/src/widgets/dnshole/DnsHoleControls.tsx @@ -11,10 +11,10 @@ import { Modal, NumberInput, NumberInputHandlers, - SimpleGrid, Stack, Text, Title, + Tooltip, UnstyledButton, rem, } from '@mantine/core'; @@ -175,127 +175,145 @@ function DnsHoleControlsWidgetTile({ widget }: DnsHoleControlsWidgetProps) { }; return ( - + {enableControls && widget.properties.showToggleAllButtons && ( - 275 ? 2 : 1} - verticalSpacing="0.25rem" - spacing="0.25rem" - > - + + + + - - - - - {t('modules/dns-hole-controls:durationModal.hours')} - hoursHandlers.current?.decrement()} - > - – - - setHours(Number(val))} - handlersRef={hoursHandlers} - max={23} - min={0} - step={1} - styles={{ input: { width: rem(54), textAlign: 'center' } }} - /> - hoursHandlers.current?.increment()} - > - + - - - - {t('modules/dns-hole-controls:durationModal.minutes')} - minutesHandlers.current?.decrement()} - > - – - - setMinutes(Number(val))} - handlersRef={minutesHandlers} - max={59} - min={0} - step={1} - styles={{ input: { width: rem(54), textAlign: 'center' } }} - /> - minutesHandlers.current?.increment()} - > - + - - - - - {t('modules/dns-hole-controls:durationModal.unlimited')} - - - - + + + + + + + + + )} + + + + + {t('modules/dns-hole-controls:durationModal.hours')} + hoursHandlers.current?.decrement()} + > + – + + setHours(Number(val))} + handlersRef={hoursHandlers} + max={23} + min={0} + step={1} + styles={{ input: { width: rem(54), textAlign: 'center' } }} + /> + hoursHandlers.current?.increment()} + > + + + + + + {t('modules/dns-hole-controls:durationModal.minutes')} + minutesHandlers.current?.decrement()} + > + – + + setMinutes(Number(val))} + handlersRef={minutesHandlers} + max={59} + min={0} + step={1} + styles={{ input: { width: rem(54), textAlign: 'center' } }} + /> + minutesHandlers.current?.increment()} + > + + + + + + + {t('modules/dns-hole-controls:durationModal.unlimited')} + - - )} + + {app.name} - - toggleDns(dnsHole.status === 'enabled' ? 'disable' : 'enable', [app.id]) - } - disabled={fetchingDnsSummary || changingStatus} - style={{ pointerEvents: enableControls ? 'auto' : 'none' }} - > - ({ - root: { - '&:hover': { - background: - theme.colorScheme === 'dark' - ? theme.colors.dark[4] - : theme.colors.gray[2], - }, - '&:active': { - background: - theme.colorScheme === 'dark' - ? theme.colors.dark[5] - : theme.colors.gray[3], + + + toggleDns(dnsHole.status === 'enabled' ? 'disable' : 'enable', [app.id]) + } + disabled={fetchingDnsSummary || changingStatus} + style={{ pointerEvents: enableControls ? 'auto' : 'none' }} + > + ({ + root: { + '&:hover': { + background: + theme.colorScheme === 'dark' + ? theme.colors.dark[4] + : theme.colors.gray[2], + }, + '&:active': { + background: + theme.colorScheme === 'dark' + ? theme.colors.dark[5] + : theme.colors.gray[3], + }, }, - }, - })} + })} + > + {t(dnsHole.status)} + + + { + setAppId(app.id); + open(); + }} > - {t(dnsHole.status)} - - - { - setAppId(app.id); - open(); - }} - > - - + + + From 4a4c5e26ca4ce63d34d947e41ac460302bd4110b Mon Sep 17 00:00:00 2001 From: hillaliy Date: Sat, 4 May 2024 10:22:39 +0300 Subject: [PATCH 6/9] Fix: move modal to new component --- src/widgets/dnshole/DnsHoleControls.tsx | 110 ++-------------------- src/widgets/dnshole/TimerModal.tsx | 120 ++++++++++++++++++++++++ 2 files changed, 129 insertions(+), 101 deletions(-) create mode 100644 src/widgets/dnshole/TimerModal.tsx diff --git a/src/widgets/dnshole/DnsHoleControls.tsx b/src/widgets/dnshole/DnsHoleControls.tsx index f407a348ab2..c9aae0de9e4 100644 --- a/src/widgets/dnshole/DnsHoleControls.tsx +++ b/src/widgets/dnshole/DnsHoleControls.tsx @@ -8,17 +8,13 @@ import { Flex, Group, Image, - Modal, - NumberInput, - NumberInputHandlers, Stack, Text, Title, Tooltip, UnstyledButton, - rem, } from '@mantine/core'; -import { useDisclosure, useElementSize } from '@mantine/hooks'; +import { useDisclosure } from '@mantine/hooks'; import { IconClockPause, IconDeviceGamepad, @@ -27,7 +23,7 @@ import { } from '@tabler/icons-react'; import { useSession } from 'next-auth/react'; import { useTranslation } from 'next-i18next'; -import { useRef, useState } from 'react'; +import { useState } from 'react'; import { useConfigContext } from '~/config/provider'; import { api } from '~/utils/api'; @@ -35,6 +31,7 @@ import { defineWidget } from '../helper'; import { WidgetLoading } from '../loading'; import { IWidget } from '../widgets'; import { useDnsHoleSummeryQuery } from './DnsHoleSummary'; +import { TimerModal } from './TimerModal'; const definition = defineWidget({ id: 'dns-hole-controls', @@ -82,14 +79,9 @@ const dnsLightStatus = ( function DnsHoleControlsWidgetTile({ widget }: DnsHoleControlsWidgetProps) { const { data: sessionData } = useSession(); const [opened, { close, open }] = useDisclosure(false); - const [hours, setHours] = useState(0); - const [minutes, setMinutes] = useState(0); - const hoursHandlers = useRef(); - const minutesHandlers = useRef(); const [appId, setAppId] = useState(''); const { isInitialLoading, data, isFetching: fetchingDnsSummary } = useDnsHoleSummeryQuery(); const { mutateAsync, isLoading: changingStatus } = useDnsHoleControlMutation(); - const { width, ref } = useElementSize(); const { t } = useTranslation(['common', 'modules/dns-hole-controls']); const enableControls = sessionData?.user.isAdmin ?? false; @@ -169,8 +161,6 @@ function DnsHoleControlsWidgetTile({ widget }: DnsHoleControlsWidgetProps) { }, } ); - setHours(0); - setMinutes(0); setAppId(''); }; @@ -225,95 +215,13 @@ function DnsHoleControlsWidgetTile({ widget }: DnsHoleControlsWidgetProps) { )} - - - - - {t('modules/dns-hole-controls:durationModal.hours')} - hoursHandlers.current?.decrement()} - > - – - - setHours(Number(val))} - handlersRef={hoursHandlers} - max={23} - min={0} - step={1} - styles={{ input: { width: rem(54), textAlign: 'center' } }} - /> - hoursHandlers.current?.increment()} - > - + - - - - {t('modules/dns-hole-controls:durationModal.minutes')} - minutesHandlers.current?.decrement()} - > - – - - setMinutes(Number(val))} - handlersRef={minutesHandlers} - max={59} - min={0} - step={1} - styles={{ input: { width: rem(54), textAlign: 'center' } }} - /> - minutesHandlers.current?.increment()} - > - + - - - - - {t('modules/dns-hole-controls:durationModal.unlimited')} - - - - + close={close} + appId={appId} + /> (); + const minutesHandlers = useRef(); + const { t } = useTranslation('modules/dns-hole-controls'); + + return ( + + + + + {t('modules/dns-hole-controls:durationModal.hours')} + hoursHandlers.current?.decrement()} + > + – + + setHours(Number(val))} + handlersRef={hoursHandlers} + max={23} + min={0} + step={1} + styles={{ input: { width: rem(54), textAlign: 'center' } }} + /> + hoursHandlers.current?.increment()} + > + + + + + + {t('modules/dns-hole-controls:durationModal.minutes')} + minutesHandlers.current?.decrement()} + > + – + + setMinutes(Number(val))} + handlersRef={minutesHandlers} + max={59} + min={0} + step={1} + styles={{ input: { width: rem(54), textAlign: 'center' } }} + /> + minutesHandlers.current?.increment()} + > + + + + + + + {t('modules/dns-hole-controls:durationModal.unlimited')} + + + + + ); +} From f21c681e25e9708947a83815bec041aab7dd337b Mon Sep 17 00:00:00 2001 From: hillaliy Date: Mon, 6 May 2024 19:51:29 +0300 Subject: [PATCH 7/9] Fix: refetchInterval, timer reset on close, styling --- src/widgets/dnshole/DnsHoleControls.tsx | 12 +++--------- src/widgets/dnshole/DnsHoleSummary.tsx | 4 ++-- src/widgets/dnshole/TimerModal.tsx | 8 ++++++-- 3 files changed, 11 insertions(+), 13 deletions(-) diff --git a/src/widgets/dnshole/DnsHoleControls.tsx b/src/widgets/dnshole/DnsHoleControls.tsx index c9aae0de9e4..f0a128cd72e 100644 --- a/src/widgets/dnshole/DnsHoleControls.tsx +++ b/src/widgets/dnshole/DnsHoleControls.tsx @@ -151,13 +151,6 @@ function DnsHoleControlsWidgetTile({ widget }: DnsHoleControlsWidgetProps) { { onSettled: () => { trpcUtils.dnsHole.summary.invalidate(); - - setTimeout( - () => { - trpcUtils.dnsHole.summary.invalidate(); - }, - (duration + 3) * 1000 - ); }, } ); @@ -165,7 +158,7 @@ function DnsHoleControlsWidgetTile({ widget }: DnsHoleControlsWidgetProps) { }; return ( - + {enableControls && widget.properties.showToggleAllButtons && ( @@ -253,7 +246,7 @@ function DnsHoleControlsWidgetTile({ widget }: DnsHoleControlsWidgetProps) { > - + {app.name} { setAppId(app.id); diff --git a/src/widgets/dnshole/DnsHoleSummary.tsx b/src/widgets/dnshole/DnsHoleSummary.tsx index b3451d23f4e..420b4ebe28a 100644 --- a/src/widgets/dnshole/DnsHoleSummary.tsx +++ b/src/widgets/dnshole/DnsHoleSummary.tsx @@ -1,4 +1,4 @@ -import { Box, Card, Center, Container, Flex, Text } from '@mantine/core'; +import { Card, Center, Container, Flex, Text } from '@mantine/core'; import { useElementSize } from '@mantine/hooks'; import { IconAd, @@ -112,7 +112,7 @@ export const useDnsHoleSummeryQuery = () => { configName: configName!, }, { - staleTime: 1000 * 60 * 2, + refetchInterval: 1000 * 60 * 2, } ); }; diff --git a/src/widgets/dnshole/TimerModal.tsx b/src/widgets/dnshole/TimerModal.tsx index 16e729c0bcb..7b7074d9683 100644 --- a/src/widgets/dnshole/TimerModal.tsx +++ b/src/widgets/dnshole/TimerModal.tsx @@ -36,7 +36,11 @@ export function TimerModal({ toggleDns, getDnsStatus, opened, close, appId }: Ti shadow="sm" size="sm" opened={opened} - onClose={close} + onClose={() => { + close(); + setHours(0); + setMinutes(0); + }} title={t('modules/dns-hole-controls:durationModal.title')} > @@ -96,7 +100,7 @@ export function TimerModal({ toggleDns, getDnsStatus, opened, close, appId }: Ti - + {t('modules/dns-hole-controls:durationModal.unlimited')}