Skip to content
This repository has been archived by the owner on Apr 26, 2021. It is now read-only.

Commit

Permalink
Merge pull request #1 from bharatari/dev
Browse files Browse the repository at this point in the history
v2.0.0
  • Loading branch information
bharatari committed Sep 18, 2018
2 parents 9765654 + 0e57054 commit 0cb1cff
Show file tree
Hide file tree
Showing 36 changed files with 399 additions and 88 deletions.
2 changes: 1 addition & 1 deletion client/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "newshub-client",
"version": "1.0.0-beta.2",
"version": "2.0.0",
"description": "",
"main": "index.js",
"engines": {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import _ from 'lodash';
import { FormatDate } from 'components/';
import React from 'react';

const ActionItem = ({ action }) => {
const name = _.get(action, 'user.fullName');
const date = _.get(action, 'createdAt');
const actionPerformed = _.get(action, 'action');

const getDescription = () => {
if (actionPerformed === 'approved') {
return 'approved this on';
} else if (actionPerformed === 'checkedOut') {
return 'checked this out on';
} else if (actionPerformed === 'checkedIn') {
return 'checked this in on';
} else if (actionPerformed === 'disabled') {
return 'disabled this on';
} else if (actionPerformed === 'rejected') {
return 'rejected this on';
} else {
return 'modified this on';
}
};

return (
<li>
<strong>{name}</strong> {getDescription()} <FormatDate datetime={date} />
</li>
);
};

export default ActionItem;
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, { PropTypes } from 'react';
import classes from './Styles.scss';
import classNames from 'classnames';
import { FormatDate, Deleter } from 'components/';
import { Actions, Devices, AdminNotes } from '../';
import { Actions, Devices, AdminNotes, ActionItem } from '../';
import reservation from 'modules/reservation/utils';
import user from 'modules/user/utils';
import access from 'utils/access';
Expand All @@ -20,38 +20,17 @@ export default class Content extends React.Component {

render() {
const { reservation: { notes, adminNotes }, roles, deleteReservation } = this.props;
const reviewedBy = () => {
const reviewedByName = _.get(this.props.reservation, 'approvedBy.fullName') || _.get(this.props.reservation, 'rejectedBy.fullName');

if (reviewedByName) {
return (
<li>
<strong>{reviewedByName}</strong> reviewed this reservation
</li>
);
}
};
const checkedOutBy = () => {
const checkedOutByName = _.get(this.props.reservation, 'checkedOutBy.fullName');

if (checkedOutByName) {
return (
<li>
<strong>{checkedOutByName}</strong> checked out this reservation
</li>
);
}
};
const checkedInBy = () => {
const checkedInByName = _.get(this.props.reservation, 'checkedInBy.fullName');

if (checkedInByName) {
return (
<li>
<strong>{checkedInByName}</strong> checked in this reservation
</li>
);

const reservationActions = _.get(this.props.reservation, 'actions');

const getReservationActions = () => {
const array = [];

for (let i = 0; i < reservationActions.length; i++) {
array.push(<ActionItem key={reservationActions[i].id} action={reservationActions[i]} />);
}

return array;
};

const color = reservation.getReservationColor(this.props.reservation);
Expand Down Expand Up @@ -116,9 +95,7 @@ export default class Content extends React.Component {
<li>
<strong>{this.props.reservation.user.fullName}</strong> created this on <FormatDate datetime={this.props.reservation.createdAt} />
</li>
{ reviewedBy() }
{ checkedOutBy() }
{ checkedInBy() }
{ reservationActions ? getReservationActions() : null }
</ul>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@ import Actions from './Actions/Component';
import AdminNotes from './AdminNotes/Component';
import Content from './Content/Component';
import Devices from './Devices/Component';
import ActionItem from './ActionItem/Component';

export {
Actions,
AdminNotes,
Content,
Devices,
ActionItem,
};
2 changes: 1 addition & 1 deletion gateway/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "newshub-gateway",
"version": "1.0.1",
"version": "2.0.0",
"description": "",
"main": "index.js",
"scripts": {
Expand Down
2 changes: 2 additions & 0 deletions gateway/src/services/proxy/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ module.exports = async (ctx, next) => {
'content-type': 'application/json; charset=utf-8',
'authorization': headers['authorization'],
});

// headers['newshub-user'] = JSON.stringify(await data.getUser(userId, headers));
}

// Don't dynamically resolve method names
Expand Down
32 changes: 32 additions & 0 deletions gateway/src/services/roomReservation/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,38 @@ const access = require('../../utils/access');
const proxy = require('../proxy/index');

module.exports = (router) => {
router.get('/api/room-reservation', async (ctx, next) => {
const path = ctx.request.path;
const query = ctx.request.search;
const headers = ctx.request.headers;
const userId = ctx.state.user ? ctx.state.user.userId : '';

try {
headers['newshub-user-id'] = userId;

headers['newshub-user'] = JSON.stringify(await data.getUser(userId, headers));

if (userId) {
headers['newshub-organization-id'] = await data.getOrganizationId(userId, {
'content-type': 'application/json; charset=utf-8',
'authorization': headers['authorization'],
});

headers['newshub-user'] = JSON.stringify(await data.getUser(userId, headers));
}

const response = await data.get(path, query, headers);

data.respond(ctx, response, next);
} catch (e) {
data.handleError(ctx, e, next);
}
// Pass user JSON in header
// Or pass JWT with claims as user JSON
// Have a docker shared secret file so all docker services
// can have access to the jwt secret
});

router.post('/api/room-reservation', async (ctx, next) => {
const path = ctx.request.path;
const body = ctx.request.body;
Expand Down
13 changes: 13 additions & 0 deletions gateway/src/utils/data.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,5 +162,18 @@ module.exports = {
} else {
return '';
}
},
async getUser(userId, headers) {
try {
let user = JSON.parse(await data.get(`/api/user/${userId}`, '', headers));

if (user) {
user.roles = JSON.parse(await data.get(`/api/role`, '?roles=all', headers));
}

return user;
} catch (e) {
return null;
}
}
};
2 changes: 0 additions & 2 deletions services/authentication/.env.sample
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
DATABASE_URL=postgres://postgres:postgres@postgres/authentication
DATABASE_SSL=false
REDIS_URL=redis://redis:6379
S3_API_KEY=key
S3_API_SECRET=secret
TEST_DB=postgres://postgres:postgres@postgres/authentication_test
TEST_REDIS_URL=redis://redis:6379
AZURE_STORAGE_CONNECTION_STRING=string
3 changes: 0 additions & 3 deletions services/authentication/config/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@
"secret": "p9g6Jt5SqfJ9HoM5hIO0UG9r1JjlhRN4fGXheh5kcG2BxMjtpCw4u1uTJTOO5iztQZVTPZ1SBueCdzSfOnAwEw=="
},
"keys": {
"S3_API_KEY": "S3_API_KEY",
"S3_API_SECRET": "S3_API_SECRET",
"SENDGRID_KEY": "SENDGRID_KEY",
"REDIS_URL": "REDIS_URL"
}
}
3 changes: 0 additions & 3 deletions services/authentication/config/production.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@
"secret": "FEATHERS_AUTH_SECRET"
},
"keys": {
"S3_API_KEY": "S3_API_KEY",
"S3_API_SECRET": "S3_API_SECRET",
"SENDGRID_KEY": "SENDGRID_KEY",
"REDIS_URL": "REDIS_URL"
}
}
3 changes: 0 additions & 3 deletions services/authentication/config/test.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@
"secret": "p9g6Jt5SqfJ9HoM5hIO0UG9r1JjlhRN4fGXheh5kcG2BxMjtpCw4u1uTJTOO5iztQZVTPZ1SBueCdzSfOnAwEw=="
},
"keys": {
"S3_API_KEY": "S3_API_KEY",
"S3_API_SECRET": "S3_API_SECRET",
"SENDGRID_KEY": "SENDGRID_KEY",
"REDIS_URL": "TEST_REDIS_URL"
}
}
4 changes: 1 addition & 3 deletions services/authentication/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "newshub-authentication",
"description": "",
"version": "1.0.0-beta.2",
"version": "2.0.0",
"homepage": "",
"main": "src/",
"keywords": [
Expand Down Expand Up @@ -53,8 +53,6 @@
"sequelize-cli": "^2.5.1",
"sequelize-fixtures": "^0.7.0",
"serve-favicon": "^2.3.0",
"skipper": "^0.6.4",
"skipper-s3": "^0.5.6",
"winston": "^2.2.0"
},
"devDependencies": {
Expand Down

0 comments on commit 0cb1cff

Please sign in to comment.