This commit is contained in:
Arav-Agarwal 2016-08-25 22:35:44 -04:00
parent 9c63a46409
commit f0fa84c47a
2 changed files with 47 additions and 16 deletions

View File

@ -1,7 +1,9 @@
import {
import {
Template
} from 'meteor/templating';
// Sets up global variables
Session.set("profInputOpen", null);
Session.set("profClassTab", "manClass");
Session.set("modifying", null);
@ -17,6 +19,9 @@ Session.set("code",null);
Session.set("noclass",null);
Session.set("notfound",null);
// Colors of the theme
var themeColors = {
"light": {
"header": "#EBEBEB",
@ -72,14 +77,14 @@ Template.profile.helpers({
}]
};
},
mainCenter() {
mainCenter() { // Centers main container
var width = window.innerWidth * 1600 / 1920 + 10;
return "width:" + width.toString() + "px;margin-left:" + -0.5 * width.toString() + "px";
},
mainHeight() {
return window.innerHeight.toString() + "px";
},
banner() {
banner() { //Styles the banner
var width = window.innerWidth * 1600 / 1920;
var height = width * 615 / 1600;
if (Meteor.user().profile.banner !== undefined) {
@ -92,7 +97,7 @@ Template.profile.helpers({
}
return "width:" + width.toString() + "px;height:" + height.toString() + "px;background-image:url(" + banner + ");background-size:" + width.toString() + "px " + height.toString() + "px";
},
avatar() {
avatar() { //Styles the avatar
var dim = window.innerWidth * 1600 / 1920 * 0.16;
var pic = "";
var userprofile = Meteor.user().profile.avatar;
@ -106,35 +111,35 @@ Template.profile.helpers({
}
return "background-image:url(" + pic + ");background-size:" + dim.toString() + "px " + dim.toString() + "px";
},
avatarDim() {
avatarDim() { //Dimensions the avatar
var dim = window.innerWidth * 1600 / 1920 * 0.16;
return "height:" + dim.toString() + "px;width:" + dim.toString() + "px;top:" + 0.43 * window.innerHeight.toString() + "px;";
},
username() {
username() { //Returns current user's username
return Meteor.user().profile.name;
},
motd() {
motd() { //Returns the current user's description
if (Meteor.user().profile.description) {
return Meteor.user().profile.description;
} else {
return "Say something about yourself!";
}
},
school() {
school() { //Returns the current user's school's name
if (Meteor.user().profile.school) {
return Meteor.user().profile.school;
} else {
return "Click here to edit...";
}
},
grade() {
grade() { //Returns the current user's grade
if (Meteor.user().profile.grade) {
return Meteor.user().profile.grade + "th";
} else {
return "Click here to edit...";
}
},
classes() {
classes() { //Loads all of the possible classes ( Limit of twenty shown ) ( Sorts by class size )
var array = classes.find(
{
status: {$eq: true},
@ -155,30 +160,30 @@ Template.profile.helpers({
}
return array;
},
profClassHeight() {
profClassHeight() { // Dimensions the class height
return 0.6 * window.innerHeight.toString() + "px";
},
classHolderHeight() {
classHolderHeight() { // Dimensions the container for the classes
return 0.26 * window.innerHeight.toString() + "px";
},
profClassTabColor(status) {        
profClassTabColor(status) { // Change this [Supposed to show the current mode that's selected via color]       
if (status === Session.get("profClassTab")) {            
return themeColors[Cookie.get("theme")].highlightText;        
} else {            
return;        
}    
},
profClassTab(tab) {
profClassTab(tab) { // Tells current class
if (tab === Session.get("profClassTab")) {
return true;
} else {
return false;
}
},
notsearching() {
notsearching() { // Tells whether user is using the searchbox
return Session.get("notsearching");
},
autocompleteClasses() {
autocompleteClasses() { // Returns current auto-completes for classes
return Session.get("autocompleteDivs");
},
notfound() {

View File

@ -1,3 +1,4 @@
//meteor things
import {
Meteor
} from 'meteor/meteor';
@ -5,15 +6,20 @@ import {
Mongo
} from 'meteor/mongo';
// Defines who the admins are - not added
superadmins = [
"ybq987@gmail.com",
"ksjdragon@gmail.com"
];
worktype = ["test", "quiz", "project", "normal", "other"];
var possiblelist = ["moderators", "banned"];
// Adds roles to superadmins
// Not necessary on every run
// Makes superadmins superadmins
for (var i = 0; i < superadmins.length; i++) {
var superadmin = superadmins[i];
if (Meteor.users.findOne({
@ -26,10 +32,14 @@ for (var i = 0; i < superadmins.length; i++) {
}
}
//
Meteor.publish('schools', function() {
return schools.find();
});
// Returns the code for classes (for debug)
Meteor.publish('classes', function() {
if (Roles.userIsInRole(this.userId, ['superadmin', 'admin'])) {
return classes.find();
@ -70,6 +80,8 @@ Meteor.publish('classes', function() {
}
});
//Gives everything in work if superadmin
Meteor.publish('work', function() {
if (Roles.userIsInRole(this.userId, ['superadmin', 'admin'])) {
return work.find();
@ -92,6 +104,8 @@ Meteor.publish('work', function() {
});
//Returns issues in sites (not implemented on client)
Meteor.publish('requests', function() {
if (Roles.userIsInRole(this.userId, ['superadmin', 'admin'])) {
return requests.find();
@ -102,6 +116,8 @@ Meteor.publish('requests', function() {
}
});
//Publishes every-persons email and user-ids
Meteor.publish('users', function() {
if (Roles.userIsInRole(this.userId, ['superadmin', 'admin'])) {
return Meteor.users.find();
@ -120,6 +136,9 @@ Security.permit(['insert', 'update', 'remove']).collections([schools, classes, w
Meteor.methods({
//Stuff that is accessible in client
//Generates private codes for classes - like google classroom
'genCode': function() {
currcode = Math.random().toString(36).substr(2, 6);
while (classes.findOne({
@ -131,6 +150,8 @@ Meteor.methods({
},
// School Functions
//Ability to create schools for selections
'createSchool': function(schoolname) {
if (Roles.userIsInRole(Meteor.userId(), ['superadmin', 'admin'])) {
schools.insert({
@ -140,6 +161,7 @@ Meteor.methods({
throw "Unauthorized";
}
},
//Deletes school
'deleteSchool': function(schoolId) {
if (Roles.userIsInRole(Meteor.userId(), ['superadmin', 'admin'])) {
schools.remove({
@ -219,6 +241,9 @@ Meteor.methods({
throw "Unauthorized";
}
},
// Allows someone to manage the class
'trackUserInClass': function(input) {
var foundclass = classes.findOne({
_id: input[1]
@ -410,6 +435,7 @@ Meteor.methods({
throw "Unauthorized";
}
},
'toggleWork': function(input) {
var workobject = work.findOne({
_id: input[0]