2022-06-12 11:56:00 -04:00
|
|
|
import React, { memo } from 'react';
|
2019-07-09 21:25:57 -07:00
|
|
|
import { ServerContext } from '@/state/server';
|
2020-03-29 22:12:50 -07:00
|
|
|
import Can from '@/components/elements/Can';
|
2020-04-26 13:21:39 -07:00
|
|
|
import ContentContainer from '@/components/elements/ContentContainer';
|
2020-07-04 15:40:41 -07:00
|
|
|
import tw from 'twin.macro';
|
2020-08-25 21:39:00 -07:00
|
|
|
import ServerContentBlock from '@/components/elements/ServerContentBlock';
|
2020-10-03 19:36:26 -07:00
|
|
|
import ServerDetailsBlock from '@/components/server/ServerDetailsBlock';
|
|
|
|
import isEqual from 'react-fast-compare';
|
|
|
|
import PowerControls from '@/components/server/PowerControls';
|
2021-03-03 19:31:39 -08:00
|
|
|
import ErrorBoundary from '@/components/elements/ErrorBoundary';
|
2021-05-16 12:35:49 -07:00
|
|
|
import Spinner from '@/components/elements/Spinner';
|
2022-06-12 11:56:00 -04:00
|
|
|
import Features from '@feature/Features';
|
|
|
|
import Console from '@/components/server/Console';
|
|
|
|
import StatGraphs from '@/components/server/StatGraphs';
|
2019-09-17 22:33:14 -07:00
|
|
|
|
2020-07-04 15:40:41 -07:00
|
|
|
export type PowerAction = 'start' | 'stop' | 'restart' | 'kill';
|
2019-09-28 13:29:49 -07:00
|
|
|
|
2020-10-03 19:36:26 -07:00
|
|
|
const ServerConsole = () => {
|
2020-08-25 21:39:00 -07:00
|
|
|
const isInstalling = ServerContext.useStoreState(state => state.server.data!.isInstalling);
|
2020-12-16 09:34:47 -07:00
|
|
|
const isTransferring = ServerContext.useStoreState(state => state.server.data!.isTransferring);
|
2020-12-27 11:18:33 -08:00
|
|
|
const eggFeatures = ServerContext.useStoreState(state => state.server.data!.eggFeatures, isEqual);
|
2020-05-16 03:16:06 -04:00
|
|
|
|
2019-06-29 16:59:50 -07:00
|
|
|
return (
|
2020-09-13 18:02:25 +01:00
|
|
|
<ServerContentBlock title={'Console'} css={tw`flex flex-wrap`}>
|
2020-10-03 21:21:09 +03:00
|
|
|
<div css={tw`w-full lg:w-1/4`}>
|
2020-10-03 19:36:26 -07:00
|
|
|
<ServerDetailsBlock/>
|
2020-12-16 09:34:47 -07:00
|
|
|
{isInstalling ?
|
2020-07-04 15:40:41 -07:00
|
|
|
<div css={tw`mt-4 rounded bg-yellow-500 p-3`}>
|
2020-04-26 13:21:39 -07:00
|
|
|
<ContentContainer>
|
2020-07-04 15:40:41 -07:00
|
|
|
<p css={tw`text-sm text-yellow-900`}>
|
2020-04-26 13:21:39 -07:00
|
|
|
This server is currently running its installation process and most actions are
|
|
|
|
unavailable.
|
|
|
|
</p>
|
|
|
|
</ContentContainer>
|
2020-03-29 22:12:50 -07:00
|
|
|
</div>
|
2020-12-16 09:34:47 -07:00
|
|
|
:
|
|
|
|
isTransferring ?
|
|
|
|
<div css={tw`mt-4 rounded bg-yellow-500 p-3`}>
|
|
|
|
<ContentContainer>
|
|
|
|
<p css={tw`text-sm text-yellow-900`}>
|
|
|
|
This server is currently being transferred to another node and all actions
|
|
|
|
are unavailable.
|
|
|
|
</p>
|
|
|
|
</ContentContainer>
|
|
|
|
</div>
|
|
|
|
:
|
|
|
|
<Can action={[ 'control.start', 'control.stop', 'control.restart' ]} matchAny>
|
|
|
|
<PowerControls/>
|
|
|
|
</Can>
|
2020-04-26 13:21:39 -07:00
|
|
|
}
|
2019-09-17 21:59:35 -07:00
|
|
|
</div>
|
2020-10-03 21:21:09 +03:00
|
|
|
<div css={tw`w-full lg:w-3/4 mt-4 lg:mt-0 lg:pl-4`}>
|
2021-05-16 12:35:49 -07:00
|
|
|
<Spinner.Suspense>
|
2021-03-03 19:31:39 -08:00
|
|
|
<ErrorBoundary>
|
2022-06-12 11:56:00 -04:00
|
|
|
<Console/>
|
2021-03-03 19:31:39 -08:00
|
|
|
</ErrorBoundary>
|
2022-06-12 11:56:00 -04:00
|
|
|
<StatGraphs/>
|
2021-05-16 12:35:49 -07:00
|
|
|
</Spinner.Suspense>
|
2022-06-12 11:56:00 -04:00
|
|
|
<Features enabled={eggFeatures} />
|
2019-09-29 13:23:15 -07:00
|
|
|
</div>
|
2020-08-25 21:39:00 -07:00
|
|
|
</ServerContentBlock>
|
2019-06-29 16:59:50 -07:00
|
|
|
);
|
|
|
|
};
|
2020-10-03 19:36:26 -07:00
|
|
|
|
|
|
|
export default memo(ServerConsole, isEqual);
|