Make password configurable / add UI for upload
This commit is contained in:
@@ -14,6 +14,9 @@ NOTE : If migration fails, try executing migrations manually with `npm run migra
|
|||||||
If everything works correctly, it is possible to connect to database with :
|
If everything works correctly, it is possible to connect to database with :
|
||||||
`psql -d CrmIntegration -p 5432 -U docker -h localhost`
|
`psql -d CrmIntegration -p 5432 -U docker -h localhost`
|
||||||
|
|
||||||
|
2. Copy `environment.env` file to `.env` file and make appropriate changes.
|
||||||
|
`BASIC_AUTH_USERNAME` and `BASIC_AUTH_PASSWORD` are required for functional app.
|
||||||
|
|
||||||
3. Start server : `npm run start-server`
|
3. Start server : `npm run start-server`
|
||||||
|
|
||||||
4. Start client : `npm run start-client`
|
4. Start client : `npm run start-client`
|
||||||
|
|||||||
@@ -5,8 +5,13 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"react": "^16.8.6",
|
"react": "^16.8.6",
|
||||||
"react-dom": "^16.8.6",
|
"react-dom": "^16.8.6",
|
||||||
|
"react-redux": "^7.0.3",
|
||||||
"react-router-dom": "^5.0.0",
|
"react-router-dom": "^5.0.0",
|
||||||
"react-scripts": "3.0.1"
|
"react-scripts": "3.0.1",
|
||||||
|
"redux": "^4.0.1",
|
||||||
|
"redux-thunk": "^2.3.0",
|
||||||
|
"semantic-ui-css": "^2.4.1",
|
||||||
|
"semantic-ui-react": "^0.87.1"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "react-scripts start",
|
"start": "react-scripts start",
|
||||||
|
|||||||
@@ -1,15 +1,24 @@
|
|||||||
import React, { Component } from 'react';
|
import React, { Component } from 'react';
|
||||||
import './App.css';
|
import './App.css';
|
||||||
import { BrowserRouter as Router, Route, Switch } from 'react-router-dom';
|
import { BrowserRouter as Router, Route, Switch } from 'react-router-dom';
|
||||||
import Home from './scenes/Home';
|
|
||||||
import NotFound from './scenes/NotFound';
|
import NotFound from './scenes/NotFound';
|
||||||
|
|
||||||
|
import { mainMenuItems } from './constants/menuItems';
|
||||||
|
|
||||||
class App extends Component {
|
class App extends Component {
|
||||||
render() {
|
render() {
|
||||||
return (
|
return (
|
||||||
<Router>
|
<Router>
|
||||||
<Switch>
|
<Switch>
|
||||||
<Route exact path="/" component={Home} />
|
{
|
||||||
|
mainMenuItems.map(mainMenuItem =>
|
||||||
|
<Route key={mainMenuItem.id}
|
||||||
|
exact
|
||||||
|
path={mainMenuItem.url}
|
||||||
|
component={mainMenuItem.component}
|
||||||
|
/>)
|
||||||
|
}
|
||||||
<Route component={NotFound} />
|
<Route component={NotFound} />
|
||||||
</Switch>
|
</Switch>
|
||||||
</Router>
|
</Router>
|
||||||
|
|||||||
21
client/src/components/MainMenu/index.js
Normal file
21
client/src/components/MainMenu/index.js
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import { NavLink } from 'react-router-dom';
|
||||||
|
import { Menu } from 'semantic-ui-react';
|
||||||
|
|
||||||
|
import { mainMenuItems } from "../../constants/menuItems";
|
||||||
|
|
||||||
|
const MainMenu = () =>
|
||||||
|
(<Menu>
|
||||||
|
{
|
||||||
|
mainMenuItems.map(mainMenuItem =>
|
||||||
|
<Menu.Item key={mainMenuItem.id}
|
||||||
|
as={NavLink}
|
||||||
|
to={mainMenuItem.url}
|
||||||
|
exact
|
||||||
|
>
|
||||||
|
{mainMenuItem.title}
|
||||||
|
</Menu.Item>)
|
||||||
|
}
|
||||||
|
</Menu>);
|
||||||
|
|
||||||
|
export default MainMenu;
|
||||||
17
client/src/constants/menuItems.js
Normal file
17
client/src/constants/menuItems.js
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
import UploadDLockData from "../scenes/UploadDLockData";
|
||||||
|
import Home from "../scenes/Home";
|
||||||
|
|
||||||
|
export const mainMenuItems = [
|
||||||
|
{
|
||||||
|
id: 'home',
|
||||||
|
title: 'Home',
|
||||||
|
url: '/',
|
||||||
|
component: Home,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'uploadDLockData',
|
||||||
|
title: 'DLock',
|
||||||
|
url: '/dlock',
|
||||||
|
component: UploadDLockData,
|
||||||
|
},
|
||||||
|
];
|
||||||
@@ -1,10 +1,17 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import ReactDOM from 'react-dom';
|
import ReactDOM from 'react-dom';
|
||||||
import './index.css';
|
import './index.css';
|
||||||
|
import 'semantic-ui-css/semantic.min.css';
|
||||||
import App from './App';
|
import App from './App';
|
||||||
import * as serviceWorker from './serviceWorker';
|
import * as serviceWorker from './serviceWorker';
|
||||||
|
import { Provider } from 'react-redux';
|
||||||
|
import { createStore, applyMiddleware } from 'redux';
|
||||||
|
import thunkMiddleware from 'redux-thunk';
|
||||||
|
import { rootReducer } from "./store/reducers";
|
||||||
|
|
||||||
ReactDOM.render(<App />, document.getElementById('root'));
|
const store = createStore(rootReducer, applyMiddleware(thunkMiddleware));
|
||||||
|
|
||||||
|
ReactDOM.render(<Provider store={store}><App /></Provider>, document.getElementById('root'));
|
||||||
|
|
||||||
// If you want your app to work offline and load faster, you can change
|
// If you want your app to work offline and load faster, you can change
|
||||||
// unregister() to register() below. Note this comes with some pitfalls.
|
// unregister() to register() below. Note this comes with some pitfalls.
|
||||||
|
|||||||
@@ -1,34 +1,35 @@
|
|||||||
import React, { Component } from 'react';
|
import React, { Component } from 'react';
|
||||||
|
|
||||||
class Home extends Component {
|
import { Container, Form } from "semantic-ui-react";
|
||||||
state = {
|
|
||||||
apiStatus: 'loading',
|
|
||||||
};
|
|
||||||
|
|
||||||
componentDidMount() {
|
import MainMenu from '../../components/MainMenu';
|
||||||
fetch('/api')
|
|
||||||
.then(response => response.json())
|
class Home extends Component {
|
||||||
.then(result => {
|
|
||||||
console.log(result);
|
|
||||||
if (result.status === 1) {
|
|
||||||
this.setState({apiStatus: 'working'});
|
|
||||||
} else {
|
|
||||||
this.setState({apiStatus: 'NOT WORKING !'});
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.catch(err => {
|
|
||||||
this.setState({apiStatus: `ERROR : ${err}`});
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
render () {
|
render () {
|
||||||
const {apiStatus} = this.state;
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<Container>
|
||||||
<h3>CRM Integration</h3>
|
<MainMenu/>
|
||||||
|
<h3>Report</h3>
|
||||||
<hr/>
|
<hr/>
|
||||||
<h5>Integration API Status : {apiStatus}</h5>
|
<Form>
|
||||||
</div>
|
<Form.Group widths="equal">
|
||||||
|
<Form.Input
|
||||||
|
fluid
|
||||||
|
required
|
||||||
|
label="Start date"
|
||||||
|
type="date"
|
||||||
|
/>
|
||||||
|
<Form.Input
|
||||||
|
fluid
|
||||||
|
required
|
||||||
|
label="End date"
|
||||||
|
type="date"
|
||||||
|
/>
|
||||||
|
</Form.Group>
|
||||||
|
<Form.Button>Show report</Form.Button>
|
||||||
|
</Form>
|
||||||
|
</Container>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,11 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
import MainMenu from "../../components/MainMenu";
|
||||||
|
|
||||||
export default function NotFound () {
|
export default function NotFound () {
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
|
<MainMenu/>
|
||||||
|
<hr />
|
||||||
<h1>Page not found</h1>
|
<h1>Page not found</h1>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
39
client/src/scenes/UploadDLockData/index.js
Normal file
39
client/src/scenes/UploadDLockData/index.js
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
import React, { Component } from 'react';
|
||||||
|
import { connect } from 'react-redux';
|
||||||
|
|
||||||
|
import { Container, Form } from "semantic-ui-react";
|
||||||
|
|
||||||
|
import MainMenu from '../../components/MainMenu';
|
||||||
|
import { uploadDoorLockData } from "../../store/actions";
|
||||||
|
|
||||||
|
class UploadDLockData extends Component {
|
||||||
|
|
||||||
|
render () {
|
||||||
|
return (
|
||||||
|
<Container>
|
||||||
|
<MainMenu/>
|
||||||
|
<h3>DLock Data</h3>
|
||||||
|
<hr/>
|
||||||
|
<Form>
|
||||||
|
<Form.Input
|
||||||
|
fluid
|
||||||
|
required
|
||||||
|
label="Select DLock file"
|
||||||
|
type="file"
|
||||||
|
/>
|
||||||
|
<Form.Button onClick={this.props.uploadDoorLockData}>Upload</Form.Button>
|
||||||
|
</Form>
|
||||||
|
</Container>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const mapStateToProps = (state) => ({
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
const mapDispatchToProps = (dispatch) => ({
|
||||||
|
uploadDoorLockData: () => uploadDoorLockData(dispatch),
|
||||||
|
});
|
||||||
|
|
||||||
|
export default connect(mapStateToProps, mapDispatchToProps)(UploadDLockData);
|
||||||
17
client/src/store/actions/doorLockActions.js
Normal file
17
client/src/store/actions/doorLockActions.js
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
import {
|
||||||
|
UPLOAD_DOOR_LOCK_DATA_PENDING,
|
||||||
|
UPLOAD_DOOR_LOCK_DATA_SUCCESS,
|
||||||
|
UPLOAD_DOOR_LOCK_DATA_FAILED
|
||||||
|
} from "../constants";
|
||||||
|
|
||||||
|
export const uploadDoorLockData = (dispatch) => {
|
||||||
|
dispatch({type: UPLOAD_DOOR_LOCK_DATA_PENDING});
|
||||||
|
fetch('/api/doorLockData')
|
||||||
|
.then(response => response.json())
|
||||||
|
.then(data => {
|
||||||
|
dispatch({type: UPLOAD_DOOR_LOCK_DATA_SUCCESS, payload: data})
|
||||||
|
})
|
||||||
|
.catch(err => {
|
||||||
|
dispatch({type: UPLOAD_DOOR_LOCK_DATA_FAILED, payload: err})
|
||||||
|
})
|
||||||
|
};
|
||||||
1
client/src/store/actions/index.js
Normal file
1
client/src/store/actions/index.js
Normal file
@@ -0,0 +1 @@
|
|||||||
|
export * from './doorLockActions';
|
||||||
3
client/src/store/constants.js
Normal file
3
client/src/store/constants.js
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
export const UPLOAD_DOOR_LOCK_DATA_PENDING = 'UPLOAD_DOOR_LOCK_DATA_PENDING';
|
||||||
|
export const UPLOAD_DOOR_LOCK_DATA_SUCCESS = 'UPLOAD_DOOR_LOCK_DATA_SUCCESS';
|
||||||
|
export const UPLOAD_DOOR_LOCK_DATA_FAILED = 'UPLOAD_DOOR_LOCK_DATA_FAILED';
|
||||||
35
client/src/store/reducers/doorLockReducers.js
Normal file
35
client/src/store/reducers/doorLockReducers.js
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
import {
|
||||||
|
UPLOAD_DOOR_LOCK_DATA_PENDING,
|
||||||
|
UPLOAD_DOOR_LOCK_DATA_SUCCESS,
|
||||||
|
UPLOAD_DOOR_LOCK_DATA_FAILED
|
||||||
|
} from "../constants";
|
||||||
|
|
||||||
|
const initialState = {
|
||||||
|
pending: false,
|
||||||
|
result: {},
|
||||||
|
error: '',
|
||||||
|
};
|
||||||
|
|
||||||
|
export const doorLockData = (state, action) => {
|
||||||
|
state = state || initialState;
|
||||||
|
action = action || {};
|
||||||
|
|
||||||
|
switch(action.type){
|
||||||
|
case UPLOAD_DOOR_LOCK_DATA_PENDING:
|
||||||
|
return Object.assign({}, state, {
|
||||||
|
pending: true,
|
||||||
|
});
|
||||||
|
case UPLOAD_DOOR_LOCK_DATA_SUCCESS:
|
||||||
|
return Object.assign({}, state, {
|
||||||
|
pending: false,
|
||||||
|
result: action.payload,
|
||||||
|
});
|
||||||
|
case UPLOAD_DOOR_LOCK_DATA_FAILED:
|
||||||
|
return Object.assign({}, state, {
|
||||||
|
pending: false,
|
||||||
|
error: action.payload,
|
||||||
|
});
|
||||||
|
default:
|
||||||
|
return state;
|
||||||
|
}
|
||||||
|
};
|
||||||
8
client/src/store/reducers/index.js
Normal file
8
client/src/store/reducers/index.js
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
import { combineReducers } from "redux";
|
||||||
|
|
||||||
|
import { doorLockData} from "./doorLockReducers";
|
||||||
|
|
||||||
|
export const rootReducer = combineReducers({
|
||||||
|
doorLockData
|
||||||
|
});
|
||||||
|
|
||||||
113
client/yarn.lock
113
client/yarn.lock
@@ -761,7 +761,7 @@
|
|||||||
dependencies:
|
dependencies:
|
||||||
regenerator-runtime "^0.13.2"
|
regenerator-runtime "^0.13.2"
|
||||||
|
|
||||||
"@babel/runtime@^7.0.0", "@babel/runtime@^7.1.2", "@babel/runtime@^7.3.4", "@babel/runtime@^7.4.2":
|
"@babel/runtime@^7.0.0", "@babel/runtime@^7.1.2", "@babel/runtime@^7.3.4", "@babel/runtime@^7.4.2", "@babel/runtime@^7.4.3":
|
||||||
version "7.4.5"
|
version "7.4.5"
|
||||||
resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.4.5.tgz#582bb531f5f9dc67d2fcb682979894f75e253f12"
|
resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.4.5.tgz#582bb531f5f9dc67d2fcb682979894f75e253f12"
|
||||||
dependencies:
|
dependencies:
|
||||||
@@ -981,6 +981,13 @@
|
|||||||
version "1.1.3"
|
version "1.1.3"
|
||||||
resolved "https://registry.yarnpkg.com/@nodelib/fs.stat/-/fs.stat-1.1.3.tgz#2b5a3ab3f918cca48a8c754c08168e3f03eba61b"
|
resolved "https://registry.yarnpkg.com/@nodelib/fs.stat/-/fs.stat-1.1.3.tgz#2b5a3ab3f918cca48a8c754c08168e3f03eba61b"
|
||||||
|
|
||||||
|
"@semantic-ui-react/event-stack@^3.1.0":
|
||||||
|
version "3.1.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/@semantic-ui-react/event-stack/-/event-stack-3.1.0.tgz#aadbe4a28b0dd7703c5f451640d0fefe66dd9208"
|
||||||
|
dependencies:
|
||||||
|
exenv "^1.2.2"
|
||||||
|
prop-types "^15.6.2"
|
||||||
|
|
||||||
"@svgr/babel-plugin-add-jsx-attribute@^4.2.0":
|
"@svgr/babel-plugin-add-jsx-attribute@^4.2.0":
|
||||||
version "4.2.0"
|
version "4.2.0"
|
||||||
resolved "https://registry.yarnpkg.com/@svgr/babel-plugin-add-jsx-attribute/-/babel-plugin-add-jsx-attribute-4.2.0.tgz#dadcb6218503532d6884b210e7f3c502caaa44b1"
|
resolved "https://registry.yarnpkg.com/@svgr/babel-plugin-add-jsx-attribute/-/babel-plugin-add-jsx-attribute-4.2.0.tgz#dadcb6218503532d6884b210e7f3c502caaa44b1"
|
||||||
@@ -2126,6 +2133,10 @@ class-utils@^0.3.5:
|
|||||||
isobject "^3.0.0"
|
isobject "^3.0.0"
|
||||||
static-extend "^0.1.1"
|
static-extend "^0.1.1"
|
||||||
|
|
||||||
|
classnames@^2.2.6:
|
||||||
|
version "2.2.6"
|
||||||
|
resolved "https://registry.yarnpkg.com/classnames/-/classnames-2.2.6.tgz#43935bffdd291f326dad0a205309b38d00f650ce"
|
||||||
|
|
||||||
clean-css@4.2.x:
|
clean-css@4.2.x:
|
||||||
version "4.2.1"
|
version "4.2.1"
|
||||||
resolved "https://registry.yarnpkg.com/clean-css/-/clean-css-4.2.1.tgz#2d411ef76b8569b6d0c84068dabe85b0aa5e5c17"
|
resolved "https://registry.yarnpkg.com/clean-css/-/clean-css-4.2.1.tgz#2d411ef76b8569b6d0c84068dabe85b0aa5e5c17"
|
||||||
@@ -2424,6 +2435,13 @@ create-hmac@^1.1.0, create-hmac@^1.1.2, create-hmac@^1.1.4:
|
|||||||
safe-buffer "^5.0.1"
|
safe-buffer "^5.0.1"
|
||||||
sha.js "^2.4.8"
|
sha.js "^2.4.8"
|
||||||
|
|
||||||
|
create-react-context@<=0.2.2:
|
||||||
|
version "0.2.2"
|
||||||
|
resolved "https://registry.yarnpkg.com/create-react-context/-/create-react-context-0.2.2.tgz#9836542f9aaa22868cd7d4a6f82667df38019dca"
|
||||||
|
dependencies:
|
||||||
|
fbjs "^0.8.0"
|
||||||
|
gud "^1.0.0"
|
||||||
|
|
||||||
create-react-context@^0.2.2:
|
create-react-context@^0.2.2:
|
||||||
version "0.2.3"
|
version "0.2.3"
|
||||||
resolved "https://registry.yarnpkg.com/create-react-context/-/create-react-context-0.2.3.tgz#9ec140a6914a22ef04b8b09b7771de89567cb6f3"
|
resolved "https://registry.yarnpkg.com/create-react-context/-/create-react-context-0.2.3.tgz#9ec140a6914a22ef04b8b09b7771de89567cb6f3"
|
||||||
@@ -3258,6 +3276,10 @@ execa@^1.0.0:
|
|||||||
signal-exit "^3.0.0"
|
signal-exit "^3.0.0"
|
||||||
strip-eof "^1.0.0"
|
strip-eof "^1.0.0"
|
||||||
|
|
||||||
|
exenv@^1.2.2:
|
||||||
|
version "1.2.2"
|
||||||
|
resolved "https://registry.yarnpkg.com/exenv/-/exenv-1.2.2.tgz#2ae78e85d9894158670b03d47bec1f03bd91bb9d"
|
||||||
|
|
||||||
exit@^0.1.2:
|
exit@^0.1.2:
|
||||||
version "0.1.2"
|
version "0.1.2"
|
||||||
resolved "https://registry.yarnpkg.com/exit/-/exit-0.1.2.tgz#0632638f8d877cc82107d30a0fff1a17cba1cd0c"
|
resolved "https://registry.yarnpkg.com/exit/-/exit-0.1.2.tgz#0632638f8d877cc82107d30a0fff1a17cba1cd0c"
|
||||||
@@ -3913,7 +3935,7 @@ hmac-drbg@^1.0.0:
|
|||||||
minimalistic-assert "^1.0.0"
|
minimalistic-assert "^1.0.0"
|
||||||
minimalistic-crypto-utils "^1.0.1"
|
minimalistic-crypto-utils "^1.0.1"
|
||||||
|
|
||||||
hoist-non-react-statics@^3.1.0:
|
hoist-non-react-statics@^3.1.0, hoist-non-react-statics@^3.3.0:
|
||||||
version "3.3.0"
|
version "3.3.0"
|
||||||
resolved "https://registry.yarnpkg.com/hoist-non-react-statics/-/hoist-non-react-statics-3.3.0.tgz#b09178f0122184fb95acf525daaecb4d8f45958b"
|
resolved "https://registry.yarnpkg.com/hoist-non-react-statics/-/hoist-non-react-statics-3.3.0.tgz#b09178f0122184fb95acf525daaecb4d8f45958b"
|
||||||
dependencies:
|
dependencies:
|
||||||
@@ -4868,6 +4890,10 @@ jest@24.7.1:
|
|||||||
import-local "^2.0.0"
|
import-local "^2.0.0"
|
||||||
jest-cli "^24.7.1"
|
jest-cli "^24.7.1"
|
||||||
|
|
||||||
|
jquery@x.*:
|
||||||
|
version "3.4.1"
|
||||||
|
resolved "https://registry.yarnpkg.com/jquery/-/jquery-3.4.1.tgz#714f1f8d9dde4bdfa55764ba37ef214630d80ef2"
|
||||||
|
|
||||||
js-levenshtein@^1.1.3:
|
js-levenshtein@^1.1.3:
|
||||||
version "1.1.6"
|
version "1.1.6"
|
||||||
resolved "https://registry.yarnpkg.com/js-levenshtein/-/js-levenshtein-1.1.6.tgz#c6cee58eb3550372df8deb85fad5ce66ce01d59d"
|
resolved "https://registry.yarnpkg.com/js-levenshtein/-/js-levenshtein-1.1.6.tgz#c6cee58eb3550372df8deb85fad5ce66ce01d59d"
|
||||||
@@ -5028,6 +5054,10 @@ jsx-ast-utils@^2.0.1:
|
|||||||
dependencies:
|
dependencies:
|
||||||
array-includes "^3.0.3"
|
array-includes "^3.0.3"
|
||||||
|
|
||||||
|
keyboard-key@^1.0.4:
|
||||||
|
version "1.0.4"
|
||||||
|
resolved "https://registry.yarnpkg.com/keyboard-key/-/keyboard-key-1.0.4.tgz#52d8fa07b7e17757072aa22a67fb4ae85e4c46b0"
|
||||||
|
|
||||||
killable@^1.0.0:
|
killable@^1.0.0:
|
||||||
version "1.0.1"
|
version "1.0.1"
|
||||||
resolved "https://registry.yarnpkg.com/killable/-/killable-1.0.1.tgz#4c8ce441187a061c7474fb87ca08e2a638194892"
|
resolved "https://registry.yarnpkg.com/killable/-/killable-1.0.1.tgz#4c8ce441187a061c7474fb87ca08e2a638194892"
|
||||||
@@ -6097,6 +6127,10 @@ pnp-webpack-plugin@1.2.1:
|
|||||||
dependencies:
|
dependencies:
|
||||||
ts-pnp "^1.0.0"
|
ts-pnp "^1.0.0"
|
||||||
|
|
||||||
|
popper.js@^1.14.4:
|
||||||
|
version "1.15.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/popper.js/-/popper.js-1.15.0.tgz#5560b99bbad7647e9faa475c6b8056621f5a4ff2"
|
||||||
|
|
||||||
portfinder@^1.0.9:
|
portfinder@^1.0.9:
|
||||||
version "1.0.20"
|
version "1.0.20"
|
||||||
resolved "https://registry.yarnpkg.com/portfinder/-/portfinder-1.0.20.tgz#bea68632e54b2e13ab7b0c4775e9b41bf270e44a"
|
resolved "https://registry.yarnpkg.com/portfinder/-/portfinder-1.0.20.tgz#bea68632e54b2e13ab7b0c4775e9b41bf270e44a"
|
||||||
@@ -6745,7 +6779,7 @@ prompts@^2.0.1:
|
|||||||
kleur "^3.0.2"
|
kleur "^3.0.2"
|
||||||
sisteransi "^1.0.0"
|
sisteransi "^1.0.0"
|
||||||
|
|
||||||
prop-types@^15.6.2:
|
prop-types@^15.6.1, prop-types@^15.6.2, prop-types@^15.7.2:
|
||||||
version "15.7.2"
|
version "15.7.2"
|
||||||
resolved "https://registry.yarnpkg.com/prop-types/-/prop-types-15.7.2.tgz#52c41e75b8c87e72b9d9360e0206b99dcbffa6c5"
|
resolved "https://registry.yarnpkg.com/prop-types/-/prop-types-15.7.2.tgz#52c41e75b8c87e72b9d9360e0206b99dcbffa6c5"
|
||||||
dependencies:
|
dependencies:
|
||||||
@@ -6938,10 +6972,32 @@ react-error-overlay@^5.1.6:
|
|||||||
version "5.1.6"
|
version "5.1.6"
|
||||||
resolved "https://registry.yarnpkg.com/react-error-overlay/-/react-error-overlay-5.1.6.tgz#0cd73407c5d141f9638ae1e0c63e7b2bf7e9929d"
|
resolved "https://registry.yarnpkg.com/react-error-overlay/-/react-error-overlay-5.1.6.tgz#0cd73407c5d141f9638ae1e0c63e7b2bf7e9929d"
|
||||||
|
|
||||||
react-is@^16.6.0, react-is@^16.7.0, react-is@^16.8.1, react-is@^16.8.4:
|
react-is@^16.6.0, react-is@^16.7.0, react-is@^16.8.1, react-is@^16.8.4, react-is@^16.8.6:
|
||||||
version "16.8.6"
|
version "16.8.6"
|
||||||
resolved "https://registry.yarnpkg.com/react-is/-/react-is-16.8.6.tgz#5bbc1e2d29141c9fbdfed456343fe2bc430a6a16"
|
resolved "https://registry.yarnpkg.com/react-is/-/react-is-16.8.6.tgz#5bbc1e2d29141c9fbdfed456343fe2bc430a6a16"
|
||||||
|
|
||||||
|
react-popper@^1.3.3:
|
||||||
|
version "1.3.3"
|
||||||
|
resolved "https://registry.yarnpkg.com/react-popper/-/react-popper-1.3.3.tgz#2c6cef7515a991256b4f0536cd4bdcb58a7b6af6"
|
||||||
|
dependencies:
|
||||||
|
"@babel/runtime" "^7.1.2"
|
||||||
|
create-react-context "<=0.2.2"
|
||||||
|
popper.js "^1.14.4"
|
||||||
|
prop-types "^15.6.1"
|
||||||
|
typed-styles "^0.0.7"
|
||||||
|
warning "^4.0.2"
|
||||||
|
|
||||||
|
react-redux@^7.0.3:
|
||||||
|
version "7.0.3"
|
||||||
|
resolved "https://registry.yarnpkg.com/react-redux/-/react-redux-7.0.3.tgz#983c5a6de81cb1e696bd1c090ba826545f9170f1"
|
||||||
|
dependencies:
|
||||||
|
"@babel/runtime" "^7.4.3"
|
||||||
|
hoist-non-react-statics "^3.3.0"
|
||||||
|
invariant "^2.2.4"
|
||||||
|
loose-envify "^1.4.0"
|
||||||
|
prop-types "^15.7.2"
|
||||||
|
react-is "^16.8.6"
|
||||||
|
|
||||||
react-router-dom@^5.0.0:
|
react-router-dom@^5.0.0:
|
||||||
version "5.0.0"
|
version "5.0.0"
|
||||||
resolved "https://registry.yarnpkg.com/react-router-dom/-/react-router-dom-5.0.0.tgz#542a9b86af269a37f0b87218c4c25ea8dcf0c073"
|
resolved "https://registry.yarnpkg.com/react-router-dom/-/react-router-dom-5.0.0.tgz#542a9b86af269a37f0b87218c4c25ea8dcf0c073"
|
||||||
@@ -7107,6 +7163,17 @@ recursive-readdir@2.2.2:
|
|||||||
dependencies:
|
dependencies:
|
||||||
minimatch "3.0.4"
|
minimatch "3.0.4"
|
||||||
|
|
||||||
|
redux-thunk@^2.3.0:
|
||||||
|
version "2.3.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/redux-thunk/-/redux-thunk-2.3.0.tgz#51c2c19a185ed5187aaa9a2d08b666d0d6467622"
|
||||||
|
|
||||||
|
redux@^4.0.1:
|
||||||
|
version "4.0.1"
|
||||||
|
resolved "https://registry.yarnpkg.com/redux/-/redux-4.0.1.tgz#436cae6cc40fbe4727689d7c8fae44808f1bfef5"
|
||||||
|
dependencies:
|
||||||
|
loose-envify "^1.4.0"
|
||||||
|
symbol-observable "^1.2.0"
|
||||||
|
|
||||||
regenerate-unicode-properties@^8.0.2:
|
regenerate-unicode-properties@^8.0.2:
|
||||||
version "8.1.0"
|
version "8.1.0"
|
||||||
resolved "https://registry.yarnpkg.com/regenerate-unicode-properties/-/regenerate-unicode-properties-8.1.0.tgz#ef51e0f0ea4ad424b77bf7cb41f3e015c70a3f0e"
|
resolved "https://registry.yarnpkg.com/regenerate-unicode-properties/-/regenerate-unicode-properties-8.1.0.tgz#ef51e0f0ea4ad424b77bf7cb41f3e015c70a3f0e"
|
||||||
@@ -7434,6 +7501,26 @@ selfsigned@^1.9.1:
|
|||||||
dependencies:
|
dependencies:
|
||||||
node-forge "0.7.5"
|
node-forge "0.7.5"
|
||||||
|
|
||||||
|
semantic-ui-css@^2.4.1:
|
||||||
|
version "2.4.1"
|
||||||
|
resolved "https://registry.yarnpkg.com/semantic-ui-css/-/semantic-ui-css-2.4.1.tgz#f5aea39fafb787cbd905ec724272a3f9cba9004a"
|
||||||
|
dependencies:
|
||||||
|
jquery x.*
|
||||||
|
|
||||||
|
semantic-ui-react@^0.87.1:
|
||||||
|
version "0.87.1"
|
||||||
|
resolved "https://registry.yarnpkg.com/semantic-ui-react/-/semantic-ui-react-0.87.1.tgz#249cca258fe05ee0a7095d8be0b3a749f34a1837"
|
||||||
|
dependencies:
|
||||||
|
"@babel/runtime" "^7.1.2"
|
||||||
|
"@semantic-ui-react/event-stack" "^3.1.0"
|
||||||
|
classnames "^2.2.6"
|
||||||
|
keyboard-key "^1.0.4"
|
||||||
|
lodash "^4.17.11"
|
||||||
|
prop-types "^15.6.2"
|
||||||
|
react-is "^16.7.0"
|
||||||
|
react-popper "^1.3.3"
|
||||||
|
shallowequal "^1.1.0"
|
||||||
|
|
||||||
"semver@2 || 3 || 4 || 5", semver@^5.3.0, semver@^5.4.1, semver@^5.5.0, semver@^5.5.1, semver@^5.6.0:
|
"semver@2 || 3 || 4 || 5", semver@^5.3.0, semver@^5.4.1, semver@^5.5.0, semver@^5.5.1, semver@^5.6.0:
|
||||||
version "5.7.0"
|
version "5.7.0"
|
||||||
resolved "https://registry.yarnpkg.com/semver/-/semver-5.7.0.tgz#790a7cf6fea5459bac96110b29b60412dc8ff96b"
|
resolved "https://registry.yarnpkg.com/semver/-/semver-5.7.0.tgz#790a7cf6fea5459bac96110b29b60412dc8ff96b"
|
||||||
@@ -7551,6 +7638,10 @@ shallow-clone@^1.0.0:
|
|||||||
kind-of "^5.0.0"
|
kind-of "^5.0.0"
|
||||||
mixin-object "^2.0.1"
|
mixin-object "^2.0.1"
|
||||||
|
|
||||||
|
shallowequal@^1.1.0:
|
||||||
|
version "1.1.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/shallowequal/-/shallowequal-1.1.0.tgz#188d521de95b9087404fd4dcb68b13df0ae4e7f8"
|
||||||
|
|
||||||
shebang-command@^1.2.0:
|
shebang-command@^1.2.0:
|
||||||
version "1.2.0"
|
version "1.2.0"
|
||||||
resolved "https://registry.yarnpkg.com/shebang-command/-/shebang-command-1.2.0.tgz#44aac65b695b03398968c39f363fee5deafdf1ea"
|
resolved "https://registry.yarnpkg.com/shebang-command/-/shebang-command-1.2.0.tgz#44aac65b695b03398968c39f363fee5deafdf1ea"
|
||||||
@@ -7947,6 +8038,10 @@ svgo@^1.0.0, svgo@^1.2.1:
|
|||||||
unquote "~1.1.1"
|
unquote "~1.1.1"
|
||||||
util.promisify "~1.0.0"
|
util.promisify "~1.0.0"
|
||||||
|
|
||||||
|
symbol-observable@^1.2.0:
|
||||||
|
version "1.2.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/symbol-observable/-/symbol-observable-1.2.0.tgz#c22688aed4eab3cdc2dfeacbb561660560a00804"
|
||||||
|
|
||||||
symbol-tree@^3.2.2:
|
symbol-tree@^3.2.2:
|
||||||
version "3.2.2"
|
version "3.2.2"
|
||||||
resolved "https://registry.yarnpkg.com/symbol-tree/-/symbol-tree-3.2.2.tgz#ae27db38f660a7ae2e1c3b7d1bc290819b8519e6"
|
resolved "https://registry.yarnpkg.com/symbol-tree/-/symbol-tree-3.2.2.tgz#ae27db38f660a7ae2e1c3b7d1bc290819b8519e6"
|
||||||
@@ -8174,6 +8269,10 @@ type-is@~1.6.17, type-is@~1.6.18:
|
|||||||
media-typer "0.3.0"
|
media-typer "0.3.0"
|
||||||
mime-types "~2.1.24"
|
mime-types "~2.1.24"
|
||||||
|
|
||||||
|
typed-styles@^0.0.7:
|
||||||
|
version "0.0.7"
|
||||||
|
resolved "https://registry.yarnpkg.com/typed-styles/-/typed-styles-0.0.7.tgz#93392a008794c4595119ff62dde6809dbc40a3d9"
|
||||||
|
|
||||||
typedarray@^0.0.6:
|
typedarray@^0.0.6:
|
||||||
version "0.0.6"
|
version "0.0.6"
|
||||||
resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777"
|
resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777"
|
||||||
@@ -8450,6 +8549,12 @@ walker@^1.0.7, walker@~1.0.5:
|
|||||||
dependencies:
|
dependencies:
|
||||||
makeerror "1.0.x"
|
makeerror "1.0.x"
|
||||||
|
|
||||||
|
warning@^4.0.2:
|
||||||
|
version "4.0.3"
|
||||||
|
resolved "https://registry.yarnpkg.com/warning/-/warning-4.0.3.tgz#16e9e077eb8a86d6af7d64aa1e05fd85b4678ca3"
|
||||||
|
dependencies:
|
||||||
|
loose-envify "^1.0.0"
|
||||||
|
|
||||||
watchpack@^1.5.0:
|
watchpack@^1.5.0:
|
||||||
version "1.6.0"
|
version "1.6.0"
|
||||||
resolved "https://registry.yarnpkg.com/watchpack/-/watchpack-1.6.0.tgz#4bc12c2ebe8aa277a71f1d3f14d685c7b446cd00"
|
resolved "https://registry.yarnpkg.com/watchpack/-/watchpack-1.6.0.tgz#4bc12c2ebe8aa277a71f1d3f14d685c7b446cd00"
|
||||||
|
|||||||
9
controllers/doorLock.js
Normal file
9
controllers/doorLock.js
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
const uploadDoorLockData = (req, res) => {
|
||||||
|
res.json({status: 'ok'});
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
uploadDoorLockData,
|
||||||
|
};
|
||||||
2
environment.env
Normal file
2
environment.env
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
BASIC_AUTH_USERNAME=username
|
||||||
|
BASIC_AUTH_PASSWORD=password
|
||||||
22
helpers/auth.js
Normal file
22
helpers/auth.js
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
'use strict';
|
||||||
|
const basicAuth = require('express-basic-auth');
|
||||||
|
|
||||||
|
function myAuthorizer(username, password) {
|
||||||
|
if (!process.env.BASIC_AUTH_USERNAME || !process.env.BASIC_AUTH_PASSWORD){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
const userMatches = basicAuth.safeCompare(username, process.env.BASIC_AUTH_USERNAME);
|
||||||
|
const passwordMatches = basicAuth.safeCompare(password, process.env.BASIC_AUTH_PASSWORD);
|
||||||
|
|
||||||
|
return userMatches & passwordMatches
|
||||||
|
}
|
||||||
|
|
||||||
|
function getUnauthorizedResponse(req) {
|
||||||
|
return 'Forbidden';
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
myAuthorizer,
|
||||||
|
getUnauthorizedResponse,
|
||||||
|
};
|
||||||
5
package-lock.json
generated
5
package-lock.json
generated
@@ -664,6 +664,11 @@
|
|||||||
"is-obj": "^1.0.0"
|
"is-obj": "^1.0.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"dotenv": {
|
||||||
|
"version": "8.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/dotenv/-/dotenv-8.0.0.tgz",
|
||||||
|
"integrity": "sha512-30xVGqjLjiUOArT4+M5q9sYdvuR4riM6yK9wMcas9Vbp6zZa+ocC9dp6QoftuhTPhFAiLK/0C5Ni2nou/Bk8lg=="
|
||||||
|
},
|
||||||
"dottie": {
|
"dottie": {
|
||||||
"version": "2.0.1",
|
"version": "2.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/dottie/-/dottie-2.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/dottie/-/dottie-2.0.1.tgz",
|
||||||
|
|||||||
@@ -21,6 +21,7 @@
|
|||||||
"node": "11.12.x"
|
"node": "11.12.x"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"dotenv": "^8.0.0",
|
||||||
"express": "^4.17.0",
|
"express": "^4.17.0",
|
||||||
"express-basic-auth": "^1.2.0",
|
"express-basic-auth": "^1.2.0",
|
||||||
"pg": "^7.11.0",
|
"pg": "^7.11.0",
|
||||||
|
|||||||
@@ -1,10 +1,12 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const { apiStatusCheck } = require('../controllers/apiStatusCheck');
|
const { apiStatusCheck } = require('../controllers/apiStatusCheck');
|
||||||
|
const { uploadDoorLockData } = require('../controllers/doorLock');
|
||||||
|
|
||||||
const express = require('express');
|
const express = require('express');
|
||||||
const router = express.Router();
|
const router = express.Router();
|
||||||
|
|
||||||
router.get('/', apiStatusCheck);
|
router.get('/', apiStatusCheck);
|
||||||
|
router.get('/doorLockData', uploadDoorLockData);
|
||||||
|
|
||||||
module.exports = router;
|
module.exports = router;
|
||||||
|
|||||||
19
server.js
19
server.js
@@ -1,34 +1,26 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
require('dotenv').config();
|
||||||
|
|
||||||
const express = require("express");
|
const express = require("express");
|
||||||
const basicAuth = require('express-basic-auth');
|
const basicAuth = require('express-basic-auth');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const routes = require('./routes');
|
const routes = require('./routes');
|
||||||
|
|
||||||
|
const { myAuthorizer, getUnauthorizedResponse } = require('./helpers/auth');
|
||||||
|
|
||||||
const app = express();
|
const app = express();
|
||||||
const port = process.env.PORT || 5000;
|
const port = process.env.PORT || 5000;
|
||||||
|
|
||||||
function myAuthorizer(username, password) {
|
|
||||||
const userMatches = basicAuth.safeCompare(username, 'senadU');
|
|
||||||
const passwordMatches = basicAuth.safeCompare(password, 'Tulipan*123*');
|
|
||||||
|
|
||||||
return userMatches & passwordMatches
|
|
||||||
}
|
|
||||||
|
|
||||||
function getUnauthorizedResponse(req) {
|
|
||||||
return 'Forbidden';
|
|
||||||
}
|
|
||||||
|
|
||||||
app.use('/api', routes);
|
app.use('/api', routes);
|
||||||
|
|
||||||
app.use(basicAuth({
|
app.use(basicAuth({
|
||||||
authorizer: myAuthorizer,
|
authorizer: myAuthorizer,
|
||||||
challenge: true,
|
challenge: true,
|
||||||
unauthorizedResponse: getUnauthorizedResponse
|
unauthorizedResponse: getUnauthorizedResponse
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//Static file declaration
|
//Static file declaration
|
||||||
app.use(express.static(path.join(__dirname, 'client/build')));
|
app.use(express.static(path.join(__dirname, 'client/build')));
|
||||||
|
|
||||||
@@ -44,4 +36,5 @@ app.get('*', (req, res) => {
|
|||||||
res.sendFile(path.join(__dirname + '/client/public/index.html'));
|
res.sendFile(path.join(__dirname + '/client/public/index.html'));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
app.listen(port, () => console.log(`App running on port ${port}!`));
|
app.listen(port, () => console.log(`App running on port ${port}!`));
|
||||||
|
|||||||
Reference in New Issue
Block a user