From 14dca336bec39bbff13627ffc6ba11df252e3490 Mon Sep 17 00:00:00 2001 From: tengge1 <930372551@qq.com> Date: Mon, 28 Oct 2019 20:25:19 +0800 Subject: [PATCH] =?UTF-8?q?=E9=87=8D=E7=BD=AE=E5=AF=86=E7=A0=81=E7=AA=97?= =?UTF-8?q?=E5=8F=A3=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ShadowEditor.Web/locales/zh-CN.json | 3 +- .../src/editor/system/UserManageWindow.jsx | 67 ++++++++-- .../editor/system/css/UserManageWindow.css | 4 + .../system/user/ResetPasswordWindow.jsx | 114 ++++++++++++++++++ .../system/user/css/ResetPasswordWindow.css | 0 5 files changed, 178 insertions(+), 10 deletions(-) create mode 100644 ShadowEditor.Web/src/editor/system/user/ResetPasswordWindow.jsx create mode 100644 ShadowEditor.Web/src/editor/system/user/css/ResetPasswordWindow.css diff --git a/ShadowEditor.Web/locales/zh-CN.json b/ShadowEditor.Web/locales/zh-CN.json index 63ae39a6..a697fb7d 100644 --- a/ShadowEditor.Web/locales/zh-CN.json +++ b/ShadowEditor.Web/locales/zh-CN.json @@ -891,5 +891,6 @@ "Register Default Role": "注册默认角色", "Is Public": "是否公开", "The scene is not existed.": "该场景不存在。", - "Permission denied.": "没有权限" + "Permission denied.": "没有权限", + "Reset Password": "重置密码" } \ No newline at end of file diff --git a/ShadowEditor.Web/src/editor/system/UserManageWindow.jsx b/ShadowEditor.Web/src/editor/system/UserManageWindow.jsx index 0501c84f..70f2f180 100644 --- a/ShadowEditor.Web/src/editor/system/UserManageWindow.jsx +++ b/ShadowEditor.Web/src/editor/system/UserManageWindow.jsx @@ -1,6 +1,7 @@ import './css/UserManageWindow.css'; -import { Window, Content, Toolbar, Button, DataGrid, Column, ToolbarFiller, SearchField } from '../../third_party'; +import { Window, Content, Toolbar, Button, DataGrid, Column, ToolbarFiller, SearchField, ToolbarSeparator } from '../../third_party'; import EditUserWindow from './user/EditUserWindow.jsx'; +import ResetPasswordWindow from './user/ResetPasswordWindow.jsx'; /** * 用户管理窗口 @@ -25,6 +26,7 @@ class UserManageWindow extends React.Component { this.handleEdit = this.handleEdit.bind(this); this.handleDelete = this.handleDelete.bind(this); this.commitDelete = this.commitDelete.bind(this); + this.handleResetPassword = this.handleResetPassword.bind(this); this.handleClose = this.handleClose.bind(this); this.handleSearch = this.handleSearch.bind(this); @@ -54,8 +56,12 @@ class UserManageWindow extends React.Component { + + - + - - - - - - - + + + + + + + ; @@ -164,6 +199,20 @@ class UserManageWindow extends React.Component { }); } + handleResetPassword() { + const { selected } = this.state; + + if (!selected) { + app.toast(_t('Please select a record.')); + return; + } + + const win = app.createElement(ResetPasswordWindow, { + id: selected + }); + app.addElement(win); + } + commitDelete(id) { fetch(`${app.options.server}/api/User/Delete?ID=${id}`, { method: 'POST' diff --git a/ShadowEditor.Web/src/editor/system/css/UserManageWindow.css b/ShadowEditor.Web/src/editor/system/css/UserManageWindow.css index 37eb6252..85fb00e2 100644 --- a/ShadowEditor.Web/src/editor/system/css/UserManageWindow.css +++ b/ShadowEditor.Web/src/editor/system/css/UserManageWindow.css @@ -11,6 +11,10 @@ font-size: 12px; } +.Window.UserManageWindow>.wrap>.content>.Toolbar>.ToolbarSeparator>.separator { + margin: 0 4px; +} + .Window.UserManageWindow>.wrap>.content>.Toolbar>.SearchField { width: 240px; } diff --git a/ShadowEditor.Web/src/editor/system/user/ResetPasswordWindow.jsx b/ShadowEditor.Web/src/editor/system/user/ResetPasswordWindow.jsx new file mode 100644 index 00000000..ef7d7cec --- /dev/null +++ b/ShadowEditor.Web/src/editor/system/user/ResetPasswordWindow.jsx @@ -0,0 +1,114 @@ +import './css/ResetPasswordWindow.css'; +import { PropTypes, Window, Content, Buttons, Form, FormControl, Label, Input, Button, Select } from '../../../third_party'; + +/** + * 重置密码窗口 + * @author tengge / https://github.com/tengge1 + */ +class ResetPasswordWindow extends React.Component { + constructor(props) { + super(props); + + this.state = { + id: props.id, + newPassword: '', + confirmPassword: '' + }; + + this.handleChange = this.handleChange.bind(this); + this.handleSave = this.handleSave.bind(this); + this.handleClose = this.handleClose.bind(this); + } + + render() { + const { newPassword, confirmPassword } = this.state; + + return + +
+ + + + + + + + +
+
+ + + + +
; + } + + handleChange(value, name) { + this.setState({ + [name]: value + }); + } + + handleSave() { + const { id, newPassword, confirmPassword } = this.state; + + if (!newPassword || newPassword.trim() === '') { + app.toast(_t('New password is not allowed to be empty.')); + return; + } + + if (!confirmPassword || confirmPassword.trim() === '') { + app.toast(_t('Confirm password is not allowed to be empty.')); + return; + } + + if (newPassword !== confirmPassword) { + app.toast(_t('New password and confirm password is not the same.')); + return; + } + + fetch(`${app.options.server}/api/User/ResetPassword`, { + method: 'POST', + headers: { + 'Content-Type': 'application/x-www-form-urlencoded' + }, + body: `ID=${id}&NewPassword=${newPassword}&ConfirmPassword=${confirmPassword}` + }).then(response => { + response.json().then(json => { + if (json.Code !== 200) { + app.toast(_t(json.Msg)); + return; + } + this.handleClose(); + }); + }); + } + + handleClose() { + app.removeElement(this); + } +} + +ResetPasswordWindow.propTypes = { + id: PropTypes.string +}; + +ResetPasswordWindow.defaultProps = { + id: '' +}; + +export default ResetPasswordWindow; \ No newline at end of file diff --git a/ShadowEditor.Web/src/editor/system/user/css/ResetPasswordWindow.css b/ShadowEditor.Web/src/editor/system/user/css/ResetPasswordWindow.css new file mode 100644 index 00000000..e69de29b