Finished profile page, fixed minor bugs, css fixes

This commit is contained in:
Kenneth Jao 2017-01-25 23:19:23 -05:00
parent 7b8a0c43c6
commit cf082c40d9
10 changed files with 155 additions and 84 deletions

View File

@ -1264,7 +1264,6 @@ textarea.clickModify {
#userFunctions {
margin-bottom: 1%;
border-bottom: 2px solid #666;
}
.userFunction {

View File

@ -69,6 +69,7 @@ Template.registerHelper('screen', (multiplier, fraction) => {
});
Template.registerHelper('divColor', (div) => { // Reactive color changing based on preferences. Colors stored in themeColors.
if(Session.get("user") === null) return;
return (Object.keys(Session.get("user")).length === 0) ? themeColors["lux"][div] : Session.get("user").preferences.theme[div];
});

View File

@ -105,7 +105,7 @@
}
#colRight {
border-left: 1px solid #666;
border-left: 1px solid #9C9C9C;
float: right;
width: 40%;
box-shadow: inset 0 0 0 99999px rgba(0,0,0,0.2);
@ -549,13 +549,14 @@
}
#creRules p {
font-size: 2vh;
padding: 0;
}
.formDiv {
width: 100%;
margin: 0;
padding: 2%;
padding: 0;
background-color: transparent;
position: relative;
display: inline;
@ -580,6 +581,8 @@
}
.profTitle {
font-size: 2vh;
margin: 1% !important;
padding-left: 0 !important;
}
@ -589,7 +592,7 @@
#creSubmit {
font-weight: 200;
width: 30%;
width: 50%;
padding: 2%;
margin: auto;
margin-top: 2%;

View File

@ -58,7 +58,7 @@
.opTitle {
font-weight: 200;
margin: 0;
margin: 1%;
}
#basicNext {
@ -230,6 +230,7 @@
#profPageWrapper #createWrapper {
margin: auto;
margin-top: -1%;
padding: 3%;
padding-bottom: 2%;
width: 30%;
@ -237,12 +238,8 @@
background-color: rgba(255,255,255,0.2);
}
.formDiv {
width: 100%;
margin: 0;
padding: 2%;
background-color: transparent;
display: inline;
#profPageWrapper .-autocomplete-container {
margin-top: -6%;
}
#profPageWrapper #creSubmit {
@ -253,10 +250,6 @@
margin-bottom: 1%;
}
#createWrapper p {
margin: 0;
}
#profPageWrapper input {
margin: 0;
padding: 2%;

View File

@ -72,7 +72,7 @@
<div id="createInfo">
<div id="createWrapper">
<div id="creRules">
<p>Submit a request for a class to be approved by an administrator.<br>
<p>Submit a request for a class to be approved by an administrator.
You can have up to 8 unapproved classes at once.</p>
</div>
<div id="formContainer">

View File

