feat: 完善节点模块,初步完成联调
parent
120b162a40
commit
a00eeb2ffd
@ -0,0 +1,157 @@
|
|||||||
|
import { apiServerEdit } from '@/services/business/server';
|
||||||
|
import { isSuccessApi } from '@/utils/forApi';
|
||||||
|
import { ModalForm, ProForm, ProFormText } from '@ant-design/pro-components';
|
||||||
|
import { FormattedMessage, useIntl } from '@umijs/max';
|
||||||
|
import { Form, message } from 'antd';
|
||||||
|
import React, { useEffect } from 'react';
|
||||||
|
import {
|
||||||
|
proFormSmallItemStyleProps,
|
||||||
|
proFormSmallModelWidth,
|
||||||
|
} from '../../../../../config/defaultForm';
|
||||||
|
|
||||||
|
export type UpdateServerFormProps = {
|
||||||
|
updateModalOpen: boolean;
|
||||||
|
handleModal: () => void;
|
||||||
|
values: Record<string, any>;
|
||||||
|
commInfo: Record<string, any>;
|
||||||
|
reload: any;
|
||||||
|
};
|
||||||
|
const UpdateServerForm: React.FC<UpdateServerFormProps> = (props) => {
|
||||||
|
const intl = useIntl();
|
||||||
|
const [form] = Form.useForm<API.ModelCategory>();
|
||||||
|
function resetForm() {
|
||||||
|
form.resetFields();
|
||||||
|
}
|
||||||
|
useEffect(() => {
|
||||||
|
if (props.updateModalOpen && props.values?.id) {
|
||||||
|
form.setFieldsValue({ ...props.values });
|
||||||
|
console.log(props.values, 'useEffect_values');
|
||||||
|
} else {
|
||||||
|
resetForm();
|
||||||
|
}
|
||||||
|
}, [props.updateModalOpen, props.values]);
|
||||||
|
return (
|
||||||
|
<ModalForm<API.ModelCategory>
|
||||||
|
className="gn_modal_form gn_form"
|
||||||
|
width={proFormSmallModelWidth}
|
||||||
|
title={intl.formatMessage({
|
||||||
|
id: 'server_state.create.form.action.edit',
|
||||||
|
defaultMessage: '编辑',
|
||||||
|
})}
|
||||||
|
open={props.updateModalOpen}
|
||||||
|
form={form}
|
||||||
|
autoFocusFirstInput
|
||||||
|
modalProps={{
|
||||||
|
destroyOnClose: true,
|
||||||
|
onCancel: () => props.handleModal(),
|
||||||
|
}}
|
||||||
|
submitTimeout={2000}
|
||||||
|
onFinish={async (values) => {
|
||||||
|
console.log(values, 'apiServerEdit_values');
|
||||||
|
let resp = await apiServerEdit({
|
||||||
|
...values,
|
||||||
|
entity_id: props?.commInfo?.id,
|
||||||
|
id: props.values.id,
|
||||||
|
});
|
||||||
|
if (isSuccessApi(resp)) {
|
||||||
|
message.success(
|
||||||
|
intl.formatMessage({ id: 'common.action.success', defaultMessage: '$$$' }),
|
||||||
|
);
|
||||||
|
props.reload();
|
||||||
|
props.handleModal();
|
||||||
|
} else {
|
||||||
|
message.error(
|
||||||
|
resp?.meta?.message ||
|
||||||
|
intl.formatMessage({ id: 'common.action.failure', defaultMessage: '$$$' }),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
props.handleModal();
|
||||||
|
return true;
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<ProForm.Group>
|
||||||
|
<ProFormText
|
||||||
|
width={proFormSmallItemStyleProps.column2Width}
|
||||||
|
name="name"
|
||||||
|
label={<FormattedMessage id="server_state.table.form.name" defaultMessage="名称" />}
|
||||||
|
placeholder={`${intl.formatMessage({
|
||||||
|
id: 'common.please_input',
|
||||||
|
defaultMessage: '$$$',
|
||||||
|
})}${intl.formatMessage({
|
||||||
|
id: 'server_state.table.form.name',
|
||||||
|
defaultMessage: '$$$',
|
||||||
|
})}`}
|
||||||
|
required={true}
|
||||||
|
rules={[
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: (
|
||||||
|
<FormattedMessage
|
||||||
|
id="server_state.table.form.rule.required.name"
|
||||||
|
defaultMessage="名称必填"
|
||||||
|
/>
|
||||||
|
),
|
||||||
|
},
|
||||||
|
]}
|
||||||
|
/>
|
||||||
|
<ProFormText
|
||||||
|
width={proFormSmallItemStyleProps.column2Width}
|
||||||
|
name="ip"
|
||||||
|
initialValue={'http://192.168.10.1'}
|
||||||
|
label={<FormattedMessage id="server_state.table.form.ip" defaultMessage="IP" />}
|
||||||
|
placeholder={`${intl.formatMessage({
|
||||||
|
id: 'common.please_input',
|
||||||
|
defaultMessage: '$$$',
|
||||||
|
})}${intl.formatMessage({
|
||||||
|
id: 'server_state.table.form.ip',
|
||||||
|
defaultMessage: '$$$',
|
||||||
|
})}`}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<ProFormText
|
||||||
|
width={proFormSmallItemStyleProps.column2Width}
|
||||||
|
name="username"
|
||||||
|
label={<FormattedMessage id="server_state.table.form.userName" defaultMessage="用户名" />}
|
||||||
|
placeholder={`${intl.formatMessage({
|
||||||
|
id: 'common.please_input',
|
||||||
|
defaultMessage: '$$$',
|
||||||
|
})}${intl.formatMessage({
|
||||||
|
id: 'server_state.table.form.userName',
|
||||||
|
defaultMessage: '$$$',
|
||||||
|
})}`}
|
||||||
|
/>
|
||||||
|
{/* // TODO 密码默认渲染*** */}
|
||||||
|
<ProFormText.Password
|
||||||
|
width={proFormSmallItemStyleProps.column2Width}
|
||||||
|
label={<FormattedMessage id="server_state.table.form.pwd" defaultMessage="密码" />}
|
||||||
|
name="passwd"
|
||||||
|
initialValue={'******'}
|
||||||
|
placeholder={`${intl.formatMessage({
|
||||||
|
id: 'common.please_input',
|
||||||
|
defaultMessage: '$$$',
|
||||||
|
})}${intl.formatMessage({
|
||||||
|
id: 'server_state.table.form.pwd',
|
||||||
|
defaultMessage: '$$$',
|
||||||
|
})}`}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<ProFormText
|
||||||
|
width={proFormSmallItemStyleProps.width}
|
||||||
|
name="port"
|
||||||
|
initialValue={8080}
|
||||||
|
label={
|
||||||
|
<FormattedMessage id="server_state.table.form.defaultPort" defaultMessage="默认端口" />
|
||||||
|
}
|
||||||
|
placeholder={`${intl.formatMessage({
|
||||||
|
id: 'common.please_input',
|
||||||
|
defaultMessage: '$$$',
|
||||||
|
})}${intl.formatMessage({
|
||||||
|
id: 'server_state.table.form.defaultPort',
|
||||||
|
defaultMessage: '$$$',
|
||||||
|
})}`}
|
||||||
|
/>
|
||||||
|
</ProForm.Group>
|
||||||
|
</ModalForm>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
export default UpdateServerForm;
|
@ -0,0 +1,99 @@
|
|||||||
|
// @ts-ignore
|
||||||
|
/* eslint-disable */
|
||||||
|
import { request } from '@umijs/max';
|
||||||
|
|
||||||
|
/**企业服务器 */
|
||||||
|
// 新建服务器
|
||||||
|
export async function apiServerAdd(body: any, options?: { [key: string]: any }) {
|
||||||
|
return request<API.Response & { data?: API.ENTITY_INDEX_DATA; msg?: string }>(
|
||||||
|
`/api/v1/enterprise/server/add`,
|
||||||
|
{
|
||||||
|
method: 'POST',
|
||||||
|
headers: {
|
||||||
|
// 'Content-Type': 'application/json',
|
||||||
|
// "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8"
|
||||||
|
},
|
||||||
|
data: body,
|
||||||
|
...(options || {}),
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
// 编辑服务器
|
||||||
|
export async function apiServerEdit(body: any, options?: { [key: string]: any }) {
|
||||||
|
return request<API.Response & { data?: API.ENTITY_INDEX_DATA; msg?: string }>(
|
||||||
|
`/api/v1/enterprise/server/edit`,
|
||||||
|
{
|
||||||
|
method: 'POST',
|
||||||
|
headers: {
|
||||||
|
// 'Content-Type': 'application/json',
|
||||||
|
// "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8"
|
||||||
|
},
|
||||||
|
data: body,
|
||||||
|
...(options || {}),
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 删除服务器
|
||||||
|
export async function apiServerDelete(body: any, options?: { [key: string]: any }) {
|
||||||
|
return request<API.Response & { data?: API.ENTITY_INDEX_DATA; msg?: string }>(
|
||||||
|
`/api/v1/enterprise/server/delete`,
|
||||||
|
{
|
||||||
|
method: 'POST',
|
||||||
|
headers: {
|
||||||
|
// 'Content-Type': 'application/json',
|
||||||
|
// "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8"
|
||||||
|
},
|
||||||
|
data: body,
|
||||||
|
...(options || {}),
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 服务器列表
|
||||||
|
export async function apiServerList(body: any, options?: { [key: string]: any }) {
|
||||||
|
return request<API.Response & { data?: API.ENTITY_INDEX_DATA; msg?: string }>(
|
||||||
|
`/api/v1/enterprise/server/list`,
|
||||||
|
{
|
||||||
|
method: 'POST',
|
||||||
|
headers: {
|
||||||
|
// 'Content-Type': 'application/json',
|
||||||
|
// "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8"
|
||||||
|
},
|
||||||
|
data: body,
|
||||||
|
...(options || {}),
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 服务器信息
|
||||||
|
export async function apiServerInfo(body: any, options?: { [key: string]: any }) {
|
||||||
|
return request<API.Response & { data?: API.ENTITY_INDEX_DATA; msg?: string }>(
|
||||||
|
`/api/v1/enterprise/server/info`,
|
||||||
|
{
|
||||||
|
method: 'POST',
|
||||||
|
headers: {
|
||||||
|
// 'Content-Type': 'application/json',
|
||||||
|
// "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8"
|
||||||
|
},
|
||||||
|
data: body,
|
||||||
|
...(options || {}),
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 服务器日志列表
|
||||||
|
export async function apiServerLog(body: any, options?: { [key: string]: any }) {
|
||||||
|
return request<API.Response & { data?: API.ENTITY_INDEX_DATA; msg?: string }>(
|
||||||
|
`/api/v1/enterprise/server/log`,
|
||||||
|
{
|
||||||
|
method: 'POST',
|
||||||
|
headers: {
|
||||||
|
// 'Content-Type': 'application/json',
|
||||||
|
// "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8"
|
||||||
|
},
|
||||||
|
data: body,
|
||||||
|
...(options || {}),
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
@ -0,0 +1,43 @@
|
|||||||
|
/*
|
||||||
|
* @Author: donghao donghao@supervision.ltd
|
||||||
|
* @Date: 2024-06-20 16:08:31
|
||||||
|
* @LastEditors: donghao donghao@supervision.ltd
|
||||||
|
* @LastEditTime: 2024-06-20 16:12:41
|
||||||
|
* @FilePath: \general-ai-platform-web\src\services\business\system.ts
|
||||||
|
* @Description: system api
|
||||||
|
*/
|
||||||
|
|
||||||
|
// @ts-ignore
|
||||||
|
/* eslint-disable */
|
||||||
|
import { request } from '@umijs/max';
|
||||||
|
|
||||||
|
/**系统管理 */
|
||||||
|
|
||||||
|
// 日志服务
|
||||||
|
export async function apiSystemLog(body: any, options?: { [key: string]: any }) {
|
||||||
|
return request<API.Response & { data?: API.ENTITY_INDEX_DATA; msg?: string }>(
|
||||||
|
`/api/v1/system/log`,
|
||||||
|
{
|
||||||
|
method: 'POST',
|
||||||
|
headers: {
|
||||||
|
// 'Content-Type': 'application/json',
|
||||||
|
// "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8"
|
||||||
|
},
|
||||||
|
data: body,
|
||||||
|
...(options || {}),
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 日志服务
|
||||||
|
export async function apiUsers(body: any, options?: { [key: string]: any }) {
|
||||||
|
return request<API.Response & { data?: API.ENTITY_INDEX_DATA; msg?: string }>(`/api/v1/users`, {
|
||||||
|
method: 'POST',
|
||||||
|
headers: {
|
||||||
|
// 'Content-Type': 'application/json',
|
||||||
|
// "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8"
|
||||||
|
},
|
||||||
|
data: body,
|
||||||
|
...(options || {}),
|
||||||
|
});
|
||||||
|
}
|
Loading…
Reference in New Issue