Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
may-ben-arie committed Jan 19, 2019
2 parents b1f4d0b + 63e4b1e commit 4f7d12e
Show file tree
Hide file tree
Showing 16 changed files with 5,494 additions and 3,723 deletions.
6,737 changes: 4,340 additions & 2,397 deletions package-lock.json

Large diffs are not rendered by default.

38 changes: 19 additions & 19 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,60 +5,60 @@
"main": "server/server.js",
"dependencies": {
"axios": "^0.15.3",
"body-parser": "^1.17.1",
"classnames": "^2.2.5",
"body-parser": "^1.18.3",
"classnames": "^2.2.6",
"co": "^4.6.0",
"compression": "^1.6.2",
"compression": "^1.7.3",
"cookie-parser": "^1.4.3",
"csv-express": "^1.2.2",
"dotenv": "^4.0.0",
"express": "^4.15.2",
"express": "^4.16.4",
"http": "0.0.0",
"immutability-helper": "^2.6.4",
"js-cache": "^1.0.2",
"js-cache": "^1.0.3",
"jsonwebtoken": "^7.4.0",
"lodash": "^4.17.4",
"mobx": "^3.1.7",
"mobx-react": "^4.1.3",
"lodash": "^4.17.11",
"mobx": "^3.6.2",
"mobx-react": "^4.4.3",
"moment": "^2.20.1",
"moment-duration-format": "^1.3.0",
"mongoose": "^4.13.10",
"multer": "^1.3.0",
"node-cache": "^4.1.1",
"multer": "^1.4.1",
"node-cache": "^4.2.0",
"node-schedule": "^1.3.0",
"prop-types": "^15.5.10",
"prop-types": "^15.6.2",
"react": "^15.4.2",
"react-big-calendar": "^0.13.0",
"react-bootstrap": "^0.30.8",
"react-bootstrap-date-picker": "^5.0.1",
"react-checkbox": "^0.1.3",
"react-csv": "^1.0.12",
"react-csv": "^1.0.19",
"react-dom": "^15.4.2",
"react-input-autosize": "^1.1.3",
"react-linkify": "^0.2.2",
"react-numeric-input": "^2.2.3",
"react-router": "^4.0.0",
"react-router-dom": "^4.0.0",
"react-router": "^4.3.1",
"react-router-dom": "^4.3.1",
"react-select": "^1.2.1",
"url-loader": "^0.5.8",
"uuid": "^3.2.1"
},
"devDependencies": {
"babel-core": "^6.24.0",
"babel-core": "^6.26.3",
"babel-loader": "^6.4.1",
"babel-polyfill": "^6.23.0",
"babel-preset-es2015": "^6.24.0",
"babel-preset-react": "^6.11.1",
"babel-preset-stage-0": "^6.22.0",
"babel-preset-stage-2": "^6.13.0",
"babili-webpack-plugin": "0.0.11",
"cross-env": "^5.1.3",
"cross-env": "^5.2.0",
"css-loader": "^0.23.1",
"mocha": "^3.2.0",
"node-sass": "^4.5.2",
"mocha": "^5.2.0",
"node-sass": "^4.11.0",
"react-bootstrap-typeahead": "^1.3.0",
"react-hot-loader": "^3.0.0-beta.6",
"sass-loader": "^6.0.3",
"sass-loader": "^6.0.7",
"style-loader": "^0.13.1",
"webpack": "^2.3.2",
"webpack-bundle-analyzer": "^2.9.2",
Expand Down
7 changes: 7 additions & 0 deletions public/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@ h3 {
text-align: center;
}

#version {
color: #f1f1f5;
text-align: center;
margin: 10px;
font-family: monospace;
}

