mirror of
https://github.com/ajnart/homarr.git
synced 2025-11-12 08:25:47 +01:00
Ping module overall
Removed useless code leftover
This commit is contained in:
@@ -113,12 +113,6 @@
|
||||
"advancedOptions": {
|
||||
"title": "Advanced options",
|
||||
"form": {
|
||||
"httpStatusCodes": {
|
||||
"label": "HTTP Status Codes",
|
||||
"placeholder": "Select valid status codes",
|
||||
"clearButtonLabel": "Clear selection",
|
||||
"nothingFound": "Nothing found"
|
||||
},
|
||||
"openServiceInNewTab": {
|
||||
"label": "Open service in new tab"
|
||||
},
|
||||
|
||||
@@ -7,7 +7,6 @@ import {
|
||||
Image,
|
||||
LoadingOverlay,
|
||||
Modal,
|
||||
MultiSelect,
|
||||
PasswordInput,
|
||||
Select,
|
||||
Space,
|
||||
@@ -25,7 +24,7 @@ import { useTranslation } from 'next-i18next';
|
||||
import { useEffect, useState } from 'react';
|
||||
import { v4 as uuidv4 } from 'uuid';
|
||||
import { useConfig } from '../../tools/state';
|
||||
import { tryMatchPort, ServiceTypeList, StatusCodes, Config } from '../../tools/types';
|
||||
import { tryMatchPort, ServiceTypeList, Config } from '../../tools/types';
|
||||
import apiKeyPaths from './apiKeyPaths.json';
|
||||
import Tip from '../layout/Tip';
|
||||
|
||||
@@ -121,7 +120,6 @@ export function AddAppShelfItemForm(props: AddAppShelfItemFormProps) {
|
||||
password: props.password ?? undefined,
|
||||
openedUrl: props.openedUrl ?? undefined,
|
||||
ping: props.ping ?? true,
|
||||
status: props.status ?? ['200'],
|
||||
newTab: props.newTab ?? true,
|
||||
},
|
||||
validate: {
|
||||
@@ -139,12 +137,6 @@ export function AddAppShelfItemForm(props: AddAppShelfItemFormProps) {
|
||||
}
|
||||
return null;
|
||||
},
|
||||
status: (value: string[]) => {
|
||||
if (!value.length) {
|
||||
return t('modal.form.validation.noStatusCodeSelected');
|
||||
}
|
||||
return null;
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
@@ -190,12 +182,6 @@ export function AddAppShelfItemForm(props: AddAppShelfItemFormProps) {
|
||||
if (newForm.openedUrl === '') newForm.openedUrl = undefined;
|
||||
if (newForm.category === null) newForm.category = undefined;
|
||||
if (newForm.ping === true) newForm.ping = undefined;
|
||||
if (
|
||||
(newForm.status.length === 1 && newForm.status[0] === '200') ||
|
||||
newForm.ping === false
|
||||
) {
|
||||
delete newForm.status;
|
||||
}
|
||||
// If service already exists, update it.
|
||||
if (config.services && config.services.find((s) => s.id === newForm.id)) {
|
||||
setConfig({
|
||||
@@ -451,26 +437,10 @@ export function AddAppShelfItemForm(props: AddAppShelfItemFormProps) {
|
||||
<Space h="sm" />
|
||||
<Stack>
|
||||
<Switch
|
||||
label={t('modal.tabs.advancedOptions.form.ping.label')}
|
||||
label="Ping service"
|
||||
defaultChecked={form.values.ping}
|
||||
{...form.getInputProps('ping')}
|
||||
/>
|
||||
{form.values.ping && (
|
||||
<MultiSelect
|
||||
required
|
||||
label={t('modal.tabs.advancedOptions.form.httpStatusCodes.label')}
|
||||
data={StatusCodes}
|
||||
placeholder={t('modal.tabs.advancedOptions.form.httpStatusCodes.placeholder')}
|
||||
clearButtonLabel={t(
|
||||
'modal.tabs.advancedOptions.form.httpStatusCodes.clearButtonLabel'
|
||||
)}
|
||||
nothingFound={t('modal.tabs.advancedOptions.form.httpStatusCodes.nothingFound')}
|
||||
defaultValue={['200']}
|
||||
clearable
|
||||
searchable
|
||||
{...form.getInputProps('status')}
|
||||
/>
|
||||
)}
|
||||
<Switch
|
||||
label={t('modal.tabs.advancedOptions.form.openServiceInNewTab.label')}
|
||||
defaultChecked={form.values.newTab}
|
||||
|
||||
@@ -62,7 +62,7 @@ export default function PingComponent(props: any) {
|
||||
<motion.div
|
||||
style={{ position: 'absolute', bottom: 20, right: 20 }}
|
||||
animate={{
|
||||
scale: isOnline === 'online' ? [1, 0.8, 1] : 1,
|
||||
scale: isOnline === 'online' ? [1, 0.7, 1] : 1,
|
||||
}}
|
||||
transition={{ repeat: Infinity, duration: 2.5, ease: 'easeInOut' }}
|
||||
>
|
||||
@@ -78,7 +78,7 @@ export default function PingComponent(props: any) {
|
||||
}
|
||||
>
|
||||
<Indicator
|
||||
size={13}
|
||||
size={15}
|
||||
color={isOnline === 'online' ? 'green' : isOnline === 'down' ? 'red' : 'yellow'}
|
||||
>
|
||||
{null}
|
||||
|
||||
@@ -35,28 +35,6 @@ interface ConfigModule {
|
||||
};
|
||||
}
|
||||
|
||||
export const StatusCodes = [
|
||||
{ value: '200', label: '200 - OK', group: 'Sucessful responses' },
|
||||
{ value: '204', label: '204 - No Content', group: 'Sucessful responses' },
|
||||
{ value: '301', label: '301 - Moved Permanently', group: 'Redirection responses' },
|
||||
{ value: '302', label: '302 - Found / Moved Temporarily', group: 'Redirection responses' },
|
||||
{ value: '304', label: '304 - Not Modified', group: 'Redirection responses' },
|
||||
{ value: '307', label: '307 - Temporary Redirect', group: 'Redirection responses' },
|
||||
{ value: '308', label: '308 - Permanent Redirect', group: 'Redirection responses' },
|
||||
{ value: '400', label: '400 - Bad Request', group: 'Client error responses' },
|
||||
{ value: '401', label: '401 - Unauthorized', group: 'Client error responses' },
|
||||
{ value: '403', label: '403 - Forbidden', group: 'Client error responses' },
|
||||
{ value: '404', label: '404 - Not Found', group: 'Client error responses' },
|
||||
{ value: '405', label: '405 - Method Not Allowed', group: 'Client error responses' },
|
||||
{ value: '408', label: '408 - Request Timeout', group: 'Client error responses' },
|
||||
{ value: '410', label: '410 - Gone', group: 'Client error responses' },
|
||||
{ value: '429', label: '429 - Too Many Requests', group: 'Client error responses' },
|
||||
{ value: '500', label: '500 - Internal Server Error', group: 'Server error responses' },
|
||||
{ value: '502', label: '502 - Bad Gateway', group: 'Server error responses' },
|
||||
{ value: '503', label: '503 - Service Unavailable', group: 'Server error responses' },
|
||||
{ value: '054', label: '504 - Gateway Timeout Error', group: 'Server error responses' },
|
||||
];
|
||||
|
||||
export const Targets = [
|
||||
{ value: '_blank', label: 'New Tab' },
|
||||
{ value: '_top', label: 'Same Window' },
|
||||
|
||||
Reference in New Issue
Block a user