2019-12-07 23:58:37 +00:00
|
|
|
import React from 'react';
|
|
|
|
import TitledGreyBox from '@/components/elements/TitledGreyBox';
|
|
|
|
import { ServerContext } from '@/state/server';
|
|
|
|
import { useStoreState } from 'easy-peasy';
|
2019-12-10 06:03:10 +00:00
|
|
|
import RenameServerBox from '@/components/server/settings/RenameServerBox';
|
2020-03-28 23:47:32 +00:00
|
|
|
import FlashMessageRender from '@/components/FlashMessageRender';
|
2020-03-30 05:05:30 +00:00
|
|
|
import Can from '@/components/elements/Can';
|
2020-04-03 21:43:24 +00:00
|
|
|
import ReinstallServerBox from '@/components/server/settings/ReinstallServerBox';
|
2020-07-04 22:58:14 +00:00
|
|
|
import tw from 'twin.macro';
|
|
|
|
import Input from '@/components/elements/Input';
|
|
|
|
import Label from '@/components/elements/Label';
|
2020-08-26 04:39:00 +00:00
|
|
|
import ServerContentBlock from '@/components/elements/ServerContentBlock';
|
2020-12-25 23:52:15 +00:00
|
|
|
import isEqual from 'react-fast-compare';
|
|
|
|
import CopyOnClick from '@/components/elements/CopyOnClick';
|
2021-12-04 18:35:55 +00:00
|
|
|
import { formatIp } from '@/helpers';
|
2022-06-20 16:38:23 +00:00
|
|
|
import { Button } from '@/components/elements/button/index';
|
2019-12-07 23:58:37 +00:00
|
|
|
|
|
|
|
export default () => {
|
2020-08-26 04:39:00 +00:00
|
|
|
const username = useStoreState(state => state.user.data!.username);
|
|
|
|
const id = ServerContext.useStoreState(state => state.server.data!.id);
|
2020-12-25 23:52:15 +00:00
|
|
|
const uuid = ServerContext.useStoreState(state => state.server.data!.uuid);
|
|
|
|
const node = ServerContext.useStoreState(state => state.server.data!.node);
|
2020-12-27 19:18:33 +00:00
|
|
|
const sftp = ServerContext.useStoreState(state => state.server.data!.sftpDetails, isEqual);
|
2019-12-07 23:58:37 +00:00
|
|
|
|
|
|
|
return (
|
2020-08-26 04:39:00 +00:00
|
|
|
<ServerContentBlock title={'Settings'}>
|
2020-07-04 22:58:14 +00:00
|
|
|
<FlashMessageRender byKey={'settings'} css={tw`mb-4`}/>
|
|
|
|
<div css={tw`md:flex`}>
|
2020-07-09 04:42:37 +00:00
|
|
|
<div css={tw`w-full md:flex-1 md:mr-10`}>
|
|
|
|
<Can action={'file.sftp'}>
|
|
|
|
<TitledGreyBox title={'SFTP Details'} css={tw`mb-6 md:mb-10`}>
|
2020-04-03 21:43:24 +00:00
|
|
|
<div>
|
2020-07-04 22:58:14 +00:00
|
|
|
<Label>Server Address</Label>
|
2021-12-04 18:35:55 +00:00
|
|
|
<CopyOnClick text={`sftp://${formatIp(sftp.ip)}:${sftp.port}`}>
|
2021-01-27 05:10:30 +00:00
|
|
|
<Input
|
|
|
|
type={'text'}
|
2021-12-04 18:35:55 +00:00
|
|
|
value={`sftp://${formatIp(sftp.ip)}:${sftp.port}`}
|
2021-01-27 05:10:30 +00:00
|
|
|
readOnly
|
|
|
|
/>
|
|
|
|
</CopyOnClick>
|
2020-03-30 05:05:30 +00:00
|
|
|
</div>
|
2020-07-04 22:58:14 +00:00
|
|
|
<div css={tw`mt-6`}>
|
|
|
|
<Label>Username</Label>
|
2021-01-27 05:10:30 +00:00
|
|
|
<CopyOnClick text={`${username}.${id}`}>
|
|
|
|
<Input
|
|
|
|
type={'text'}
|
|
|
|
value={`${username}.${id}`}
|
|
|
|
readOnly
|
|
|
|
/>
|
|
|
|
</CopyOnClick>
|
2020-03-30 05:05:30 +00:00
|
|
|
</div>
|
2020-07-04 22:58:14 +00:00
|
|
|
<div css={tw`mt-6 flex items-center`}>
|
|
|
|
<div css={tw`flex-1`}>
|
|
|
|
<div css={tw`border-l-4 border-cyan-500 p-3`}>
|
|
|
|
<p css={tw`text-xs text-neutral-200`}>
|
2020-04-03 21:43:24 +00:00
|
|
|
Your SFTP password is the same as the password you use to access this panel.
|
|
|
|
</p>
|
|
|
|
</div>
|
|
|
|
</div>
|
2020-07-04 22:58:14 +00:00
|
|
|
<div css={tw`ml-4`}>
|
2022-06-20 16:38:23 +00:00
|
|
|
<a href={`sftp://${username}.${id}@${formatIp(sftp.ip)}:${sftp.port}`}>
|
|
|
|
<Button.Text variant={Button.Variants.Secondary}>Launch SFTP</Button.Text>
|
|
|
|
</a>
|
2020-04-03 21:43:24 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</TitledGreyBox>
|
2020-07-09 04:42:37 +00:00
|
|
|
</Can>
|
2020-12-25 23:52:15 +00:00
|
|
|
<TitledGreyBox title={'Debug Information'} css={tw`mb-6 md:mb-10`}>
|
|
|
|
<div css={tw`flex items-center justify-between text-sm`}>
|
|
|
|
<p>Node</p>
|
|
|
|
<code css={tw`font-mono bg-neutral-900 rounded py-1 px-2`}>{node}</code>
|
|
|
|
</div>
|
|
|
|
<CopyOnClick text={uuid}>
|
|
|
|
<div css={tw`flex items-center justify-between mt-2 text-sm`}>
|
|
|
|
<p>Server ID</p>
|
|
|
|
<code css={tw`font-mono bg-neutral-900 rounded py-1 px-2`}>{uuid}</code>
|
|
|
|
</div>
|
|
|
|
</CopyOnClick>
|
|
|
|
</TitledGreyBox>
|
2020-07-10 02:56:46 +00:00
|
|
|
</div>
|
|
|
|
<div css={tw`w-full mt-6 md:flex-1 md:mt-0`}>
|
2020-04-03 21:43:24 +00:00
|
|
|
<Can action={'settings.rename'}>
|
2020-07-04 22:58:14 +00:00
|
|
|
<div css={tw`mb-6 md:mb-10`}>
|
2020-04-03 21:43:24 +00:00
|
|
|
<RenameServerBox/>
|
|
|
|
</div>
|
|
|
|
</Can>
|
|
|
|
<Can action={'settings.reinstall'}>
|
|
|
|
<ReinstallServerBox/>
|
|
|
|
</Can>
|
|
|
|
</div>
|
2019-12-10 06:03:10 +00:00
|
|
|
</div>
|
2020-08-26 04:39:00 +00:00
|
|
|
</ServerContentBlock>
|
2019-12-07 23:58:37 +00:00
|
|
|
);
|
|
|
|
};
|