import { useState } from 'react'; import { useModel } from 'umi'; import { Space, Button, Table, Row, Col, Alert, Tooltip } from 'antd'; import { ProCard } from '@ant-design/pro-components'; import type { ColumnsType } from 'antd/es/table'; import { EyeOutlined, EyeInvisibleOutlined } from '@ant-design/icons'; import useRequest from '@/utils/useRequest'; import { createDeploymentConfig } from '@/services/ob-deploy-web/Deployments'; import { handleQuit } from '@/utils'; import { componentsNameConfig, allComponentsKeys, onlyComponentsKeys, modeConfig, obproxyComponent, } from '../constants'; import styles from './index.less'; interface ComponentsNodeConfig { name: string; servers: string[]; key: string; isTooltip: boolean; } export default function CheckInfo() { const { configData, currentType, setCheckOK, lowVersion, setCurrentStep, handleQuitProgress, } = useModel('global'); const { components = {}, auth, home_path } = configData || {}; const { oceanbase = {}, obproxy = {}, ocpexpress = {}, obagent = {}, } = components; const [showPwd, setShowPwd] = useState(false); const { run: handleCreateConfig, loading } = useRequest( createDeploymentConfig, { onSuccess: ({ success }: API.OBResponse) => { if (success) { setCheckOK(true); } }, }, ); const prevStep = () => { setCurrentStep(3); }; const handlePreCheck = () => { handleCreateConfig({ name: oceanbase?.appname }, { ...configData }); }; const getComponentsList = () => { const componentsList: API.TableComponentInfo[] = []; allComponentsKeys.forEach((key) => { if (components?.[key]) { const componentConfig = componentsNameConfig?.[key] || {}; componentsList.push({ ...componentConfig, version: components?.[key].version, key, }); } }); return componentsList; }; const getComponentsNodeConfigList = () => { const componentsNodeConfigList: ComponentsNodeConfig[] = []; let currentOnlyComponentsKeys = onlyComponentsKeys.filter( (key) => key !== 'obagent', ); if (lowVersion) { currentOnlyComponentsKeys = currentOnlyComponentsKeys.filter( (key) => key !== 'ocpexpress', ); } currentOnlyComponentsKeys.forEach((key) => { if (componentsNameConfig?.[key]) { componentsNodeConfigList.push({ key, name: componentsNameConfig?.[key]?.name, servers: components?.[key]?.servers?.join(','), isTooltip: key === obproxyComponent, }); } }); return componentsNodeConfigList; }; const dbConfigColumns: ColumnsType = [ { title: 'Zone 名称', dataIndex: 'name', width: 200, render: (text) => text || '-', }, { title: 'OB Server 节点', dataIndex: 'servers', render: (text) => { const serversIps = text.map((item: API.OceanbaseServers) => item.ip); const str = serversIps.join(','); return (
{str}
); }, }, { title: 'Root Server 节点', dataIndex: 'rootservice', width: 200, render: (text) => text || '-', }, ]; const getMoreColumns = (label: string) => { const columns: ColumnsType = [ { title: `${label}参数名称`, dataIndex: 'key', render: (text) => text, }, { title: '参数值', dataIndex: 'value', render: (text, record) => (record.adaptive ? '自适应' : text || '-'), }, { title: '介绍', dataIndex: 'description', render: (text) => (
{text}
), }, ]; return columns; }; const componentsList = getComponentsList(); const componentsNodeConfigList = getComponentsNodeConfigList(); const initDir = `${home_path}/oceanbase/store`; const clusterConfigInfo = [ { key: 'cluster', group: '集群配置', content: [ { label: '配置模式', value: modeConfig[oceanbase?.mode] }, { label: 'root@sys 密码', value: (
{oceanbase?.root_password}
), }, { label: '数据目录', value: (
{oceanbase?.data_dir || initDir}
), }, { label: '日志目录', value: (
{oceanbase?.redo_dir || initDir}
), }, { label: 'SQL 端口', value: oceanbase?.mysql_port }, { label: 'RPC 端口', value: oceanbase?.rpc_port }, ], more: oceanbase?.parameters?.length ? [ { label: componentsNameConfig['oceanbase'].name, parameters: oceanbase?.parameters, }, ] : [], }, ]; if (currentType === 'all') { const content = [ { label: 'OBProxy 服务端口', value: obproxy?.listen_port }, { label: 'OBProxy Exporter 端口', value: obproxy?.prometheus_listen_port, }, { label: 'OBAgent 管理服务端口', value: obagent?.monagent_http_port }, { label: 'OBAgent 监控服务端口', value: obagent?.mgragent_http_port }, ]; if (!lowVersion) { content.push({ label: 'OCPExpress 端口', value: ocpexpress?.port }); } let more: any = []; if (obproxy?.parameters?.length) { more = [ { label: componentsNameConfig['obproxy'].name, parameters: obproxy?.parameters, }, { label: componentsNameConfig['obagent'].name, parameters: obagent?.parameters, }, ]; if (!lowVersion) { more.push({ label: componentsNameConfig['ocpexpress'].name, parameters: ocpexpress?.parameters, }); } } clusterConfigInfo.push({ key: 'components', group: '组件配置', content, more, }); } return ( {oceanbase?.appname} {currentType === 'all' ? '完全部署' : '精简部署'} {componentsList.map( (item: API.TableComponentInfo, index: number) => ( 1 ? { marginTop: 16 } : {}} key={item.key} > {item?.showComponentName} {componentsNameConfig[item.key]?.type} {item?.version} ), )} {currentType === 'all' ? ( {componentsNodeConfigList.map( (item: ComponentsNodeConfig) => ( {item.isTooltip ? (
{item?.servers}
) : ( item?.servers )}
), )}
) : null} {auth?.user} {auth?.password ? (
{showPwd ? (
{auth?.password}
setShowPwd(false)} />
) : (
****** setShowPwd(true)} />
)}
) : ( '-' )}
{home_path} {clusterConfigInfo?.map((item, index) => ( {item.content.map((subItem) => ( {subItem.value} ))} {item?.more?.length ? item?.more.map((moreItem) => (
)) : null} ))}
); }