refactor: add script install command

This commit is contained in:
moonrailgun 2023-11-07 22:36:07 +08:00
parent 2967fcd05d
commit c41994879a
2 changed files with 45 additions and 7 deletions

View File

@ -9,6 +9,7 @@ import {
Steps, Steps,
Switch, Switch,
Table, Table,
Tabs,
Tooltip, Tooltip,
Typography, Typography,
} from 'antd'; } from 'antd';
@ -71,7 +72,20 @@ export const Servers: React.FC = React.memo(() => {
onCancel={() => setIsModalOpen(false)} onCancel={() => setIsModalOpen(false)}
> >
<div> <div>
<AddServerStep /> <Tabs
items={[
{
key: 'script',
label: 'Script',
children: <InstallScript />,
},
{
key: 'manual',
label: 'Manual',
children: <AddServerStep />,
},
]}
/>
</div> </div>
</Modal> </Modal>
</div> </div>
@ -218,6 +232,27 @@ export const ServerList: React.FC<{
}); });
ServerList.displayName = 'ServerList'; ServerList.displayName = 'ServerList';
export const InstallScript: React.FC = React.memo(() => {
const workspaceId = useCurrentWorkspaceId();
const command = `curl -o- ${window.location.origin}/serverStatus/${workspaceId}/install.sh | bash`;
return (
<div>
<div>Run this command in your linux machine</div>
<Typography.Paragraph
copyable={{
format: 'text/plain',
text: command,
}}
className="h-[96px] flex p-2 rounded bg-black bg-opacity-5 border border-black border-opacity-10 overflow-auto"
>
<span>{command}</span>
</Typography.Paragraph>
</div>
);
});
export const AddServerStep: React.FC = React.memo(() => { export const AddServerStep: React.FC = React.memo(() => {
const workspaceId = useCurrentWorkspaceId(); const workspaceId = useCurrentWorkspaceId();
const [current, setCurrent] = useState(0); const [current, setCurrent] = useState(0);
@ -272,7 +307,10 @@ export const AddServerStep: React.FC = React.memo(() => {
description: ( description: (
<div> <div>
run reporter with:{' '} run reporter with:{' '}
<Typography.Text code={true} copyable={{ text: command }}> <Typography.Text
code={true}
copyable={{ format: 'text/plain', text: command }}
>
{command} {command}
</Typography.Text> </Typography.Text>
<Button <Button

View File

@ -26,16 +26,16 @@ export const Profile: React.FC = React.memo(() => {
<Card> <Card>
<Form layout="vertical"> <Form layout="vertical">
<Form.Item label="User Id">
<Typography.Text copyable={true} code={true}>
{userInfo?.id}
</Typography.Text>
</Form.Item>
<Form.Item label="Current Workspace Id"> <Form.Item label="Current Workspace Id">
<Typography.Text copyable={true} code={true}> <Typography.Text copyable={true} code={true}>
{userInfo?.currentWorkspace?.id} {userInfo?.currentWorkspace?.id}
</Typography.Text> </Typography.Text>
</Form.Item> </Form.Item>
<Form.Item label="User Id">
<Typography.Text copyable={true} code={true}>
{userInfo?.id}
</Typography.Text>
</Form.Item>
<Form.Item label="Password"> <Form.Item label="Password">
<Button danger={true} onClick={() => setOpenChangePassword(true)}> <Button danger={true} onClick={() => setOpenChangePassword(true)}>
Change Password Change Password