mirror of
https://github.com/ajnart/homarr.git
synced 2025-11-11 07:55:52 +01:00
✨ add ping service toggle
This commit is contained in:
@@ -97,6 +97,9 @@
|
|||||||
"advancedOptions": {
|
"advancedOptions": {
|
||||||
"title": "Advanced Options",
|
"title": "Advanced Options",
|
||||||
"form": {
|
"form": {
|
||||||
|
"ping": {
|
||||||
|
"label": "Ping Service"
|
||||||
|
},
|
||||||
"httpStatusCodes": {
|
"httpStatusCodes": {
|
||||||
"label": "HTTP Status Codes",
|
"label": "HTTP Status Codes",
|
||||||
"placeholder": "Select valid status codes",
|
"placeholder": "Select valid status codes",
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import {
|
|||||||
MultiSelect,
|
MultiSelect,
|
||||||
PasswordInput,
|
PasswordInput,
|
||||||
Select,
|
Select,
|
||||||
|
Space,
|
||||||
Stack,
|
Stack,
|
||||||
Switch,
|
Switch,
|
||||||
Tabs,
|
Tabs,
|
||||||
@@ -18,13 +19,13 @@ import {
|
|||||||
Tooltip,
|
Tooltip,
|
||||||
} from '@mantine/core';
|
} from '@mantine/core';
|
||||||
import { useForm } from '@mantine/form';
|
import { useForm } from '@mantine/form';
|
||||||
|
import { useDebouncedValue } from '@mantine/hooks';
|
||||||
import { IconApps } from '@tabler/icons';
|
import { IconApps } from '@tabler/icons';
|
||||||
|
import { useTranslation } from 'next-i18next';
|
||||||
import { useEffect, useState } from 'react';
|
import { useEffect, useState } from 'react';
|
||||||
import { v4 as uuidv4 } from 'uuid';
|
import { v4 as uuidv4 } from 'uuid';
|
||||||
import { useDebouncedValue } from '@mantine/hooks';
|
|
||||||
import { useTranslation } from 'next-i18next';
|
|
||||||
import { useConfig } from '../../tools/state';
|
import { useConfig } from '../../tools/state';
|
||||||
import { tryMatchPort, ServiceTypeList, StatusCodes } from '../../tools/types';
|
import { ServiceTypeList, StatusCodes, tryMatchPort } from '../../tools/types';
|
||||||
import Tip from '../layout/Tip';
|
import Tip from '../layout/Tip';
|
||||||
|
|
||||||
export function AddItemShelfButton(props: any) {
|
export function AddItemShelfButton(props: any) {
|
||||||
@@ -109,6 +110,7 @@ export function AddAppShelfItemForm(props: { setOpened: (b: boolean) => void } &
|
|||||||
username: props.username ?? undefined,
|
username: props.username ?? undefined,
|
||||||
password: props.password ?? undefined,
|
password: props.password ?? undefined,
|
||||||
openedUrl: props.openedUrl ?? undefined,
|
openedUrl: props.openedUrl ?? undefined,
|
||||||
|
ping: props.ping ?? true,
|
||||||
status: props.status ?? ['200'],
|
status: props.status ?? ['200'],
|
||||||
newTab: props.newTab ?? true,
|
newTab: props.newTab ?? true,
|
||||||
},
|
},
|
||||||
@@ -177,7 +179,11 @@ export function AddAppShelfItemForm(props: { setOpened: (b: boolean) => void } &
|
|||||||
if (newForm.newTab === true) newForm.newTab = undefined;
|
if (newForm.newTab === true) newForm.newTab = undefined;
|
||||||
if (newForm.openedUrl === '') newForm.openedUrl = undefined;
|
if (newForm.openedUrl === '') newForm.openedUrl = undefined;
|
||||||
if (newForm.category === null) newForm.category = undefined;
|
if (newForm.category === null) newForm.category = undefined;
|
||||||
if (newForm.status.length === 1 && newForm.status[0] === '200') {
|
if (newForm.ping === true) newForm.ping = undefined;
|
||||||
|
if (
|
||||||
|
(newForm.status.length === 1 && newForm.status[0] === '200') ||
|
||||||
|
newForm.ping === false
|
||||||
|
) {
|
||||||
delete newForm.status;
|
delete newForm.status;
|
||||||
}
|
}
|
||||||
// If service already exists, update it.
|
// If service already exists, update it.
|
||||||
@@ -210,6 +216,7 @@ export function AddAppShelfItemForm(props: { setOpened: (b: boolean) => void } &
|
|||||||
<Tabs.Tab value="Advanced Options">{t('modal.tabs.advancedOptions.title')}</Tabs.Tab>
|
<Tabs.Tab value="Advanced Options">{t('modal.tabs.advancedOptions.title')}</Tabs.Tab>
|
||||||
</Tabs.List>
|
</Tabs.List>
|
||||||
<Tabs.Panel value="Options">
|
<Tabs.Panel value="Options">
|
||||||
|
<Space h="sm" />
|
||||||
<Stack>
|
<Stack>
|
||||||
<TextInput
|
<TextInput
|
||||||
required
|
required
|
||||||
@@ -394,7 +401,14 @@ export function AddAppShelfItemForm(props: { setOpened: (b: boolean) => void } &
|
|||||||
</Stack>
|
</Stack>
|
||||||
</Tabs.Panel>
|
</Tabs.Panel>
|
||||||
<Tabs.Panel value={t('modal.tabs.advancedOptions.title')}>
|
<Tabs.Panel value={t('modal.tabs.advancedOptions.title')}>
|
||||||
|
<Space h="sm" />
|
||||||
<Stack>
|
<Stack>
|
||||||
|
<Switch
|
||||||
|
label={t('modal.tabs.advancedOptions.form.ping.label')}
|
||||||
|
defaultChecked={form.values.ping}
|
||||||
|
{...form.getInputProps('ping')}
|
||||||
|
/>
|
||||||
|
{form.values.ping && (
|
||||||
<MultiSelect
|
<MultiSelect
|
||||||
required
|
required
|
||||||
label={t('modal.tabs.advancedOptions.form.httpStatusCodes.label')}
|
label={t('modal.tabs.advancedOptions.form.httpStatusCodes.label')}
|
||||||
@@ -409,6 +423,7 @@ export function AddAppShelfItemForm(props: { setOpened: (b: boolean) => void } &
|
|||||||
searchable
|
searchable
|
||||||
{...form.getInputProps('status')}
|
{...form.getInputProps('status')}
|
||||||
/>
|
/>
|
||||||
|
)}
|
||||||
<Switch
|
<Switch
|
||||||
label={t('modal.tabs.advancedOptions.form.openServiceInNewTab.label')}
|
label={t('modal.tabs.advancedOptions.form.openServiceInNewTab.label')}
|
||||||
defaultChecked={form.values.newTab}
|
defaultChecked={form.values.newTab}
|
||||||
|
|||||||
@@ -1,21 +1,21 @@
|
|||||||
|
import { useSortable } from '@dnd-kit/sortable';
|
||||||
|
import { CSS } from '@dnd-kit/utilities';
|
||||||
import {
|
import {
|
||||||
Text,
|
|
||||||
Card,
|
|
||||||
Anchor,
|
Anchor,
|
||||||
AspectRatio,
|
AspectRatio,
|
||||||
|
Card,
|
||||||
Center,
|
Center,
|
||||||
createStyles,
|
createStyles,
|
||||||
useMantineColorScheme,
|
|
||||||
Image,
|
Image,
|
||||||
|
Text,
|
||||||
|
useMantineColorScheme,
|
||||||
} from '@mantine/core';
|
} from '@mantine/core';
|
||||||
import { motion } from 'framer-motion';
|
import { motion } from 'framer-motion';
|
||||||
import { useState } from 'react';
|
import { useState } from 'react';
|
||||||
import { useSortable } from '@dnd-kit/sortable';
|
|
||||||
import { CSS } from '@dnd-kit/utilities';
|
|
||||||
import { serviceItem } from '../../tools/types';
|
|
||||||
import PingComponent from '../../modules/ping/PingModule';
|
import PingComponent from '../../modules/ping/PingModule';
|
||||||
import AppShelfMenu from './AppShelfMenu';
|
|
||||||
import { useConfig } from '../../tools/state';
|
import { useConfig } from '../../tools/state';
|
||||||
|
import { serviceItem } from '../../tools/types';
|
||||||
|
import AppShelfMenu from './AppShelfMenu';
|
||||||
|
|
||||||
const useStyles = createStyles((theme) => ({
|
const useStyles = createStyles((theme) => ({
|
||||||
item: {
|
item: {
|
||||||
@@ -134,7 +134,7 @@ export function AppShelfItem(props: any) {
|
|||||||
</Anchor>
|
</Anchor>
|
||||||
</motion.i>
|
</motion.i>
|
||||||
</AspectRatio>
|
</AspectRatio>
|
||||||
<PingComponent url={service.url} status={service.status} />
|
{service.ping !== false && <PingComponent url={service.url} status={service.status} />}
|
||||||
</Card.Section>
|
</Card.Section>
|
||||||
</Center>
|
</Center>
|
||||||
</Card>
|
</Card>
|
||||||
|
|||||||
@@ -183,5 +183,6 @@ export interface serviceItem {
|
|||||||
username?: string;
|
username?: string;
|
||||||
openedUrl?: string;
|
openedUrl?: string;
|
||||||
newTab?: boolean;
|
newTab?: boolean;
|
||||||
|
ping?: boolean;
|
||||||
status?: string[];
|
status?: string[];
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user