-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Case sensitive renaming * Update `cvat-js` lib. * Add `.env` file * Add basic redux capabilities * Remove `setTimeout` as it was fixes in `cvat-js` * Remove redundant state field
- Loading branch information
Showing
15 changed files
with
130 additions
and
68 deletions.
There are no files selected for viewing
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,8 @@ | ||
REACT_APP_VERSION=${npm_package_version} | ||
REACT_APP_API_PROTOCOL=http | ||
REACT_APP_API_HOST=localhost | ||
REACT_APP_API_PORT=7000 | ||
REACT_APP_API_HOST_URL=${REACT_APP_API_PROTOCOL}://${REACT_APP_API_HOST}:${REACT_APP_API_PORT} | ||
REACT_APP_API_FULL_URL=${REACT_APP_API_PROTOCOL}://${REACT_APP_API_HOST}:${REACT_APP_API_PORT}/api/v1 | ||
REACT_APP_LOGIN=admin | ||
REACT_APP_PASSWORD=admin |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
export const loginAction = () => (dispatch: any) => { | ||
dispatch({ | ||
type: 'LOGIN', | ||
payload: true, | ||
}) | ||
} | ||
|
||
export const logoutAction = () => (dispatch: any) => { | ||
dispatch({ | ||
type: 'LOGOUT', | ||
payload: false, | ||
}) | ||
} |
This file was deleted.
Oops, something went wrong.
File renamed without changes.
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,46 @@ | ||
import React, { PureComponent } from 'react'; | ||
import { BrowserRouter as Router, Route, Redirect } from 'react-router-dom'; | ||
import { connect } from 'react-redux'; | ||
|
||
import Dashboard from '../dashboard/dashboard'; | ||
|
||
import { loginAction, logoutAction } from '../../actions/authentication-action'; | ||
|
||
import './app.scss'; | ||
|
||
declare const window: any; | ||
|
||
const mapDispatchToProps = (dispatch: any) => ({ | ||
login: () => { dispatch(loginAction()) }, | ||
logout: () => { dispatch(logoutAction()) }, | ||
}) | ||
|
||
const mapStateToProps = (state: any) => ({ | ||
...state.authenticateReducer, | ||
}) | ||
|
||
class App extends PureComponent<any, any> { | ||
componentDidMount() { | ||
window.cvat.server.login(process.env.REACT_APP_LOGIN, process.env.REACT_APP_PASSWORD).then( | ||
(_response: any) => { | ||
this.props.login(); | ||
}, | ||
(_error: any) => { | ||
this.props.logout(); | ||
} | ||
); | ||
} | ||
|
||
render() { | ||
return( | ||
<Router> | ||
<div> | ||
<Redirect from="/" to="dashboard" /> | ||
<Route path="/dashboard" component={ Dashboard } /> | ||
</div> | ||
</Router> | ||
); | ||
} | ||
} | ||
|
||
export default connect(mapStateToProps, mapDispatchToProps)(App); |
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
File renamed without changes.
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
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,10 @@ | ||
export default (state = {}, action: any) => { | ||
switch (action.type) { | ||
case 'LOGIN': | ||
return { ...state, isLoggedIn: action.payload }; | ||
case 'LOGOUT': | ||
return { ...state, isLoggedIn: action.payload }; | ||
default: | ||
return state; | ||
} | ||
} |
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,7 @@ | ||
import { combineReducers } from 'redux'; | ||
|
||
import authenticationReducer from './authenticate-reducer'; | ||
|
||
export default combineReducers({ | ||
authenticationReducer, | ||
}); |
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,19 @@ | ||
import { createStore, applyMiddleware, compose } from 'redux'; | ||
import thunk from 'redux-thunk'; | ||
|
||
import rootReducer from './reducers/root-reducer'; | ||
|
||
export default function configureStore(initialState = {}) { | ||
return createStore( | ||
rootReducer, | ||
initialState, | ||
compose( | ||
applyMiddleware(thunk), | ||
(window as any).__REDUX_DEVTOOLS_EXTENSION__ | ||
? | ||
(window as any).__REDUX_DEVTOOLS_EXTENSION__({ trace: true }) | ||
: | ||
(f: any) => f | ||
) | ||
); | ||
} |