Skip to content

Commit 8a36438

Browse files
committed
feat: optimize env (#80)
* style: remove radio reset style * ci: ts ignore * feat: optimize env management
1 parent 4aafa57 commit 8a36438

File tree

21 files changed

+367
-268
lines changed

21 files changed

+367
-268
lines changed

app/controller/envManagement.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,14 @@ class EnvManagementController extends Controller {
1212
// 新增环境
1313
async addEnv() {
1414
const { ctx, app } = this;
15-
const { envName, hostIp, url, remark, tagIds } = ctx.request.body;
15+
const { envName, hostIp, uicUsername, uicPasswd, url, remark, tagIds } = ctx.request.body;
1616
if (_.isNil(envName)) throw new Error('缺少必要参数 envName');
1717
if (_.isNil(url)) throw new Error('缺少必要参数 url');
1818
const result = await ctx.service.envManagement.addEnv({
1919
envName,
2020
hostIp,
21+
uicUsername,
22+
uicPasswd,
2123
url,
2224
remark,
2325
tags: tagIds.join(','),
@@ -32,11 +34,14 @@ class EnvManagementController extends Controller {
3234
// 编辑环境
3335
async editEnv() {
3436
const { ctx, app } = this;
35-
const { id, envName, hostIp, url, remark, tagIds } = ctx.request.body;
37+
const { id, envName, hostIp, uicUsername, uicPasswd, url, remark, tagIds } =
38+
ctx.request.body;
3639
if (_.isNil(id)) throw new Error('缺少必要参数id');
3740
await ctx.service.envManagement.editEnv({
3841
id,
3942
envName,
43+
uicUsername,
44+
uicPasswd,
4045
hostIp,
4146
url,
4247
remark,

app/model/env_management.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ module.exports = (app) => {
66
id: { type: INTEGER, primaryKey: true, autoIncrement: true },
77
envName: { type: STRING(255), field: 'env_name' },
88
hostIp: { type: STRING(20), field: 'host_ip' },
9+
uicUsername: { type: STRING(255), field: 'uic_username' },
10+
uicPasswd: { type: STRING(255), field: 'uic_passwd' },
911
url: { type: STRING(2048), field: 'url' },
1012
remark: STRING(255),
1113
tags: { type: STRING(60), field: 'tag_ids' },

app/service/envManagement.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,16 @@ class EnvManagementService extends Service {
66
const { ctx } = this;
77
const { tags = '', search = '' } = params;
88
const envResult = await ctx.model.EnvManagement.findAll({
9-
attributes: ['id', 'envName', 'hostIp', 'url', 'remark', 'tags'],
9+
attributes: [
10+
'id',
11+
'envName',
12+
'hostIp',
13+
'uicUsername',
14+
'uicPasswd',
15+
'url',
16+
'remark',
17+
'tags',
18+
],
1019
where: {
1120
status: 1,
1221
$or: [
@@ -43,10 +52,12 @@ class EnvManagementService extends Service {
4352
}
4453
editEnv(env) {
4554
const { ctx } = this;
46-
const { id, envName, hostIp, url, remark, tags } = env;
55+
const { id, envName, hostIp, uicUsername, uicPasswd, url, remark, tags } = env;
4756
const newEnv = {};
4857
if (!_.isNil(envName)) newEnv.envName = envName;
4958
if (!_.isNil(hostIp)) newEnv.hostIp = hostIp;
59+
if (!_.isNil(uicUsername)) newEnv.uicUsername = uicUsername;
60+
if (!_.isNil(uicPasswd)) newEnv.uicPasswd = uicPasswd;
5061
if (!_.isNil(url)) newEnv.url = url;
5162
if (!_.isNil(remark)) newEnv.remark = remark;
5263
if (!_.isNil(tags)) newEnv.tags = tags;

app/web/components/dtCodemirror/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ function DtCodemirror(props: any) {
9191
}, []);
9292
return (
9393
<div className="dt-codemirror">
94+
{/* @ts-ignore */}
9495
<CodeMirror {...props} />
9596
<Select
9697
showSearch

app/web/layouts/header/header.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ const HeaderComponent = (props: any) => {
8080
return (
8181
<Header className="dt-layout-header header_component">
8282
<div className="dt-header-log-wrapper logo">
83+
{/* @ts-ignore */}
8384
<Link to="/page/toolbox">
8485
<img className="logo_img" src={logo} />
8586
<span className="system-title">Doraemon</span>
@@ -107,6 +108,7 @@ const HeaderComponent = (props: any) => {
107108
>
108109
{children.map((navChild: any) => (
109110
<Menu.Item key={navChild.path}>
111+
{/* @ts-ignore */}
110112
<Link to={navChild.path}>
111113
{navChild.icon}
112114
<span>{navChild.name}</span>
@@ -118,6 +120,7 @@ const HeaderComponent = (props: any) => {
118120
} else {
119121
return (
120122
<Menu.Item key={path}>
123+
{/* @ts-ignore */}
121124
<Link to={path}>
122125
{icon}
123126
<span>{name}</span>

app/web/layouts/sider/index.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ const SiderComponent = (props: any) => {
6767
>
6868
{children.map((navChild) => (
6969
<Menu.Item key={navChild.path}>
70+
{/* @ts-ignore */}
7071
<Link to={navChild.path}>
7172
{navChild.icon}
7273
<span>{navChild.name}</span>
@@ -78,6 +79,7 @@ const SiderComponent = (props: any) => {
7879
} else {
7980
return (
8081
<Menu.Item key={path}>
82+
{/* @ts-ignore */}
8183
<Link to={path}>
8284
{icon}
8385
<span>{name}</span>

app/web/main.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ const clientRender = () => {
3030
const render = (Page: any) => {
3131
ReactDOM.hydrate(
3232
EASY_ENV_IS_DEV ? (
33+
// @ts-ignore
3334
<AppContainer>
3435
<Page />
3536
</AppContainer>

app/web/pages/configCenter/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ const ConfigCenter = () => {
4242
dataIndex: 'filename',
4343
width: 200,
4444
render: (value: any, row: any) => (
45+
// @ts-ignore
4546
<Link to={`/page/config-detail/${row.id}`}>{value}</Link>
4647
),
4748
},

app/web/pages/configDetail/index.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ const ConfigDetail = (props: any) => {
105105
<Col span={18}>
106106
<Breadcrumb>
107107
<Breadcrumb.Item>
108+
{/* @ts-ignore */}
108109
<Link to="/page/config-center">配置中心</Link>
109110
</Breadcrumb.Item>
110111
<Breadcrumb.Item>配置详情</Breadcrumb.Item>
@@ -124,6 +125,7 @@ const ConfigDetail = (props: any) => {
124125
<div className="page-content">
125126
<Row gutter={16}>
126127
<Col span={18}>
128+
{/* @ts-ignore */}
127129
<CodeMirror
128130
ref={codeEditorRef}
129131
value={config}
@@ -147,6 +149,7 @@ const ConfigDetail = (props: any) => {
147149
<QuestionCircleOutlined />
148150
</Tooltip>
149151
</Title>
152+
{/* @ts-ignore */}
150153
<CodeMirror
151154
ref={shellEditorRef}
152155
value={shell}

app/web/pages/envManagement/components/envModal/index.tsx

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@ import { Form, Input, message as Message, Modal, Select, Spin } from 'antd';
33
import { isEmpty, isFunction, isNull } from 'lodash';
44

55
import { API } from '@/api';
6+
import { urlReg } from '@/utils/reg';
67
const FormItem = Form.Item;
78
const { TextArea } = Input;
89
const { Option } = Select;
910

1011
const EnvForm = (props: any) => {
1112
const { value, tagList = [], forwardRef } = props;
12-
const { envName, hostIp, url, remark, tags = [] } = value;
13+
const { envName, hostIp, uicUsername, uicPasswd, url, remark, tags = [] } = value;
1314
const tagIds = tags.map((item: any) => Number(item.id));
1415
return (
1516
<Form
@@ -19,6 +20,8 @@ const EnvForm = (props: any) => {
1920
initialValues={{
2021
envName,
2122
hostIp,
23+
uicUsername,
24+
uicPasswd,
2225
url,
2326
tagIds,
2427
remark,
@@ -30,24 +33,37 @@ const EnvForm = (props: any) => {
3033
rules={[{ required: true, message: '请输入环境名称' }]}
3134
hasFeedback
3235
>
33-
<Input placeholder="请输入环境名称" />
36+
<Input placeholder="请输入环境名称" maxLength={255} />
3437
</FormItem>
3538
<FormItem
3639
label="主机IP"
3740
name="hostIp"
3841
rules={[{ required: true, message: '请输入主机IP' }]}
3942
hasFeedback
4043
>
41-
<Input placeholder="请输入主机IP" />
44+
<Input placeholder="请输入主机IP" maxLength={255} />
45+
</FormItem>
46+
<FormItem label="UIC用户名" name="uicUsername" hasFeedback>
47+
<Input placeholder="请输入UIC用户名" maxLength={255} />
48+
</FormItem>
49+
<FormItem label="UIC密码" name="uicPasswd" hasFeedback>
50+
<Input type="password" placeholder="请输入UIC密码" maxLength={255} />
4251
</FormItem>
4352
<Fragment>
4453
<FormItem
4554
label="访问地址"
4655
name="url"
47-
rules={[{ required: true, message: '请输入访问地址' }]}
56+
rules={[
57+
{ required: true, message: '请输入访问地址' },
58+
{
59+
required: true,
60+
pattern: urlReg,
61+
message: '请输入正确格式的访问地址,以 http(s):// 开头',
62+
},
63+
]}
4864
hasFeedback
4965
>
50-
<TextArea placeholder="请输入访问地址" rows={2} maxLength={2000} />
66+
<Input placeholder="请输入访问地址" maxLength={2000} />
5167
</FormItem>
5268
</Fragment>
5369
<FormItem
@@ -59,6 +75,14 @@ const EnvForm = (props: any) => {
5975
required: true,
6076
message: '请选择标签',
6177
},
78+
{
79+
validator: (rule, value = [], callback) => {
80+
if (value?.length > 3) {
81+
callback('最多选择三个标签');
82+
}
83+
callback();
84+
},
85+
},
6286
]}
6387
hasFeedback
6488
>

0 commit comments

Comments
 (0)