index.tsx 3.6 KB
Newer Older
R
Rongfeng Fu 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113
import { useEffect } from 'react';
import { useModel } from 'umi';
import { Space, ConfigProvider } from 'antd';
import { HomeOutlined, ReadOutlined, ProfileOutlined } from '@ant-design/icons';
import useRequest from '@/utils/useRequest';
import { queryDeploymentInfoByTaskStatusType } from '@/services/ob-deploy-web/Deployments';
import Welcome from './components/Welcome';
import InstallConfig from './components/InstallConfig';
import NodeConfig from './components/NodeConfig';
import ClusterConfig from './components/ClusterConfig';
import PreCheck from './components/PreCheck';
import InstallProcess from './components/InstallProcess';
import InstallFinished from './components/InstallFinished';
import ExitPage from './components/ExitPage';
import Steps from './components/Steps';
import theme from './theme';
import styles from './index.less';

export default function IndexPage() {
  const { setCurrentStep, setConfigData, currentStep } = useModel('global');
  const { run: fetchDeploymentInfo } = useRequest(
    queryDeploymentInfoByTaskStatusType,
  );

  const contentConfig = {
    1: <InstallConfig />,
    2: <NodeConfig />,
    3: <ClusterConfig />,
    4: <PreCheck />,
    5: <InstallProcess />,
    6: <InstallFinished />,
    7: <ExitPage />,
  };

  useEffect(() => {
    fetchDeploymentInfo({ task_status: 'INSTALLING' }).then(
      ({ success, data }: API.OBResponse) => {
        if (success && data?.items?.length) {
          setCurrentStep(5);
          setConfigData({
            components: { oceanbase: { appname: data?.items[0]?.name } },
          });
        }
      },
    );
  }, []);

  const containerStyle = {
    minHeight: `${
      currentStep < 6 ? 'calc(100% - 220px)' : 'calc(100% - 50px)'
    }`,
    paddingTop: `${currentStep < 6 ? '170px' : '50px'}`,
  };

  return (
    <ConfigProvider theme={theme}>
      <header className={styles.pageHeader}>
        <img src="/assets/oceanbase.png" className={styles.logo} alt="logo" />
        <span className={styles.logoText}>部署</span>
        <Space className={styles.actionContent} size={25}>
          <a
            className={styles.action}
            href="https://www.oceanbase.com/"
            target="_blank"
            data-aspm-click="c307509.d317285"
            data-aspm-desc="顶部导航-访问官网"
            data-aspm-param={``}
            data-aspm-expo
          >
            <HomeOutlined className={styles.actionIcon} />
            访问官网
          </a>
          <a
            className={styles.action}
            href="https://ask.oceanbase.com/"
            target="_blank"
            data-aspm-click="c307509.d317284"
            data-aspm-desc="顶部导航-访问论坛"
            data-aspm-param={``}
            data-aspm-expo
          >
            <ProfileOutlined className={styles.actionIcon} />
            访问论坛
          </a>
          <a
            className={styles.action}
            href="https://www.oceanbase.com/docs/obd-cn"
            target="_blank"
            data-aspm-click="c307509.d317286"
            data-aspm-desc="顶部导航-帮助中心"
            data-aspm-param={``}
            data-aspm-expo
          >
            <ReadOutlined className={styles.actionIcon} />
            帮助中心
          </a>
        </Space>
      </header>
      <Steps />
      {currentStep === 0 ? (
        <Welcome />
      ) : (
        <div className={styles.pageContainer} style={containerStyle}>
          <main className={styles.pageMain}>
            <div className={styles.pageContent}>
              {contentConfig[currentStep]}
            </div>
          </main>
        </div>
      )}
    </ConfigProvider>
  );
}