Skip to content

Commit

Permalink
applied new notification system to all the views
Browse files Browse the repository at this point in the history
  • Loading branch information
inderpreetsingh committed Aug 11, 2014
1 parent f154e2b commit b2f2498
Show file tree
Hide file tree
Showing 19 changed files with 50 additions and 31 deletions.
7 changes: 2 additions & 5 deletions OGV/client/styles/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -79,15 +79,12 @@ h2 {
}

.secondary-menu{
max-width:450px;
position:absolute;
margin-top:50px;
left:40%;
margin-top:100px;
}

.sm-item{
float:left;
padding-left:10px;
padding-bottom:10px;
width:100px;
text-align: center;
}
Expand Down
4 changes: 2 additions & 2 deletions OGV/client/views/authentication/forgot_password.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ Template.forgotPassword.events({
isEmail(email)) {
Accounts.forgotPassword({email:email},function(err){
if (err) {
Session.set('alert',err.message);
throwError(err.reason);
} else {
Session.set('alert','Email Sent, Please check your mailbox to reset your password');
throwNotification('Email Sent, Please check your mailbox to reset your password');
}
});
}
Expand Down
2 changes: 1 addition & 1 deletion OGV/client/views/authentication/login.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ Template.logIn.events({
throwError(err.reason);
console.log(err);
} else {
Session.set('alert', 'Welcome back');
throwNotification('Welcome back');
Router.go('/upload');
}
});
Expand Down
2 changes: 1 addition & 1 deletion OGV/client/views/authentication/logout.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Template.logOut.events({
'click #log-out':function(e,t)
{
Meteor.logout(function() {
Session.set('alert','Bye!, See you back soon');
throwError('Bye!, See you back soon');
});

return false;
Expand Down
2 changes: 1 addition & 1 deletion OGV/client/views/authentication/reset_password.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ Template.resetPassword.events({
if (err) {
throwError('We\'re sorry but something went wrong');
} else {
Session.set('alert', 'Your password has been changed. Welcome back!');
throwNotification('Your password has been changed. Welcome back!');
Session.set('resetPassword',null);
}
});
Expand Down
3 changes: 1 addition & 2 deletions OGV/client/views/authentication/signup.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,7 @@ Template.signUp.events({
if (err) {
throwError(err.reason);
} else {
console.log("account creation success");
Session.set('alert','Congrats! Check your inbox at ' + email + ' to verify it');
throwNotification('Congrats! Check your inbox at ' + email + ' to verify it');
}
});
}
Expand Down
2 changes: 1 addition & 1 deletion OGV/client/views/cfs_uploader.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ function uploadFile(event, temp)
if (err) {
throwError(err.reason);
} else {
Session.set('alert', "File Uploaded, and will appear in file manager after it's converted" );
throwNotification( "File Uploaded, and will appear in file manager after it's converted");
Router.go("/description/" +fileObj._id);
}
});
Expand Down
15 changes: 14 additions & 1 deletion OGV/client/views/dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,20 @@ Template.dashboard.events({
gobjPath = adminDash.find('#dash-g-obj-path').val();

settings = OgvSettings.findOne();
OgvSettings.update( settings._id, { $set: { siteName: primaryBranding, mailUrl : mailUrl, mgedPath : mgedPath, gobjPath :gobjPath }});
OgvSettings.update( settings._id, {
$set: {
siteName: primaryBranding,
mailUrl : mailUrl,
mgedPath : mgedPath,
gobjPath :gobjPath
}
}, function(error, res) {
if (error) {
throwError(error.reason);
} else {
throwNotification("Admin Settings saved");
}
});
}
});

