更换日志组件为logrus,修改资产的账号和密码不再为必填选项

This commit is contained in:
dushixiang
2020-12-27 21:44:40 +08:00
parent 20030dac7d
commit bbeed5344a
23 changed files with 183 additions and 90 deletions

View File

@ -386,7 +386,7 @@ class Asset extends Component {
itemRender: itemRender
}}
extra={[
<Logout/>
<Logout key='logout'/>
]}
subTitle="资产"
>

View File

@ -7,12 +7,29 @@ const {Option} = Select;
// 子级页面
// Ant form create 表单内置方法
const protocolMapping = {
'ssh': [
{text: '自定义', value: 'custom'},
{text: '授权凭证', value: 'credential'},
{text: '私钥', value: 'private-key'}
],
'rdp': [{text: '自定义', value: 'custom'}, {text: '授权凭证', value: 'credential'}],
'vnc': [{text: '自定义', value: 'custom'}, {text: '授权凭证', value: 'credential'}],
'telnet': [{text: '自定义', value: 'custom'}, {text: '授权凭证', value: 'credential'}]
}
const AssetModal = function ({title, visible, handleOk, handleCancel, confirmLoading, credentials, model}) {
const [form] = Form.useForm();
let [accountType, setAccountType] = useState(model.accountType);
let initAccountTypes = []
if (model.protocol) {
initAccountTypes = protocolMapping[model.protocol];
}
let [accountTypes, setAccountTypes] = useState(initAccountTypes);
useEffect(() => {
setAccountType(model.accountType);
});
@ -35,18 +52,35 @@ const AssetModal = function ({title, visible, handleOk, handleCancel, confirmLoa
switch (e.target.value) {
case 'ssh':
port = 22;
break;
case 'rdp':
port = 3389;
break;
case 'vnc':
port = 5901;
setAccountTypes(protocolMapping['ssh']);
form.setFieldsValue({
accountType: 'custom',
});
handleAccountTypeChange('custom');
break;
case 'rdp':
port = 3389;
setAccountTypes(protocolMapping['rdp']);
form.setFieldsValue({
accountType: 'custom',
});
handleAccountTypeChange('custom');
break;
case 'vnc':
port = 5901;
setAccountTypes(protocolMapping['vnc']);
form.setFieldsValue({
accountType: 'custom',
});
handleAccountTypeChange('custom');
break;
case 'telnet':
port = 23;
setAccountTypes(protocolMapping['telnet']);
form.setFieldsValue({
accountType: 'custom',
});
handleAccountTypeChange('custom');
break;
default:
port = 65535;
@ -57,6 +91,11 @@ const AssetModal = function ({title, visible, handleOk, handleCancel, confirmLoa
});
};
const handleAccountTypeChange = v => {
setAccountType(v);
model.accountType = v;
}
return (
<Modal
@ -106,13 +145,10 @@ const AssetModal = function ({title, visible, handleOk, handleCancel, confirmLoa
</Form.Item>
<Form.Item label="账户类型" name='accountType' rules={[{required: true, message: '请选择接账户类型'}]}>
<Select onChange={(v) => {
setAccountType(v);
model.accountType = v;
}}>
<Option value="custom">自定义</Option>
<Option value="credential">授权凭证</Option>
<Option value="private-key">私钥</Option>
<Select onChange={handleAccountTypeChange}>
{accountTypes.map(item => {
return (<Option key={item.value} value={item.value}>{item.text}</Option>)
})}
</Select>
</Form.Item>
@ -138,13 +174,11 @@ const AssetModal = function ({title, visible, handleOk, handleCancel, confirmLoa
{
accountType === 'custom' ?
<>
<Form.Item label="授权账户" name='username' rules={[{required: true, message: '请输入授权账户'}]}
noStyle={!(accountType === 'custom')}>
<Form.Item label="授权账户" name='username' noStyle={!(accountType === 'custom')}>
<Input placeholder="输入授权账户"/>
</Form.Item>
<Form.Item label="授权密码" name='password' rules={[{required: true, message: '请输入授权密码'}]}
noStyle={!(accountType === 'custom')}>
<Form.Item label="授权密码" name='password' noStyle={!(accountType === 'custom')}>
<Input placeholder="输入授权密码"/>
</Form.Item>
</>

View File

@ -57,7 +57,7 @@ class BatchCommand extends Component {
itemRender: itemRender
}}
extra={[
<Logout/>
<Logout key='logout'/>
]}
subTitle="动态指令"
>

View File

@ -361,7 +361,7 @@ class DynamicCommand extends Component {
itemRender: itemRender
}}
extra={[
<Logout/>
<Logout key='logout'/>
]}
subTitle="批量动态指令执行"
>

View File

@ -282,7 +282,7 @@ class Credential extends Component {
itemRender: itemRender
}}
extra={[
<Logout/>
<Logout key='logout'/>
]}
subTitle="访问资产的账户、密钥等"
>

View File

@ -88,7 +88,7 @@ class Dashboard extends Component {
}}
subTitle="仪表盘"
extra={[
<Logout/>
<Logout key='logout'/>
]}
>
</PageHeader>

View File

@ -359,7 +359,7 @@ class OfflineSession extends Component {
itemRender: itemRender
}}
extra={[
<Logout/>
<Logout key='logout'/>
]}
subTitle="离线会话管理"
>

View File

@ -350,7 +350,7 @@ class OnlineSession extends Component {
itemRender: itemRender
}}
extra={[
<Logout/>
<Logout key='logout'/>
]}
subTitle="查询实时在线会话"
>

View File

@ -109,7 +109,7 @@ class Setting extends Component {
itemRender: itemRender
}}
extra={[
<Logout/>
<Logout key='logout'/>
]}
subTitle="系统设置"
>

View File

@ -80,7 +80,7 @@ class Info extends Component {
itemRender: itemRender
}}
extra={[
<Logout/>
<Logout key='logout'/>
]}
subTitle="个人中心"
>

View File

@ -18,6 +18,7 @@ class Logout extends Component {
return (
<div>
<Popconfirm
key='login-btn-pop'
title="您确定要退出登录吗?"
onConfirm={this.confirm}
okText="确定"

View File

@ -310,7 +310,7 @@ class User extends Component {
itemRender: itemRender
}}
extra={[
<Logout/>
<Logout key='logout'/>
]}
subTitle="平台用户管理"
>