diff --git a/chromebook-checkout-meteor/.meteor/packages b/chromebook-checkout-meteor/.meteor/packages index 4ac05ba..0c6661b 100644 --- a/chromebook-checkout-meteor/.meteor/packages +++ b/chromebook-checkout-meteor/.meteor/packages @@ -5,9 +5,10 @@ # but you can also edit it by hand. meteor-platform -autopublish insecure iron:router momentjs:moment accounts-google accounts-ui +alanning:roles +mrt:purecss diff --git a/chromebook-checkout-meteor/.meteor/versions b/chromebook-checkout-meteor/.meteor/versions index a0f01ef..15fc234 100644 --- a/chromebook-checkout-meteor/.meteor/versions +++ b/chromebook-checkout-meteor/.meteor/versions @@ -3,8 +3,8 @@ accounts-google@1.0.3 accounts-oauth@1.1.3 accounts-ui@1.1.4 accounts-ui-unstyled@1.1.5 +alanning:roles@1.2.13 application-configuration@1.0.4 -autopublish@1.0.2 autoupdate@1.1.4 base64@1.0.2 binary-heap@1.0.2 @@ -47,6 +47,7 @@ minimongo@1.0.6 mobile-status-bar@1.0.2 momentjs:moment@2.8.4 mongo@1.0.10 +mrt:purecss@0.6.0 oauth@1.1.3 oauth2@1.1.2 observe-sequence@1.0.4 diff --git a/chromebook-checkout-meteor/client/chromebook.css b/chromebook-checkout-meteor/client/chromebook.css index 8ae242c..68e82bc 100644 --- a/chromebook-checkout-meteor/client/chromebook.css +++ b/chromebook-checkout-meteor/client/chromebook.css @@ -2,20 +2,40 @@ body { -webkit-user-select: none; } +.pure-u-3-5 { + margin-top: 1.5%; + margin-bottom: 1.5%; +} + .chromebook { font-family: Lato; padding-left:2%; margin-left:3%; margin-right:3%; - margin-top:.7%; - margin-bottom:.7%; + margin-bottom: 0%; box-shadow: 3px 3px 10px #c2c2c2; color: #000000; + height: 10%; } -.time { - font-size: 75%; +.timestamp { color: #6D6E6D; + float: right; +} + +.user { + font-size: 65%; + margin-top: 2%; + padding-top: 0%; + margin-bottom: 0%; + text-align: right; + padding-right: 10%; +} +.time { + margin-top: 0%; + font-size: 50%; + text-align: right; + padding-right: 10% } .available { diff --git a/chromebook-checkout-meteor/client/chromebook.html b/chromebook-checkout-meteor/client/chromebook.html index dea6631..c193fbf 100644 --- a/chromebook-checkout-meteor/client/chromebook.html +++ b/chromebook-checkout-meteor/client/chromebook.html @@ -1,5 +1,11 @@ diff --git a/chromebook-checkout-meteor/client/chromebook.js b/chromebook-checkout-meteor/client/chromebook.js index 9b7ef04..10d8f91 100644 --- a/chromebook-checkout-meteor/client/chromebook.js +++ b/chromebook-checkout-meteor/client/chromebook.js @@ -4,6 +4,8 @@ var statusmap = { 2: "unavailable" } +Meteor.subscribe('chromebook'); + Template.chromebook.helpers({ status_class: function() { return statusmap[this.status]; @@ -14,6 +16,9 @@ Template.chromebook.helpers({ } else { return moment(this.last_checkout).fromNow(); } + }, + username: function() { + return Meteor.users.findOne({_id: this.userid}).profile.name; } }); @@ -21,9 +26,11 @@ Template.chromebook.events({ 'click .available': function() { Chromebooks.update(this._id, {$set: {status: 1}}); Chromebooks.update(this._id, {$set: {last_checkout: new Date()}}); + Chromebooks.update(this._id, {$set: {userid: Meteor.userId()}}); }, 'click .checkedout': function() { Chromebooks.update(this._id, {$set: {status: 0}}); Chromebooks.update(this._id, {$set: {last_checkout: null}}); + Chromebooks.update(this._id, {$set: {userid: null}}); } }); \ No newline at end of file diff --git a/chromebook-checkout-meteor/client/initial.js b/chromebook-checkout-meteor/client/initial.js index 43f78d3..74f5b2f 100644 --- a/chromebook-checkout-meteor/client/initial.js +++ b/chromebook-checkout-meteor/client/initial.js @@ -10,6 +10,9 @@ var links = [ Template.initial.events({ 'click .chromeicon': function() { var randomint = Math.floor(Math.random() * (links.length - 1)); - window.open(links[randomint], "_blank") + window.open(links[randomint], "_blank"); + }, + 'click #submit': function() { + Router.go('/checkout'); } }) diff --git a/chromebook-checkout-meteor/client/router.js b/chromebook-checkout-meteor/client/router.js index dae5a46..0149b42 100644 --- a/chromebook-checkout-meteor/client/router.js +++ b/chromebook-checkout-meteor/client/router.js @@ -2,6 +2,18 @@ Router.route('/', function() { this.render("initial"); }) -Router.route('/checkout'); +Router.route('/checkout', function() { + if (Meteor.user()) { + this.render("checkout"); + } else { + this.redirect('/login'); + } +}); -Router.route('/login'); \ No newline at end of file +Router.route('/login', function() { + if (Meteor.user()) { + this.redirect('/checkout'); + } else { + this.render("login"); + } +}); \ No newline at end of file diff --git a/chromebook-checkout-meteor/collections/chromebooks.js b/chromebook-checkout-meteor/collections/chromebooks.js index 4969269..c3139df 100644 --- a/chromebook-checkout-meteor/collections/chromebooks.js +++ b/chromebook-checkout-meteor/collections/chromebooks.js @@ -1 +1 @@ -Chromebooks = new Mongo.Collection("chromebook"); \ No newline at end of file +Chromebooks = new Mongo.Collection("chromebook"); diff --git a/chromebook-checkout-meteor/server/users.js b/chromebook-checkout-meteor/server/users.js new file mode 100644 index 0000000..d03a7d4 --- /dev/null +++ b/chromebook-checkout-meteor/server/users.js @@ -0,0 +1,56 @@ +Meteor.publish('chromebook', function() { + return Chromebooks.find(); +}); + +var adminusers = [ + "ybq987@gmail.com", + // "ksjdragon@gmail.com", + // "mminer@bloomfield.org", + "qalieh.yaman90@bloomfield.org" +]; +for (var i = 0; i < adminusers.length; i++) { + var adminuser = adminusers[i]; + var userID = Meteor.users.findOne({"services.google.email": adminuser})._id; + Meteor.users.update(userID, {$set: {roles: ['admin']}}); +}; + +Accounts.validateNewUser(function (user) { + var loggedInUser = Meteor.user(); + + if (Roles.userIsInRole(loggedInUser, ['admin'])) { + return true; + } + + throw new Meteor.Error(403, "Not authorized to create new users"); +}); + +Meteor.methods({ + deleteUser: function (targetUserId, group) { + var loggedInUser = Meteor.user() + + if (!loggedInUser || + !Roles.userIsInRole(loggedInUser, + ['admin'], group)) { + throw new Meteor.Error(403, "Access denied") + } + + // remove permissions for target group + Roles.setUserRoles(targetUserId, [], group) + + // do other actions required when a user is removed... + } +}) + +Meteor.methods({ + updateRoles: function (targetUserId, roles, group) { + var loggedInUser = Meteor.user() + + if (!loggedInUser || + !Roles.userIsInRole(loggedInUser, + ['admin'], group)) { + throw new Meteor.Error(403, "Access denied") + } + + Roles.setUserRoles(targetUserId, roles, group) + } +}) \ No newline at end of file