Skip to content
This repository has been archived by the owner on Feb 16, 2024. It is now read-only.

Commit

Permalink
Added room details view.
Browse files Browse the repository at this point in the history
  • Loading branch information
Aldaviva committed Jan 25, 2014
1 parent 76338d4 commit 9218417
Show file tree
Hide file tree
Showing 16 changed files with 502 additions and 226 deletions.
3 changes: 2 additions & 1 deletion config.example.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
"dbHost": "127.0.0.1",
"dbPort": 27017,
"dbName": "floorplan",
"mountPoint": "/"
"mountPoint": "/",
"stormApiRoot": "http://54.212.42.221/api/"
}
154 changes: 31 additions & 123 deletions public/scripts/DetailsPane.js
Original file line number Diff line number Diff line change
@@ -1,164 +1,72 @@
this.DetailsPane = (function(){

var OFFICES = {
mv: {
address: '516 Clyde Avenue\nMountain View, CA 94043',
mapsUrl: 'https://maps.google.com/maps?q=Blue+Jeans+Network&hl=en&ll=37.398528,-122.046776&spn=0.270018,0.528374&cid=14115605422088510097&gl=US&t=m&z=12',
yelpId: 'bluejeans-mountain-view'
},
sf: {
address: '625 2nd Street\nSuite 104\nSan Francisco, CA 94107',
mapsUrl: 'https://maps.google.com/maps?q=625+2nd+Street+%23104,+San+Francisco,+CA+94107&hl=en&ll=37.781366,-122.391386&spn=0.066887,0.132093&sll=37.781358,-122.391386&sspn=0.066887,0.132093&hnear=625+2nd+St+%23104,+San+Francisco,+California+94107&t=m&z=14&iwloc=A',
yelpId: null
},
oc: {
address: '3333 Michelson Drive\nSuite 700\nIrvine, CA 92612',
mapsUrl: 'https://maps.google.com/maps?q=3333+Michelson+Drive,+Suite+700,+Irvine,+CA+92612&hl=en&ll=33.672926,-117.843475&spn=1.131436,2.113495&sll=33.916327,-118.105384&sspn=1.128228,2.113495&t=m&hnear=3333+Michelson+Dr+%23700,+Irvine,+Orange,+California+92612&z=10',
yelpId: null
},
blr: {
address: 'Xylem Tech Park\n5th Floor\nUnit 501 and 502\nWhite Field Road\nDevasandra Extension\nMahadevapura\nBangalore\nKarnataka\n560048',
mapsUrl: 'https://www.google.com/maps?source=embed&near=International+Technology+Park+Bangalore,+1st+Floor,+Innovator+Building,+Whitefield+Road,+Bangalore,+Karnataka+560066,+India&geocode=CZMgqS6v0udsFW4mxgAd5SeiBCkzTpso5RGuOzFPgVFRu2mhtA&q=xylem&f=l&dq=Xylem+Tech+Park,+Bangalore&sll=12.985966,77.735909&sspn=0.295278,0.286308&ie=UTF8&hq=xylem&hnear=&ll=12.994438,77.701664&spn=0.015974,0.032787&z=14&iwloc=A&vpsrc=0&oi=map_misc&ct=api_logo',
yelpId: null
}
};

var DetailsPane = Backbone.View.extend({
initialize: function(){
_.bindAll(this);

mediator.subscribe("activatePersonConfirmed", function(person, opts){
this.els.intro.hide();
this.els.content.show();
this.trigger('change:model', person, opts);
this.toggleIntro(false);
this.setPersonModel(person);
}, {}, this);

this.on('change:model', this.setModel);
mediator.subscribe("activateRoom", function(endpoint, opts){
this.toggleIntro(false);
this.setRoomModel(endpoint);
}, {}, this);

this.els = {};
this.introView = new IntroView();
this.personDetailsView = new PersonDetailsView();
this.roomDetailsView = new RoomDetailsView();
},

render: function(){
if(this.$el.is(':empty')){
this.$el.addClass(floorplanParams.officeId);
var office = OFFICES[floorplanParams.officeId];

var intro = this.els.intro = $('<div>', { class: 'intro' });
intro.append($('<h2>', { text: 'Blue Jeans' }));
intro.append($('<h3>', { class: 'address' }).append($('<a>', {
text : office.address,
title : "View in Google Maps",
href : office.mapsUrl || '#',
target : '_blank'
})));

if(office.yelpId){
this.els.rating = $('<div>', { class: 'rating' })
.click(function(){
window.open('http://www.yelp.com/biz/bluejeans-mountain-view');
});
intro.append(this.els.rating);
}


var content = this.els.content = $('<div>', { class: 'content' });

this.els.photo = $('<img>', { class: 'photo' });
this.els.name = $('<h2>', { class: 'name' });
this.els.title = $('<h3>', { class: 'title' });

content.append(this.els.photo);
content.append(this.els.name);
content.append(this.els.title);

var dl = $('<dl>');
this.els.email = $('<a>');
this.els.linkedInProfile = $('<a>', { text: 'view profile', target: '_blank' });
this.els.workPhone = $('<dd>');
this.els.mobilePhone = $('<dd>');

dl.append($('<dt>', { text: 'Email' }));
dl.append($('<dd>').append(this.els.email));

dl.append($('<dt>', { text: 'LinkedIn' }));
dl.append($('<dd>').append(this.els.linkedInProfile));

dl.append($('<dt>', { text: 'Mobile' }));
dl.append(this.els.mobilePhone);

dl.append($('<dt>', { text: 'Work' }));
dl.append(this.els.workPhone);

content.append(dl);

var correctionsLink = $('<a>', {
class: 'corrections',
href: 'mailto:[email protected]',
text: 'Suggest a correction'
});

this.$el.append(intro);
this.$el.append(content);
this.$el.append(correctionsLink);

office.yelpId && this.renderRating(office.yelpId);
}

if(this.model){
this.els.photo.attr('src', this.model.getPhotoPath());
this.els.name.text(this.model.get('fullname'));
this.els.title.text(this.model.get('title') || '');

var email = this.model.get('email');
this.els.email
.attr('href', 'mailto:'+email+((email||'').indexOf('@') == -1 ? '@bluejeans.com' : ''))
.text(email)
.closest('dd').prev('dt').addBack().toggle(!!email);
this.introView.$el
.hide()
.appendTo(this.$el);

this.els.linkedInProfile
.attr('href', 'http://www.linkedin.com/profile/view?id='+this.model.get('linkedInId'))
.closest('dd').prev('dt').addBack().toggle(!!this.model.get('linkedInId'));
this.personDetailsView.$el
.appendTo(this.$el);

this.els.mobilePhone
.text(formatPhoneNumber(this.model.get('mobilePhone')))
.prev('dt').addBack().toggle(!!this.model.get('mobilePhone'));
this.roomDetailsView.$el
.appendTo(this.$el);

this.els.workPhone
.text(formatPhoneNumber(this.model.get('workPhone')))
.prev('dt').addBack().toggle(!!this.model.get('workPhone'));
this.$el.append(correctionsLink);
}

this.introView.render();
this.personDetailsView.render();
this.roomDetailsView.render();

return this.el;
},

setModel: function(model){
this.model = model;
setPersonModel: function(model){
this.personDetailsView.model = model;
this.roomDetailsView.model = null;
this.render();
},

renderRating: function(yelpId){
yelp.getRating(yelpId)
.then(_.bind(function(rating){
this.els.rating
.css('background-position', '-2px '+(-3 - 18*2*(rating.stars-.5))+'px')
.attr('title', rating.stars + ' stars on Yelp\n('+rating.reviews+' reviews)');
}, this))
setRoomModel: function(model){
this.personDetailsView.model = null;
this.roomDetailsView.model = model;
this.render();
},

toggleIntro: function(shouldShow){
this.els.intro.toggle(!!shouldShow);
this.els.content.toggle(!shouldShow);
this.introView.$el.toggle(!!shouldShow);
this.personDetailsView.$el.toggle(!shouldShow);
this.roomDetailsView.$el.toggle(!shouldShow);
}
});

function formatPhoneNumber(phoneNumber){
if(phoneNumber){
return phoneNumber.replace(/[\(\)]/g, '').replace(/[\.]/g, '-');
} else {
return phoneNumber;
}
}

return DetailsPane;

})();
73 changes: 73 additions & 0 deletions public/scripts/IntroView.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
this.IntroView = (function(){

var OFFICES = {
mv: {
address: '516 Clyde Avenue\nMountain View, CA 94043',
mapsUrl: 'https://maps.google.com/maps?q=Blue+Jeans+Network&hl=en&ll=37.398528,-122.046776&spn=0.270018,0.528374&cid=14115605422088510097&gl=US&t=m&z=12',
yelpId: 'bluejeans-mountain-view'
},
sf: {
address: '625 2nd Street\nSuite 104\nSan Francisco, CA 94107',
mapsUrl: 'https://maps.google.com/maps?q=625+2nd+Street+%23104,+San+Francisco,+CA+94107&hl=en&ll=37.781366,-122.391386&spn=0.066887,0.132093&sll=37.781358,-122.391386&sspn=0.066887,0.132093&hnear=625+2nd+St+%23104,+San+Francisco,+California+94107&t=m&z=14&iwloc=A',
yelpId: null
},
oc: {
address: '3333 Michelson Drive\nSuite 700\nIrvine, CA 92612',
mapsUrl: 'https://maps.google.com/maps?q=3333+Michelson+Drive,+Suite+700,+Irvine,+CA+92612&hl=en&ll=33.672926,-117.843475&spn=1.131436,2.113495&sll=33.916327,-118.105384&sspn=1.128228,2.113495&t=m&hnear=3333+Michelson+Dr+%23700,+Irvine,+Orange,+California+92612&z=10',
yelpId: null
},
blr: {
address: 'Xylem Tech Park\n5th Floor\nUnit 501 and 502\nWhite Field Road\nDevasandra Extension\nMahadevapura\nBangalore\nKarnataka\n560048',
mapsUrl: 'https://www.google.com/maps?source=embed&near=International+Technology+Park+Bangalore,+1st+Floor,+Innovator+Building,+Whitefield+Road,+Bangalore,+Karnataka+560066,+India&geocode=CZMgqS6v0udsFW4mxgAd5SeiBCkzTpso5RGuOzFPgVFRu2mhtA&q=xylem&f=l&dq=Xylem+Tech+Park,+Bangalore&sll=12.985966,77.735909&sspn=0.295278,0.286308&ie=UTF8&hq=xylem&hnear=&ll=12.994438,77.701664&spn=0.015974,0.032787&z=14&iwloc=A&vpsrc=0&oi=map_misc&ct=api_logo',
yelpId: null
}
};

var IntroView = Backbone.View.extend({

className: 'intro',

initialize: function(){
_.bindAll(this);
},

render: function(){
if(this.$el.is(':empty')){
this.$el.addClass(floorplanParams.officeId);
var office = OFFICES[floorplanParams.officeId];

this.$el.append($('<h2>', { text: 'Blue Jeans' }));
this.$el.append($('<h3>', { class: 'address' }).append($('<a>', {
text : office.address,
title : "View in Google Maps",
href : office.mapsUrl || '#',
target : '_blank'
})));

if(office.yelpId){
var ratingEl = $('<div>', { class: 'rating' })
.click(function(){
window.open('http://www.yelp.com/biz/bluejeans-mountain-view');
});
this.$el.append(ratingEl);
}

office.yelpId && this.renderRating(office.yelpId);
}

return this.el;
},

renderRating: function(yelpId){
yelp.getRating(yelpId)
.then(_.bind(function(rating){
this.$('.rating')
.css('background-position', '-2px '+(-3 - 18*2*(rating.stars-.5))+'px')
.attr('title', rating.stars + ' stars on Yelp\n('+rating.reviews+' reviews)');
}, this));
}
});

return IntroView;

})();
60 changes: 31 additions & 29 deletions public/scripts/Map.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
this.Map = (function(){

var SVG_NAMESPACE = 'http://www.w3.org/2000/svg';
var STORM_API_ROOT = 'http://54.212.42.221/api/';

/*
* options: {
Expand All @@ -14,7 +13,8 @@ this.Map = (function(){

events: {
"click .photos image": 'onIconClick',
"click .seats rect": 'onSeatClick'
"click .seats rect": 'onSeatClick',
"click .roomNames .roomArea": 'onRoomClick'
},

initialize: function(){
Expand All @@ -32,6 +32,10 @@ this.Map = (function(){
mediator.subscribe('filterByTag', this.filterByTag);
mediator.subscribe('change:query', this.filterByName);
}

if(!this.options.skipEndpoints){
data.endpoints.on('status', this.renderEndpointBadge);
}
},

render: function(){
Expand All @@ -55,11 +59,6 @@ this.Map = (function(){
seatsFragment.appendChild(deskEl);
}
this.seatsGroup.append(seatsFragment);

if(!this.options.skipEndpoints){
this.renderEndpointBadges();
setInterval(this.renderEndpointBadges, 5*1000);
}
}
return this.el;
},
Expand Down Expand Up @@ -98,6 +97,14 @@ this.Map = (function(){
mediator.publish("map:clickDesk", deskId);
},

onRoomClick: function(event){
if(!this.options.skipEndpoints){
var roomEl = $(event.currentTarget).closest(".room");
var endpointId = roomEl.attr("endpoint:id");
mediator.publish("map:clickRoom", endpointId);
}
},

filterByTag: function(params){
var tagsToShow = params.tagsToShow;

Expand Down Expand Up @@ -157,28 +164,23 @@ this.Map = (function(){
}
},

renderEndpointBadges: function(){
var badgeEls = this.$('.endpointBadges rect');
badgeEls.each(function(index, badgeEl){
var endpointId = $(badgeEl).attr("endpoint:id");
$.getJSON(STORM_API_ROOT+"endpoints/"+endpointId+"/status")
.done(function(endpointStatus){
var isAvailable = !endpointStatus.isCallActive && !endpointStatus.isReserved;
var titleText;
if(isAvailable){
svgAddClass(badgeEl, 'available');
svgRemoveClass(badgeEl, 'busy');
titleText = "probably available";
} else {
svgAddClass(badgeEl, 'busy');
svgRemoveClass(badgeEl, 'available');
titleText = endpointStatus.isCallActive
? "busy\n(call active)"
: "busy\n(calendar reservation)";
}
setTitle(badgeEl, titleText);
});
});
renderEndpointBadge: function(endpoint, status){
var badgeEl = this.$(".roomNames .room[endpoint\\:id='"+endpoint.id+"'] .statusBadge").get(0);
if(badgeEl){
var isAvailable = !status.callActive && !status.reserved;
var titleText;
svgAddClass(badgeEl, "loaded");
if(isAvailable){
svgRemoveClass(badgeEl, 'busy');
titleText = "available";
} else {
svgAddClass(badgeEl, 'busy');
titleText = status.callActive
? "in a call"
: "reserved";
}
setTitle(badgeEl, titleText);
}
}
});

Expand Down
Loading

0 comments on commit 9218417

Please sign in to comment.