mirror of
https://github.com/ajnart/homarr.git
synced 2025-11-10 07:25:48 +01:00
🐛 Fix reversed dns-hole controls
This commit is contained in:
@@ -1,15 +1,16 @@
|
||||
/* eslint-disable no-await-in-loop */
|
||||
import { z } from 'zod';
|
||||
import { getCookie } from 'cookies-next';
|
||||
import { NextApiRequest, NextApiResponse } from 'next';
|
||||
import { getConfig } from '../../../../tools/config/getConfig';
|
||||
import { z } from 'zod';
|
||||
|
||||
import { findAppProperty } from '../../../../tools/client/app-properties';
|
||||
import { getConfig } from '../../../../tools/config/getConfig';
|
||||
import { AdGuard } from '../../../../tools/server/sdk/adGuard/adGuard';
|
||||
import { PiHoleClient } from '../../../../tools/server/sdk/pihole/piHole';
|
||||
import { ConfigAppType } from '../../../../types/app';
|
||||
import { AdGuard } from '../../../../tools/server/sdk/adGuard/adGuard';
|
||||
|
||||
const getQuerySchema = z.object({
|
||||
status: z.enum(['enabled', 'disabled']),
|
||||
action: z.enum(['enable', 'disable']),
|
||||
});
|
||||
|
||||
export const Post = async (request: NextApiRequest, response: NextApiResponse) => {
|
||||
@@ -31,11 +32,11 @@ export const Post = async (request: NextApiRequest, response: NextApiResponse) =
|
||||
const app = applicableApps[i];
|
||||
|
||||
if (app.integration?.type === 'pihole') {
|
||||
await processPiHole(app, parseResult.data.status === 'disabled');
|
||||
await processPiHole(app, parseResult.data.action === 'enable');
|
||||
return;
|
||||
}
|
||||
|
||||
await processAdGuard(app, parseResult.data.status === 'disabled');
|
||||
await processAdGuard(app, parseResult.data.action === 'disable');
|
||||
}
|
||||
|
||||
response.status(200).json({});
|
||||
|
||||
@@ -2,11 +2,12 @@
|
||||
import Consola from 'consola';
|
||||
import { getCookie } from 'cookies-next';
|
||||
import { NextApiRequest, NextApiResponse } from 'next';
|
||||
|
||||
import { findAppProperty } from '../../../../tools/client/app-properties';
|
||||
import { getConfig } from '../../../../tools/config/getConfig';
|
||||
import { AdGuard } from '../../../../tools/server/sdk/adGuard/adGuard';
|
||||
import { PiHoleClient } from '../../../../tools/server/sdk/pihole/piHole';
|
||||
import { AdStatistics } from '../../../../widgets/dnshole/type';
|
||||
import { AdGuard } from '../../../../tools/server/sdk/adGuard/adGuard';
|
||||
|
||||
export const Get = async (request: NextApiRequest, response: NextApiResponse) => {
|
||||
const configName = getCookie('config-name', { req: request });
|
||||
|
||||
@@ -5,13 +5,14 @@ import { AdGuard } from '~/tools/server/sdk/adGuard/adGuard';
|
||||
import { PiHoleClient } from '~/tools/server/sdk/pihole/piHole';
|
||||
import { ConfigAppType } from '~/types/app';
|
||||
import { AdStatistics } from '~/widgets/dnshole/type';
|
||||
|
||||
import { createTRPCRouter, publicProcedure } from '../trpc';
|
||||
|
||||
export const dnsHoleRouter = createTRPCRouter({
|
||||
control: publicProcedure
|
||||
.input(
|
||||
z.object({
|
||||
status: z.enum(['enabled', 'disabled']),
|
||||
action: z.enum(['enable', 'disable']),
|
||||
configName: z.string(),
|
||||
})
|
||||
)
|
||||
@@ -25,11 +26,11 @@ export const dnsHoleRouter = createTRPCRouter({
|
||||
await Promise.all(
|
||||
applicableApps.map(async (app) => {
|
||||
if (app.integration?.type === 'pihole') {
|
||||
await processPiHole(app, input.status === 'disabled');
|
||||
await processPiHole(app, input.action === 'enable');
|
||||
return;
|
||||
}
|
||||
|
||||
await processAdGuard(app, input.status === 'disabled');
|
||||
await processAdGuard(app, input.action === 'enable');
|
||||
})
|
||||
);
|
||||
}),
|
||||
|
||||
@@ -1,15 +1,16 @@
|
||||
import { Badge, Box, Button, Card, Group, Image, Stack, Text, SimpleGrid } from '@mantine/core';
|
||||
import { Badge, Box, Button, Card, Group, Image, SimpleGrid, Stack, Text } from '@mantine/core';
|
||||
import { useElementSize } from '@mantine/hooks';
|
||||
import { useTranslation } from 'next-i18next';
|
||||
import { IconDeviceGamepad, IconPlayerPlay, IconPlayerStop } from '@tabler/icons-react';
|
||||
import { useTranslation } from 'next-i18next';
|
||||
import { api } from '~/utils/api';
|
||||
|
||||
import { useConfigContext } from '../../config/provider';
|
||||
import { queryClient } from '../../tools/server/configurations/tanstack/queryClient.tool';
|
||||
import { defineWidget } from '../helper';
|
||||
import { WidgetLoading } from '../loading';
|
||||
import { IWidget } from '../widgets';
|
||||
import { PiholeApiSummaryType } from './type';
|
||||
import { queryClient } from '../../tools/server/configurations/tanstack/queryClient.tool';
|
||||
import { api } from '~/utils/api';
|
||||
import { useDnsHoleSummeryQuery } from './DnsHoleSummary';
|
||||
import { PiholeApiSummaryType } from './type';
|
||||
|
||||
const definition = defineWidget({
|
||||
id: 'dns-hole-controls',
|
||||
@@ -43,12 +44,12 @@ function DnsHoleControlsWidgetTile({ widget }: DnsHoleControlsWidgetProps) {
|
||||
}
|
||||
|
||||
return (
|
||||
<Stack justify="space-between" h={"100%"} spacing="0.25rem">
|
||||
<Stack justify="space-between" h={'100%'} spacing="0.25rem">
|
||||
<SimpleGrid ref={ref} cols={width > 275 ? 2 : 1} verticalSpacing="0.25rem" spacing="0.25rem">
|
||||
<Button
|
||||
onClick={async () => {
|
||||
await mutateAsync({
|
||||
status: 'enabled',
|
||||
action: 'enable',
|
||||
configName,
|
||||
});
|
||||
await queryClient.invalidateQueries({ queryKey: ['dns-hole-summary'] });
|
||||
@@ -63,7 +64,7 @@ function DnsHoleControlsWidgetTile({ widget }: DnsHoleControlsWidgetProps) {
|
||||
<Button
|
||||
onClick={async () => {
|
||||
await mutateAsync({
|
||||
status: 'disabled',
|
||||
action: 'disable',
|
||||
configName,
|
||||
});
|
||||
await queryClient.invalidateQueries({ queryKey: ['dns-hole-summary'] });
|
||||
|
||||
Reference in New Issue
Block a user