misc_pterodactyl-panel/resources/scripts/components/admin/nodes/NodeSettingsContainer.tsx

130 lines
4.5 KiB
TypeScript
Raw Normal View History

2021-09-13 03:22:33 +00:00
import { Node } from '@/api/admin/nodes/getNodes';
import { faDatabase } from '@fortawesome/free-solid-svg-icons';
2021-01-30 20:53:47 +00:00
import React from 'react';
import AdminBox from '@/components/admin/AdminBox';
import tw from 'twin.macro';
import Field from '@/components/elements/Field';
import SpinnerOverlay from '@/components/elements/SpinnerOverlay';
2021-09-13 03:22:33 +00:00
import { Field as FormikField, useFormikContext } from 'formik';
2021-02-11 17:21:49 +00:00
import LocationSelect from '@/components/admin/nodes/LocationSelect';
2021-03-12 21:12:45 +00:00
import DatabaseSelect from '@/components/admin/nodes/DatabaseSelect';
import Label from '@/components/elements/Label';
2021-01-30 20:53:47 +00:00
2021-09-13 03:22:33 +00:00
export default function NodeSettingsContainer ({ node }: { node?: Node }) {
2021-03-23 23:47:24 +00:00
const { isSubmitting } = useFormikContext();
return (
2021-09-13 03:22:33 +00:00
<AdminBox icon={faDatabase} title={'Settings'} css={tw`w-full relative`}>
2021-03-23 23:47:24 +00:00
<SpinnerOverlay visible={isSubmitting}/>
2021-08-02 16:23:58 +00:00
<div css={tw`mb-6`}>
<Field
id={'name'}
name={'name'}
label={'Name'}
type={'text'}
/>
</div>
<div css={tw`mb-6`}>
<LocationSelect selected={node?.relations.location || null}/>
</div>
<div css={tw`mb-6`}>
<DatabaseSelect selected={node?.relations.databaseHost || null}/>
</div>
<div css={tw`mb-6`}>
<Field
id={'fqdn'}
name={'fqdn'}
label={'FQDN'}
type={'text'}
/>
</div>
2021-09-13 03:22:33 +00:00
<div css={tw`mb-6`}>
<Field
id={'daemonBase'}
name={'daemonBase'}
label={'Data Directory'}
type={'text'}
disabled={node !== undefined}
/>
</div>
2021-08-02 16:23:58 +00:00
<div css={tw`mt-6`}>
<Label htmlFor={'scheme'}>SSL</Label>
<div>
<label css={tw`inline-flex items-center mr-2`}>
<FormikField
name={'scheme'}
type={'radio'}
value={'https'}
/>
<span css={tw`text-neutral-300 ml-2`}>Enabled</span>
</label>
<label css={tw`inline-flex items-center ml-2`}>
<FormikField
name={'scheme'}
type={'radio'}
value={'http'}
/>
<span css={tw`text-neutral-300 ml-2`}>Disabled</span>
</label>
2021-03-23 23:47:24 +00:00
</div>
2021-08-02 16:23:58 +00:00
</div>
<div css={tw`mt-6`}>
<Label htmlFor={'behindProxy'}>Behind Proxy</Label>
<div>
<label css={tw`inline-flex items-center mr-2`}>
<FormikField
name={'behindProxy'}
type={'radio'}
2021-09-13 03:22:33 +00:00
value={'false'}
2021-08-02 16:23:58 +00:00
/>
<span css={tw`text-neutral-300 ml-2`}>No</span>
</label>
<label css={tw`inline-flex items-center ml-2`}>
<FormikField
name={'behindProxy'}
type={'radio'}
2021-09-13 03:22:33 +00:00
value={'true'}
2021-08-02 16:23:58 +00:00
/>
<span css={tw`text-neutral-300 ml-2`}>Yes</span>
</label>
2021-03-23 23:47:24 +00:00
</div>
2021-08-02 16:23:58 +00:00
</div>
<div css={tw`mt-6`}>
<Label htmlFor={'public'}>Automatic Allocation</Label>
<div>
<label css={tw`inline-flex items-center mr-2`}>
<FormikField
name={'public'}
type={'radio'}
2021-09-13 03:22:33 +00:00
value={'false'}
2021-08-02 16:23:58 +00:00
/>
<span css={tw`text-neutral-300 ml-2`}>Disabled</span>
</label>
<label css={tw`inline-flex items-center ml-2`}>
<FormikField
name={'public'}
type={'radio'}
2021-09-13 03:22:33 +00:00
value={'true'}
2021-08-02 16:23:58 +00:00
/>
<span css={tw`text-neutral-300 ml-2`}>Enabled</span>
</label>
2021-03-23 23:47:24 +00:00
</div>
2021-08-02 16:23:58 +00:00
</div>
2021-03-23 23:47:24 +00:00
</AdminBox>
);
2021-09-13 03:22:33 +00:00
}