2022-11-25 20:25:03 +00:00
|
|
|
import { memo } from 'react';
|
|
|
|
import isEqual from 'react-fast-compare';
|
|
|
|
|
|
|
|
import { Alert } from '@/components/elements/alert';
|
2020-03-30 05:12:50 +00:00
|
|
|
import Can from '@/components/elements/Can';
|
2020-08-26 04:39:00 +00:00
|
|
|
import ServerContentBlock from '@/components/elements/ServerContentBlock';
|
2021-05-16 19:35:49 +00:00
|
|
|
import Spinner from '@/components/elements/Spinner';
|
2022-06-21 22:43:59 +00:00
|
|
|
import Console from '@/components/server/console/Console';
|
2022-06-20 21:26:47 +00:00
|
|
|
import PowerButtons from '@/components/server/console/PowerButtons';
|
2022-06-21 22:43:59 +00:00
|
|
|
import ServerDetailsBlock from '@/components/server/console/ServerDetailsBlock';
|
2022-11-25 20:25:03 +00:00
|
|
|
import StatGraphs from '@/components/server/console/StatGraphs';
|
|
|
|
import Features from '@feature/Features';
|
|
|
|
import { ServerContext } from '@/state/server';
|
2019-09-18 05:33:14 +00:00
|
|
|
|
2020-07-04 22:40:41 +00:00
|
|
|
export type PowerAction = 'start' | 'stop' | 'restart' | 'kill';
|
2019-09-28 20:29:49 +00:00
|
|
|
|
2022-11-25 20:25:03 +00:00
|
|
|
function ServerConsoleContainer() {
|
|
|
|
const name = ServerContext.useStoreState(state => state.server.data!.name);
|
|
|
|
const description = ServerContext.useStoreState(state => state.server.data!.description);
|
|
|
|
const isInstalling = ServerContext.useStoreState(state => state.server.isInstalling);
|
|
|
|
const isTransferring = ServerContext.useStoreState(state => state.server.data!.isTransferring);
|
|
|
|
const eggFeatures = ServerContext.useStoreState(state => state.server.data!.eggFeatures, isEqual);
|
|
|
|
const isNodeUnderMaintenance = ServerContext.useStoreState(state => state.server.data!.isNodeUnderMaintenance);
|
2020-05-16 07:16:06 +00:00
|
|
|
|
2019-06-29 23:59:50 +00:00
|
|
|
return (
|
2022-07-01 00:30:01 +00:00
|
|
|
<ServerContentBlock title={'Console'}>
|
2022-11-06 23:02:30 +00:00
|
|
|
{(isNodeUnderMaintenance || isInstalling || isTransferring) && (
|
2022-07-01 00:30:01 +00:00
|
|
|
<Alert type={'warning'} className={'mb-4'}>
|
2022-11-06 23:02:30 +00:00
|
|
|
{isNodeUnderMaintenance
|
|
|
|
? 'The node of this server is currently under maintenance and all actions are unavailable.'
|
|
|
|
: isInstalling
|
2022-06-28 00:36:24 +00:00
|
|
|
? 'This server is currently running its installation process and most actions are unavailable.'
|
|
|
|
: 'This server is currently being transferred to another node and all actions are unavailable.'}
|
|
|
|
</Alert>
|
|
|
|
)}
|
2023-01-12 19:31:47 +00:00
|
|
|
<div className={'mb-4 grid grid-cols-4 gap-4'}>
|
|
|
|
<div className={'hidden pr-4 sm:col-span-2 sm:block lg:col-span-3'}>
|
|
|
|
<h1 className={'font-header text-2xl leading-relaxed text-slate-50 line-clamp-1'}>{name}</h1>
|
2022-06-20 21:26:47 +00:00
|
|
|
<p className={'text-sm line-clamp-2'}>{description}</p>
|
|
|
|
</div>
|
2023-01-12 19:31:47 +00:00
|
|
|
<div className={'col-span-4 self-end sm:col-span-2 lg:col-span-1'}>
|
2022-06-26 19:13:52 +00:00
|
|
|
<Can action={['control.start', 'control.stop', 'control.restart']} matchAny>
|
2023-01-12 19:31:47 +00:00
|
|
|
<PowerButtons className={'flex space-x-2 sm:justify-end'} />
|
2022-06-20 21:26:47 +00:00
|
|
|
</Can>
|
|
|
|
</div>
|
|
|
|
</div>
|
2023-01-12 19:31:47 +00:00
|
|
|
<div className={'mb-4 grid grid-cols-4 gap-2 sm:gap-4'}>
|
|
|
|
<div className={'col-span-4 flex lg:col-span-3'}>
|
2022-06-21 22:43:59 +00:00
|
|
|
<Spinner.Suspense>
|
2022-06-26 19:13:52 +00:00
|
|
|
<Console />
|
2022-06-21 22:43:59 +00:00
|
|
|
</Spinner.Suspense>
|
|
|
|
</div>
|
2023-01-12 19:31:47 +00:00
|
|
|
<ServerDetailsBlock className={'order-last col-span-4 lg:order-none lg:col-span-1'} />
|
2019-09-18 04:59:35 +00:00
|
|
|
</div>
|
2023-01-12 19:31:47 +00:00
|
|
|
<div className={'grid grid-cols-1 gap-2 sm:gap-4 md:grid-cols-3'}>
|
2021-05-16 19:35:49 +00:00
|
|
|
<Spinner.Suspense>
|
2022-06-26 19:13:52 +00:00
|
|
|
<StatGraphs />
|
2021-05-16 19:35:49 +00:00
|
|
|
</Spinner.Suspense>
|
2019-09-29 20:23:15 +00:00
|
|
|
</div>
|
2022-06-26 19:13:52 +00:00
|
|
|
<Features enabled={eggFeatures} />
|
2020-08-26 04:39:00 +00:00
|
|
|
</ServerContentBlock>
|
2019-06-29 23:59:50 +00:00
|
|
|
);
|
2022-11-25 20:25:03 +00:00
|
|
|
}
|
2020-10-04 02:36:26 +00:00
|
|
|
|
2022-06-21 22:43:59 +00:00
|
|
|
export default memo(ServerConsoleContainer, isEqual);
|