From 0b6710d066f65ffce924dc6fcd8d80af11dc9fd0 Mon Sep 17 00:00:00 2001 From: r1bb3t Date: Fri, 20 Jul 2018 20:53:30 -0700 Subject: [PATCH 1/7] sent credential errors to the front end --- app/ews/roomlists.js | 2 ++ app/ews/rooms.js | 4 ++- app/routes.js | 24 ++++++++++++-- scss/_globals.scss | 4 +++ static/css/styles.css | 3 ++ static/css/styles.css.map | 2 +- .../src/components/flightboard/Flightboard.js | 33 ++++++++++++++----- .../src/components/flightboard/RoomFilter.js | 23 +++++++++---- 8 files changed, 77 insertions(+), 18 deletions(-) diff --git a/app/ews/roomlists.js b/app/ews/roomlists.js index 59e4fa3..b046052 100644 --- a/app/ews/roomlists.js +++ b/app/ews/roomlists.js @@ -17,6 +17,8 @@ module.exports = function (callback) { roomLists.push(item.Name); }); callback(null, roomLists.sort()); + }, (err) => { + callback(err, null); }); }; diff --git a/app/ews/rooms.js b/app/ews/rooms.js index 80624aa..c5d733d 100644 --- a/app/ews/rooms.js +++ b/app/ews/rooms.js @@ -17,7 +17,9 @@ module.exports = function (callback) { exch.GetRoomLists().then((lists) => { var roomLists = lists.items; resolve(roomLists); - }); + }, (err) => { + callback(err, null); + }; }) return promise; }; diff --git a/app/routes.js b/app/routes.js index a7ee307..ed0003c 100644 --- a/app/routes.js +++ b/app/routes.js @@ -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 type 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); + } }); }); @@ -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 type 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); + } }); }); diff --git a/scss/_globals.scss b/scss/_globals.scss index b8630ff..f44acee 100644 --- a/scss/_globals.scss +++ b/scss/_globals.scss @@ -22,6 +22,10 @@ body { background-color: $bodyBackground; } +.credentials-error { + text-align: center; +} + #fb__spinner-wrap { text-align: center; diff --git a/static/css/styles.css b/static/css/styles.css index 657c0e9..08bbd36 100644 --- a/static/css/styles.css +++ b/static/css/styles.css @@ -17,6 +17,9 @@ body { color: #ffffff; background-color: #191919; } +.credentials-error { + text-align: center; } + #fb__spinner-wrap { text-align: center; } #fb__spinner-wrap #fb__spinner { diff --git a/static/css/styles.css.map b/static/css/styles.css.map index 6260170..032ceab 100644 --- a/static/css/styles.css.map +++ b/static/css/styles.css.map @@ -1,6 +1,6 @@ { "version": 3, -"mappings": "AAEA;;;;;;;IAOK;EACH,WAAW,EAAE,2BAA2B;;AAG1C;IACK;EACH,MAAM,EAAE,IAAI;EACZ,KAAK,EAAE,IAAI;;AAGb,IAAK;EACH,KAAK,ECNO,OAAO;EDOnB,gBAAgB,ECHD,OAAO;;ADMxB,iBAAkB;EAChB,UAAU,EAAE,MAAM;EAElB,8BAAa;IACX,KAAK,EAAE,KAAK;IACZ,MAAM,EAAE,KAAK;IACb,MAAM,EAAE,IAAI;;AAIhB,IAAK;EACH,SAAS,EAAE,GAAG;;AAGhB,UAAW;EACT,UAAU,ECdS,IAAS;EDe5B,OAAO,EAAE,CAAC;EACV,aAAa,EAAE,iBAA+B;;AAGhD,gBAAiB;EACf,YAAY,EAAE,IAAI;;AAGpB,UAAW;EACT,aAAa,EAAE,IAAI;;AAGrB;qBACsB;EACpB,SAAS,EAAE,IAAI;EACf,aAAa,EAAE,GAAG;;AAIlB,eAAE;EACA,KAAK,EC9CK,OAAO;ADgDnB,gBAAG;EACD,cAAc,EAAE,SAAS;EACzB,SAAS,EAAE,KAAK;EAChB,WAAW,EAAE,CAAC;EACd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MAC3D,KAAK,EAAE,IAAI", "sources": ["../../scss/_globals.scss","../../scss/_variables.scss"], "names": [], "file": "styles.css" diff --git a/ui-react/src/components/flightboard/Flightboard.js b/ui-react/src/components/flightboard/Flightboard.js index 488f64e..712015f 100644 --- a/ui-react/src/components/flightboard/Flightboard.js +++ b/ui-react/src/components/flightboard/Flightboard.js @@ -9,6 +9,7 @@ class Flightboard extends Component { super(props); this.state = { response: false, + error: false, now: new Date(), rooms: [] } @@ -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 + }); + } }) } @@ -38,15 +49,21 @@ class Flightboard extends Component { } render() { - const { response, now } = this.state; + const { error, now, response, rooms } = this.state; return (
- { response ? - this.state.rooms.map((room, key) => - + { response && !error ? + (!error ? + rooms.map((room, key) => + + ) + : +
+
{rooms.error}
+
) : diff --git a/ui-react/src/components/flightboard/RoomFilter.js b/ui-react/src/components/flightboard/RoomFilter.js index 094b55f..5a9df18 100644 --- a/ui-react/src/components/flightboard/RoomFilter.js +++ b/ui-react/src/components/flightboard/RoomFilter.js @@ -7,6 +7,7 @@ class RoomFilter extends Component { super(props); this.state = { response: false, + error: false, roomlists: [] } } @@ -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 + }); + } }) } @@ -32,7 +43,7 @@ class RoomFilter extends Component { } render() { - const { response } = this.state; + const { error, response } = this.state; return (
  • @@ -44,7 +55,7 @@ class RoomFilter extends Component { {fbConfig.roomFilter.filterAllTitle}
  • - { response ? + { response && !error ? this.state.roomlists.map((item, key) =>
  • {item} From 9df0eb7227df32e04fa30b4a9ed979fdf5f0febf Mon Sep 17 00:00:00 2001 From: r1bb3t Date: Fri, 20 Jul 2018 20:57:36 -0700 Subject: [PATCH 2/7] fixing syntax error --- app/ews/rooms.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/ews/rooms.js b/app/ews/rooms.js index c5d733d..7702873 100644 --- a/app/ews/rooms.js +++ b/app/ews/rooms.js @@ -19,7 +19,7 @@ module.exports = function (callback) { resolve(roomLists); }, (err) => { callback(err, null); - }; + }); }) return promise; }; From 684f9094dcef7af292246e10ed5696a960327227 Mon Sep 17 00:00:00 2001 From: r1bb3t Date: Fri, 20 Jul 2018 21:03:42 -0700 Subject: [PATCH 3/7] added an extra look at the error from state. might want to use a function to render since the nested ternary statement is a little confusing and somewhat unreadable. --- ui-react/src/components/flightboard/Flightboard.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui-react/src/components/flightboard/Flightboard.js b/ui-react/src/components/flightboard/Flightboard.js index 712015f..75258e6 100644 --- a/ui-react/src/components/flightboard/Flightboard.js +++ b/ui-react/src/components/flightboard/Flightboard.js @@ -55,7 +55,7 @@ class Flightboard extends Component {
    - { response && !error ? + { response ? (!error ? rooms.map((room, key) => From fd8211afc866be5cb347117cfbe469b89554628c Mon Sep 17 00:00:00 2001 From: r1bb3t Date: Fri, 20 Jul 2018 21:05:53 -0700 Subject: [PATCH 4/7] updated verbage --- app/routes.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/routes.js b/app/routes.js index ed0003c..4d8ef4f 100644 --- a/app/routes.js +++ b/app/routes.js @@ -10,7 +10,7 @@ module.exports = function(app) { ews(function(err, 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 type them correctly and that you have access to Exchange Roomlists.'}); + 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.'}); @@ -30,7 +30,7 @@ module.exports = function(app) { ews(function(err, 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 type them correctly and that you have access to Exchange Roomlists.'}); + 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.'}); From eac21fd9222e1c27281dd3613ac50b4f6b6a031d Mon Sep 17 00:00:00 2001 From: r1bb3t Date: Fri, 20 Jul 2018 21:19:11 -0700 Subject: [PATCH 5/7] updated todo list --- TODO.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/TODO.md b/TODO.md index 91da8ba..9395a06 100644 --- a/TODO.md +++ b/TODO.md @@ -2,12 +2,12 @@ ## 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 ### Icebox: * [ ] - Add Room Booking component/feature -* [ ] - Oauth +* [ ] - OAuth ### Done: * [x] - Test on multiple mobile devices @@ -15,3 +15,4 @@ * [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 From d7447fbbf2379f15307f4fc8ff587c2329e465b8 Mon Sep 17 00:00:00 2001 From: r1bb3t Date: Fri, 20 Jul 2018 21:20:04 -0700 Subject: [PATCH 6/7] updated todo list --- TODO.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/TODO.md b/TODO.md index 9395a06..3ae9456 100644 --- a/TODO.md +++ b/TODO.md @@ -4,6 +4,9 @@ ### To Do: * [ ] - 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 From 3ff6efb7299ede6aec8b79b0d8640fe383778dba Mon Sep 17 00:00:00 2001 From: r1bb3t Date: Fri, 20 Jul 2018 23:11:28 -0700 Subject: [PATCH 7/7] updated socket so endpoint is no longer needed and will use the current server and port by default. updated readme to reflect changes --- README.md | 44 +++++++++---------- .../components/flightboard/FlightboardRow.js | 8 ++-- ui-react/src/components/global/Socket.js | 36 +++------------ ui-react/src/config/flightboard.config.js | 14 ++---- 4 files changed, 37 insertions(+), 65 deletions(-) diff --git a/README.md b/README.md index ed581a9..98ecfb5 100644 --- a/README.md +++ b/README.md @@ -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 ``` @@ -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 @@ -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' : { @@ -182,10 +186,6 @@ There are three main directories in the `ui-react/src/` folder: 'filterTitle' : 'Locations', 'filterAllTitle' : 'All Conference Rooms', }, - - 'socket' : { - 'endpoint' : 'http://localhost:8080', - } }; ``` @@ -193,11 +193,11 @@ There are three main directories in the `ui-react/src/` folder: ### 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 diff --git a/ui-react/src/components/flightboard/FlightboardRow.js b/ui-react/src/components/flightboard/FlightboardRow.js index 7f5e52d..73bee03 100644 --- a/ui-react/src/components/flightboard/FlightboardRow.js +++ b/ui-react/src/components/flightboard/FlightboardRow.js @@ -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 + ': ' }); } } @@ -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 (
    diff --git a/ui-react/src/components/global/Socket.js b/ui-react/src/components/global/Socket.js index 59c59f5..fc1e886 100644 --- a/ui-react/src/components/global/Socket.js +++ b/ui-react/src/components/global/Socket.js @@ -1,63 +1,41 @@ import React, { Component } from 'react'; - import socketIOClient from 'socket.io-client'; -let fbConfig = require('../../config/flightboard.config.js'); - class Socket extends Component { constructor(props) { super(props); this.state = { response: false, now: new Date(), - rooms: [], - endpoint: fbConfig.socket.endpoint + rooms: [] } } - componentDidMount() { - const { endpoint } = this.state; - const socket = socketIOClient(endpoint); - - console.log("socket connect at: " + endpoint); - console.log("====================================="); + componentDidMount = () => { + const socket = socketIOClient(); socket.on('updatedRooms', (rooms) => { let time = new Date(); - for (var i = 0; i < rooms.length; i++) { - var meetingRoom = rooms[i].Name; - console.log("updating: " + meetingRoom); + for (let i = 0; i < rooms.length; i++) { + let meetingRoom = rooms[i].Name; } - console.log(" "); - console.log("time: " + time.toLocaleTimeString()); - console.log("====================================="); this.props.response({ response: true, now: new Date(), rooms: rooms - }) - - this.setState({ - response: true, - now: new Date(), - rooms: rooms }); }); - } - componentWillUnmount () { - const { endpoint } = this.state; - const socket = socketIOClient(endpoint); + componentWillUnmount = () => { + const socket = socketIOClient(); socket.close(); } - render() { return null; } - } export default Socket; diff --git a/ui-react/src/config/flightboard.config.js b/ui-react/src/config/flightboard.config.js index 2124866..aff8e55 100644 --- a/ui-react/src/config/flightboard.config.js +++ b/ui-react/src/config/flightboard.config.js @@ -1,11 +1,9 @@ module.exports = { 'board' : { - 'text' : { - 'nextUp' : 'Next Up', - 'statusAvailable' : 'Open', - 'statusBusy' : 'Busy', - 'statusError' : 'Error' - } + 'nextUp' : 'Next Up', + 'statusAvailable' : 'Open', + 'statusBusy' : 'Busy', + 'statusError' : 'Error' }, 'navbar' : { @@ -16,8 +14,4 @@ module.exports = { 'filterTitle' : 'Locations', 'filterAllTitle' : 'All Conference Rooms', }, - - 'socket' : { - 'endpoint' : 'http://localhost:8080', - } };