diff --git a/README.md b/README.md index 1142446..c106fe6 100644 --- a/README.md +++ b/README.md @@ -20,6 +20,8 @@ In the event of wanting to commercially distribute a closed source modification ## Updates +* v0.3.1 + * Removed skipped rooms/room blacklist filtering from front end to back end. * v0.3 * Cleaned up unnecessarily nested component folder structure * [#8](https://github.com/danxfisher/MeetEasier/pull/8) - add script-shortcuts to `package.json` in root @@ -163,13 +165,27 @@ There are three main directories in the `ui-react/src/` folder: ```javascript module.exports = { + 'board' : { + 'text' : { + 'nextUp' : 'Next Up', + 'statusAvailable' : 'Open', + 'statusBusy' : 'Busy', + 'statusError' : 'Error' + } + }, + + 'navbar' : { 'title' : 'Conference Room Availability', + }, + + 'roomFilter' : { 'filterTitle' : 'Locations', 'filterAllTitle' : 'All Conference Rooms', - 'roomsToSkip' : [ - 'ROOM_EMAIL@DOMAIN.COM' - ], - 'socketEndpoint' : 'http://localhost:8080' + }, + + 'socket' : { + 'endpoint' : 'http://localhost:8080', + } }; ``` @@ -181,7 +197,7 @@ There are three main directories in the `ui-react/src/` folder: * 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. * 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 on lines 37-39 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 `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). ```javascript // if the email domain != your corporate domain, // replace email domain with domain from auth config diff --git a/config/ews/roomlists.js b/app/ews/roomlists.js similarity index 94% rename from config/ews/roomlists.js rename to app/ews/roomlists.js index 5a7e143..59e4fa3 100644 --- a/config/ews/roomlists.js +++ b/app/ews/roomlists.js @@ -2,7 +2,7 @@ module.exports = function (callback) { // modules ------------------------------------------------------------------- var ews = require("ews-javascript-api"); - var auth = require("../auth.js"); + var auth = require("../../config/auth.js"); // ews ----------------------------------------------------------------------- var exch = new ews.ExchangeService(ews.ExchangeVersion.Exchange2016); diff --git a/config/ews/rooms.js b/app/ews/rooms.js similarity index 77% rename from config/ews/rooms.js rename to app/ews/rooms.js index 66b1721..80624aa 100644 --- a/config/ews/rooms.js +++ b/app/ews/rooms.js @@ -2,7 +2,8 @@ module.exports = function (callback) { // modules ------------------------------------------------------------------- var ews = require("ews-javascript-api"); - var auth = require("../auth.js"); + var auth = require("../../config/auth.js"); + var blacklist = require("../../config/room-blacklist.js"); // ews ----------------------------------------------------------------------- var exch = new ews.ExchangeService(ews.ExchangeVersion.Exchange2016); @@ -30,22 +31,27 @@ module.exports = function (callback) { roomLists.forEach(function (item, i, array) { exch.GetRooms(new ews.Mailbox(item.Address)).then((rooms) => { rooms.forEach(function (roomItem, roomIndex, roomsArray) { - var room = {}; - - // if the email addresses != your corporate domain, - // replace email domain with domain - var email = roomItem.Address; - email = email.substring(0, email.indexOf('@')); - email = email + '@' + auth.domain; - - var roomAlias = roomItem.Name.toLowerCase().replace(/\s+/g, "-"); - - room.Roomlist = item.Name; - room.Name = roomItem.Name; - room.RoomAlias = roomAlias; - room.Email = email; - roomAddresses.push(room); - + // use either email var or roomItem.Address - depending on your use case + let inBlacklist = isRoomInBlacklist(roomItem.Address); + + // if not in blacklist, proceed as normal; otherwise, skip + if (!inBlacklist) { + let room = {}; + + // if the email addresses != your corporate domain, + // replace email domain with domain + let email = roomItem.Address; + email = email.substring(0, email.indexOf('@')); + email = email + '@' + auth.domain; + + let roomAlias = roomItem.Name.toLowerCase().replace(/\s+/g, "-"); + + room.Roomlist = item.Name; + room.Name = roomItem.Name; + room.RoomAlias = roomAlias; + room.Email = email; + roomAddresses.push(room); + } }); counter++; @@ -107,7 +113,7 @@ module.exports = function (callback) { fillRoomData(context, room, response.Items); }, (error) => { // handle the error here -// callback(error, null); + // callback(error, null); fillRoomData(context, room, undefined, { errorMessage: error.response.errorMessage }); }); }); @@ -115,6 +121,11 @@ module.exports = function (callback) { return promise; }; + // check if room is in blacklist + function isRoomInBlacklist(email) { + return blacklist.roomEmails.includes(email); + } + // do all of the process for the appointment times function processTime(appointmentTime) { var time = JSON.stringify(appointmentTime); @@ -136,13 +147,12 @@ module.exports = function (callback) { return 0; //default return value (no sorting) } + + // perform promise chain to get rooms getListOfRooms() .then(getRoomsInLists) .then(getAppointmentsForRooms) .then(function(rooms){ callback(null, rooms); }); - - - }; diff --git a/app/routes.js b/app/routes.js index f9a8a65..a7ee307 100644 --- a/app/routes.js +++ b/app/routes.js @@ -5,7 +5,7 @@ module.exports = function(app) { // returns an array of room objects app.get('/api/rooms', function(req, res) { - var ews = require('../config/ews/rooms.js'); + var ews = require('./ews/rooms.js'); ews(function(err, rooms) { res.json(rooms); @@ -15,7 +15,7 @@ module.exports = function(app) { // returns an array of roomlist objects app.get('/api/roomlists', function(req, res) { - var ews = require('../config/ews/roomlists.js'); + var ews = require('./ews/roomlists.js'); ews(function(err, roomlists) { res.json(roomlists); diff --git a/config/controller.js b/app/socket-controller.js similarity index 100% rename from config/controller.js rename to app/socket-controller.js diff --git a/config/room-blacklist.js b/config/room-blacklist.js new file mode 100644 index 0000000..81f5e58 --- /dev/null +++ b/config/room-blacklist.js @@ -0,0 +1,5 @@ +module.exports = { + 'roomEmails' : [ + 'ROOM_EMAIL@DOMAIN.com' + ] +}; diff --git a/server.js b/server.js index a4f5a75..76d2550 100644 --- a/server.js +++ b/server.js @@ -20,8 +20,8 @@ var theserver = app.listen(port, function(){ var io = require('socket.io').listen(theserver); // controller if using room lists - var controller = require('./config/controller.js')(io); + var controller = require('./app/socket-controller.js')(io); // log something so we know the server is working correctly - console.log('now we are cooking.'); + console.log(`now we're cooking.`); }); diff --git a/ui-react/src/components/flightboard/FlightboardRow.js b/ui-react/src/components/flightboard/FlightboardRow.js index eb24b0c..7f5e52d 100644 --- a/ui-react/src/components/flightboard/FlightboardRow.js +++ b/ui-react/src/components/flightboard/FlightboardRow.js @@ -8,8 +8,7 @@ class FlightboardRow extends Component { super(props); this.state = { nextUp: '', - timesPresent: false, - skippedRoom: false + timesPresent: false } } @@ -32,25 +31,12 @@ class FlightboardRow extends Component { } } - isRoomSkipped = () => { - const { item } = this.props; - - fbConfig.board.roomsToSkip.forEach(function(configItem, configKey) { - if(configItem === item.Email) { - this.setState({ - skippedRoom: true - }); - } - }); - } - componentDidMount = () => { - this.isRoomSkipped(); this.getAppointmentTime(); } render() { - const { nextUp, skippedRoom, timesPresent } = this.state; + const { nextUp, timesPresent } = this.state; const { item, now } = this.props; const styles = { @@ -62,79 +48,77 @@ class FlightboardRow extends Component { const room = item.Name.toLowerCase().replace(/\s+/g, "-"); const roomlist = 'roomlist-' + item.Roomlist.toLowerCase().replace(/\s+/g, "-"); - // if the room needs to be skipped, return null - if (!skippedRoom) { - let meetingRoomClass = `${ room } meeting-room ${ item.Busy ? 'meeting-room-busy' : '' }`; - meetingRoomClass += item.Busy ? ' meeting-room-busy' : ''; - meetingRoomClass += item.ErrorMessage ? ' meeting-room-error' : ''; - const meetingClass = item.ErrorMessage - ? 'meeting-error' - : item.Busy - ? 'meeting-busy' - : 'meeting-open'; - let statusText = item.ErrorMessage - ? fbConfig.board.text.statusError - : item.Busy - ? fbConfig.board.text.statusBusy - : fbConfig.board.text.statusAvailable; + // set row class based on meet room status + let meetingRoomClass = `${ room } meeting-room ${ item.Busy ? 'meeting-room-busy' : '' }`; + meetingRoomClass += item.Busy ? ' meeting-room-busy' : ''; + meetingRoomClass += item.ErrorMessage ? ' meeting-room-error' : ''; + const meetingClass = item.ErrorMessage + ? 'meeting-error' + : item.Busy + ? 'meeting-busy' + : 'meeting-open'; + let statusText = item.ErrorMessage + ? fbConfig.board.text.statusError + : item.Busy + ? fbConfig.board.text.statusBusy + : fbConfig.board.text.statusAvailable; - return ( -
-
-
-
-
-
-
- {statusText} -
+ return ( +
+
+
+
+
+
+
+ {statusText}
-
-
- {item.Name} -
+
+
+
+ {item.Name} +
+
+
+
+ {timesPresent && item.Appointments[0].End >= now && +
+ + {nextUp} + + + {item.Appointments[0].Subject} + +
+ }
-
-
- {timesPresent && item.Appointments[0].End >= now && -
- - {nextUp} - - - {item.Appointments[0].Subject} - -
- } -
-
- {timesPresent ? - new Date(parseInt(item.Appointments[0].Start, 10)).toLocaleTimeString([], {hour: '2-digit', minute: '2-digit'}) + ' - ' + new Date(parseInt(item.Appointments[0].End, 10)).toLocaleTimeString([], {hour: '2-digit', minute: '2-digit'}) - : '' - } -
-
- {timesPresent && item.Appointments[0].End >= now && - item.Appointments[0].Organizer - } -
+
+ {timesPresent ? + new Date(parseInt(item.Appointments[0].Start, 10)).toLocaleTimeString([], {hour: '2-digit', minute: '2-digit'}) + ' - ' + new Date(parseInt(item.Appointments[0].End, 10)).toLocaleTimeString([], {hour: '2-digit', minute: '2-digit'}) + : '' + }
-
-
+
+ {timesPresent && item.Appointments[0].End >= now && + item.Appointments[0].Organizer + } +
+
+
+
- - - + + + -
- ) - } +
+ ) } } diff --git a/ui-react/src/config/flightboard.config.js b/ui-react/src/config/flightboard.config.js index d623856..2124866 100644 --- a/ui-react/src/config/flightboard.config.js +++ b/ui-react/src/config/flightboard.config.js @@ -1,8 +1,5 @@ module.exports = { 'board' : { - 'roomsToSkip' : [ - 'ROOM_EMAIL@DOMAIN.com' - ], 'text' : { 'nextUp' : 'Next Up', 'statusAvailable' : 'Open',