import { intl } from '@/utils/intl'; 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, getErrorInfo } from '@/utils'; import { componentsConfig, allComponentsKeys, onlyComponentsKeys, modeConfig, obproxyComponent, } from '../constants'; import { getLocale } from 'umi'; import EnStyles from './indexEn.less'; import ZhStyles from './indexZh.less'; const locale = getLocale(); const styles = locale === 'zh-CN' ? ZhStyles : EnStyles; interface ComponentsNodeConfig { name: string; servers: string[]; key: string; isTooltip: boolean; } export default function CheckInfo() { const { configData, currentType, setCheckOK, lowVersion, setCurrentStep, handleQuitProgress, setErrorVisible, setErrorsList, errorsList, } = 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); } }, onError: (e: any) => { const errorInfo = getErrorInfo(e); setErrorVisible(true); setErrorsList([...errorsList, errorInfo]); }, }, ); const prevStep = () => { setCurrentStep(3); window.scrollTo(0, 0); }; const handlePreCheck = () => { handleCreateConfig({ name: oceanbase?.appname }, { ...configData }); }; const getComponentsList = () => { const componentsList: API.TableComponentInfo[] = []; allComponentsKeys.forEach((key) => { if (components?.[key]) { const componentConfig = componentsConfig?.[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 (componentsConfig?.[key]) { componentsNodeConfigList.push({ key, name: componentsConfig?.[key]?.name, servers: components?.[key]?.servers?.join(','), isTooltip: key === obproxyComponent, }); } }); return componentsNodeConfigList; }; const dbConfigColumns: ColumnsType = [ { title: intl.formatMessage({ id: 'OBD.pages.components.CheckInfo.ZoneName', defaultMessage: 'Zone 名称', }), dataIndex: 'name', width: 200, render: (text) => text || '-', }, { title: intl.formatMessage({ id: 'OBD.pages.components.CheckInfo.ObServerNodes', defaultMessage: 'OB Server 节点', }), dataIndex: 'servers', render: (text) => { const serversIps = text.map((item: API.OceanbaseServers) => item.ip); const str = serversIps.join(','); return (
{str}
); }, }, { title: intl.formatMessage({ id: 'OBD.pages.components.CheckInfo.RootServerNodes', defaultMessage: 'Root Server 节点', }), dataIndex: 'rootservice', width: 200, render: (text) => text || '-', }, ]; const getMoreColumns = (label: string) => { const columns: ColumnsType = [ { title: label, dataIndex: 'key', render: (text) => text, }, { title: intl.formatMessage({ id: 'OBD.pages.components.CheckInfo.ParameterValue', defaultMessage: '参数值', }), dataIndex: 'value', render: (text, record) => record.adaptive ? intl.formatMessage({ id: 'OBD.pages.components.CheckInfo.Adaptive', defaultMessage: '自动分配', }) : text || '-', }, { title: intl.formatMessage({ id: 'OBD.pages.components.CheckInfo.Introduction', defaultMessage: '介绍', }), dataIndex: 'description', render: (text) => (
{text}
), }, ]; return columns; }; const componentsList = getComponentsList(); const componentsNodeConfigList = getComponentsNodeConfigList(); const initDir = `${home_path}/oceanbase/store`; const clusterConfigInfo = [ { key: 'cluster', group: intl.formatMessage({ id: 'OBD.pages.components.CheckInfo.ClusterConfiguration', defaultMessage: '集群配置', }), content: [ { label: intl.formatMessage({ id: 'OBD.pages.components.CheckInfo.ConfigurationMode', defaultMessage: '配置模式', }), colSpan: 5, value: modeConfig[oceanbase?.mode], }, { label: intl.formatMessage({ id: 'OBD.pages.components.CheckInfo.RootSysPassword', defaultMessage: 'root@sys 密码', }), colSpan: 5, value: (
{oceanbase?.root_password}
), }, { label: intl.formatMessage({ id: 'OBD.pages.components.CheckInfo.DataDirectory', defaultMessage: '数据目录', }), value: (
{oceanbase?.data_dir || initDir}
), }, { label: intl.formatMessage({ id: 'OBD.pages.components.CheckInfo.LogDirectory', defaultMessage: '日志目录', }), value: (
{oceanbase?.redo_dir || initDir}
), }, { label: intl.formatMessage({ id: 'OBD.pages.components.CheckInfo.SqlPort', defaultMessage: 'SQL 端口', }), colSpan: 3, value: oceanbase?.mysql_port, }, { label: intl.formatMessage({ id: 'OBD.pages.components.CheckInfo.RpcPort', defaultMessage: 'RPC 端口', }), colSpan: 3, value: oceanbase?.rpc_port, }, ], more: oceanbase?.parameters?.length ? [ { label: componentsConfig['oceanbase'].labelName, parameters: oceanbase?.parameters, }, ] : [], }, ]; if (currentType === 'all') { const content = [ { label: intl.formatMessage({ id: 'OBD.pages.components.CheckInfo.ObproxyServicePort', defaultMessage: 'OBProxy 服务端口', }), value: obproxy?.listen_port, }, { label: intl.formatMessage({ id: 'OBD.pages.components.CheckInfo.PortObproxyExporter', defaultMessage: 'OBProxy Exporter 端口', }), value: obproxy?.prometheus_listen_port, }, { label: intl.formatMessage({ id: 'OBD.pages.components.CheckInfo.ObagentMonitoringServicePort', defaultMessage: 'OBAgent 监控服务端口', }), value: obagent?.monagent_http_port, }, { label: intl.formatMessage({ id: 'OBD.pages.components.CheckInfo.ObagentManageServicePorts', defaultMessage: 'OBAgent 管理服务端口', }), value: obagent?.mgragent_http_port, }, ]; if (!lowVersion) { content.push({ label: intl.formatMessage({ id: 'OBD.pages.components.CheckInfo.PortOcpExpress', defaultMessage: 'OCP Express 端口', }), value: ocpexpress?.port, }); } let more: any = []; if (obproxy?.parameters?.length) { more = [ { label: componentsConfig['obproxy'].labelName, parameters: obproxy?.parameters, }, { label: componentsConfig['obagent'].labelName, parameters: obagent?.parameters, }, ]; if (!lowVersion) { more.push({ label: componentsConfig['ocpexpress'].labelName, parameters: ocpexpress?.parameters, }); } } clusterConfigInfo.push({ key: 'components', group: intl.formatMessage({ id: 'OBD.pages.components.CheckInfo.ComponentConfiguration', defaultMessage: '组件配置', }), content, more, }); } return ( {oceanbase?.appname} {currentType === 'all' ? intl.formatMessage({ id: 'OBD.pages.components.CheckInfo.FullyDeployed', defaultMessage: '完全部署', }) : intl.formatMessage({ id: 'OBD.pages.components.CheckInfo.ThinDeployment', defaultMessage: '精简部署', })} {componentsList.map( (item: API.TableComponentInfo, index: number) => ( 1 ? { marginTop: 16 } : {}} key={item.key} > {item?.showComponentName} {componentsConfig[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} ))}
); }