Skip to content

Commit

Permalink
Merge pull request #30 from danxfisher/error-handling
Browse files Browse the repository at this point in the history
Error handling
  • Loading branch information
danxfisher authored Jul 21, 2018
2 parents 68516dd + 3ff6efb commit 7890f3e
Show file tree
Hide file tree
Showing 13 changed files with 119 additions and 84 deletions.
44 changes: 22 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,20 +63,15 @@ This application assumes you have:
```
$ npm install
```
3. Navigate to `ui-react/`. In the `package.json` file, change:
```
"proxy" : "http://localhost:8080"
```
to whatever the IP of where express is running. Typically you can use something similar to the default but you can change the IP and port as long as it coincides with what is in `server.js`.
4. In the root directory, open a terminal or cmd:
3. In the root directory, open a terminal or cmd:
```
$ npm run build
```
5. In the root directory, open a terminal or cmd:
4. In the root directory, open a terminal or cmd:
```
$ npm start
```
6. If you want to start the react development server, in the root directory run:
5. If you want to start the react development server, in the root directory run:
```
$ npm start-ui-dev
```
Expand All @@ -86,7 +81,8 @@ This application assumes you have:
## Root Folder Structure Explained

* `app/` : Routes for EWS APIs
* `config/` : All EWS functionality
* `app/ews/` : All EWS functionality
* `confg/` : All server side configuration settings
* `scss/` : All styles
* `static/` : All global static files
* `ui-react/` : Front end React routes and components
Expand Down Expand Up @@ -161,17 +157,25 @@ There are three main directories in the `ui-react/src/` folder:
export DOMAIN=domain.com
```

* In `/config/room-blacklist.js`, add any room by email to exclude it from the list of rooms:

```javascript
module.exports = {
'roomEmails' : [
'ROOM_EMAIL@DOMAIN.com'
]
};
```

* In `/ui-react/src/config/flightboard.config.js`, manage your customizations:

```javascript
module.exports = {
'board' : {
'text' : {
'nextUp' : 'Next Up',
'statusAvailable' : 'Open',
'statusBusy' : 'Busy',
'statusError' : 'Error'
}
'nextUp' : 'Next Up',
'statusAvailable' : 'Open',
'statusBusy' : 'Busy',
'statusError' : 'Error'
},
'navbar' : {
Expand All @@ -182,22 +186,18 @@ There are three main directories in the `ui-react/src/` folder:
'filterTitle' : 'Locations',
'filterAllTitle' : 'All Conference Rooms',
},
'socket' : {
'endpoint' : 'http://localhost:8080',
}
};
```

* Upload your logo to `/static/img/logo.png`

### Advanced

* All EWS functionality is located in `config/ews`.
* To change the interval in which the web socket emits, edit the interval time in `config/controller.js`. By default, it is set to 1 minute.
* All EWS functionality is located in `app/ews`.
* To change the interval in which the web socket emits, edit the interval time in `app/socket-controller.js`. By default, it is set to 1 minute.
* To update styles, make sure you install grunt first with `npm install -g grunt-cli`. Then run `grunt` in the root directory to watch for SCSS changes. Use the `.scss` files located in the `/scss` folder.
* All React components can be locally styled by adding a new `.css` file and importing it into the component itself if you'd prefer to do it that way.
* In `config/ews/rooms.js`, there is a block of code that may not be necessary but were added as a convenience. Feel free to use it, comment it out, or remove it completely. It was designed for a use case where the email addresses (ex: jsmith@domain.com) do not match the corporate domain (ex: jsmith-enterprise).
* In `app/ews/rooms.js`, there is a block of code that may not be necessary but were added as a convenience. Feel free to use it, comment it out, or remove it completely. It was designed for a use case where the email addresses (ex: jsmith@domain.com) do not match the corporate domain (ex: jsmith-enterprise).
```javascript
// if the email domain != your corporate domain,
// replace email domain with domain from auth config
Expand Down
10 changes: 7 additions & 3 deletions TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,20 @@
## Last updated: 07.18.2018

### To Do:
* [ ] - Handle credentials error
* [ ] - Handle room list error ('no folder in store')
* [ ] - Handle Socket error (ERR CONNECTION REFUSED)
* [ ] - Update Wiki
* [ ] - update to es6
* [ ] - add better comments
* [ ] - Jest/Cypress for Unit/Integration/Functional testing

### Icebox:
* [ ] - Add Room Booking component/feature
* [ ] - Oauth
* [ ] - OAuth