Expand Down
2 changes: 1 addition & 1 deletion OGV/client/views/menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Template.menu.events({
'click #log-out':function(e,t)
{
Meteor.logout(function() {
Session.set('alert','Bye!, See you back soon');
throwError('Bye!, See you back soon');
});

return false;
Expand Down
12 changes: 7 additions & 5 deletions OGV/client/views/modelMeta.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,15 @@ Template.modelMeta.events({

ThumbFiles.insert(fsFile,function(err,thumbFile) {
if (err) {
Session.set('alert', err.reason);
throwError(err.reason);
} else {
Session.set('alert', "Image Uploaded" );
throwNotification("Image has been Uploaded" );
ModelFiles.update(modelId, {$set: {name: filename, about: description, thumbnail:thumbFile._id}}, function(error, res) {
if(error) {
console.log(error);
}
if (error) {
throwError(error.reason);
} else {
throwNotification("Data about model has been saved");
}
});

}
Expand Down
3 changes: 2 additions & 1 deletion OGV/client/views/model_viewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ Template.modelViewer.rendered = function()
function getObjFiles(model)
{
var objUrls = [];
console.log("getting objs");
throwNotification("getting obj files");
modelId = model._id;
OBJFiles.find({ gFile : modelId }).forEach( function (objFile) {
objUrls.push(objFile.url());
Expand Down Expand Up @@ -188,4 +188,5 @@ function generateEmbedCode()
var thisURL = Meteor.absoluteUrl() + "/models/" + model._id;
embedCode = "<iframe width=\"500\" height=\"250\" src=\"" + thisURL + "\" frameborder=\"0\"></iframe>";
console.log(embedCode);
return embedCode;
}
7 changes: 7 additions & 0 deletions OGV/client/views/primaryBranding.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Template.primaryBranding.helpers({
primaryBranding: function()
{
settings = OgvSettings.findOne();
return settings.siteName;
}
});
2 changes: 0 additions & 2 deletions OGV/client/views/social.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,6 @@ Template.lovemeter.events({
Meteor.call('love', love, function(error, loveId) {
if (error){
throwError(error.reason);
} else {

}
});
}
Expand Down
5 changes: 2 additions & 3 deletions OGV/collections/models.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@ gStore = new FS.Store.FileSystem("modelFiles", {
var fileId = fileObj._id;
Meteor.call('convertFile', fileId, function(err) {
if (err) {
console.log("convertFileError");
console.log(err);
throwError(err.reason);
} else {
Session.set("alert","File has been converted");
throwNotification("File has been converted");
}

});
Expand Down
6 changes: 4 additions & 2 deletions OGV/collections/ogv_meta.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ OgvSettings = new Meteor.Collection('OgvSettings');
OgvSettings.allow({
insert: function(userId, setting)
{
throw (new Meteor.Error(550, "You are not allowed to insert new settings, you can edit the old ones though"));
return false;
},
update: function(userId, setting)
Expand All @@ -13,8 +14,9 @@ OgvSettings.allow({
{
if (roles[role] === 'admin') isAdmin = true;
}
console.log("is admin is");
console.log(isAdmin);
if (!isAdmin) {
throw (new Meteor.Error(550, "Sorry you need to be admin before you can edit site settings"));
}
return isAdmin;
}
});
1 change: 1 addition & 0 deletions OGV/collections/profile.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ ProfilePictures.allow({
if (file.extension() == 'jpg') {
return true;
} else {
throw ( new Meteor.Error(550, "Only .jpg files are allowed"));
return false;
}
},
Expand Down
2 changes: 1 addition & 1 deletion OGV/collections/social.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ Meteor.methods({
}

if(alreadyLoved) {
console.log("you already love this");
throw (new Meteor.Error(550,"you already love this"));
} else {
loversArray.push(user._id);
return Lovers.update({postId: loveAttributes.postId},{$set: {lovers: loversArray}}); // update lovers
Expand Down
2 changes: 1 addition & 1 deletion OGV/lib/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ var loggingIn = function(pause) {
}


Router.onBeforeAction(function() { clearErrors(); });
Router.onBeforeAction(function() { clearNotifications(); });
Router.onBeforeAction(validateUser,{only:['cfsUploader','filemanager','dashboard','modelMeta']});
Router.onBeforeAction(actionReady, {only:['index']});
Router.onBeforeAction(loggingIn);
2 changes: 1 addition & 1 deletion OGV/server/cfs_uploader.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ Meteor.methods({
console.log(cmd);
child = exec(cmd, Meteor.bindEnvironment (function (error, stdout, stderr) {
if (error) {
console.log("There's some error in converting file" + error);
throw (new Meteor.Error("There's some error in converting file" + error));
} else {
console.log("File has been converted" + objects[i] + i);
objFS = new FS.File(objPath[i]);
Expand Down

0 comments on commit b2f2498

Please sign in to comment.