mirror of
https://github.com/tengge1/ShadowEditor.git
synced 2026-01-25 15:08:11 +00:00
重置密码窗口。
This commit is contained in:
parent
1fca21ffa6
commit
14dca336be
@ -891,5 +891,6 @@
|
||||
"Register Default Role": "注册默认角色",
|
||||
"Is Public": "是否公开",
|
||||
"The scene is not existed.": "该场景不存在。",
|
||||
"Permission denied.": "没有权限"
|
||||
"Permission denied.": "没有权限",
|
||||
"Reset Password": "重置密码"
|
||||
}
|
||||
@ -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 {
|
||||
<Button onClick={this.handleAdd}>{_t('Create')}</Button>
|
||||
<Button onClick={this.handleEdit}>{_t('Edit')}</Button>
|
||||
<Button onClick={this.handleDelete}>{_t('Delete')}</Button>
|
||||
<ToolbarSeparator />
|
||||
<Button onClick={this.handleResetPassword}>{_t('Reset Password')}</Button>
|
||||
<ToolbarFiller />
|
||||
<SearchField placeholder={_t('Search Content')} onInput={this.handleSearch} />
|
||||
<SearchField placeholder={_t('Search Content')}
|
||||
onInput={this.handleSearch}
|
||||
/>
|
||||
</Toolbar>
|
||||
<DataGrid data={data}
|
||||
pages
|
||||
@ -73,13 +79,42 @@ class UserManageWindow extends React.Component {
|
||||
onRefresh={this.handleRefresh}
|
||||
keyField={'ID'}
|
||||
>
|
||||
<Column type={'number'} title={'#'} />
|
||||
<Column field={'Username'} title={_t('Username')} width={120} />
|
||||
<Column field={'Name'} title={_t('NickName')} align={'center'} renderer={this.renderName} />
|
||||
<Column field={'RoleName'} title={_t('Role')} width={120} align={'center'} renderer={this.renderRoleName} />
|
||||
<Column field={'CreateTime'} title={_t('Create Date')} width={120} align={'center'} renderer={this.renderDate} />
|
||||
<Column field={'UpdateTime'} title={_t('Update Date')} width={120} align={'center'} renderer={this.renderDate} />
|
||||
<Column field={'Status'} title={_t('Status')} width={80} align={'center'} renderer={this.renderStatus} />
|
||||
<Column type={'number'}
|
||||
title={'#'}
|
||||
/>
|
||||
<Column field={'Username'}
|
||||
title={_t('Username')}
|
||||
width={120}
|
||||
/>
|
||||
<Column field={'Name'}
|
||||
title={_t('NickName')}
|
||||
align={'center'}
|
||||
renderer={this.renderName}
|
||||
/>
|
||||
<Column field={'RoleName'}
|
||||
title={_t('Role')}
|
||||
width={120}
|
||||
align={'center'}
|
||||
renderer={this.renderRoleName}
|
||||
/>
|
||||
<Column field={'CreateTime'}
|
||||
title={_t('Create Date')}
|
||||
width={120}
|
||||
align={'center'}
|
||||
renderer={this.renderDate}
|
||||
/>
|
||||
<Column field={'UpdateTime'}
|
||||
title={_t('Update Date')}
|
||||
width={120}
|
||||
align={'center'}
|
||||
renderer={this.renderDate}
|
||||
/>
|
||||
<Column field={'Status'}
|
||||
title={_t('Status')}
|
||||
width={80}
|
||||
align={'center'}
|
||||
renderer={this.renderStatus}
|
||||
/>
|
||||
</DataGrid>
|
||||
</Content>
|
||||
</Window>;
|
||||
@ -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'
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
114
ShadowEditor.Web/src/editor/system/user/ResetPasswordWindow.jsx
Normal file
114
ShadowEditor.Web/src/editor/system/user/ResetPasswordWindow.jsx
Normal file
@ -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 <Window
|
||||
className={_t('ResetPasswordWindows')}
|
||||
title={_t('Reset Password')}
|
||||
style={{ width: '320px', height: '200px' }}
|
||||
mask={false}
|
||||
onClose={this.handleClose}
|
||||
>
|
||||
<Content>
|
||||
<Form>
|
||||
<FormControl>
|
||||
<Label>{_t('New Password')}</Label>
|
||||
<Input name={'newPassword'}
|
||||
type={'password'}
|
||||
value={newPassword}
|
||||
onChange={this.handleChange}
|
||||
/>
|
||||
</FormControl>
|
||||
<FormControl>
|
||||
<Label>{_t('Confirm Password')}</Label>
|
||||
<Input name={'confirmPassword'}
|
||||
type={'password'}
|
||||
value={confirmPassword}
|
||||
onChange={this.handleChange}
|
||||
/>
|
||||
</FormControl>
|
||||
</Form>
|
||||
</Content>
|
||||
<Buttons>
|
||||
<Button onClick={this.handleSave}>{_t('OK')}</Button>
|
||||
<Button onClick={this.handleClose}>{_t('Cancel')}</Button>
|
||||
</Buttons>
|
||||
</Window>;
|
||||
}
|
||||
|
||||
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;
|
||||
Loading…
x
Reference in New Issue
Block a user