Skip to content

Commit b265eb0

Browse files
committed
init commit for webapp
adding authentication reducer
1 parent cb2fbf7 commit b265eb0

14 files changed

Lines changed: 10450 additions & 0 deletions

File tree

projectforge-webapp/.gitignore

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# dependencies
2+
/node_modules
3+
/.pnp
4+
.pnp.js
5+
6+
# testing
7+
/coverage
8+
9+
# production
10+
/build
11+
12+
# misc
13+
.DS_Store
14+
.env.local
15+
.env.development.local
16+
.env.test.local
17+
.env.production.local
18+
19+
npm-debug.log*
20+
yarn-debug.log*
21+
yarn-error.log*

projectforge-webapp/README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Building the WebApp
2+
3+
## Building with yarn/npm
4+
1. Before running the app you need to install the dependencies with `yarn install` or `npm install`.
5+
2. Then you can build the webapp via `yarn build` or `npm run build`.
6+
7+
## Development with hot-code-replacement (recommended)
8+
1. Start ProjectForge. See [ProjectForge ReadMe](../README.adoc)
9+
2. Start web server with hot-code-replacement:
10+
1. Run `yarn start` or `npm start` in terminal.
11+
2. Open browser (if not started automatically) on yarn/npm port (default is 3000).
12+
13+
Now you can modify the Web files directly in the directory ```projectforge-webapp``` and
14+
any change is automatically deployed instantly for your web browser.

projectforge-webapp/package.json

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"name": "projectforge-webapp",
3+
"version": "0.1.0",
4+
"private": false,
5+
"dependencies": {
6+
"react": "^16.8.3",
7+
"react-dom": "^16.8.3",
8+
"react-redux": "^6.0.1",
9+
"react-scripts": "2.1.5",
10+
"redux": "^4.0.1"
11+
},
12+
"scripts": {
13+
"start": "react-scripts start",
14+
"build": "react-scripts build",
15+
"test": "react-scripts test",
16+
"eject": "react-scripts eject"
17+
},
18+
"eslintConfig": {
19+
"extends": "react-app"
20+
},
21+
"browserslist": [
22+
">0.2%",
23+
"not dead",
24+
"not ie <= 11",
25+
"not op_mini all"
26+
]
27+
}
5.55 KB
Binary file not shown.
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="utf-8" />
5+
<link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico" />
6+
<meta
7+
name="viewport"
8+
content="width=device-width, initial-scale=1, shrink-to-fit=no"
9+
/>
10+
<meta name="theme-color" content="#000000" />
11+
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
12+
<title>ProjectForge</title>
13+
</head>
14+
<body>
15+
<noscript>You need to enable JavaScript to run this app.</noscript>
16+
<div id="root"></div>
17+
</body>
18+
</html>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"short_name": "ProjectForge",
3+
"name": "ProjectForge",
4+
"icons": [
5+
{
6+
"src": "favicon.ico",
7+
"sizes": "64x64 32x32 24x24 16x16",
8+
"type": "image/x-icon"
9+
}
10+
],
11+
"start_url": ".",
12+
"display": "standalone",
13+
"theme_color": "#000000",
14+
"background_color": "#ffffff"
15+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
export const USER_LOGIN_BEGIN = 'USER_LOGIN_BEGIN';
2+
export const USER_LOGIN_SUCCESS = 'USER_LOGIN_SUCCESS';
3+
export const USER_LOGIN_FAILURE = 'USER_LOGIN_FAILURE';
4+
export const USER_LOGOUT = 'USER_LOGOUT';
5+
6+
export const userLoginBegin = keepSignedIn => ({
7+
type: USER_LOGIN_BEGIN,
8+
payload: {
9+
keepSignedIn
10+
}
11+
});
12+
13+
export const userLoginSuccess = (userId, authenticationToken) => ({
14+
type: USER_LOGIN_SUCCESS,
15+
payload: {
16+
userId,
17+
authenticationToken
18+
}
19+
});
20+
21+
export const userLoginFailure = error => ({
22+
type: USER_LOGIN_FAILURE,
23+
payload: {
24+
error
25+
}
26+
});
27+
28+
export const userLogout = () => ({
29+
type: USER_LOGOUT
30+
});
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import React from 'react';
2+
import {connect} from 'react-redux';
3+
4+
function ProjectForge({loggedIn}) {
5+
if (!loggedIn) {
6+
7+
}
8+
}
9+
10+
const mapStateToProps = state => ({
11+
loggedIn: state.authentication.user !== null
12+
});
13+
14+
export default connect(mapStateToProps)(ProjectForge);

projectforge-webapp/src/index.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import React from 'react';
2+
import ReactDOM from 'react-dom';
3+
import {createStore} from 'redux';
4+
import {Provider} from 'react-redux';
5+
import reducer from './reducers';
6+
import ProjectForge from './containers/ProjectForge';
7+
import * as serviceWorker from './serviceWorker';
8+
9+
const store = createStore(reducer);
10+
11+
ReactDOM.render(
12+
<Provider store={store}>
13+
<ProjectForge />
14+
</Provider>,
15+
document.getElementById('root')
16+
);
17+
18+
// If you want your app to work offline and load faster, you can change
19+
// unregister() to register() below. Note this comes with some pitfalls.
20+
// Learn more about service workers: http://bit.ly/CRA-PWA
21+
serviceWorker.unregister();
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import {USER_LOGIN_BEGIN, USER_LOGIN_FAILURE, USER_LOGIN_SUCCESS, USER_LOGOUT} from '../actions/authentication';
2+
3+
const initialState = {
4+
keepSignedIn: false,
5+
loading: false,
6+
error: null,
7+
user: null
8+
};
9+
10+
const reducer = (state = initialState, {type, payload}) => {
11+
switch (type) {
12+
case USER_LOGIN_BEGIN:
13+
return {
14+
...state,
15+
loading: true,
16+
error: null,
17+
user: null,
18+
keepSignedIn: payload.keepSignedIn
19+
};
20+
case USER_LOGIN_SUCCESS:
21+
return {
22+
...state,
23+
loading: false,
24+
user: {
25+
id: payload.userId,
26+
token: payload.authenticationToken
27+
}
28+
};
29+
case USER_LOGIN_FAILURE:
30+
return {
31+
...state,
32+
loading: false,
33+
error: payload.error
34+
};
35+
case USER_LOGOUT:
36+
return {
37+
...state,
38+
user: null
39+
};
40+
default:
41+
return state;
42+
}
43+
};
44+
45+
export default reducer;

0 commit comments

Comments
 (0)