formatted chromebook display

This commit is contained in:
Yaman 2014-12-25 17:42:54 -05:00
parent bcc85b6446
commit 125b4253ba
9 changed files with 117 additions and 11 deletions

View File

@ -5,9 +5,10 @@
# but you can also edit it by hand. # but you can also edit it by hand.
meteor-platform meteor-platform
autopublish
insecure insecure
iron:router iron:router
momentjs:moment momentjs:moment
accounts-google accounts-google
accounts-ui accounts-ui
alanning:roles
mrt:purecss

View File

@ -3,8 +3,8 @@ accounts-google@1.0.3
accounts-oauth@1.1.3 accounts-oauth@1.1.3
accounts-ui@1.1.4 accounts-ui@1.1.4
accounts-ui-unstyled@1.1.5 accounts-ui-unstyled@1.1.5
alanning:roles@1.2.13
application-configuration@1.0.4 application-configuration@1.0.4
autopublish@1.0.2
autoupdate@1.1.4 autoupdate@1.1.4
base64@1.0.2 base64@1.0.2
binary-heap@1.0.2 binary-heap@1.0.2
@ -47,6 +47,7 @@ minimongo@1.0.6
mobile-status-bar@1.0.2 mobile-status-bar@1.0.2
momentjs:moment@2.8.4 momentjs:moment@2.8.4
mongo@1.0.10 mongo@1.0.10
mrt:purecss@0.6.0
oauth@1.1.3 oauth@1.1.3
oauth2@1.1.2 oauth2@1.1.2
observe-sequence@1.0.4 observe-sequence@1.0.4

View File

@ -2,20 +2,40 @@ body {
-webkit-user-select: none; -webkit-user-select: none;
} }
.pure-u-3-5 {
margin-top: 1.5%;
margin-bottom: 1.5%;
}
.chromebook { .chromebook {
font-family: Lato; font-family: Lato;
padding-left:2%; padding-left:2%;
margin-left:3%; margin-left:3%;
margin-right:3%; margin-right:3%;
margin-top:.7%; margin-bottom: 0%;
margin-bottom:.7%;
box-shadow: 3px 3px 10px #c2c2c2; box-shadow: 3px 3px 10px #c2c2c2;
color: #000000; color: #000000;
height: 10%;
} }
.time { .timestamp {
font-size: 75%;
color: #6D6E6D; 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 { .available {

View File

@ -1,5 +1,11 @@
<template name="chromebook"> <template name="chromebook">
<div class="chromebook {{status_class}}"> <div class="chromebook {{status_class}}">
<p>Chromebook #{{number}} <span class="time">{{time_ago}}</span></p> <p class="pure-u-3-5">Chromebook #{{number}}</p>
{{#if status }}
<div class="timestamp pure-u-2-5">
<p class="user"> <b>{{username}}</b></p>
<p class="time">{{time_ago}}</p>
</div>
{{/if}}
</div> </div>
</template> </template>

View File

@ -4,6 +4,8 @@ var statusmap = {
2: "unavailable" 2: "unavailable"
} }
Meteor.subscribe('chromebook');
Template.chromebook.helpers({ Template.chromebook.helpers({
status_class: function() { status_class: function() {
return statusmap[this.status]; return statusmap[this.status];
@ -14,6 +16,9 @@ Template.chromebook.helpers({
} else { } else {
return moment(this.last_checkout).fromNow(); 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() { 'click .available': function() {
Chromebooks.update(this._id, {$set: {status: 1}}); Chromebooks.update(this._id, {$set: {status: 1}});
Chromebooks.update(this._id, {$set: {last_checkout: new Date()}}); Chromebooks.update(this._id, {$set: {last_checkout: new Date()}});
Chromebooks.update(this._id, {$set: {userid: Meteor.userId()}});
}, },
'click .checkedout': function() { 'click .checkedout': function() {
Chromebooks.update(this._id, {$set: {status: 0}}); Chromebooks.update(this._id, {$set: {status: 0}});
Chromebooks.update(this._id, {$set: {last_checkout: null}}); Chromebooks.update(this._id, {$set: {last_checkout: null}});
Chromebooks.update(this._id, {$set: {userid: null}});
} }
}); });

View File

@ -10,6 +10,9 @@ var links = [
Template.initial.events({ Template.initial.events({
'click .chromeicon': function() { 'click .chromeicon': function() {
var randomint = Math.floor(Math.random() * (links.length - 1)); 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');
} }
}) })

View File

@ -2,6 +2,18 @@ Router.route('/', function() {
this.render("initial"); this.render("initial");
}) })
Router.route('/checkout'); Router.route('/checkout', function() {
if (Meteor.user()) {
this.render("checkout");
} else {
this.redirect('/login');
}
});
Router.route('/login'); Router.route('/login', function() {
if (Meteor.user()) {
this.redirect('/checkout');
} else {
this.render("login");
}
});

View File

@ -1 +1 @@
Chromebooks = new Mongo.Collection("chromebook"); Chromebooks = new Mongo.Collection("chromebook");

View File

@ -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)
}
})