diff --git a/sysom_web/src/locales/zh-CN/pages.js b/sysom_web/src/locales/zh-CN/pages.js index 9cc6e2fc39d7c96cdf2bbf5b476ecafa02ec4f67..8baecf58eaeb4494935244bacb653d7a4f6da78b 100644 --- a/sysom_web/src/locales/zh-CN/pages.js +++ b/sysom_web/src/locales/zh-CN/pages.js @@ -214,6 +214,7 @@ export default { 'pages.account.create_success': '创建成功', 'pages.account.create_account_modal': '创建用户', 'pages.account.add_account': '添加账号', + 'pages.hostTable.batchimportfile': '上传文件', 'pages.hostTable.batchimport': '批量导入', 'pages.hostTable.importexcel': '导入excel文件', 'pages.hostTable.temdownload': '模板下载', diff --git a/sysom_web/src/pages/host/List/index.jsx b/sysom_web/src/pages/host/List/index.jsx index 4fe6da0bbf4f7d35c3b387079765619eab1ebd21..7183a8d5ee8cc281aafa2ed1235fdbea514d7a01 100644 --- a/sysom_web/src/pages/host/List/index.jsx +++ b/sysom_web/src/pages/host/List/index.jsx @@ -12,6 +12,7 @@ import { } from '../service'; import BulkImport from '../components/BulkImport'; import HostModalForm from '../components/HostModalForm'; +import BulkImportFile from '../components/BulkImportFile'; const { Option } = Select; @@ -490,6 +491,7 @@ const HostList = () => { > + ); }} diff --git a/sysom_web/src/pages/host/components/BulkImportFile.jsx b/sysom_web/src/pages/host/components/BulkImportFile.jsx new file mode 100644 index 0000000000000000000000000000000000000000..0f4f10cf01a23ae52038528ee94cb075c6dd45fc --- /dev/null +++ b/sysom_web/src/pages/host/components/BulkImportFile.jsx @@ -0,0 +1,70 @@ +import { Button, message, Alert } from "antd"; +import { ModalForm, ProFormUploadButton, ProFormText } from "@ant-design/pro-form"; +import { FormattedMessage } from 'umi'; +import { scpFileToHost } from '../service' + +const Tip = () => { + return ( + + ) +} + + +const BulkImportFile = (props) => { + + const BulkImportFileEvent = async (values) => { + console.log(props.selectedRows) + const formData = new FormData(); + formData.append('opt', 'send-file') + formData.append('remote_nodes', props.selectedRowKeys) + formData.append('file', values.file[0].originFileObj) + formData.append('remomte_path', values.dir) + const token = localStorage.getItem('token') + await scpFileToHost(formData, token).then((res) => { + props.onCleanSelected(); + message.success(res.message) + return true; + }).catch((err) => { + console.log(err) + message.error(result.message); + }) + } + + return ( + + + + } + onFinish={async (values) => { + return await BulkImportFileEvent(values) + }} + > + + { return false } + }} + /> + + + ) +} + +export default BulkImportFile + diff --git a/sysom_web/src/pages/host/service.js b/sysom_web/src/pages/host/service.js index a686c7b527addaf80452860384b33cbfba32a0b0..37bdbc336272ede28126a3f70e4eab8e8fef5f6d 100644 --- a/sysom_web/src/pages/host/service.js +++ b/sysom_web/src/pages/host/service.js @@ -8,6 +8,7 @@ import { const CLUSTER_URL = '/api/v1/cluster/'; const HOST_URL = '/api/v1/host/'; +const SCP_URL = '/api/v1/host/scp/'; export async function getCluster(options) { const msg = await request(CLUSTER_URL, { @@ -211,4 +212,22 @@ export async function batchDelHost(body, token, options) { }, ...(options || {}) }) +} + +/** + * scp传输文件 + * @param {*} body + * @param {*} token + * @param {*} options + * @returns + */ +export async function scpFileToHost(body, token, options) { + return request(SCP_URL, { + method: 'post', + data: body, + headers: { + 'Authorization': token, + }, + ...(options || {}) + }) } \ No newline at end of file