Skip to content

Commit

Permalink
Merge pull request #231 from fengyangsy/issue-#230
Browse files Browse the repository at this point in the history
Add register page
  • Loading branch information
yeasy authored Mar 14, 2021
2 parents d639176 + 6c04d5d commit 9d67d70
Show file tree
Hide file tree
Showing 11 changed files with 229 additions and 61 deletions.
1 change: 1 addition & 0 deletions src/dashboard/mock/organization.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,5 @@ function getOrgs(req, res) {

export default {
'GET /api/organizations': getOrgs,
organizations
};
42 changes: 42 additions & 0 deletions src/dashboard/mock/user.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import Mock from 'mockjs';
import faker from 'faker';
import paginator from 'cello-paginator';
import organizations from './organization';

const users = Mock.mock({
'data|11': [
Expand Down Expand Up @@ -123,6 +124,47 @@ export default {
currentAuthority: 'guest',
});
},
'POST /api/register': (req, res) => {
const { username, orgName } = req.body;
if (!username || username === '') {
res.send({
success: false,
message: 'username is necessary!'
});
return;
}
if (!orgName || orgName === '') {
res.send({
success: false,
message: 'orgName is necessary!'
});
return;
}
let success = true;
let message = '';
organizations.organizations.data.forEach(function(value){
if (value.name === orgName) {
success = false;
message = 'The org is exist!';
}
});
if (!success) {
res.send({
success,
message
});
return;
}
organizations.organizations.data.push({
id: Mock.Random.guid(),
name: orgName,
created_at: Date.now()
});
res.send({
success: true,
message: 'register success!'
});
},
'GET /api/500': (req, res) => {
res.status(500).send({
timestamp: 1513932555104,
Expand Down
11 changes: 6 additions & 5 deletions src/dashboard/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,13 @@
"not ie <= 10"
],
"dependencies": {
"@ant-design/icons": "^4.1.0",
"@ant-design/pro-layout": "^5.0.0",
"@antv/data-set": "^0.10.1",
"antd": "^4.2.5",
"@ant-design/icons": "^4.1.0",
"bizcharts": "3.5.2-beta.1",
"bizcharts-plugin-slider": "^2.1.1-beta.1",
"cello-paginator": "^1.0.1",
"classnames": "^2.2.6",
"enquire-js": "^0.2.1",
"express": "^4.16.4",
Expand All @@ -79,12 +81,11 @@
"react-dom": "^16.8.0",
"react-fittext": "^1.0.0",
"react-media": "^1.9.2",
"react-redux": "^7.2.2",
"redux": "^4.0.5",
"resize-observer-polyfill": "^1.5.1",
"cello-paginator": "^1.0.1",
"umi-request": "^1.2.19",
"@ant-design/pro-layout": "^5.0.0",
"umi": "^3.1.4",
"redux": "^4.0.5",
"umi-request": "^1.2.19",
"validator": "^11.0.0"
},
"devDependencies": {
Expand Down
22 changes: 21 additions & 1 deletion src/dashboard/src/components/Login/map.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
import React from 'react';
import { UserOutlined, LockOutlined, MobileOutlined, MailOutlined } from '@ant-design/icons';
import {
UserOutlined,
LockOutlined,
MobileOutlined,
MailOutlined,
TeamOutlined,
} from '@ant-design/icons';
import styles from './index.less';

export default {
Expand Down Expand Up @@ -62,4 +68,18 @@ export default {
},
],
},
OrgName: {
props: {
size: 'large',
id: 'orgName',
prefix: <TeamOutlined className={styles.prefixIcon} />,
placeholder: 'org1',
},
rules: [
{
required: true,
message: 'Please enter the name of organization!',
},
],
},
};
11 changes: 5 additions & 6 deletions src/dashboard/src/components/StandardTable/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,22 +101,21 @@ class StandardTable extends PureComponent {
<Fragment>
{intl.formatMessage({
id: 'component.standardTable.selected',
defaultMessage: 'Selected'
defaultMessage: 'Selected',
})}
<a style={{ fontWeight: 600 }}>{selectedRowKeys.length}</a>{' '}
{intl.formatMessage({
id: 'component.standardTable.item',
defaultMessage: 'Item'
defaultMessage: 'Item',
})}
&nbsp;&nbsp;
{needTotalList.map(item => (
<span style={{ marginLeft: 8 }} key={item.dataIndex}>
{item.title}
{intl.formatMessage({
id: 'component.standardTable.total',
defaultMessage: 'Total'
})}
{' '}
defaultMessage: 'Total',
})}{' '}
&nbsp;
<span style={{ fontWeight: 600 }}>
{item.render ? item.render(item.total) : item.total}
Expand All @@ -126,7 +125,7 @@ class StandardTable extends PureComponent {
<a onClick={this.cleanSelectedKeys} style={{ marginLeft: 24 }}>
{intl.formatMessage({
id: 'component.standardTable.clean',
defaultMessage: 'Clean'
defaultMessage: 'Clean',
})}
</a>
</Fragment>
Expand Down
7 changes: 6 additions & 1 deletion src/dashboard/src/locales/en-US/login.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,12 @@ export default {
'app.login.remember-me': 'Remember me',
'app.login.forgot-password': 'Forgot your password?',
'app.login.sign-in-with': 'Sign in with',
'app.login.signup': 'Sign up',
'app.login.signUp': 'Sign up',
'app.login.login': 'Login',
'app.register.register': 'Register',
'app.register.orgName': 'Organization name',
'app.register.success': 'The organization and user register success!',
'app.register.orgName.example': 'For example: org1.cello.com',
'app.register.get-verification-code': 'Get code',
'app.login.verification-code-warning':
'This project is a demo project and will not actually send you a verification code. Please switch to the account password login interface and log in as prompted.',
Expand All @@ -23,6 +26,8 @@ export default {
'validation.email.required': 'Please enter your email!',
'validation.email.wrong-format': 'The email address is in the wrong format!',
'validation.userName.required': 'Please enter your userName!',
'validation.orgName.required': 'Please enter your organization name!',
'validation.orgName.check': 'Organization name format error!',
'validation.password.required': 'Please enter your password!',
'validation.password.twice': 'The passwords entered twice do not match!',
'validation.password.strength.msg':
Expand Down
7 changes: 6 additions & 1 deletion src/dashboard/src/locales/zh-CN/login.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,12 @@ export default {
'app.login.remember-me': '自动登录',
'app.login.forgot-password': '忘记密码',
'app.login.sign-in-with': '其他登录方式',
'app.login.signup': '注册账户',
'app.login.signUp': '注册账户',
'app.login.login': '登录',
'app.register.register': '注册',
'app.register.orgName': '组织名',
'app.register.success': '组织和用户注册成功',
'app.register.orgName.example': '例如:org1.cello.com',
'app.register.get-verification-code': '获取验证码',
'app.login.verification-code-warning':
'此项目为演示项目,并不会真的给您发送验证码。请切换到账户密码登录界面按提示登录。',
Expand All @@ -23,6 +26,8 @@ export default {
'validation.email.required': '请输入邮箱地址!',
'validation.email.wrong-format': '邮箱地址格式错误!',
'validation.userName.required': '请输入用户名!',
'validation.orgName.required': '请输入组织名!',
'validation.orgName.check': '组织名格式错误!',
'validation.password.required': '请输入密码!',
'validation.password.twice': '两次输入的密码不匹配!',
'validation.password.strength.msg': '请至少输入 6 个字符。请不要使用容易被猜到的密码。',
Expand Down
26 changes: 25 additions & 1 deletion src/dashboard/src/models/login.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { history } from 'umi';
import { stringify } from 'qs';
import { fakeAccountLogin } from '@/services/api';
import { fakeAccountLogin, register } from '@/services/api';
import { setAuthority } from '@/utils/authority';
import { getPageQuery } from '@/utils/utils';
import { reloadAuthorized } from '@/utils/Authorized';
Expand All @@ -10,6 +10,10 @@ export default {

state: {
status: undefined,
register: {
success: true,
registerMsg: '',
},
},

effects: {
Expand Down Expand Up @@ -52,6 +56,17 @@ export default {
}
},

*register({ payload }, { call, put }) {
const response = yield call(register, payload);
yield put({
type: 'changeRegisterStatus',
payload: {
success: response.success,
msg: response.success ? 'Register successfully!' : response.message,
},
});
},

*logout(_, { put }) {
yield put({
type: 'changeLoginStatus',
Expand Down Expand Up @@ -85,5 +100,14 @@ export default {
type: payload.type,
};
},
changeRegisterStatus(state, { payload }) {
return {
...state,
register: {
success: payload.success,
registerMsg: payload.msg,
},
};
},
},
};
7 changes: 4 additions & 3 deletions src/dashboard/src/pages/Operator/Node/New/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,10 @@ class Index extends PureComponent {
const { location, children, intl } = this.props;
return (
<PageHeaderWrapper
title={
intl.formatMessage({ id: 'app.operator.node.new.title', defaultMessage: 'Create Node' })
}
title={intl.formatMessage({
id: 'app.operator.node.new.title',
defaultMessage: 'Create Node',
})}
tabActiveKey={location.pathname}
>
<Card bordered={false}>
Expand Down
Loading

0 comments on commit 9d67d70

Please sign in to comment.