Skip to content

Commit

Permalink
Merge pull request #142 from ReCodEx/fixes
Browse files Browse the repository at this point in the history
Some fixes
  • Loading branch information
SemaiCZE committed Nov 20, 2017
2 parents ef51ba1 + 6e77cc9 commit d182b11
Show file tree
Hide file tree
Showing 8 changed files with 504 additions and 32 deletions.
1 change: 1 addition & 0 deletions .env-sample
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ NODE_ENV=production
API_BASE=https://recodex.projekty.ms.mff.cuni.cz:4000/v1
PORT=443
# WEBPACK_DEV_SERVER_PORT=8081 # might be usefull for dev environment, if port 8081 is necessary for something
# REDUX_DEV_SERVER_PORT=8082

TITLE=ReCodEx
ALLOW_NORMAL_REGISTRATION=true
Expand Down
15 changes: 13 additions & 2 deletions bin/dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@ import WebpackDevServer from 'webpack-dev-server';
import path from 'path';
import config from '../config/webpack.config';
import colors from 'colors';
import remotedev from 'remotedev-server';

const PORT = process.env.PORT || 8080;
const WEBPACK_DEV_SERVER_PORT = process.env.WEBPACK_DEV_SERVER_PORT || 8081;
const REDUX_DEV_SERVER_PORT = process.env.REDUX_DEV_SERVER_PORT || 8082;

let app = new Express();
app.set('view engine', 'ejs');
Expand Down Expand Up @@ -37,14 +39,23 @@ var server = new WebpackDevServer(webpack(config), {
stats: { colors: true }
});

remotedev({
hostname: '127.0.0.1',
port: REDUX_DEV_SERVER_PORT
});

server.listen(WEBPACK_DEV_SERVER_PORT, 'localhost', () => {
console.log(
`${colors.yellow('WebpackDevServer')} is running on ${colors.underline(`http://localhost:${WEBPACK_DEV_SERVER_PORT}`)}`
`${colors.yellow('WebpackDevServer')} is running on ${colors.underline(
`http://localhost:${WEBPACK_DEV_SERVER_PORT}`
)}`
);
});

app.listen(PORT, () => {
console.log(
`${colors.green('WebApp')} is running on ${colors.underline(`http://localhost:${PORT}`)}`
`${colors.green('WebApp')} is running on ${colors.underline(
`http://localhost:${PORT}`
)}`
);
});
1 change: 1 addition & 0 deletions config/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ module.exports = {
NODE_ENV: "'" + process.env.NODE_ENV + "'",
API_BASE: "'" + process.env.API_BASE + "'",
TITLE: "'" + process.env.TITLE + "'",
REDUX_DEV_SERVER_PORT: "'" + process.env.REDUX_DEV_SERVER_PORT + "'",
ALLOW_NORMAL_REGISTRATION:
"'" + process.env.ALLOW_NORMAL_REGISTRATION + "'",
ALLOW_LDAP_REGISTRATION:
Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,8 @@
"postcss-loader": "^2.0.5",
"prettier": "^1.3.1",
"react-intl-translations-manager": "^5.0.0",
"remote-redux-devtools": "^0.5.12",
"remotedev-server": "^0.2.4",
"request": "^2.61.0",
"scroll-behavior": "^0.4.0",
"strip-loader": "^0.1.2",
Expand Down
16 changes: 10 additions & 6 deletions src/components/widgets/InfoBox/InfoBox.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import PropTypes from 'prop-types';
import { FormattedMessage, FormattedNumber } from 'react-intl';
import Icon from 'react-fontawesome';
import classNames from 'classnames';
import GroupsName from '../../../components/Groups/GroupsName';

const InfoBox = ({
title,
Expand All @@ -12,7 +13,7 @@ const InfoBox = ({
progress,
description = '',
color = 'green'
}) => (
}) =>
<div
className={classNames({
'info-box': true,
Expand All @@ -23,22 +24,25 @@ const InfoBox = ({
<Icon name={icon} spin={spin} />
</span>
<div className="info-box-content">
<span className="info-box-text">{title}</span>
<span className="info-box-number">{value}</span>
<span className="info-box-text">
{title}
</span>
<span className="info-box-number">
{value}
</span>
<div className="progress">
<div className="progress-bar" style={{ width: `${progress * 100}%` }} />
</div>
<span className="progress-description">
{description}
</span>
</div>
</div>
);
</div>;

InfoBox.propTypes = {
title: PropTypes.oneOfType([
PropTypes.string,
PropTypes.shape({ type: PropTypes.oneOf([FormattedMessage]) })
PropTypes.shape({ type: PropTypes.oneOf([FormattedMessage, GroupsName]) })
]).isRequired,
value: PropTypes.oneOfType([
PropTypes.number,
Expand Down
2 changes: 1 addition & 1 deletion src/pages/User/User.js
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ export default withLinks(
isAdmin: isSuperadmin,
studentOfGroupsIds: studentOfGroupsIdsSelector(userId)(state).toArray(),
groupAssignments: groupId => groupsAssignmentsSelector(groupId)(state),
groupStatistics: createGroupsStatsSelector(state),
groupStatistics: groupId => createGroupsStatsSelector(groupId)(state),
usersStatistics: statistics =>
statistics.find(stat => stat.userId === userId) || {},
commonGroups
Expand Down
20 changes: 14 additions & 6 deletions src/redux/store.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { canUseDOM } from 'exenv';

import { createStore, compose, applyMiddleware } from 'redux';
import { composeWithDevTools } from 'remote-redux-devtools';
import { routerMiddleware } from 'react-router-redux';
import thunkMiddleware from 'redux-thunk';
import promiseMiddleware from 'redux-promise-middleware';
Expand All @@ -14,6 +15,8 @@ import filter from 'redux-storage-decorator-filter';
import { actionTypes as authActionTypes } from './modules/auth';
import { actionTypes as switchingActionTypes } from './modules/userSwitching';

const REDUX_DEV_SERVER_PORT = process.env.REDUX_DEV_SERVER_PORT !== 'undefined' ? process.env.REDUX_DEV_SERVER_PORT : 8082;

const engine = filter(createEngine('recodex/store'), ['userSwitching']);

const getMiddleware = history => [
Expand All @@ -33,13 +36,18 @@ const getMiddleware = history => [
)
];

const composeEnhancers = composeWithDevTools({
realtime: true,
name: 'ReCodEx',
host: '127.0.0.1',
port: REDUX_DEV_SERVER_PORT
});

const dev = history =>
compose(
applyMiddleware(
...getMiddleware(history),
loggerMiddleware(!canUseDOM || !window.devToolsExtension)
),
canUseDOM && window.devToolsExtension ? window.devToolsExtension() : f => f // use the DEVtools if the extension is installed
composeEnhancers(
compose(
applyMiddleware(...getMiddleware(history), loggerMiddleware(!canUseDOM))
)
);

const prod = history => compose(applyMiddleware(...getMiddleware(history)));
Expand Down
Loading

0 comments on commit d182b11

Please sign in to comment.