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.
meteor-platform
autopublish
insecure
iron:router
momentjs:moment
accounts-google
accounts-ui
alanning:roles
mrt:purecss

View File

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

View File

@ -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 {

View File

@ -1,5 +1,11 @@
<template name="chromebook">
<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>
</template>

View File

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

View File

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

View File

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