Skip to content

Commit

Permalink
Merge branch 'develop' into set-engine-requirements
Browse files Browse the repository at this point in the history
  • Loading branch information
am-jo-zt authored Nov 22, 2017
2 parents f4f7525 + 853a642 commit dd52e05
Show file tree
Hide file tree
Showing 17 changed files with 8,167 additions and 72 deletions.
10 changes: 10 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# http://editorconfig.org

root = true

[*]
charset = utf-8

[*.{js,html,css,scss,json,yml}]
indent_style = space
indent_size = 2
4 changes: 4 additions & 0 deletions .env.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export USERNAME=
export PASSWORD=
export DOMAIN=
export PORT=
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/.env
/.sass-cache/
/node_modules/
/iisnode/
Expand Down
17 changes: 12 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,18 +56,17 @@ This application assumes you have:
"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 `ui-react/`, open a terminal or cmd:
4. In the root directory, open a terminal or cmd:
```
$ npm install
$ npm run build
```
5. In the root directory, open a terminal or cmd:
```
$ node server.js
$ npm start
```
6. If you want to start the react development server, in `ui-react/` run:
6. If you want to start the react development server, in the root directory run:
```
$ npm start
$ npm start-ui-dev
```
***
Expand Down Expand Up @@ -142,6 +141,14 @@ There are three main directories in the `ui-react/src/` folder:
};
```
* Alternatively, username, password and domain can be set as environment variable
```bash
export USERNAME=svcacct_email@domain.com
export PASSWORD=password
export DOMAIN=domain.com
```
* In `/ui-react/src/config/flightboard.config.js`, manage your customizations:
```javascript
Expand Down
6 changes: 3 additions & 3 deletions config/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
module.exports = {
// this user MUST have full access to all the room accounts
'exchange' : {
'username' : 'SVCACCT_EMAIL@DOMAIN.COM',
'password' : 'PASSWORD',
'username' : process.env.USERNAME || 'SVCACCT_EMAIL@DOMAIN.COM',
'password' : process.env.PASSWORD || 'PASSWORD',
'uri' : 'https://outlook.office365.com/EWS/Exchange.asmx'
},
// Ex: CONTOSO.COM, Contoso.com, Contoso.co.uk, etc.
'domain' : 'DOMAIN.COM'
'domain' : process.env.DOMAIN || 'DOMAIN.COM'
};
78 changes: 40 additions & 38 deletions config/ews/rooms.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,54 +59,56 @@ module.exports = function (callback) {
return promise;
};

var fillRoomData = function (context, room, appointments = [], option = {}) {
room.Appointments = [];
appointments.forEach(function(appt, index) {
// get start time from appointment
var start = processTime(appt.Start.momentDate),
end = processTime(appt.End.momentDate),
now = Date.now();

room.Busy = index === 0
? start < now && now < end
: room.Busy;

room.Appointments.push({
"Subject" : appt.Subject,
"Organizer" : appt.Organizer.Name,
"Start" : start,
"End" : end
});
});

if (option.errorMessage) {
room.ErrorMessage = option.errorMessage;
}

context.itemsProcessed++;

if (context.itemsProcessed === context.roomAddresses.length) {
context.roomAddresses.sort(sortByRoomName);
context.callback(context.roomAddresses);
}
};

// promise: get current or upcoming appointments for each room
var getAppointmentsForRooms = function (roomAddresses) {
var promise = new Promise(function (resolve, reject) {
var itemsProcessed = 0;
var context = {
callback: resolve,
itemsProcessed: 0,
roomAddresses
};

roomAddresses.forEach(function(room, index, array){
var calendarFolderId = new ews.FolderId(ews.WellKnownFolderName.Calendar, new ews.Mailbox(room.Email));
var view = new ews.CalendarView(ews.DateTime.Now, new ews.DateTime(ews.DateTime.Now.TotalMilliSeconds + ews.TimeSpan.FromHours(240).asMilliseconds()), 6);
exch.FindAppointments(calendarFolderId, view).then((response) => {

var appointments = response.Items;
var appointment = appointments[0];

if (appointments) {
room.Appointments = [];
appointments.forEach(function(appt, index, array) {
// get start time from appointment
var start = processTime(appt.Start.momentDate);
var end = processTime(appt.End.momentDate);
var now = Date.now();

if(index === 0) {
if (start < now && now < end) {
room.Busy = true;
}
else {
room.Busy = false;
}
}

room.Appointments.push({
"Subject" : appt.Subject,
"Organizer" : appt.Organizer.Name,
"Start" : start,
"End" : end
});
});
}

itemsProcessed++;

if (itemsProcessed === array.length) {
roomAddresses.sort(sortByRoomName);
resolve(roomAddresses);
}
fillRoomData(context, room, response.Items);
}, (error) => {
// handle the error here
callback(error, null);
// callback(error, null);
fillRoomData(context, room, undefined, { errorMessage: error.response.errorMessage });
});
});
});
Expand Down
Loading

0 comments on commit dd52e05

Please sign in to comment.