### Done:
* [x] - Test on multiple mobile devices
* [x] - Flightboard - if next up day != today, show day
* [x] - Make "Next Up", "Open", "Busy", "Upcoming", etc. all customizable as to enable multilingual support
* [x] - Look into port issues
* [x] - Change domain so it can be .com, .co.uk, etc
* [x] - Handle credentials error
2 changes: 2 additions & 0 deletions app/ews/roomlists.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ module.exports = function (callback) {
roomLists.push(item.Name);
});
callback(null, roomLists.sort());
}, (err) => {
callback(err, null);
});

};
2 changes: 2 additions & 0 deletions app/ews/rooms.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ module.exports = function (callback) {
exch.GetRoomLists().then((lists) => {
var roomLists = lists.items;
resolve(roomLists);
}, (err) => {
callback(err, null);
});
})
return promise;
Expand Down
24 changes: 22 additions & 2 deletions app/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,17 @@ module.exports = function(app) {
var ews = require('./ews/rooms.js');

ews(function(err, rooms) {
res.json(rooms);
if (err) {
if (err.responseCode === 127) {
res.json({error: 'Oops, there seems to be an issue with the credentials you have supplied. Make sure you typed them correctly and that you have access to Exchange Roomlists.'});
}
else {
res.json({error: 'Hmm, there seems to be a weird issue occuring.'});
}
}
else {
res.json(rooms);
}
});
});

Expand All @@ -18,7 +28,17 @@ module.exports = function(app) {
var ews = require('./ews/roomlists.js');

ews(function(err, roomlists) {
res.json(roomlists);
if (err) {
if (err.responseCode === 127) {
res.json({error: 'Oops, there seems to be an issue with the credentials you have supplied. Make sure you typed them correctly and that you have access to Exchange Roomlists.'});
}
else {
res.json({error: 'Hmm, there seems to be a weird issue occuring.'});
}
}
else {
res.json(roomlists);
}
});
});

Expand Down
4 changes: 4 additions & 0 deletions scss/_globals.scss
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ body {
background-color: $bodyBackground;
}

.credentials-error {
text-align: center;
}

#fb__spinner-wrap {
text-align: center;

Expand Down
3 changes: 3 additions & 0 deletions static/css/styles.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion static/css/styles.css.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 24 additions & 7 deletions ui-react/src/components/flightboard/Flightboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ class Flightboard extends Component {
super(props);
this.state = {
response: false,
error: false,
now: new Date(),
rooms: []
}
Expand All @@ -18,10 +19,20 @@ class Flightboard extends Component {
return fetch('/api/rooms')
.then((response) => response.json())
.then((data) => {
this.setState({
response: true,
rooms: data
});
if(!data.error){
this.setState({
response: true,
error: false,
rooms: data
});
}
else {
this.setState({
response: true,
error: true,
rooms: data
});
}
})
}

Expand All @@ -38,15 +49,21 @@ class Flightboard extends Component {
}

render() {
const { response, now } = this.state;
const { error, now, response, rooms } = this.state;

return (
<div className="tracker-wrap">
<Socket response={this.handleSocket} />

{ response ?
this.state.rooms.map((room, key) =>
<FlightboardRow item={room} now={now} key={key} filter={this.props.filter} />
(!error ?
rooms.map((room, key) =>
<FlightboardRow item={room} now={now} key={key} filter={this.props.filter} />
)
:
<div className="container">
<div className="credentials-error">{rooms.error}</div>
</div>
)
:
<Spinner />
Expand Down
8 changes: 4 additions & 4 deletions ui-react/src/components/flightboard/FlightboardRow.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class FlightboardRow extends Component {
});
if (item.Appointments[0].Start < now && now < item.Appointments[0].End) { } else {
this.setState({
nextUp: fbConfig.board.text.nextUp + ': '
nextUp: fbConfig.board.nextUp + ': '
});
}
}
Expand Down Expand Up @@ -58,10 +58,10 @@ class FlightboardRow extends Component {
? 'meeting-busy'
: 'meeting-open';
let statusText = item.ErrorMessage
? fbConfig.board.text.statusError
? fbConfig.board.statusError
: item.Busy
? fbConfig.board.text.statusBusy
: fbConfig.board.text.statusAvailable;
? fbConfig.board.statusBusy
: fbConfig.board.statusAvailable;

return (
<div className={'row-padder ' + roomlist} style={this.props.filter === roomlist || this.props.filter === 'roomlist-all' || this.props.filter === '' ? styles.show : styles.hide}>
Expand Down
23 changes: 17 additions & 6 deletions ui-react/src/components/flightboard/RoomFilter.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ class RoomFilter extends Component {
super(props);
this.state = {
response: false,
error: false,
roomlists: []
}
}
Expand All @@ -15,10 +16,20 @@ class RoomFilter extends Component {
return fetch('/api/roomlists')
.then((response) => response.json())
.then((data) => {
this.setState({
response: true,
roomlists: data
});
if(!data.error){
this.setState({
response: true,
error: false,
roomlists: data
});
}
else {
this.setState({
response: true,
error: true,
roomlists: data
});
}
})
}

Expand All @@ -32,7 +43,7 @@ class RoomFilter extends Component {
}

render() {
const { response } = this.state;
const { error, response } = this.state;

return (
<li>
Expand All @@ -44,7 +55,7 @@ class RoomFilter extends Component {
{fbConfig.roomFilter.filterAllTitle}
</li>

{ response ?
{ response && !error ?
this.state.roomlists.map((item, key) =>
<li onClick={this.filterFlightboard} id={'roomlist-' + item.toLowerCase().replace(/\s+/g, "-")}>
{item}
Expand Down
Loading

0 comments on commit 7890f3e

Please sign in to comment.