.loader {
border: 8px solid #f3f3f3; /* Light grey */
border-top: 8px solid #3498db; /* Blue */
Expand Down
5 changes: 5 additions & 0 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@
<div id="root">
<div class="loader"></div>
</div>
<div id="version">
Version 2.0.0 <br>
<span class="glyphicon glyphicon-chevron-left"></span>
<span class="glyphicon glyphicon-chevron-right"></span>
with <span class="glyphicon glyphicon-heart"></span> by Midburn Tech</div>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/core-js/2.4.1/core.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/babel-polyfill/6.23.0/polyfill.min.js"></script>
Expand Down
6 changes: 4 additions & 2 deletions server/routes/permissions.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,10 @@ const addLocalAdmin = co.wrap(function* (userDetails) {

router.get('/public/permissions/me', co.wrap(function* (req, res) {
yield addLocalAdmin(req.userDetails);
const permissions = yield permissionsUtils.getPermissions(req.userDetails);
return res.json(permissions);
if (req.userDetails.anonymousAccess) {
return res.json({anonymousAccess: true, roles: []})
}
return res.json({anonymousAccess: false, roles: req.userDetails.permissions, profile: req.userDetails.email})
}));

router.get('/permissions/admins', co.wrap(function* (req, res) {
Expand Down
1 change: 0 additions & 1 deletion server/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ app.use(co.wrap(function* (req, res, next) {
res.clearCookie(JWT_KEY);
return res.redirect(SPARK_HOST);
} else {
// TODO: (may) maybe read the default value from spark
req.userDetails = { eventId: consts.DEFAULT_EVENT_ID, anonymousAccess: true }
next();
}
Expand Down
2 changes: 1 addition & 1 deletion server/utils/permissions.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ function getUserIdRegex(userId) {

module.exports = {
getPermissions: co.wrap(function* (userDetails) {
if (!userDetails) {
if (!userDetails || !userDetails.email) {
return [];
}
const userId = userDetails.email;
Expand Down
1 change: 1 addition & 0 deletions src/components/Header/Header.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class Header extends React.Component {
<div className="header">
<a className="logo" href="https://spark.midburn.org">
<img className="logo-img" src="http://tickets-registration.midburn.org/midburn.png"/>
<div id="profile">{ document.permissions.anonymousAccess ? "Log In" : document.permissions.profile }</div>
</a>
<div className="header-nav">
<ul className="nav" style={{display: 'flex', justifyContent: 'center'}}>
Expand Down
10 changes: 9 additions & 1 deletion src/components/Header/Header.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,20 @@

.logo {
float: left;
margin: 6px;
display: flex;
align-items: center;

.logo-img {
height: 38px;
margin: 6px;
}

#profile {
margin-left: 10px;
color: white;
}
}

.header-nav {
flex: 1;
padding-right: 50px;
Expand Down
5 changes: 3 additions & 2 deletions src/components/VolunteerRequest/FillUserDataView.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export default class FillUserDataView extends Component {
this.state = {
contactEmail: '',
contactPhoneNumber: '',
profileEmail: '',
profileEmail: document.permissions.anonymousAccess ? '' : document.permissions.profile,

showValidation: false
}
Expand Down Expand Up @@ -73,7 +73,8 @@ export default class FillUserDataView extends Component {
</FormGroup>
<FormGroup controlId="profileEmail">
<ControlLabel>{profileTitle[language]}</ControlLabel>
<FormControl className="en-input" onChange={this.handleTextChange} placeholder="[email protected]"/>
<FormControl defaultValue={document.permissions.anonymousAccess ? '' : document.permissions.profile}
className="en-input" onChange={this.handleTextChange} placeholder="[email protected]"/>
</FormGroup>
</div>
<div className='button-container'>
Expand Down
2 changes: 1 addition & 1 deletion src/components/VolunteerShifts/VolunteerShifts.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export default class VolunteerShifts extends React.Component {
};

fetchShifts() {
const departments = document.roles.map(role => role.department_id);
const departments = document.permissions.roles.map(role => role.department_id);

for (let index = 0; index < departments.length; index++) {
axios.get(`/api/v1/departments/${departments[index]}/shifts/me`, {credentials: 'include'}).then(response => {
Expand Down
4 changes: 2 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import axios from 'axios';

async function fetchUserRoles() {
try {
const response = await axios.get('api/v1/public/permissions/me', {credentials: 'include'});
const permissions = await axios.get('api/v1/public/permissions/me', {credentials: 'include'});
const events = await axios.get('api/v1/public/events', {credentials: 'include'});
document.roles = response.data;
document.permissions = permissions.data;
document.events = events.data;
// document.roles = [{departmentId: '42ea4150-e739-11e7-822d-e92efb1d493b',
// permission: 'manager'}];
Expand Down
2 changes: 1 addition & 1 deletion src/model/ShiftManagerModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ function ShiftManagerModel() {

this.initDepartments = async() => {
const resp = await axios('/api/v1/public/departments', {credentials: 'include'})
if (!document.roles) {
if (!document.permissions) {
setTimeout(this.initDepartments, 1000);
} else {
this.departments = resp.data
Expand Down
10 changes: 5 additions & 5 deletions src/model/permissionsUtils.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
export const isAdmin = _ =>
!!document.roles.find(role => role.permission === 'admin')
!!document.permissions.roles.find(role => role.permission === 'admin')

export const isManager = _ =>
!!document.roles.find(role => role.permission === 'manager')
!!document.permissions.roles.find(role => role.permission === 'manager')

export const isManagerOfDepartment = departmentId =>
!!document.roles.find(role => role.departmentId === departmentId && role.permission === 'manager')
!!document.permissions.roles.find(role => role.departmentId === departmentId && role.permission === 'manager')

export const isVolunteer = _ =>
!!document.roles.find(role => role.permission === 'volunteer')
!!document.permissions.roles.find(role => role.permission === 'volunteer')

export const isVolunteerOfDepartment = departmentId =>
!!document.roles.find(role => role.departmentId === departmentId && role.permission === 'volunteer')
!!document.permissions.roles.find(role => role.departmentId === departmentId && role.permission === 'volunteer')
2 changes: 1 addition & 1 deletion src/routes/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class App extends React.Component {
}

render() {
const routes = this.routes(document.roles)
const routes = this.routes(document.permissions.roles)
if (!routes) {
return <ComingSoon/>;
}
Expand Down
Loading

0 comments on commit 4f7d12e

Please sign in to comment.