@ -215,22 +215,7 @@ Template.profile.events({
});
Session.set("newClasses", newClasses);
$(".creInput").each(function(){$(this).val('');});
/*if (!teachers.findOne({
name: values.teacher
})) {
Meteor.call("createTeacher", values.teacher, values.school, function(error, result) {
if (error !== undefined) {
sAlert.error(error.message, {
effect: 'stackslide',
position: 'top'
});
} else {
sendData("createClass");
}
});
} else {
sendData("createClass");
}*/
},
'click #backArrow' () {
slideToField(Session.get("sections")[1]-1);
@ -343,9 +328,10 @@ Template.profile.events({
}
} catch(err) {}
},
'click .classBox .fa-plus' (event) {
'click .classBox .fa-plus, click #classBody .classBox' (event) {
var profile = Session.get("profile");
var id = event.target.parentNode.getAttribute("classid");
while(event.target.getAttribute("classid") === null) event.target = event.target.parentNode;
var id = event.target.getAttribute("classid");
if(profile.classes.indexOf(id) === -1) {
profile.classes.push(id);
Session.set("profile", profile);
@ -382,6 +368,74 @@ Template.profile.events({
return b.subscribers - a.subscribers;
}));
}
},
'click #profileSubmit' () {
// clear html and make page uninteractable
var myClasses = Session.get("profile").classes;
var newClasses = Session.get("newClasses");
var message = "Sorry, your profile couldn't be created. Please try again!";
_.each(myClasses, function(myClass) {
Meteor.call("joinClass", [myClass, ""], function(err, result) {
if(err !== undefined) {
sAlert.error(message, {
effect: 'stackslide',
position: 'top'
});
}
})
});
_.each(newClasses, function(newClass) {
if (!teachers.findOne({
name: newClass.teacher
})) {
Meteor.call("createTeacher", newClass.teacher, newClass.school, function(error, result) {
if (error !== undefined) {
sAlert.error(message, {
effect: 'stackslide',
position: 'top'
});
} else {
Meteor.call("createClass", newClass, function(error, result) {
if(error !== undefined) {
sAlert.error(message, {
effect: 'stackslide',
position: 'top'
});
}
});
}
});
} else {
Meteor.call("createClass", newClass, function(error, result) {
if(error !== undefined) {
sAlert.error(message, {
effect: 'stackslide',
position: 'top'
});
}
});
}
});
var profile = Session.get("profile");
profile.complete = true;
profile.preferences = Meteor.user().profile.preferences;
profile.classes.push(Meteor.userId());
Meteor.call("editProfile", profile, function(err, result) {
if(err !== undefined) {
sAlert.error(message, {
effect: 'stackslide',
position: 'top'
});
}
Meteor.subscribe('classes');
Meteor.subscribe('schools');
Meteor.subscribe('teachers');
Meteor.subscribe('work');
Meteor.subscribe('requests');
Meteor.subscribe("personalUser");
Meteor.subscribe('users');
});
}
});

View File

