-
Notifications
You must be signed in to change notification settings - Fork 3.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
User interface with react and antd #755
Merged
Merged
Changes from 1 commit
Commits
Show all changes
38 commits
Select commit
Hold shift + click to select a range
6ef145b
CVAT-UI: Second try
bsekachev 7ce8038
Login page, router
bsekachev 36338b2
Registration
bsekachev df50516
Changed text
bsekachev 2b68a43
Added auto complete
bsekachev 57b540f
Minor fixes
bsekachev 13e0e44
Merge branch 'develop' into bs/cvat_ui
bsekachev 50b1762
Added logout actions
bsekachev 054f081
Added logout reducers
bsekachev 64f19af
Added header
bsekachev 452d230
Improved header
bsekachev 3a5f9cc
Added empty-tasks
bsekachev 9a08429
Tasks page initialized
bsekachev 8f6815c
Dinamic resolution
bsekachev c575a2c
Dinamic resolution
bsekachev 32ff5a1
Added preview
bsekachev f73a0a8
Adjusted task item
bsekachev c323cfc
Added menu
bsekachev 7cba9e0
Improved error handling
bsekachev d40bb09
Adjusted progress color
bsekachev ee30f2f
Some eslint fixes
bsekachev ff0e3e8
Task search and pagination
bsekachev a653314
Merge branch 'develop' into bs/cvat_ui
bsekachev 2ff5e2e
Pagination & filter works together
bsekachev af173b3
Core entrypoint
bsekachev f61b97f
Configurable host
bsekachev f5dd6c3
Prebuilt cvat-core
bsekachev b0e72a2
Couple of fixes
bsekachev c7ad2f8
Added icons
bsekachev b690df4
Merge branch 'develop' into bs/cvat_ui
bsekachev ddfe50b
Fixed preview tests
bsekachev fadf494
Owner/assignee name instead of id
bsekachev c7051fd
Task previews in redux state
bsekachev 86d1eb1
Some class components -> functional components
bsekachev 0e6eed5
Code refactoring
bsekachev 40fd26f
Code refactoring
bsekachev 21b1b48
Separated validation patterns
bsekachev 9e64aaf
Frozen scikit-image version 0.15
bsekachev File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Login page, router
- Loading branch information
commit 7ce803800061d0320f90bcda80afb0cd3c755578
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
import React from 'react'; | ||
import Text from 'antd/lib/typography/Text'; | ||
import { FormComponentProps } from 'antd/lib/form/Form'; | ||
import { | ||
Button, | ||
Icon, | ||
Input, | ||
Form, | ||
Row, | ||
Col | ||
} from 'antd'; | ||
|
||
interface LoginFormProps { | ||
onSubmit(login: string, password: string): void; | ||
} | ||
|
||
class LoginForm extends React.PureComponent<FormComponentProps & LoginFormProps> { | ||
constructor(props: FormComponentProps & LoginFormProps) { | ||
super(props); | ||
} | ||
|
||
private handleSubmit(e: React.FormEvent) { | ||
e.preventDefault(); | ||
this.props.form.validateFields((error, values) => { | ||
if (!error) { | ||
this.props.onSubmit(values.username, values.password); | ||
} | ||
}); | ||
} | ||
|
||
public render() { | ||
const { getFieldDecorator } = this.props.form; | ||
|
||
return ( | ||
<Form onSubmit={this.handleSubmit.bind(this)} className='login-form'> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please avoid There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See my comment above |
||
<Form.Item> | ||
{getFieldDecorator('username', { | ||
rules: [{ | ||
required: true, | ||
message: 'Please specify a username', | ||
}], | ||
})( | ||
<Input | ||
autoComplete='username' | ||
prefix={<Icon type='user' style={{ color: 'rgba(0,0,0,.25)'}} />} | ||
placeholder='Username' | ||
/> | ||
)} | ||
bsekachev marked this conversation as resolved.
Show resolved
Hide resolved
|
||
</Form.Item> | ||
<Form.Item> | ||
{getFieldDecorator('password', { | ||
rules: [{ | ||
required: true, | ||
message: 'Please specify a password', | ||
}], | ||
})( | ||
<Input | ||
autoComplete='current-password' | ||
prefix={<Icon type='user' style={{ color: 'rgba(0,0,0,.25)'}} />} | ||
placeholder='Password' | ||
type='password' | ||
/> | ||
)} | ||
</Form.Item> | ||
<Form.Item> | ||
<Row type='flex' justify='start' align='middle'> | ||
<Col> | ||
<Button type='primary' htmlType='submit' className='login-form-button'> | ||
Sign in | ||
</Button> | ||
</Col> | ||
</Row> | ||
</Form.Item> | ||
</Form> | ||
); | ||
} | ||
} | ||
|
||
export default Form.create<FormComponentProps & LoginFormProps>()(LoginForm); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,84 @@ | ||
import React from 'react'; | ||
import { Button, Icon, Input, Form, Col, Row } from 'antd'; | ||
import { connect } from 'react-redux'; | ||
import { RouteComponentProps } from 'react-router'; | ||
import { Redirect, Link, withRouter } from 'react-router-dom'; | ||
|
||
import Title from 'antd/lib/typography/Title'; | ||
import Text from 'antd/lib/typography/Text'; | ||
import { | ||
Col, | ||
Row | ||
} from 'antd'; | ||
|
||
import LoginForm from '../components/login-form'; | ||
|
||
import { loginAsync } from '../actions/auth-actions'; | ||
import { AuthState } from '../reducers/auth-reducer'; | ||
|
||
interface LoginPageProps { | ||
auth: AuthState; | ||
} | ||
|
||
interface LoginPageActions { | ||
login(login: string, password: string): void; | ||
} | ||
|
||
export default class LoginPage extends React.PureComponent { | ||
function mapStateToProps(state: any): LoginPageProps { | ||
return { | ||
auth: state.auth, | ||
}; | ||
} | ||
|
||
function mapDispatchToProps(dispatch: any): LoginPageActions { | ||
return { | ||
login: (login: string, password: string) => dispatch(loginAsync(login, password)), | ||
} | ||
} | ||
|
||
class LoginPage extends React.PureComponent< | ||
LoginPageProps & | ||
LoginPageActions & | ||
RouteComponentProps> { | ||
constructor(props: any) { | ||
super(props); | ||
} | ||
|
||
public render() { | ||
const { loginError } = this.props.auth; | ||
const sizes = { | ||
xs: { span: 14 }, | ||
sm: { span: 14 }, | ||
md: { span: 10 }, | ||
lg: { span: 4 }, | ||
xl: { span: 4 }, | ||
} | ||
return ( | ||
<div> | ||
<Row type="flex" justify="center" align="middle"> | ||
<Col xs={{span: 14}} sm={{span: 12}} md={{span: 10}} lg={{span: 8}} xl={{span: 6}}> | ||
<Form> | ||
<Title>Login</Title> | ||
</Form> | ||
</Col> | ||
</Row> | ||
</div> | ||
<Row type='flex' justify='center' align='middle'> | ||
<Col {...sizes}> | ||
<Redirect to='/auth/login'/> | ||
<Title level={2}> Login </Title> | ||
<LoginForm onSubmit={this.props.login}/> | ||
{ loginError && | ||
<Row> | ||
<Col> | ||
<Text type="danger"> { loginError.message } </Text> | ||
</Col> | ||
</Row> | ||
} | ||
<Row type='flex' justify='start' align='top'> | ||
<Col> | ||
<Text strong> | ||
New to CVAT? Create <Link to="/auth/register">an account</Link> | ||
</Text> | ||
</Col> | ||
</Row> | ||
</Col> | ||
</Row> | ||
); | ||
} | ||
} | ||
|
||
export default withRouter(connect( | ||
mapStateToProps, | ||
mapDispatchToProps, | ||
)(LoginPage)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
private handleSubmit = (event: React.FormEvent) => { ... }
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not really sure it's a good idea to use such a syntax. Because it isn't a part of specification for now, as far as I know.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't worry it's a good practice in React community and is part of the ES7 specification you can enable it simply add @babel/plugin-proposal-class-properties.
And in any case, I don't recommend you use
bind
in render method if it not necessary, in the future, it will bad impact on performance, take a look at official documentation https://reactjs.org/docs/handling-events.html.