Comments
This commit is contained in:
parent
9c63a46409
commit
f0fa84c47a
@ -1,7 +1,9 @@
|
|||||||
import {
|
import {
|
||||||
Template
|
Template
|
||||||
} from 'meteor/templating';
|
} from 'meteor/templating';
|
||||||
|
|
||||||
|
// Sets up global variables
|
||||||
|
|
||||||
Session.set("profInputOpen", null);
|
Session.set("profInputOpen", null);
|
||||||
Session.set("profClassTab", "manClass");
|
Session.set("profClassTab", "manClass");
|
||||||
Session.set("modifying", null);
|
Session.set("modifying", null);
|
||||||
@ -17,6 +19,9 @@ Session.set("code",null);
|
|||||||
Session.set("noclass",null);
|
Session.set("noclass",null);
|
||||||
Session.set("notfound",null);
|
Session.set("notfound",null);
|
||||||
|
|
||||||
|
|
||||||
|
// Colors of the theme
|
||||||
|
|
||||||
var themeColors = {
|
var themeColors = {
|
||||||
"light": {
|
"light": {
|
||||||
"header": "#EBEBEB",
|
"header": "#EBEBEB",
|
||||||
@ -72,14 +77,14 @@ Template.profile.helpers({
|
|||||||
}]
|
}]
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
mainCenter() {
|
mainCenter() { // Centers main container
|
||||||
var width = window.innerWidth * 1600 / 1920 + 10;
|
var width = window.innerWidth * 1600 / 1920 + 10;
|
||||||
return "width:" + width.toString() + "px;margin-left:" + -0.5 * width.toString() + "px";
|
return "width:" + width.toString() + "px;margin-left:" + -0.5 * width.toString() + "px";
|
||||||
},
|
},
|
||||||
mainHeight() {
|
mainHeight() {
|
||||||
return window.innerHeight.toString() + "px";
|
return window.innerHeight.toString() + "px";
|
||||||
},
|
},
|
||||||
banner() {
|
banner() { //Styles the banner
|
||||||
var width = window.innerWidth * 1600 / 1920;
|
var width = window.innerWidth * 1600 / 1920;
|
||||||
var height = width * 615 / 1600;
|
var height = width * 615 / 1600;
|
||||||
if (Meteor.user().profile.banner !== undefined) {
|
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";
|
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 dim = window.innerWidth * 1600 / 1920 * 0.16;
|
||||||
var pic = "";
|
var pic = "";
|
||||||
var userprofile = Meteor.user().profile.avatar;
|
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";
|
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;
|
var dim = window.innerWidth * 1600 / 1920 * 0.16;
|
||||||
return "height:" + dim.toString() + "px;width:" + dim.toString() + "px;top:" + 0.43 * window.innerHeight.toString() + "px;";
|
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;
|
return Meteor.user().profile.name;
|
||||||
},
|
},
|
||||||
motd() {
|
motd() { //Returns the current user's description
|
||||||
if (Meteor.user().profile.description) {
|
if (Meteor.user().profile.description) {
|
||||||
return Meteor.user().profile.description;
|
return Meteor.user().profile.description;
|
||||||
} else {
|
} else {
|
||||||
return "Say something about yourself!";
|
return "Say something about yourself!";
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
school() {
|
school() { //Returns the current user's school's name
|
||||||
if (Meteor.user().profile.school) {
|
if (Meteor.user().profile.school) {
|
||||||
return Meteor.user().profile.school;
|
return Meteor.user().profile.school;
|
||||||
} else {
|
} else {
|
||||||
return "Click here to edit...";
|
return "Click here to edit...";
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
grade() {
|
grade() { //Returns the current user's grade
|
||||||
if (Meteor.user().profile.grade) {
|
if (Meteor.user().profile.grade) {
|
||||||
return Meteor.user().profile.grade + "th";
|
return Meteor.user().profile.grade + "th";
|
||||||
} else {
|
} else {
|
||||||
return "Click here to edit...";
|
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(
|
var array = classes.find(
|
||||||
{
|
{
|
||||||
status: {$eq: true},
|
status: {$eq: true},
|
||||||
@ -155,30 +160,30 @@ Template.profile.helpers({
|
|||||||
}
|
}
|
||||||
return array;
|
return array;
|
||||||
},
|
},
|
||||||
profClassHeight() {
|
profClassHeight() { // Dimensions the class height
|
||||||
return 0.6 * window.innerHeight.toString() + "px";
|
return 0.6 * window.innerHeight.toString() + "px";
|
||||||
},
|
},
|
||||||
classHolderHeight() {
|
classHolderHeight() { // Dimensions the container for the classes
|
||||||
return 0.26 * window.innerHeight.toString() + "px";
|
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")) {
|
if (status === Session.get("profClassTab")) {
|
||||||
return themeColors[Cookie.get("theme")].highlightText;
|
return themeColors[Cookie.get("theme")].highlightText;
|
||||||
} else {
|
} else {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
profClassTab(tab) {
|
profClassTab(tab) { // Tells current class
|
||||||
if (tab === Session.get("profClassTab")) {
|
if (tab === Session.get("profClassTab")) {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
notsearching() {
|
notsearching() { // Tells whether user is using the searchbox
|
||||||
return Session.get("notsearching");
|
return Session.get("notsearching");
|
||||||
},
|
},
|
||||||
autocompleteClasses() {
|
autocompleteClasses() { // Returns current auto-completes for classes
|
||||||
return Session.get("autocompleteDivs");
|
return Session.get("autocompleteDivs");
|
||||||
},
|
},
|
||||||
notfound() {
|
notfound() {
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
|
//meteor things
|
||||||
import {
|
import {
|
||||||
Meteor
|
Meteor
|
||||||
} from 'meteor/meteor';
|
} from 'meteor/meteor';
|
||||||
@ -5,15 +6,20 @@ import {
|
|||||||
Mongo
|
Mongo
|
||||||
} from 'meteor/mongo';
|
} from 'meteor/mongo';
|
||||||
|
|
||||||
|
// Defines who the admins are - not added
|
||||||
|
|
||||||
superadmins = [
|
superadmins = [
|
||||||
"ybq987@gmail.com",
|
"ybq987@gmail.com",
|
||||||
"ksjdragon@gmail.com"
|
"ksjdragon@gmail.com"
|
||||||
];
|
];
|
||||||
|
|
||||||
worktype = ["test", "quiz", "project", "normal", "other"];
|
worktype = ["test", "quiz", "project", "normal", "other"];
|
||||||
var possiblelist = ["moderators", "banned"];
|
var possiblelist = ["moderators", "banned"];
|
||||||
|
|
||||||
// Adds roles to superadmins
|
// Adds roles to superadmins
|
||||||
// Not necessary on every run
|
// Not necessary on every run
|
||||||
|
// Makes superadmins superadmins
|
||||||
|
|
||||||
for (var i = 0; i < superadmins.length; i++) {
|
for (var i = 0; i < superadmins.length; i++) {
|
||||||
var superadmin = superadmins[i];
|
var superadmin = superadmins[i];
|
||||||
if (Meteor.users.findOne({
|
if (Meteor.users.findOne({
|
||||||
@ -26,10 +32,14 @@ for (var i = 0; i < superadmins.length; i++) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
|
||||||
Meteor.publish('schools', function() {
|
Meteor.publish('schools', function() {
|
||||||
return schools.find();
|
return schools.find();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Returns the code for classes (for debug)
|
||||||
|
|
||||||
Meteor.publish('classes', function() {
|
Meteor.publish('classes', function() {
|
||||||
if (Roles.userIsInRole(this.userId, ['superadmin', 'admin'])) {
|
if (Roles.userIsInRole(this.userId, ['superadmin', 'admin'])) {
|
||||||
return classes.find();
|
return classes.find();
|
||||||
@ -70,6 +80,8 @@ Meteor.publish('classes', function() {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
//Gives everything in work if superadmin
|
||||||
|
|
||||||
Meteor.publish('work', function() {
|
Meteor.publish('work', function() {
|
||||||
if (Roles.userIsInRole(this.userId, ['superadmin', 'admin'])) {
|
if (Roles.userIsInRole(this.userId, ['superadmin', 'admin'])) {
|
||||||
return work.find();
|
return work.find();
|
||||||
@ -92,6 +104,8 @@ Meteor.publish('work', function() {
|
|||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
//Returns issues in sites (not implemented on client)
|
||||||
|
|
||||||
Meteor.publish('requests', function() {
|
Meteor.publish('requests', function() {
|
||||||
if (Roles.userIsInRole(this.userId, ['superadmin', 'admin'])) {
|
if (Roles.userIsInRole(this.userId, ['superadmin', 'admin'])) {
|
||||||
return requests.find();
|
return requests.find();
|
||||||
@ -102,6 +116,8 @@ Meteor.publish('requests', function() {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
//Publishes every-persons email and user-ids
|
||||||
|
|
||||||
Meteor.publish('users', function() {
|
Meteor.publish('users', function() {
|
||||||
if (Roles.userIsInRole(this.userId, ['superadmin', 'admin'])) {
|
if (Roles.userIsInRole(this.userId, ['superadmin', 'admin'])) {
|
||||||
return Meteor.users.find();
|
return Meteor.users.find();
|
||||||
@ -120,6 +136,9 @@ Security.permit(['insert', 'update', 'remove']).collections([schools, classes, w
|
|||||||
|
|
||||||
|
|
||||||
Meteor.methods({
|
Meteor.methods({
|
||||||
|
//Stuff that is accessible in client
|
||||||
|
|
||||||
|
//Generates private codes for classes - like google classroom
|
||||||
'genCode': function() {
|
'genCode': function() {
|
||||||
currcode = Math.random().toString(36).substr(2, 6);
|
currcode = Math.random().toString(36).substr(2, 6);
|
||||||
while (classes.findOne({
|
while (classes.findOne({
|
||||||
@ -131,6 +150,8 @@ Meteor.methods({
|
|||||||
},
|
},
|
||||||
|
|
||||||
// School Functions
|
// School Functions
|
||||||
|
|
||||||
|
//Ability to create schools for selections
|
||||||
'createSchool': function(schoolname) {
|
'createSchool': function(schoolname) {
|
||||||
if (Roles.userIsInRole(Meteor.userId(), ['superadmin', 'admin'])) {
|
if (Roles.userIsInRole(Meteor.userId(), ['superadmin', 'admin'])) {
|
||||||
schools.insert({
|
schools.insert({
|
||||||
@ -140,6 +161,7 @@ Meteor.methods({
|
|||||||
throw "Unauthorized";
|
throw "Unauthorized";
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
//Deletes school
|
||||||
'deleteSchool': function(schoolId) {
|
'deleteSchool': function(schoolId) {
|
||||||
if (Roles.userIsInRole(Meteor.userId(), ['superadmin', 'admin'])) {
|
if (Roles.userIsInRole(Meteor.userId(), ['superadmin', 'admin'])) {
|
||||||
schools.remove({
|
schools.remove({
|
||||||
@ -219,6 +241,9 @@ Meteor.methods({
|
|||||||
throw "Unauthorized";
|
throw "Unauthorized";
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// Allows someone to manage the class
|
||||||
|
|
||||||
'trackUserInClass': function(input) {
|
'trackUserInClass': function(input) {
|
||||||
var foundclass = classes.findOne({
|
var foundclass = classes.findOne({
|
||||||
_id: input[1]
|
_id: input[1]
|
||||||
@ -410,6 +435,7 @@ Meteor.methods({
|
|||||||
throw "Unauthorized";
|
throw "Unauthorized";
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
'toggleWork': function(input) {
|
'toggleWork': function(input) {
|
||||||
var workobject = work.findOne({
|
var workobject = work.findOne({
|
||||||
_id: input[0]
|
_id: input[0]
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user