@ -77,6 +77,7 @@ AdminConfig = {
{ label: 'Name', name: 'profile.name' },
{ label: 'School', name: 'profile.school' },
{ label: 'Graduation Year', name:'profile.grade' },
{ label: 'Complete', name:'profile.complete'},
{ label: 'Icon', name: '_id', template: 'adminUserDisplay' },
],
templates: {
@ -98,6 +99,7 @@ AdminConfig = {
{ label: 'Name', name: 'profile.name' },
{ label: 'School', name: 'profile.school' },
{ label: 'Graduation Year', name:'profile.grade' },
{ label: 'Complete', name:'profile.complete'},
{ label: 'Icon', name: '_id', template: 'adminUserDisplay' },
],
templates: {

View File

@ -1,14 +1,14 @@
themeColors = {
"lux": {
"background": "White.jpg",
"mainColor": "#DBDBDB",
"secondaryColor": "#567393",
"sidebarColor": "#6C94B4",
"userDropdownColor": "#E6E6E6",
"iconHighlight": "#FFF",
"modeHighlight": "#D34949",
"classCardColor":"#EBEBEB",
"textColor": "#000"
"mainColor": "#4D82AC",
"secondaryColor": "#4C75A2",
"sidebarColor": "#5E88A8",
"userDropdownColor": "#427EB4",
"iconHighlight": "#39CAFF",
"modeHighlight": "#F02C2C",
"classCardColor":"#5D86A8",
"textColor": "#FFF"
},
"nox": {
"background": "Black.jpg",

View File

@ -8,26 +8,30 @@ function completeProfile() {
Router.route('/', {
waitOn: function() {
if(!Meteor.userId()) {
return;
}
return [
Meteor.subscribe('classes', this.params._id),
Meteor.subscribe('schools', this.params._id),
Meteor.subscribe('teachers', this.params._id),
Meteor.subscribe('work', this.params._id),
Meteor.subscribe('requests', this.params._id),
Meteor.subscribe('personalUser', this.params._id),
Meteor.subscribe('users', this.params._id)
];
},
action: function() {
if (!Meteor.userId() || !completeProfile()) {
this.redirect('/login');
} else {
return [
Meteor.subscribe('classes', this.params._id),
Meteor.subscribe('schools', this.params._id),
Meteor.subscribe('teachers', this.params._id),
Meteor.subscribe('work', this.params._id),
Meteor.subscribe('requests', this.params._id),
Meteor.subscribe('users', this.params._id)
];
}
},
action: function() {
if(_.contains([null, undefined, ""], Meteor.user().profile.school ||
_.contains([null, undefined, ""], Meteor.user().profile.grade))) {
this.redirect('/profile');
} else {
Session.set("user", Meteor.user().profile);
this.render("main");
if(_.contains([null, undefined, ""], Meteor.user().profile.school ||
_.contains([null, undefined, ""], Meteor.user().profile.grade))) {
this.redirect('/profile');
} else {
Session.set("user", Meteor.user().profile);
this.render("main");
}
}
}
});
@ -37,10 +41,8 @@ Router.route('/login', {
if (!Meteor.userId()) {
this.render("login");
} else if (!completeProfile()) {
Session.set("user", Meteor.user().profile);
this.redirect('/profile');
} else {
Session.set("user", Meteor.user().profile);
this.redirect('/');
}
}
@ -48,21 +50,22 @@ Router.route('/login', {
Router.route('/profile', {
waitOn: function() {
return [
Meteor.subscribe('classes', this.params._id),
Meteor.subscribe('schools', this.params._id),
Meteor.subscribe('teachers', this.params._id),
Meteor.subscribe('work', this.params._id),
Meteor.subscribe('requests', this.params._id),
Meteor.subscribe('personalUser', this.params._id),
Meteor.subscribe('users', this.params._id)
];
},
action: function() {
if (!Meteor.userId() || completeProfile()) {
this.redirect('/login');
} else {
return [
Meteor.subscribe('classes', this.params._id),
Meteor.subscribe('schools', this.params._id),
Meteor.subscribe('teachers', this.params._id),
Meteor.subscribe('work', this.params._id),
Meteor.subscribe('requests', this.params._id),
Meteor.subscribe('users', this.params._id)
];
this.render("profile");
}
},
action: function() {
this.render("profile");
}
});

View File

@ -65,7 +65,23 @@ Meteor.publish('classes', function() {
} else {
Meteor.call('createProfile', this.userId);
return classes.find({
_id: null
privacy: false,
status: true,
}, {
// Return non-sensitive fields
fields: {
school: 1,
name: 1,
hour: 1,
teacher: 1,
admin: 1,
status: 1,
privacy: 1,
category: 1,
moderators: 1,
banned: 1,
subscribers: 1
}
});
}
}
@ -108,6 +124,15 @@ Meteor.publish('requests', function() {
}
});
Meteor.publish("personalUser", function() {
return Meteor.users.find({_id: this.userId}, {
fields: {
'services': 1,
'profile': 1
}
});
});
//Publishes every-persons email and user-ids
Meteor.publish('users', function() {
@ -119,9 +144,7 @@ Meteor.publish('users', function() {
fields: {
'services.google.email': 1,
'services.google.picture': 1,
'profile.banner': 1,
'profile.grade': 1,
'profile.description': 1,
'profile.name': 1,
'profile.school': 1
}
@ -129,7 +152,6 @@ Meteor.publish('users', function() {
}
});
// Allows only superadmins to edit collections from client
Security.permit(['insert', 'update', 'remove']).collections([schools, classes, work]).ifHasRole('superadmin');
@ -595,7 +617,6 @@ Meteor.methods({
throw new Meteor.Error(errors[security]);
}
},
// User Functions
'editProfile': function(change) {
var refyear = new Date().getUTCFullYear();
@ -605,15 +626,11 @@ Meteor.methods({
"school": change.school,
"grade": change.grade,
"classes": current.classes,
"description": change.description,
"banner": change.banner,
"preferences": change.preferences,
"name": current.name,
"complete": current.complete
"complete": change.complete
};
if (current.description && current.description.length > 50) {
current.description = current.description.slice(0, 50);
}
if ((current.grade <= refyear || current.grade >= refyear + 4) && current.grade !== 0) {
current.grade = refyear;
}
@ -646,7 +663,6 @@ Meteor.methods({
_id: userId
});
var current = currentuser.profile;
current.banner = "/Banners/defaultcover.jpg";
current.classes = [userId];
current.preferences = {
"theme": themeColors.lux,