Updating framework to meteor 3 and later

This commit is contained in:
Brian McGonagill 2025-06-21 07:28:59 -05:00
parent 717994508a
commit cca29bc591
58 changed files with 2332 additions and 1611 deletions

View file

@ -4,29 +4,27 @@
# 'meteor add' and 'meteor remove' will edit this file for you, # 'meteor add' and 'meteor remove' will edit this file for you,
# but you can also edit it by hand. # but you can also edit it by hand.
meteor-base@1.5.1 # Packages every Meteor app needs to have meteor-base@1.5.2 # Packages every Meteor app needs to have
mobile-experience@1.1.1 # Packages for a great mobile UX mobile-experience@1.1.2 # Packages for a great mobile UX
mongo@1.16.10 # The database Meteor supports right now mongo@2.1.2 # The database Meteor supports right now
blaze-html-templates # Compile .html files into Meteor Blaze views blaze-html-templates # Compile .html files into Meteor Blaze views
jquery # Wrapper package for npm-installed jquery jquery # Wrapper package for npm-installed jquery
reactive-var@1.0.12 # Reactive variable for tracker reactive-var@1.0.13 # Reactive variable for tracker
tracker@1.3.3 # Meteor's client-side reactive programming library tracker@1.3.4 # Meteor's client-side reactive programming library
standard-minifier-css@1.9.2 # CSS minifier run for production mode standard-minifier-css@1.9.3 # CSS minifier run for production mode
standard-minifier-js@2.8.1 # JS minifier run for production mode standard-minifier-js@3.1.0 # JS minifier run for production mode
es5-shim@4.8.0 # ECMAScript 5 compatibility for older browsers es5-shim@4.8.1 # ECMAScript 5 compatibility for older browsers
ecmascript@0.16.8 # Enable ECMAScript2015+ syntax in app code ecmascript@0.16.11 # Enable ECMAScript2015+ syntax in app code
typescript@4.9.5 # Enable TypeScript syntax in .ts and .tsx modules typescript@5.6.4 # Enable TypeScript syntax in .ts and .tsx modules
shell-server@0.5.0 # Server-side component of the `meteor shell` command shell-server@0.6.1 # Server-side component of the `meteor shell` command
hot-module-replacement@0.5.3 # Update code in development without reloading the page hot-module-replacement@0.5.4 # Update code in development without reloading the page
blaze-hot # Update files using Blaze's API with HMR blaze-hot # Update files using Blaze's API with HMR
alanning:roles@2.2.0 roles@1.0.1
email@2.2.6 session@1.2.2
session@1.2.1 email@3.1.2
arianjahiri:meteor-handlebars-helpers
raix:handlebar-helpers ostrio:flow-router-extra
kadira:flow-router accounts-password@3.2.0
kadira:blaze-layout
accounts-password@2.4.0

View file

@ -1 +1 @@
METEOR@2.16 METEOR@3.3

View file

@ -1,94 +1,94 @@
accounts-base@2.2.11 accounts-base@3.1.1
accounts-password@2.4.0 accounts-password@3.2.0
alanning:roles@2.2.0 allow-deny@2.1.0
allow-deny@1.1.1 arianjahiri:meteor-handlebars-helpers@0.0.1
autoupdate@1.8.0 autoupdate@2.0.1
babel-compiler@7.10.5 babel-compiler@7.12.0
babel-runtime@1.5.1 babel-runtime@1.5.2
base64@1.0.12 base64@1.0.13
binary-heap@1.0.11 binary-heap@1.0.12
blaze@2.9.0 blaze@3.0.2
blaze-hot@1.1.2 blaze-hot@2.0.0
blaze-html-templates@1.2.1 blaze-html-templates@3.0.0
blaze-tools@1.1.4 blaze-tools@2.0.0
boilerplate-generator@1.7.2 boilerplate-generator@2.0.1
caching-compiler@1.2.2 caching-compiler@2.0.1
caching-html-compiler@1.2.2 caching-html-compiler@2.0.0
callback-hook@1.5.1 callback-hook@1.6.0
check@1.4.1 check@1.4.4
ddp@1.4.1 core-runtime@1.0.0
ddp-client@2.6.2 ddp@1.4.2
ddp-common@1.4.1 ddp-client@3.1.1
ddp-rate-limiter@1.2.1 ddp-common@1.4.4
ddp-server@2.7.1 ddp-rate-limiter@1.2.2
deps@1.0.12 ddp-server@3.1.2
diff-sequence@1.1.2 deps@1.0.5-pre.1
dynamic-import@0.7.3 diff-sequence@1.1.3
ecmascript@0.16.8 dynamic-import@0.7.4
ecmascript-runtime@0.8.1 ecmascript@0.16.11
ecmascript-runtime-client@0.12.1 ecmascript-runtime@0.8.3
ecmascript-runtime-server@0.11.0 ecmascript-runtime-client@0.12.3
ejson@1.1.3 ecmascript-runtime-server@0.11.1
email@2.2.6 ejson@1.1.5
es5-shim@4.8.0 email@3.1.2
fetch@0.1.4 es5-shim@4.8.1
geojson-utils@1.0.11 facts-base@1.0.2
hot-code-push@1.0.4 fetch@0.1.6
hot-module-replacement@0.5.3 geojson-utils@1.0.12
html-tools@1.1.4 hot-code-push@1.0.5
htmljs@1.2.1 hot-module-replacement@0.5.4
id-map@1.1.1 html-tools@2.0.0
inter-process-messaging@0.1.1 htmljs@2.0.1
jquery@3.0.0 id-map@1.2.0
kadira:blaze-layout@2.0.1 inter-process-messaging@0.1.2
kadira:flow-router@2.12.1 jquery@3.0.2
launch-screen@2.0.0 launch-screen@2.0.1
localstorage@1.2.0 localstorage@1.2.1
logging@1.3.4 logging@1.3.6
meteor@1.11.5 meteor@2.1.1
meteor-base@1.5.1 meteor-base@1.5.2
minifier-css@1.6.4 minifier-css@2.0.1
minifier-js@2.8.0 minifier-js@3.0.2
minimongo@1.9.4 minimongo@2.0.2
mobile-experience@1.1.1 mobile-experience@1.1.2
mobile-status-bar@1.1.0 mobile-status-bar@1.1.1
modern-browsers@0.1.10 modern-browsers@0.2.2
modules@0.20.0 modules@0.20.3
modules-runtime@0.13.1 modules-runtime@0.13.2
modules-runtime-hot@0.14.2 modules-runtime-hot@0.14.3
mongo@1.16.10 mongo@2.1.2
mongo-decimal@0.1.3 mongo-decimal@0.2.0
mongo-dev-server@1.1.0 mongo-dev-server@1.1.1
mongo-id@1.0.8 mongo-id@1.0.9
npm-mongo@4.17.2 npm-mongo@6.10.2
observe-sequence@1.0.22 observe-sequence@2.0.0
ordered-dict@1.1.0 ordered-dict@1.2.0
promise@0.12.2 ostrio:flow-router-extra@3.12.0
raix:handlebar-helpers@0.2.5 promise@1.0.0
random@1.2.1 random@1.2.2
rate-limit@1.1.1 rate-limit@1.1.2
react-fast-refresh@0.2.8 react-fast-refresh@0.2.9
reactive-dict@1.3.1 reactive-dict@1.3.2
reactive-var@1.0.12 reactive-var@1.0.13
reload@1.3.1 reload@1.3.2
retry@1.1.0 retry@1.1.1
routepolicy@1.1.1 roles@1.0.1
session@1.2.1 routepolicy@1.1.2
sha@1.0.9 session@1.2.2
shell-server@0.5.0 sha@1.0.10
socket-stream-client@0.5.2 shell-server@0.6.1
spacebars@1.6.0 socket-stream-client@0.6.1
spacebars-compiler@1.3.2 spacebars@2.0.0
standard-minifier-css@1.9.2 spacebars-compiler@2.0.0
standard-minifier-js@2.8.1 standard-minifier-css@1.9.3
templating@1.4.3 standard-minifier-js@3.1.0
templating-compiler@1.4.2 templating@1.4.4
templating-runtime@1.6.4 templating-compiler@2.0.0
templating-tools@1.2.3 templating-runtime@2.0.1
tracker@1.3.3 templating-tools@2.0.0
typescript@4.9.5 tracker@1.3.4
ui@1.0.13 typescript@5.6.4
underscore@1.6.2 underscore@1.6.4
url@1.3.2 url@1.3.5
webapp@1.13.8 webapp@2.0.7
webapp-hashing@1.1.1 webapp-hashing@1.1.2

View file

@ -1,4 +1,5 @@
import { SysConfig } from '../../../imports/api/systemConfig.js'; import { SysConfig } from '../../../imports/api/systemConfig.js';
import { FlowRouter } from 'meteor/ostrio:flow-router-extra';
Template.login.onCreated(function() { Template.login.onCreated(function() {
this.subscribe("SystemConfig"); this.subscribe("SystemConfig");

View file

@ -1,4 +1,5 @@
import { SysConfig } from "../../../imports/api/systemConfig.js"; import { SysConfig } from "../../../imports/api/systemConfig.js";
import { FlowRouter } from 'meteor/ostrio:flow-router-extra';
Template.reg.onCreated(function() { Template.reg.onCreated(function() {
this.subscribe("SystemConfig"); this.subscribe("SystemConfig");
@ -29,12 +30,15 @@ Template.reg.helpers({
return Session.get("missingReq"); return Session.get("missingReq");
}, },
allowReg: function() { allowReg: function() {
let conf = SysConfig.findOne(); const sysConf = async() => {
if (typeof conf != 'undefined') { let conf = await SysConfig.findOneAsync();
return conf.allowReg; if (!conf) {
} else { return true;
return true } else {
return conf.allowReg;
}
} }
sysConf();
} }
}); });
@ -84,14 +88,16 @@ Template.reg.events({
let userId = Meteor.userId(); let userId = Meteor.userId();
console.log("User ID: " + userId); console.log("User ID: " + userId);
Meteor.call("addToRole", "user", function(err, result) { const addRole = async() => {
if (err) { let result = await Meteor.callAsync("addToRole", "user");
console.log(" ERROR: ROLES - Error adding user to role: " + err); if (!result) {
console.log(" ERROR: ROLES - Error adding user to role: ");
} else { } else {
// console.log("User should be added to role - teacher."); // console.log("User should be added to role - teacher.");
FlowRouter.go('/dashboard'); FlowRouter.go('/dashboard');
} }
}); }
addRole();
} }
} }
}, },

View file

@ -15,7 +15,7 @@
<label for="newPassConf">Enter New Password</label> <label for="newPassConf">Enter New Password</label>
{{#if $eq passMatch false}}<p class="red-text">Passwords do not match!</p>{{/if}} {{#if $eq passMatch false}}<p class="red-text">Passwords do not match!</p>{{/if}}
</div> </div>
<div class="col s12 m6 l6 input-field outlined"> <div class="col s12 m6 l6 input-field">
<select name="userRole" id="userRole" class="userRole {{#if $eq roleEmpty true}}red lighten-2 white-text{{/if}}"> <select name="userRole" id="userRole" class="userRole {{#if $eq roleEmpty true}}red lighten-2 white-text{{/if}}">
<option value="{{userRole}}" selected>{{userRole}}</option> <option value="{{userRole}}" selected>{{userRole}}</option>
<option value="admin">Admin</option> <option value="admin">Admin</option>

View file

@ -16,10 +16,10 @@ Template.userInfoModal.onRendered(function() {
var elemse = document.querySelectorAll('select'); var elemse = document.querySelectorAll('select');
var instancese = M.FormSelect.init(elemse, {}); var instancese = M.FormSelect.init(elemse, {});
Meteor.setTimeout(() => { // Meteor.setTimeout(() => {
instances = M.Modal.init(elems, {}); // instances = M.Modal.init(elems, {});
instancese = M.FormSelect.init(elemse, {}); // instancese = M.FormSelect.init(elemse, {});
}, 500); // }, 500);
}); });
Template.userInfoModal.helpers({ Template.userInfoModal.helpers({
@ -35,19 +35,34 @@ Template.userInfoModal.helpers({
userInfo: function() { userInfo: function() {
let usersId = Session.get("usersId"); let usersId = Session.get("usersId");
if (usersId != "" && usersId != null) { if (usersId != "" && usersId != null) {
let usersInfo = Meteor.users.findOne({ _id: usersId }); const uIn = async() => {
// console.dir(usersInfo); let usersInfo = await Meteor.users.findOneAsync({ _id: usersId });
Session.set("usersInfo", usersInfo); if (!usersInfo) {
return usersInfo; console.log("No information found for this user.");
return;
} else {
Session.set("usersInfo", usersInfo);
return usersInfo;
}
// console.dir(usersInfo);
}
uIn();
} else { } else {
return; return;
} }
}, },
userRole: function() { userRole: function() {
let userRole = Roles.getRolesForUser( Session.get("usersId")); const getRole = async() => {
Session.set("usersRole", userRole); let userRole = Roles.getRolesForUserAsync( Session.get("usersId"));
console.log(userRole); if (!userRole) {
return userRole; return;
} else {
Session.set("usersRole", userRole);
console.log(userRole);
return userRole;
}
}
getRole();
}, },
rolesOptions: function() { rolesOptions: function() {
return Roles.find(); return Roles.find();
@ -121,36 +136,33 @@ Template.userInfoModal.events({
} }
}); });
changePassword = function(userId, passwd) { changePassword = async function(userId, passwd) {
console.log("would change password."); console.log("would change password.");
Meteor.call('edit.userPass', userId, passwd, function(err, result) { let result = await Meteor.callAsync('edit.userPass', userId, passwd);
if (err) { if (!result) {
console.log(" ERROR changing user passwrod:" + err); console.log(" ERROR changing user passwrod:");
} else { } else {
showSnackbar("Successfully Saved Changes!", "green"); showSnackbar("Successfully Saved Changes!", "green");
console.log(" Password changed successfully!"); console.log(" Password changed successfully!");
} }
});
} }
changeUserEmail = function(usersId, usersEmail) { changeUserEmail = async function(usersId, usersEmail) {
console.log("Would change user email"); console.log("Would change user email");
Meteor.call('update.userEmail', usersId, usersEmail, function(err, result) { let result = await Meteor.callAsync('update.userEmail', usersId, usersEmail);
if (err) { if (!result) {
console.log(" ERROR updating user email: " + err); console.log(" ERROR updating user email: " + err);
} else { } else {
showSnackbar("Email updated successfully!", "green"); showSnackbar("Email updated successfully!", "green");
} }
});
} }
changeUserRole = function(userId, role) { changeUserRole = async function(userId, role) {
console.log("Would change user Role."); console.log("Would change user Role.");
Meteor.call('edit.userRole', userId, role, function(err, result) { let result = await Meteor.callAsync('edit.userRole', userId, role);
if (err) { if (!result) {
console.log(" ERROR updating user role: " + err); console.log(" ERROR updating user role: " + err);
} else { } else {
showSnackbar("Role Successfully Updated!", "green"); showSnackbar("Role Successfully Updated!", "green");
} }
});
} }

View file

@ -23,7 +23,7 @@ Template.userMgmt.helpers({
return this.emails[0].address; return this.emails[0].address;
}, },
userRole: function() { userRole: function() {
return Roles.getRolesForUser( this._id ); return Roles.getRolesForUserAsync( this._id );
} }
}); });

View file

@ -40,27 +40,25 @@ Template.cleanUpModalConfirm.events({
} }
}); });
cleanUp = function(methodName, whatItems) { cleanUp = async function(methodName, whatItems) {
Meteor.call(methodName, function(err, result) { let result = Meteor.callAsync(methodName);
if (err) { if (!result) {
console.log(" ERROR cleaning " + whatItems + ": " + err); console.log(" ERROR cleaning " + whatItems + ": " + err);
} else { } else {
showSnackbar(whatItems + " have been cleaned up!", "green"); showSnackbar(whatItems + " have been cleaned up!", "green");
let confirmModal = document.getElementById('cleanUpConfirm'); let confirmModal = document.getElementById('cleanUpConfirm');
M.Modal.getInstance(confirmModal).close(); M.Modal.getInstance(confirmModal).close();
} }
});
} }
cleanTasks = function(methodName, whatItems) { cleanTasks = async function(methodName, whatItems) {
let timeFrame = Session.get("overdueVal"); let timeFrame = Session.get("overdueVal");
Meteor.call(methodName, timeFrame, function(err, result) { let result = await Meteor.call(methodName, timeFrame);
if (err) { if (!result) {
console.log(" ERROR cleaning " + whatItems + ": " + err); console.log(" ERROR cleaning " + whatItems + ": " + err);
} else { } else {
showSnackbar(whatItems + " have been cleaned up!", "green"); showSnackbar(whatItems + " have been cleaned up!", "green");
let confirmModal = document.getElementById('cleanUpConfirm'); let confirmModal = document.getElementById('cleanUpConfirm');
M.Modal.getInstance(confirmModal).close(); M.Modal.getInstance(confirmModal).close();
} }
});
} }

View file

@ -29,15 +29,7 @@ Template.listMgmtForm.events({
Session.set("listNameMiss", true); Session.set("listNameMiss", true);
return; return;
} else { } else {
Meteor.call('add.list', listName, shared, function(err, result) { addList(listName, shared);
if (err) {
// console.log(" ERROR adding list name: " + err);
} else {
// console.log(" SUCCESS adding list name.");
$("#listNameInp").val("");
$("#isShared").prop("checked", false);
}
});
} }
}, },
'click .renameListMgmt' (event) { 'click .renameListMgmt' (event) {
@ -50,16 +42,7 @@ Template.listMgmtForm.events({
Session.set("listNameMiss", true); Session.set("listNameMiss", true);
return; return;
} else { } else {
Meteor.call('edit.list', listId, listName, shared, function(err, result) { editList(listId, listName, shared);
if (err) {
// console.log(" ERROR editing list name: " + err);
} else {
// console.log(" SUCCESS editing list name.");
$("#listNameInp").val("");
$("#isShared").prop("checked", false);
Session.set("listNameEditMode", false);
}
});
} }
}, },
'submit .listAdd' (event) { 'submit .listAdd' (event) {
@ -74,30 +57,36 @@ Template.listMgmtForm.events({
return; return;
} else { } else {
if (editMode == false) { if (editMode == false) {
Meteor.call('add.list', listName, shared, function(err, result) { addList(listName, shared);
if (err) {
// console.log(" ERROR adding list name: " + err);
} else {
// console.log(" SUCCESS adding list name.");
$("#listNameInp").val("");
$("#isShared").prop("checked", false);
}
});
} else { } else {
Meteor.call('edit.list', listId, listName, shared, function(err, result) { editList(listId, listName, shared);
if (err) {
// console.log(" ERROR editing list name: " + err);
} else {
// console.log(" SUCCESS editing list name.");
$("#listNameInp").val("");
$("#isShared").prop("checked", false);
Session.set("listNameEditMode", false);
}
});
} }
} }
}, },
'change #isCompleted' (event) { 'change #isCompleted' (event) {
Session.set("showCompletedLists", true); Session.set("showCompletedLists", true);
}, },
}); });
const addList = async(listName, shared) => {
let result = await Meteor.callAsync('add.list', listName, shared);
if (!result) {
// console.log(" ERROR adding list name: ");
} else {
// console.log(" SUCCESS adding list name.");
$("#listNameInp").val("");
$("#isShared").prop("checked", false);
}
}
const editList = async(listId, listName, shared) => {
let result = await Meteor.callAsync('edit.list', listId, listName, shared);
if (!result) {
// console.log(" ERROR editing list name: " + err);
} else {
// console.log(" SUCCESS editing list name.");
$("#listNameInp").val("");
$("#isShared").prop("checked", false);
Session.set("listNameEditMode", false);
}
}

View file

@ -34,9 +34,14 @@ Template.listMgmtTbl.events({
}, },
'click .editListName' (event) { 'click .editListName' (event) {
event.preventDefault(); event.preventDefault();
let listInfo = Lists.findOne({ _id: this._id }); const lInfo = async() => {
let listName = listInfo.listName; let listInfo = await Lists.findOneAsync({ _id: this._id });
let listShared = listInfo.listShared; return listInfo;
}
let listData = lInfo();
let listName = listData.listName;
let listShared = listData.listShared;
$("#listNameInp").val(listName); $("#listNameInp").val(listName);
if (listShared == true) { if (listShared == true) {
$("#isShared").prop("checked", true); $("#isShared").prop("checked", true);
@ -49,23 +54,27 @@ Template.listMgmtTbl.events({
'click .markListComplete' (event) { 'click .markListComplete' (event) {
event.preventDefault(); event.preventDefault();
let listId = this._id; let listId = this._id;
Meteor.call('mark.complete', listId, function(err, result) { const markComp = async() => {
if (err) { let result = await Meteor.callAsync('mark.complete', listId);
// console.log(" ERROR marking complete: " + err); if (!result) {
console.log(" ERROR marking complete.");
} else { } else {
// console.log(" SUCCESS marking complete."); // console.log(" SUCCESS marking complete.");
} }
}); }
markComp();
}, },
'click .markListNotComplete' (event) { 'click .markListNotComplete' (event) {
event.preventDefault(); event.preventDefault();
let listId = this._id; let listId = this._id;
Meteor.call('mark.incomplete', listId, function(err, result) { const markInc = async() => {
if (err) { let result = await Meteor.callAsync('mark.incomplete', listId);
if (!result) {
console.log("Issue marking list incomplete.");
} else { } else {
// console.log("List marked incomplete.");
} }
}); }
markInc();
} }
}); });

View file

@ -1,3 +1,5 @@
import { FlowRouter } from 'meteor/ostrio:flow-router-extra';
Template.mgmtPage.onCreated(function() { Template.mgmtPage.onCreated(function() {
}); });

View file

@ -35,36 +35,19 @@ Template.prodMgmtForm.events({
'click .saveProdMgmt, click .editProdMgmt' (event) { 'click .saveProdMgmt, click .editProdMgmt' (event) {
let name = $("#prodName").val(); let name = $("#prodName").val();
let store = $("#prodStore").val(); let store = $("#prodStore").val();
let prodId = Session.get("prodEditId"); let prodId = Session.get("prodEditId");
let prodEditMode = Session.get("prodEditMode"); let prodEditMode = Session.get("prodEditMode");
if (store == null) { if (store == null) {
store = ""; store = "";
} }
if (name == "" || name == null) { if (name == "" || name == null) {
Session.set("prodNameRed", true); Session.set("prodNameRed", true);
return; return;
} else { } else {
if (prodEditMode == true) { if (prodEditMode == true) {
Meteor.call('edit.product', prodId, name, store, function(err, result) { editProd(prodId, name, store);
if (err) {
console.log(" ERROR: can't add product: " + err);
} else {
$("#prodName").val("");
showSnackbar("Successfully Edited Product!", "green");
}
});
} else { } else {
Meteor.call('add.product', name, store, function(err, result) { newProd(name, store);
if (err) {
console.log(" ERROR: can't add product: " + err);
} else {
$("#prodName").val("");
showSnackbar("Product Added Succssfully!", "green");
}
});
} }
} }
}, },
@ -76,5 +59,33 @@ Template.prodMgmtForm.events({
} else { } else {
Session.set("noStoreSet", false); Session.set("noStoreSet", false);
} }
} },
'submit .prodInputForm' (event) {
},
}); });
const newProd = async(name, store) => {
let result = await Meteor.callAsync('add.product', name, store);
try {
if (!result) {
console.log("No result when trying to add a new product.");
showSnackbar("Unable to add new product.");
} else {
$("#prodName").val("");
showSnackbar("New Product Added!", "green");
}
} catch(error) {
console.log(" ERROR - couldn't add product: " + error);
}
}
const editProd = async(prodId, name, store) => {
let result = await Meteor.callAsync('edit.product', prodId, name, store);
if (!result) {
console.log(" ERROR: can't add product: " + err);
} else {
$("#prodName").val("");
showSnackbar("Successfully Edited Product!", "green");
}
}

View file

@ -57,10 +57,17 @@ Template.prodMgmtTbl.events({
event.preventDefault(); event.preventDefault();
Session.set("prodEditMode", true); Session.set("prodEditMode", true);
Session.set("prodEditId", this._id); Session.set("prodEditId", this._id);
let prodInfo = Products.findOne({ _id: this._id }); const getProds = async() => {
$("#prodName").val(prodInfo.prodName); let prodInfo = await Products.findOneAsync({ _id: this._id });
$("#prodStore").val(prodInfo.prodStore); if (!prodInfo) {
// $('select').formSelect(); console.log("No Product Returned.");
} else {
$("#prodName").val(prodInfo.prodName);
$("#prodStore").val(prodInfo.prodStore);
}
}
getProds();
}, },
'click #filterProds' (event) { 'click #filterProds' (event) {
event.preventDefault(); event.preventDefault();

View file

@ -23,14 +23,7 @@ Template.storeMgmtForm.events({
Session.set("borderRed", true); Session.set("borderRed", true);
return; return;
} else { } else {
Meteor.call("add.store", storeName, function(err, result) { addStore(storeName);
if (err) {
console.log("ERROR: Store add failed: " + err);
} else {
$("#storeName").val("");
showSnackbar("Store Added Successfully!", "green");
}
});
} }
}, },
'click .cancelStoreMgmt' (event) { 'click .cancelStoreMgmt' (event) {
@ -38,51 +31,51 @@ Template.storeMgmtForm.events({
$("#storeName").val(""); $("#storeName").val("");
Session.set("editModeStore", false); Session.set("editModeStore", false);
}, },
// 'submit #storeForm' (event) { 'submit #storeForm' (event) {
// event.preventDefault(); event.preventDefault();
// let editMode = Session.get("editModeStore"); let editMode = Session.get("editModeStore");
// let storeName = $("#storeName").val(); let storeName = $("#storeName").val();
// if (storeName == "" || storeName == null) { if (storeName == "" || storeName == null) {
// Session.set("borderRed", true); Session.set("borderRed", true);
// return; return;
// } else { } else {
// if (editMode == false) { if (editMode == false) {
// Meteor.call("add.store", storeName, function(err, result) { addStore(storeName);
// if (err) { } else {
// console.log("ERROR: Store add failed: " + err); let storeId = Session.get("storeIdEdit");
// } else { editStore(storeId, storeName);
// $("#storeName").val(""); }
// } }
// }); },
// } else {
// let storeId = Session.get("storeIdEdit");
// Meteor.call("edit.store", storeId, storeName, function(err, result) {
// if (err) {
// console.log("ERROR: Store add failed: " + err);
// } else {
// $("#storeName").val("");
// Session.set("editModeStore", false);
// }
// });
// }
// }
// },
'click .editStoreMgmt' (event) { 'click .editStoreMgmt' (event) {
let storeName = $("#storeName").val(); let storeName = $("#storeName").val();
let storeId = Session.get("storeIdEdit"); let storeId = Session.get("storeIdEdit");
if (storeName == "" || storeName == null) { if (storeName == "" || storeName == null) {
Session.set("borderRed", true); Session.set("borderRed", true);
return; return;
} else { } else {
Meteor.call("edit.store", storeId, storeName, function(err, result) { editStore(storeId, storeName);
if (err) {
console.log("ERROR: Store add failed: " + err);
} else {
$("#storeName").val("");
Session.set("editModeStore", false);
showSnackbar("Store Updated Successfully!", "green");
}
});
} }
} }
}); });
const addStore = async(storeName) => {
let result = await Meteor.callAsync("add.store", storeName);
if (!result) {
console.log("ERROR: Store add failed.");
} else {
$("#storeName").val("");
showSnackbar("Store Added Successfully!", "green");
}
}
const editStore = async(storeId, storeName) => {
let result = await Meteor.callAsync("edit.store", storeId, storeName);
if (!result) {
console.log("ERROR: Store add failed: " + err);
} else {
$("#storeName").val("");
Session.set("editModeStore", false);
showSnackbar("Store Updated Successfully!", "green");
}
}

View file

@ -27,34 +27,34 @@ Template.systemAdmin.onRendered(function() {
}); });
Template.systemAdmin.helpers({ Template.systemAdmin.helpers({
currConfigs: function() {
},
}); });
Template.systemAdmin.events({ Template.systemAdmin.events({
'change #allowGenReg, change #allowAdmReg' (evnnt) { 'change #allowGenReg, change #allowAdmReg' (evnnt) {
let genReg = $("#allowGenReg").prop('checked'); let genReg = $("#allowGenReg").prop('checked');
let admReg = $("#allowAdmReg").prop('checked'); let admReg = $("#allowAdmReg").prop('checked');
// console.log("General Reg set to: " + genReg); const addNoSysReg = async() => {
Meteor.call("add.noSysAdminReg", admReg, genReg, function(err, result) { let result = await Meteor.callAsync("add.noSysAdminReg", admReg, genReg);
if (err) { if (!result) {
// console.log(" ERROR updating permission to allow general registration: " + err); showSnackbar("Registration Permission Change Failed.", "red");
// showSnackbar("Registration Permission Change Failed.", "red");
} else { } else {
// console.log(" Successfully updated permission to allow general registration.");
showSnackbar("Registration Permission Successfully Changed.", "green") showSnackbar("Registration Permission Successfully Changed.", "green")
} }
}); }
addNoSysReg();
}, },
'change #recvUpdateMsgs' (event) { 'change #recvUpdateMsgs' (event) {
let updSet = $("#recvUpdateMsgs").prop('checked'); let updSet = $("#recvUpdateMsgs").prop('checked');
Meteor.call('allow.updateInfo', updSet, function(err, result) { const allowUpdateInfo = async() => {
if (err) { let result = await Meteor.callAsync('allow.updateInfo', updSet);
console.log(" ERROR changing update setting: " + err); if (!result) {
console.log(" ERROR changing update setting.");
showSnackbar("Update Setting Change Failed.", "red");
} else { } else {
showSnackbar("Update Setting Changed Successfully!", "green"); showSnackbar("Update Setting Changed Successfully!", "green");
} }
}); }
allowUpdateInfo();
}, },
}); });

View file

@ -92,9 +92,10 @@ Template.taskForm.events({
} }
if (taskUserErr == false && taskDateErr == false && taskNameErr == false) { if (taskUserErr == false && taskDateErr == false && taskNameErr == false) {
Meteor.call("add.task", taskNameArr, userInfo[0], userInfo[1], taskDateArr, actDate, function(err, result) { const addTask = async() => {
if (err) { let result = await Meteor.callAsync("add.task", taskNameArr, userInfo[0], userInfo[1], taskDateArr, actDate);
console.log(" ERROR adding the new task: " + err); if (!result) {
console.log(" ERROR adding the new task.");
} else { } else {
console.log(" SUCCESS adding the new task."); console.log(" SUCCESS adding the new task.");
Session.set("taskDateArr", []); Session.set("taskDateArr", []);
@ -102,7 +103,8 @@ Template.taskForm.events({
$("#taskUser").val(""); $("#taskUser").val("");
$('select').formSelect(); $('select').formSelect();
} }
}); }
addTask();
} else { } else {
showSnackbar("ERROR: Missing Required Fields!", "red"); showSnackbar("ERROR: Missing Required Fields!", "red");
} }
@ -113,7 +115,6 @@ Template.taskForm.events({
Session.set("hideCompletedTasks", true); Session.set("hideCompletedTasks", true);
} else { } else {
Session.set("hideCompletedTasks", false); Session.set("hideCompletedTasks", false);
} }
} }
}); });

View file

@ -43,13 +43,15 @@ Template.taskTbl.events({
'click .markTaskComplete' (event) { 'click .markTaskComplete' (event) {
event.preventDefault(); event.preventDefault();
let taskId = this._id; let taskId = this._id;
Meteor.call("markTask.complete", taskId, function(err, result) { const markComp = async() => {
if (err) { let result = await Meteor.callAsync("markTask.complete", taskId);
if (!result) {
console.log(" ERROR marking task completeL " + err); console.log(" ERROR marking task completeL " + err);
showSnackbar("ERROR Marking Task Complete!", "red"); showSnackbar("ERROR Marking Task Complete!", "red");
} else { } else {
showSnackbar("Successfully Marked Task Complete!", "green"); showSnackbar("Successfully Marked Task Complete!", "green");
} }
}); }
markComp();
}, },
}); });

View file

@ -2,12 +2,13 @@
<h4>My Dashboard</h4> <h4>My Dashboard</h4>
<div class="row"> <div class="row">
{{#if $eq currConfig.allowUpdates true}} {{#if $eq currConfig.allowUpdates true}}
{{#if updatesExist}} {{#if $eq updatesExist true}}
<div class="col s12"> <div class="col s12">
<div class="card green darken-3" id="updateInfoCard"> <ul class="collapsible green darken-3 white-text">
<div class="card-content white-text"> <li>
<div class="card-title">Update Available</div> <div class="collapsible-header"><strong>Update Available</strong></div>
<div class="row"> <div class="collapsible-body">
<div class="row">
{{#each updates}} {{#each updates}}
<div class="col s12"> <div class="col s12">
<div class="row"> <div class="row">
@ -33,8 +34,9 @@
<hr /> <hr />
{{/each}} {{/each}}
</div> </div>
</div> </div>
</div> </li>
</ul>
</div> </div>
{{/if}} {{/if}}
{{/if}} {{/if}}

View file

@ -7,6 +7,8 @@ import moment from 'moment';
import { TaskItems } from "../../imports/api/tasks"; import { TaskItems } from "../../imports/api/tasks";
import { UpdateInfo } from '../../imports/api/updateInfo.js'; import { UpdateInfo } from '../../imports/api/updateInfo.js';
import { SysConfig } from '../../imports/api/systemConfig.js'; import { SysConfig } from '../../imports/api/systemConfig.js';
import { FlowRouter } from 'meteor/ostrio:flow-router-extra';
import { M } from '../lib/assets/materialize.js';
Template.dashboard.onCreated(function() { Template.dashboard.onCreated(function() {
this.subscribe("userList"); this.subscribe("userList");
@ -23,7 +25,10 @@ Template.dashboard.onCreated(function() {
}); });
Template.dashboard.onRendered(function() { Template.dashboard.onRendered(function() {
setTimeout(function() {
var elems = document.querySelectorAll('.collapsible');
var instances = M.Collapsible.init(elems, {});
}, 200);
}); });
Template.dashboard.helpers({ Template.dashboard.helpers({
@ -61,18 +66,47 @@ Template.dashboard.helpers({
}, },
updates: function() { updates: function() {
let updateAvail = UpdateInfo.find({}); let updateAvail = UpdateInfo.find({});
return updateAvail; try {
}, if (!updateAvail) {
updatesExist: function() { console.log("No update info found.");
let updateExists = UpdateInfo.find({ viewed: false }).fetch(); return false;
if (updateExists.length > 0) { } else {
return true; console.dir(updateAvail);
} else { return updateAvail;
return false; }
} catch(error) {
console.log(" ERROR trying to grab update info: " + error);
} }
}, },
updatesExist: function() {
const ifUpdate = async() => {
let updateExists = await UpdateInfo.findOneAsync({ viewed: false });
if (!updateExists) {
console.log("Update doesn't exist as false.");
return false;
} else {
console.log("Update found with false.");
return true;
}
}
let updateAvail = ifUpdate();
return updateAvail;
},
currConfig: function() { currConfig: function() {
return SysConfig.findOne({}); const getSys = async() => {
let currSys = SysConfig.findOneAsync({});
try {
if (!currSys) {
// console.log("No System Config found.")
} else {
return currSys;
}
} catch(error) {
console.log(" ERROR trying to fetch current system config: " + error);
}
}
let currConf = getSys();
return currConf;
}, },
descriptionSinHTML: function() { descriptionSinHTML: function() {
let desc = this.description; let desc = this.description;
@ -141,12 +175,19 @@ Template.dashboard.events({
'click .readLink' (event) { 'click .readLink' (event) {
let eventId = event.currentTarget.id; let eventId = event.currentTarget.id;
Meteor.call('markUpdate.read', eventId, function(err, result) { const markUpdate = async() => {
if (err) { let result = await Meteor.callAsync('markUpdate.read', eventId);
console.log(" ERROR marking update as 'read': " + err); try {
} else { if (!result) {
console.log("marked read successfully!"); console.log(" Error marking this read.");
showSnackbar("Error Marking Read!", "red");
} else {
showSnackbar("Successfully Marked as Read.", "green");
}
} catch(error) {
console.log(" ERROR trying to mark this update as read: " + error);
} }
}); }
markUpdate();
} }
}); });

View file

@ -22,14 +22,16 @@ Template.deleteConfirmationModal.events({
let deleteId = Session.get("deleteId"); let deleteId = Session.get("deleteId");
let method = Session.get("method"); let method = Session.get("method");
Meteor.call(method, deleteId, function(err, result) { const delItem = async() => {
if (err) { let result = await Meteor.callAsync(method, deleteId);
if (!result) {
console.log(" ERROR deleting item from modal: " + err); console.log(" ERROR deleting item from modal: " + err);
} else { } else {
console.log(" SUCCESSFULLY deleted."); console.log(" SUCCESSFULLY deleted.");
// put the new modal open / close here // put the new modal open / close here
// $('#modalDelete').modal('close'); // $('#modalDelete').modal('close');
} }
}); }
delItem();
}, },
}); });

View file

@ -12,7 +12,7 @@
<li><a href="#" id="mymenus" class="navBtn {{#if $eq myTheme 'dark'}}white-text{{/if}}">My Menus</a></li> <li><a href="#" id="mymenus" class="navBtn {{#if $eq myTheme 'dark'}}white-text{{/if}}">My Menus</a></li>
<li><a href="#" id="myTasks" class="navBtn {{#if $eq myTheme 'dark'}}white-text{{/if}}">My Tasks</a></li> <li><a href="#" id="myTasks" class="navBtn {{#if $eq myTheme 'dark'}}white-text{{/if}}">My Tasks</a></li>
<li><a href="#" class="navBtn {{#if $eq myTheme 'dark'}}white-text{{/if}}" id="mySettings">My Settings</a></li> <li><a href="#" class="navBtn {{#if $eq myTheme 'dark'}}white-text{{/if}}" id="mySettings">My Settings</a></li>
{{#if isInRole 'systemadmin'}} {{#if isInRole "systemadmin"}}
<li><a href="#" id="manage" class="navBtn {{#if $eq myTheme 'dark'}}white-text{{/if}}">Manage</a></li> <li><a href="#" id="manage" class="navBtn {{#if $eq myTheme 'dark'}}white-text{{/if}}">Manage</a></li>
{{/if}} {{/if}}
<li class="signOut {{#if $eq myTheme 'dark'}}white-text{{/if}}"><a href="#" class="signOut">Log Out</a></li> <li class="signOut {{#if $eq myTheme 'dark'}}white-text{{/if}}"><a href="#" class="signOut">Log Out</a></li>

View file

@ -1,15 +1,38 @@
import { Meteor } from 'meteor/meteor';
import { M } from '../lib/assets/materialize'; import { M } from '../lib/assets/materialize';
import { UpdateInfo } from '../../imports/api/updateInfo.js'; import { UpdateInfo } from '../../imports/api/updateInfo.js';
import { FlowRouter } from 'meteor/ostrio:flow-router-extra';
import { Roles } from 'meteor/roles';
Template.headerBar.onCreated(function() { Template.headerBar.onCreated(function() {
this.subscribe("UpdateVersion"); this.subscribe("UpdateVersion");
this.subscribe("assignment");
}); });
Template.headerBar.onRendered(function() { Template.headerBar.onRendered(function() {
var elems = document.querySelectorAll('.sidenav'); var elems = document.querySelectorAll('.sidenav');
var instances = M.Sidenav.init(elems, {}); var instances = M.Sidenav.init(elems, {});
var elemd = document.querySelectorAll('.dropdown-trigger'); var elemd = document.querySelectorAll('.dropdown-trigger');
var instances = M.Dropdown.init(elemd, {}); var instances = M.Dropdown.init(elemd, {});
setTimeout(function() {
const getRoles = async() => {
let userId = Meteor.userId();
// let isRole = await Roles.userIsInRoleAsync(userId, "systemadmin");
let isRole = await Roles.getRolesForUserAsync(userId);
try {
if (!isRole) {
console.log("SystemAdmin role for user not found: " + isRole);;
} else {
console.log("Found role for the user: ");
console.dir(isRole);
}
} catch(error) {
console.log(" ERROR getting role for user: " + error);
}
}
getRoles();
}, 1000);
}); });
Template.headerBar.helpers({ Template.headerBar.helpers({

View file

@ -48,6 +48,7 @@ Template.listItemsForm.helpers({
} }
}, },
itemProdName: function() { itemProdName: function() {
return Products.find({}); return Products.find({});
}, },
editMode: function() { editMode: function() {
@ -66,14 +67,7 @@ Template.listItemsForm.events({
if (item == null || item == "") { if (item == null || item == "") {
Session.set("itemReqErr", true); Session.set("itemReqErr", true);
} else { } else {
Meteor.call("add.listItem", item, listId, function(err, result) { addItem(item, listId);
if (err) {
console.log(" ERROR adding item to list: " + err);
} else {
console.log(" SUCCESS adding item to list.");
$("#findListItems").val("");
}
});
} }
}, },
'keydown #findListItems' (event) { 'keydown #findListItems' (event) {
@ -83,14 +77,7 @@ Template.listItemsForm.events({
if (item == null || item == "") { if (item == null || item == "") {
Session.set("itemReqErr", true); Session.set("itemReqErr", true);
} else { } else {
Meteor.call("add.listItem", item, listId, function(err, result) { addItem(item, listId);
if (err) {
console.log(" ERROR adding item to list: " + err);
} else {
console.log(" SUCCESS adding item to list.");
$("#findListItems").val("");
}
});
} }
} }
}, },
@ -110,8 +97,11 @@ Template.listItemsForm.events({
'keyup #findListItems' (event) { 'keyup #findListItems' (event) {
if (event.which !== 13) { if (event.which !== 13) {
let findItemVal = $("#findListItems").val(); let findItemVal = $("#findListItems").val();
// console.log(findItemVal);
let listItemInfo = Products.find({ prodName: {$regex: findItemVal + '.*', $options: 'i'}}).fetch(); let listItemInfo = Products.find({ prodName: {$regex: findItemVal + '.*', $options: 'i'}}).fetch();
if (typeof listItemInfo != 'undefined' && listItemInfo != "" && listItemInfo != null) { if (!listItemInfo) {
console.log("No data for key input.");
} else {
getDataList(listItemInfo); getDataList(listItemInfo);
} }
} }
@ -128,7 +118,21 @@ Template.listItemsForm.events({
}); });
getDataList = function(listItemInfo) { getDataList = function(listItemInfo) {
// console.log(listItemInfo);
let listItemObjArray = []; let listItemObjArray = [];
listItemObjArray = listItemInfo.map(info => ({ id: info._id, text: info.prodName, store: info.prodStore })) listItemObjArray = listItemInfo.map(info => ({ id: info._id, text: info.prodName, store: info.prodStore }))
Session.set("findListItems", listItemObjArray); Session.set("findListItems", listItemObjArray);
} }
const addItem = async(item, listId) => {
let result = await Meteor.callAsync("add.listItem", item, listId);
try {
if (!result) {
console.log(" ISSUE adding list item. See logs.");
} else {
$("#findListItems").val("");
}
} catch(error) {
console.log(" ERROR adding list item: " + error);
}
}

View file

@ -22,13 +22,13 @@ Template.listItemsTbl.helpers({
let showRecvd = Session.get("showReceivedItems"); let showRecvd = Session.get("showReceivedItems");
let searchVal = Session.get("searchVal"); let searchVal = Session.get("searchVal");
if (showRecvd == false) { if (showRecvd == false) {
if (typeof searchVal == 'undefined' || searchVal.length === 0) { if (!searchVal) {
return ListItems.find({ itemReceived: false }); return ListItems.find({ itemReceived: false });
} else { } else {
return ListItems.find({ itemReceived: false, itemName: { $regex: searchVal + '.*', $options: 'i' } }); return ListItems.find({ itemReceived: false, itemName: { $regex: searchVal + '.*', $options: 'i' } });
} }
} else { } else {
if (typeof searchVal == 'undefined' || searchVal.length == 0) { if (!searchVal) {
return ListItems.find({}); return ListItems.find({});
} else { } else {
return ListItems.find({ itemName: { $regex: searchVal + '.*', $options: 'i' } }); return ListItems.find({ itemName: { $regex: searchVal + '.*', $options: 'i' } });

View file

@ -1,5 +1,6 @@
import { Lists } from '../../imports/api/lists.js'; import { Lists } from '../../imports/api/lists.js';
import { M } from '../lib/assets/materialize.js'; import { M } from '../lib/assets/materialize.js';
import { FlowRouter } from 'meteor/ostrio:flow-router-extra';
Template.listsTbl.onCreated(function() { Template.listsTbl.onCreated(function() {
this.subscribe("myLists"); this.subscribe("myLists");
@ -25,17 +26,19 @@ Template.listsTbl.events({
if (listId == "addList") { if (listId == "addList") {
// opens the modal and allows you to add a new List // opens the modal and allows you to add a new List
} else { } else {
// console.log("listId is: " + listId); console.log("listId is: " + listId);
Session.set("listId", listId); Session.set("listId", listId);
Meteor.call('add.userLast', "List", listId, function(err, result) { const addUserLast = async() => {
if (err) { let result = await Meteor.callAsync('add.userLast', "List", listId);
if (!result) {
console.log(" ERROR setting user last list id in db: " + err); console.log(" ERROR setting user last list id in db: " + err);
} else { } else {
Meteor.setTimeout(function() { setTimeout(function() {
FlowRouter.go('/listitems'); FlowRouter.go('/listitems');
}, 100); }, 100);
} }
}); }
addUserLast();
} }
} }
}, },
@ -47,15 +50,17 @@ Template.listsTbl.events({
let splitList = listFullId.split("_"); let splitList = listFullId.split("_");
let listId = splitList[1]; let listId = splitList[1];
// console.log("listId is " + listId); // console.log("listId is " + listId);
Meteor.call("mark.complete", listId, function(err, result){ const markComp = async() => {
if (err) { let result = await Meteor.callAsync("mark.complete", listId);
console.log(" ERROR marking list complete! " + err); if (!result) {
console.log(" ERROR marking list complete!");
showSnackbar("ERROR! List Not Makred Complete!", "red"); showSnackbar("ERROR! List Not Makred Complete!", "red");
} else { } else {
// console.log(" SUCCESS marking list complete."); // console.log(" SUCCESS marking list complete.");
showSnackbar("List Marked Complete!", "green"); showSnackbar("List Marked Complete!", "green");
} }
}); }
markComp();
} }
} }
}); });

View file

@ -7,20 +7,27 @@ Template.MainLayout.onCreated(function() {
Template.MainLayout.onRendered(function() { Template.MainLayout.onRendered(function() {
this.autorun(() => { this.autorun(() => {
let myId = Meteor.userId(); let myId = Meteor.userId();
let myprefs = UserConfig.findOne({ user: myId }); const getConfig = async() => {
if (typeof myprefs != 'undefined') { let myprefs = await UserConfig.findOneAsync({ user: myId });
if (myprefs.darkMode == "light") { try {
console.log("Found theme as light"); if (!myprefs) {
Session.set("myTheme", "light"); console.log("User Prefs appear undefined.");
document.documentElement.setAttribute('theme', "light"); } else {
} else { if (myprefs.darkMode == "light") {
console.log("Found theme as dark"); console.log("Found theme as light");
Session.set("myTheme", "dark"); Session.set("myTheme", "light");
document.documentElement.setAttribute('theme', "dark"); document.documentElement.setAttribute('theme', "light");
} } else {
} else { console.log("Found theme as dark");
console.log("User Prefs appear undefined."); Session.set("myTheme", "dark");
document.documentElement.setAttribute('theme', "dark");
}
}
} catch(error) {
console.log(" ERROR getting user preferences: " + error);
}
} }
getConfig();
}); });
}); });

View file

@ -53,12 +53,14 @@ Template.addProdToListModal.events({
event.preventDefault(); event.preventDefault();
let selectedItems = Session.get("itemsSelected"); let selectedItems = Session.get("itemsSelected");
let listId = $("#chooseList").val(); let listId = $("#chooseList").val();
Meteor.call('add.itemsFromMenuItem', selectedItems, listId, function(err, result) { const addItemsFromMenu = async() => {
if (err) { let result = await Meteor.callAsync('add.itemsFromMenuItem', selectedItems, listId);
if (!result) {
console.log(" ERROR adding menu components to list: " + err); console.log(" ERROR adding menu components to list: " + err);
} else { } else {
showSnackbar("Items Added to List!", "green"); showSnackbar("Items Added to List!", "green");
} }
}); }
addItemsFromMenu();
} }
}); });

View file

@ -38,13 +38,27 @@ Template.menuItemsForm.helpers({
if (Session.get("menuId")) { if (Session.get("menuId")) {
menuId = Session.get("menuId"); menuId = Session.get("menuId");
} else { } else {
menuId = UserLast.findOne({ view: "Menu" }).viewId; const menuInfor = async() => {
let result = await UserLast.findOneAsync({ view: "Menu" }).viewId;
if (!result) {
} else {
return result;
}
}
let menuId = menuInfor();
} }
let menuInfo = Menus.findOne({ _id: menuId }); const menuData = async() => {
if (menuInfo) { let menuInfo = await Menus.findOneAsync({ _id: menuId });
return menuInfo.menuName; if (!menuInfo) {
return;
} else {
return menuInfo.menuName;
}
} }
let menuInformation = menuData();
return menuInformation;
} }
}); });
@ -55,10 +69,54 @@ Template.menuItemsForm.events({
let dateSrv = $("#dateServed").val(); let dateSrv = $("#dateServed").val();
let menuId = Session.get("menuId"); let menuId = Session.get("menuId");
const mie = async() => {
let menuItemExists = await MenuItems.findOneAsync({ itemName: menuItem });
if (!menuItemExists) {
// call to add it
notExists();
} else {
// call to add it to the menu only
itExists(menuItemExists);
}
}
mie();
let menuItemExists = MenuItems.findOne({ itemName: menuItem }); const notExists = async() => {
// add the item as new and add to the menu
if (menuItem == null || menuItem == "") {
Session.set("menuItemErr", true);
} else {
const addMenuItem = async() => {
let result = await Meteor.callAsync('add.menuItem', menuItem);
if (!result) {
console.log(" ERROR adding menu item: " + err);
} else {
// console.log(" SUCCESS adding menu item.");
return result;
}
}
let addedItem = addMenuItem();
if (typeof menuItemExists != 'undefined' && menuItemExists != null && menuItemExists != "") { if (!addedItem) {
console.log("Item was not added.");
} else {
// now add this item to the menu
const addToMenu = async() => {
let result2 = await Meteor.callAsync('addto.Menu', menuId, menuItem, result, dateSrv);
if (!result2) {
console.log(" ERROR adding menuitem to menu: " + error);
} else {
$("#menuItemInp").val("");
$("#dateServed").val("");
// console.log("Added item to menu - no problem.");
}
}
addToMenu();
}
}
}
const itExists = async(menuItemExists) => {
// use the existing item on the menu // use the existing item on the menu
let menuItemId = menuItemExists._id; let menuItemId = menuItemExists._id;
let isLinked = menuItemExists.isLinked; let isLinked = menuItemExists.isLinked;
@ -75,30 +133,6 @@ Template.menuItemsForm.events({
} }
}); });
} }
} else {
// add the item as new and add to the menu
if (menuItem == null || menuItem == "") {
Session.set("menuItemErr", true);
} else {
Meteor.call('add.menuItem', menuItem, function(err, result) {
if (err) {
console.log(" ERROR adding menu item: " + err);
} else {
// console.log(" SUCCESS adding menu item.");
$("#menuItemInp").val("");
$("#dateServed").val("");
// now add this item to the menu
Meteor.call('addto.Menu', menuId, menuItem, result, dateSrv, false, function(error, nresult) {
if (error) {
console.log(" ERROR adding menuitem to menu: " + error);
} else {
// console.log("Added item to menu - no problem.");
}
});
}
});
}
} }
}, },
'click .shiftOneDay' (event) { 'click .shiftOneDay' (event) {
@ -110,13 +144,14 @@ Template.menuItemsForm.events({
let menuItemId = menuInfo[i]._id; let menuItemId = menuInfo[i]._id;
let momentAddDay = moment(menuInfo[i].serveDate).add(1, 'day').format("MMM DD, YYYY"); let momentAddDay = moment(menuInfo[i].serveDate).add(1, 'day').format("MMM DD, YYYY");
// console.log(momentAddDay); // console.log(momentAddDay);
Meteor.call('shiftDate', menuItemId, momentAddDay, function(err,result) { const shiftDay = async() => {
if (err) { let result = await Meteor.callAsync('shiftDate', menuItemId, momentAddDay);
if (!result) {
console.log(" ERROR shifting meal days: " + err); console.log(" ERROR shifting meal days: " + err);
} else { } else {
showSnackbar("Items Shifted Out by 1 Calendar Day", "green"); showSnackbar("Items Shifted Out by 1 Calendar Day", "green");
} }
}); }
} }
}, },
'keyup #menuItemInp' (event) { 'keyup #menuItemInp' (event) {

View file

@ -30,11 +30,21 @@ Template.menuItemsTbl.helpers({
if (Session.get("menuId")) { if (Session.get("menuId")) {
menuId = Session.get("menuId"); menuId = Session.get("menuId");
} else { } else {
menuId = UserLast.findOne({ view: "Menu" }).viewId; const menu = async() => {
let menId = await UserLast.findOneAsync({ view: "Menu" }).viewId;
if (!menId) {
} else {
return menId;
}
}
menuId = menu();
} }
let menuInfo = Menus.find({ _id: menuId }, { sort: { serveDateActual: 1 }}); if (menuId) {
if (menuInfo) { let menuInfo = Menus.find({ _id: menuId }, { sort: { serveDateActual: 1 }});
return menuInfo if (menuInfo) {
return menuInfo;
}
} }
} }
}); });

View file

@ -42,7 +42,7 @@ Template.modalLinkProducts.events({
let links = M.FormSelect.getInstance(linkSelect).getSelectedValues(); let links = M.FormSelect.getInstance(linkSelect).getSelectedValues();
if (typeof links != undefined && links != [] && links != null) { if (typeof links != undefined && links != [] && links != null) {
// let's split these links into their parts, and make an array of objects // let's split these links into their parts, and make an array of objects
for (i=0; i<links.length; i++) { for (let i=0; i<links.length; i++) {
let linkArray = links[i].split('|'); let linkArray = links[i].split('|');
let key = linkArray[0]; let key = linkArray[0];
let value = linkArray[1]; let value = linkArray[1];
@ -50,25 +50,33 @@ Template.modalLinkProducts.events({
linkObjArray.push(linkObj); linkObjArray.push(linkObj);
} }
Meteor.call("add.menuProdLinks", menuItemId, menuItemName, linkObjArray, function(err, result) { const addMenuProdLinks = async() => {
if (err) { let result = await Meteor.callAsync("add.menuProdLinks", menuItemId, menuItemName, linkObjArray);
if (!result) {
console.log(" ERROR adding product links to this menu item: " + err); console.log(" ERROR adding product links to this menu item: " + err);
} else { } else {
Meteor.call('update.menuItemLinked', menuItemId, true, function(err, result) { updMenuItemLinks();
if (err) {
console.log(" ERROR adding link to menu item: " + err);
} else {
Meteor.call('link.inMenu', menuItemId, true, function(error, nresult) {
if (error) {
console.log(" ERROR adding link to menu sub-item: " + error);
} else {
showSnackbar("Products added to Menu Item successfully!", "green");
}
});
}
});
} }
}); }
addMenuProdLinks();
const updMenuItemLinks = async() => {
let result = await Meteor.callAsync('update.menuItemLinked', menuItemId, true);
if (!result) {
console.log(" ERROR adding link to menu item: " + err);
} else {
linkInMenu();
}
}
const linkInMenu = async() => {
let result = await Meteor.callAsync('link.inMenu', menuItemId, true);
if (!result) {
console.log(" ERROR adding link to menu sub-item: " + error);
} else {
showSnackbar("Products added to Menu Item successfully!", "green");
}
}
} }
} }
}); });

View file

@ -27,14 +27,16 @@ Template.addMenuModal.events({
if (menuName == "" || menuName == null) { if (menuName == "" || menuName == null) {
Session.set("menuNameErr", true); Session.set("menuNameErr", true);
} else { } else {
Meteor.call("add.menu", menuName, function(err, result) { const addMenu = async() => {
if (err) { let result = await Meteor.callAsync("add.menu", menuName);
if (!result) {
console.log(" ERROR adding menu: " + err); console.log(" ERROR adding menu: " + err);
} else { } else {
console.log(" SUCCESS adding menu."); console.log(" SUCCESS adding menu.");
$("#menuNameInp").val(""); $("#menuNameInp").val("");
} }
}); }
addMenu();
} }
}, },
}); });

View file

@ -1,5 +1,6 @@
import { Menus } from '../../imports/api/menu.js'; import { Menus } from '../../imports/api/menu.js';
import { M } from '../lib/assets/materialize.js'; import { M } from '../lib/assets/materialize.js';
import { FlowRouter } from 'meteor/ostrio:flow-router-extra';
Template.mainMenuTbl.onCreated(function() { Template.mainMenuTbl.onCreated(function() {
this.subscribe("myMenus"); this.subscribe("myMenus");
@ -21,41 +22,48 @@ Template.mainMenuTbl.events({
'click li.collection-item' (event) { 'click li.collection-item' (event) {
event.preventDefault(); event.preventDefault();
let sender = event.target; let sender = event.target;
// console.log("Sender origination from: "); // console.log("Sender originated from: ");
// console.log(sender.localName); // console.log(sender.localName);
if (sender.localName == "li") { if (sender.localName == "li") {
let menuId = event.currentTarget.id; let menuId = event.currentTarget.id;
if (menuId == "addMenu") { if (menuId == "addMenu") {
// console.log("add menu clicked"); console.log("add menu clicked");
} else { } else {
// console.log("menuId is: " + menuId); console.log("menuId is: " + menuId);
Meteor.call('add.userLast', "Menu", menuId, function(err, result) { const addUserLast = async() => {
if (err) { let result = await Meteor.callAsync('add.userLast', "Menu", menuId);
console.log(" ERROR writing last menu viewed by user to db: " + err); if (!result) {
console.log(" ERROR writing last menu viewed by user to db.");
} else { } else {
Session.set("menuId", menuId); Session.set("menuId", menuId);
Meteor.setTimeout(function() { Meteor.setTimeout(function() {
FlowRouter.go('/menuitems'); FlowRouter.go('/menuitems');
}, 100); }, 100);
} }
}); }
addUserLast();
} }
} else if (sender.localName == "i") { } else if (sender.localName == "i") {
let menuId = this._id; let menuId = this._id;
Meteor.call("markMenu.complete", menuId, function(err, result) { const makrMenuComp = async() => {
if (err) { let result = await Meteor.callAsync("markMenu.complete", menuId);
console.log(" ERROR: can't mark menu complete: " + err); if (!result) {
console.log(" ERROR: can't mark menu complete.");
} else { } else {
console.log(" SUCCESS marking menu complete."); console.log(" SUCCESS marking menu complete.");
Meteor.call('setAllMade.menuItem', menuId, function(err, result) { setAllMade();
if (err) {
console.log(" ERROR: cannot set all items as made: " + err);
} else {
console.log(" SUCCESS setting all items made.");
}
});
} }
}); }
makrMenuComp();
const setAllMade = async() => {
let result = await Meteor.callAsync('setAllMade.menuItem', menuId);
if (!result) {
console.log(" ERROR: cannot set all items as made.");
} else {
console.log(" SUCCESS setting all items made.");
}
}
} }
}, },
}); });

View file

@ -40,7 +40,7 @@ Template.myTasksForm.events({
if (taskDateArray == null || taskDateArray == []|| taskDateArray == "") { if (taskDateArray == null || taskDateArray == []|| taskDateArray == "") {
taskDateErr = true; taskDateErr = true;
} else { } else {
for (i = 0; i < taskDateArray.length; i++) { for (let i = 0; i < taskDateArray.length; i++) {
// console.log(taskDateArray[i]); // console.log(taskDateArray[i]);
let actDateTask = new Date(taskDateArray[i]); let actDateTask = new Date(taskDateArray[i]);
actDate.push(actDateTask); actDate.push(actDateTask);
@ -49,10 +49,11 @@ Template.myTasksForm.events({
console.log("Date Error: " + taskDateErr + " - Name Error: " + taskNameErr); console.log("Date Error: " + taskDateErr + " - Name Error: " + taskNameErr);
if (taskDateErr == false && taskNameErr == false) { if (taskDateErr == false && taskNameErr == false) {
Meteor.call("add.task", taskNameArray, "self", "selfId", taskDateArray, actDate, function(err, result) { const addTask = async() => {
if (err) { let result = await Meteor.callAsync("add.task", taskNameArray, "self", "selfId", taskDateArray, actDate);
console.log(" ERROR adding task for self: " + err); if (!result) {
showSnackbar("ERROR adding task for self!", "red"); console.log(" ERROR adding task for self: ");
showSnackbar("Error adding task for self!", "red");
} else { } else {
console.log(" SUCCESS adding task for self."); console.log(" SUCCESS adding task for self.");
Session.set("taskDateArr", []); Session.set("taskDateArr", []);
@ -60,7 +61,8 @@ Template.myTasksForm.events({
$("#myTaskDate").val(""); $("#myTaskDate").val("");
showSnackbar("Added Tasks Successfully!", "green"); showSnackbar("Added Tasks Successfully!", "green");
} }
}); }
addTask();
} else { } else {
showSnackbar("Error! Both Task & Date are Required!", "red"); showSnackbar("Error! Both Task & Date are Required!", "red");
} }

View file

@ -55,15 +55,15 @@ Template.myTasksTbl.events({
'click .markMyTaskComplete' (event) { 'click .markMyTaskComplete' (event) {
event.preventDefault(); event.preventDefault();
let taskId = this._id; let taskId = this._id;
Meteor.call("markTask.complete", taskId, function(err, result) { const makrTaskComp = async() => {
if (err) { let result = await Meteor.callAsync("markTask.complete", taskId);
if (!result) {
console.log(" ERROR marking task completeL " + err); console.log(" ERROR marking task completeL " + err);
showSnackbar("ERROR Marking Task Complete!", "red"); showSnackbar("ERROR Marking Task Complete!", "red");
} else { } else {
showSnackbar("Successfully Marked Task Complete!", "green"); showSnackbar("Successfully Marked Task Complete!", "green");
} }
}); }
}, },
'click .deleteMyTask' (event) { 'click .deleteMyTask' (event) {
event.preventDefault(); event.preventDefault();

View file

@ -5,15 +5,29 @@ Template.userConfig.onCreated(function() {
}); });
Template.userConfig.onRendered(function() { Template.userConfig.onRendered(function() {
let myConfig = UserConfig.findOne({ user: Meteor.userId() }); const getConfig = async() => {
if (typeof myConfig != 'undefined') { // console.log("tried to get switch config.")
console.log("My Pref: " + myConfig.darkPref); let myConfig = await UserConfig.findOneAsync({ user: Meteor.userId() });
if (myConfig.darkMode == 'light') { try {
$("#darkMode").prop('checked', false); // console.dir(myConfig);
} else { if (!myConfig) {
$("#darkMode").prop('checked', true); // console.log("config not found, setting to light mode.");
$("#darkMode").prop('checked', false);
} else {
// console.log("My Pref: " + myConfig.darkMode);
if (myConfig.darkMode == 'light') {
$("#darkMode").prop('checked', false);
} else {
// console.log("should be checked.")
$("#darkMode").prop('checked', true);
}
}
} catch(error) {
console.log(" ERROR getting dark theme for setting swtich: " + error);
} }
} }
getConfig();
}); });
Template.userConfig.helpers({ Template.userConfig.helpers({
@ -22,23 +36,22 @@ Template.userConfig.helpers({
Template.userConfig.events({ Template.userConfig.events({
'click #darkMode' (event) { 'click #darkMode' (event) {
let darkModePref = $("#darkMode").prop('checked'); let darkModePref = $("#darkMode").prop('checked')
if (darkModePref == true) { if (darkModePref == true) {
Meteor.call('update.darkModePref', 'dark', function(err, reuslt) { let mode = 'dark';
if (err) { setDarkMode(mode);
console.log(" ERROR: could not set dark mode preference to dark: " + err);
} else {
showSnackbar("Dark Mode Preference Set to Dark", "green");
}
});
} else { } else {
Meteor.call('update.darkModePref', 'light', function(err, result) { let mode = 'light';
if (err) { setDarkMode(mode);
console.log(" ERROR: could not set dark mode preference to light: " + err);
} else {
showSnackbar("Dark Mode Preference Set to Light", "green");
}
});
} }
}, },
}); });
const setDarkMode = async(mode) => {
let result = await Meteor.callAsync('update.darkModePref', mode);
if (!result) {
console.log(" - Did not receive back a 'result' from the update.");
} else {
showSnackbar("Dark Mode Preference Set to " + mode, "green");
}
}

View file

@ -25,38 +25,48 @@ Meteor.methods({
let iname = itemName.charAt(0).toUpperCase() + itemName.slice(1); let iname = itemName.charAt(0).toUpperCase() + itemName.slice(1);
// look up the item from the Products collection // look up the item from the Products collection
let prodInfo = Products.findOne({ prodName: iname }); const prodIsIn = async() => {
if (!prodInfo) { let prodInfo = await Products.findOneAsync({ prodName: iname });
Meteor.call("add.product", itemName, [""], function(err, result) { try {
if (err) { if (!prodInfo) {
console.log(" ERROR adding item to products: " + err); // add product info first
} else { const addProd = async() => {
// console.log(" SUCCESS adding item to Products."); let added = await Meteor.callAsync("add.product", itemName, [""]);
if (!added) {
console.log(" ERROR adding item to products: " + err);
} else {
// console.log(" SUCCESS adding item to Products.");
return ListItems.insert({ return ListItems.insertAsync({
itemName: iname,
listId: listId,
prodId: result,
addedBy: this.userId,
itemStore: "",
itemOrdered: false,
itemReceived: false,
dateAddedToList: new Date(),
});
}
}
} else {
return ListItems.insertAsync({
itemName: iname, itemName: iname,
listId: listId, listId: listId,
prodId: result, prodId: prodInfo._id,
addedBy: this.userId, addedBy: this.userId,
itemStore: "", itemStore: prodInfo.prodStore,
itemOrdered: false, itemOrdered: false,
itemReceived: false, itemReceived: false,
dateAddedToList: new Date(), dateAddedToList: new Date(),
}); });
} }
}); } catch(error) {
} else { console.log(" ERROR adding new product and item: " + error);
return ListItems.insert({ }
itemName: iname,
listId: listId,
prodId: prodInfo._id,
addedBy: this.userId,
itemStore: prodInfo.prodStore,
itemOrdered: false,
itemReceived: false,
dateAddedToList: new Date(),
});
} }
let prodIn = prodIsIn();
return prodIn;
}, },
'add.itemsFromMenuItem' (itemIds, listId) { 'add.itemsFromMenuItem' (itemIds, listId) {
check(itemIds, [String]); check(itemIds, [String]);
@ -75,7 +85,7 @@ Meteor.methods({
if (onList == 0) { if (onList == 0) {
// now pull the product // now pull the product
let prodInfo = Products.findOne({ _id: itemIds[i] }); let prodInfo = Products.findOne({ _id: itemIds[i] });
ListItems.insert({ ListItems.insertAsync({
itemName: prodInfo.prodName, itemName: prodInfo.prodName,
listId: listId, listId: listId,
prodId: prodInfo._id, prodId: prodInfo._id,
@ -98,7 +108,7 @@ Meteor.methods({
throw new Meteor.Error('You are not allowed to set items as ordered. Make sure you are logged in with valid user credentials.'); throw new Meteor.Error('You are not allowed to set items as ordered. Make sure you are logged in with valid user credentials.');
} }
return ListItems.update({ _id: itemId }, { return ListItems.updateAsync({ _id: itemId }, {
$set: { $set: {
itemOrdered: true, itemOrdered: true,
dateOrdered: new Date(), dateOrdered: new Date(),
@ -116,7 +126,7 @@ Meteor.methods({
throw new Meteor.Error('You are not allowed to set items as not ordered. Make sure you are logged in with valid user credentials.'); throw new Meteor.Error('You are not allowed to set items as not ordered. Make sure you are logged in with valid user credentials.');
} }
return ListItems.update({ _id: itemId }, { return ListItems.updateAsync({ _id: itemId }, {
$set: { $set: {
itemOrdered: false, itemOrdered: false,
dateUnOrdered: new Date(), dateUnOrdered: new Date(),
@ -130,7 +140,7 @@ Meteor.methods({
throw new Meteor.Error('You are not allowed to set items as received. Make sure you are logged in with valid user credentials.'); throw new Meteor.Error('You are not allowed to set items as received. Make sure you are logged in with valid user credentials.');
} }
return ListItems.update({ _id: itemId }, { return ListItems.updateAsync({ _id: itemId }, {
$set: { $set: {
itemReceived: true, itemReceived: true,
dateReceived: new Date(), dateReceived: new Date(),
@ -145,7 +155,7 @@ Meteor.methods({
throw new Meteor.Error('You are not allowed to set items as not received. Make sure you are logged in with valid user credentials.'); throw new Meteor.Error('You are not allowed to set items as not received. Make sure you are logged in with valid user credentials.');
} }
return ListItems.update({ _id: itemId }, { return ListItems.updateAsync({ _id: itemId }, {
$set: { $set: {
itemReceived: false, itemReceived: false,
dateNotReceived: new Date(), dateNotReceived: new Date(),
@ -164,7 +174,7 @@ Meteor.methods({
throw new Meteor.Error('You are not allowed to add items. Make sure you are logged in with valid user credentials.'); throw new Meteor.Error('You are not allowed to add items. Make sure you are logged in with valid user credentials.');
} }
return ListItems.update({ _id: itemId }, { return ListItems.updateAsync({ _id: itemId }, {
$set: { $set: {
itemName: itemName, itemName: itemName,
} }
@ -177,6 +187,6 @@ Meteor.methods({
throw new Meteor.Error('You are not allowed to delete list items. Make sure you are logged in with valid user credentials.'); throw new Meteor.Error('You are not allowed to delete list items. Make sure you are logged in with valid user credentials.');
} }
return ListItems.remove({ _id: itemId }); return ListItems.removeAsync({ _id: itemId });
} }
}); });

View file

@ -20,7 +20,7 @@ Meteor.methods({
throw new Meteor.Error('You are not allowed to add lists. Make sure you are logged in with valid user credentials.'); throw new Meteor.Error('You are not allowed to add lists. Make sure you are logged in with valid user credentials.');
} }
return Lists.insert({ return Lists.insertAsync({
listName: listName, listName: listName,
listShared: isShared, listShared: isShared,
listOwner: this.userId, listOwner: this.userId,
@ -36,7 +36,7 @@ Meteor.methods({
throw new Meteor.Error('You are not allowed to edit lists. Make sure you are logged in with valid user credentials.'); throw new Meteor.Error('You are not allowed to edit lists. Make sure you are logged in with valid user credentials.');
} }
return Lists.update({ _id: listId }, { return Lists.updateAsync({ _id: listId }, {
$set: { $set: {
listName: listName, listName: listName,
listShared: isShared, listShared: isShared,
@ -50,7 +50,7 @@ Meteor.methods({
throw new Meteor.Error('You are not allowed to delete lists. Make sure you are logged in with valid user credentials.'); throw new Meteor.Error('You are not allowed to delete lists. Make sure you are logged in with valid user credentials.');
} }
return Lists.remove({ _id: listId }); return Lists.removeAsync({ _id: listId });
}, },
'mark.complete' (listId) { 'mark.complete' (listId) {
check(listId, String); check(listId, String);
@ -59,7 +59,7 @@ Meteor.methods({
throw new Meteor.Error('You are not allowed to mark lists complete. Make sure you are logged in with valid user credentials.'); throw new Meteor.Error('You are not allowed to mark lists complete. Make sure you are logged in with valid user credentials.');
} }
return Lists.update({ _id: listId }, { return Lists.updateAsync({ _id: listId }, {
$set: { $set: {
listComplete: true, listComplete: true,
completedOn: new Date() completedOn: new Date()
@ -73,7 +73,7 @@ Meteor.methods({
throw new Meteor.Error('You are not allowed to restore completed lists. Make sure you are logged in with valid user credentials.'); throw new Meteor.Error('You are not allowed to restore completed lists. Make sure you are logged in with valid user credentials.');
} }
return Lists.update({ _id: listId }, { return Lists.updateAsync({ _id: listId }, {
$set: { $set: {
listComplete: false, listComplete: false,
completedOn: new Date() completedOn: new Date()
@ -85,6 +85,6 @@ Meteor.methods({
throw new Meteor.Error('You are not allowed to clean up old lists. Make sure you are logged in with valid user credentials.'); throw new Meteor.Error('You are not allowed to clean up old lists. Make sure you are logged in with valid user credentials.');
} }
return Lists.remove({ listComplete: true }); return Lists.removeAsync({ listComplete: true });
}, },
}); });

View file

@ -15,7 +15,7 @@ Meteor.methods({
'set.ScriptRun' (scriptName) { 'set.ScriptRun' (scriptName) {
check(scriptName, String); check(scriptName, String);
MScripts.insert({ MScripts.insertAsync({
scriptName: scriptName, scriptName: scriptName,
hasRun: true, hasRun: true,
runOn: new Date(), runOn: new Date(),

View file

@ -22,7 +22,7 @@ Meteor.methods({
throw new Meteor.Error('You are not allowed to add menus. Make sure you are logged in with valid user credentials.'); throw new Meteor.Error('You are not allowed to add menus. Make sure you are logged in with valid user credentials.');
} }
return Menus.insert({ return Menus.insertAsync({
menuName: menuName, menuName: menuName,
menuOwner: this.userId, menuOwner: this.userId,
menuComplete: false, menuComplete: false,
@ -36,7 +36,7 @@ Meteor.methods({
throw new Meteor.Error('You are not allowed to edit menus. Make sure you are logged in with valid user credentials.'); throw new Meteor.Error('You are not allowed to edit menus. Make sure you are logged in with valid user credentials.');
} }
return Menus.update({ _id: menuId }, { return Menus.updateAsync({ _id: menuId }, {
$set: { $set: {
menuName: menuName, menuName: menuName,
} }
@ -49,7 +49,7 @@ Meteor.methods({
throw new Meteor.Error('You are not allowed to delete menus. Make sure you are logged in with valid user credentials.'); throw new Meteor.Error('You are not allowed to delete menus. Make sure you are logged in with valid user credentials.');
} }
return Menus.remove({ _id: menuId }); return Menus.removeAsync({ _id: menuId });
}, },
'markMenu.complete' (menuId) { 'markMenu.complete' (menuId) {
check(menuId, String); check(menuId, String);
@ -58,7 +58,7 @@ Meteor.methods({
throw new Meteor.Error('You are not allowed to mark menus complete. Make sure you are logged in with valid user credentials.'); throw new Meteor.Error('You are not allowed to mark menus complete. Make sure you are logged in with valid user credentials.');
} }
return Menus.update({ _id: menuId }, { return Menus.updateAsync({ _id: menuId }, {
$set: { $set: {
menuComplete: true, menuComplete: true,
} }
@ -71,7 +71,7 @@ Meteor.methods({
throw new Meteor.Error('You are not allowed to mark menus not complete. Make sure you are logged in with valid user credentials.'); throw new Meteor.Error('You are not allowed to mark menus not complete. Make sure you are logged in with valid user credentials.');
} }
return Menus.update({ _id: menuId }, { return Menus.updateAsync({ _id: menuId }, {
$set: { $set: {
menuComplete: false, menuComplete: false,
} }
@ -90,7 +90,7 @@ Meteor.methods({
for (i=0; i < menuList.length; i++) { for (i=0; i < menuList.length; i++) {
let removeMenu = true; let removeMenu = true;
let items = MenuItems.find({ menuId: menuList[i]._id }).fetch(); let items = MenuItems.find({ menuId: menuList[i]._id }).fetch();
for (j=0; j < items.length; j++) { for (let j=0; j < items.length; j++) {
let srvDate = moment(items[j].serveDateActual); let srvDate = moment(items[j].serveDateActual);
let today = moment(); let today = moment();
let expired = moment(today).isAfter(srvDate); let expired = moment(today).isAfter(srvDate);
@ -107,14 +107,14 @@ Meteor.methods({
// next let's add the ids of any menus that are marked complete // next let's add the ids of any menus that are marked complete
let markedComplete = Menus.find({ menuComplete: true }).fetch(); let markedComplete = Menus.find({ menuComplete: true }).fetch();
for (k = 0; k < markedComplete.length; k++) { for (let k = 0; k < markedComplete.length; k++) {
let menuId = markedComplete[k]._id; let menuId = markedComplete[k]._id;
removeMenuIds.push(menuId); removeMenuIds.push(menuId);
} }
// finally we'll cycle through the ids and remove the items we collected up. // finally we'll cycle through the ids and remove the items we collected up.
for (l = 0; l < removeMenuIds.length; l++) { for (let l = 0; l < removeMenuIds.length; l++) {
Menus.remove({ _id: removeMenuIds[l] }); Menus.removeAsync({ _id: removeMenuIds[l] });
} }
}, },
'addto.Menu' (menuId, menuItem, menuItemId, dateSrv, isLinked) { 'addto.Menu' (menuId, menuItem, menuItemId, dateSrv, isLinked) {
@ -130,7 +130,7 @@ Meteor.methods({
serveDateActual = new Date(dateSrv); serveDateActual = new Date(dateSrv);
return Menus.update({ _id: menuId }, { return Menus.updateAsync({ _id: menuId }, {
$addToSet: { $addToSet: {
menuItems: menuItems:
{ {
@ -151,7 +151,7 @@ Meteor.methods({
throw new Meteor.Error('You are not allowed to link menu items to products. Make sure you are logged in with valid user credentials.'); throw new Meteor.Error('You are not allowed to link menu items to products. Make sure you are logged in with valid user credentials.');
} }
return Menus.update({ 'menuItems.menuItemId': menuItemId }, { return Menus.updateAsync({ 'menuItems.menuItemId': menuItemId }, {
$set: { $set: {
"menuItems.$.isLinked": isLinked "menuItems.$.isLinked": isLinked
} }
@ -167,7 +167,7 @@ Meteor.methods({
let ids = itemIds.split('_'); let ids = itemIds.split('_');
console.log("item ids: " + ids[0] + " and " + ids[1]); console.log("item ids: " + ids[0] + " and " + ids[1]);
return Menus.update({ _id: ids[0] }, { return Menus.updateAsync({ _id: ids[0] }, {
$pull: { $pull: {
menuItems: { menuItems: {
menuItemId: ids[1], menuItemId: ids[1],

View file

@ -19,7 +19,7 @@ Meteor.methods({
throw new Meteor.Error('You are not allowed to add items. Make sure you are logged in with valid user credentials.'); throw new Meteor.Error('You are not allowed to add items. Make sure you are logged in with valid user credentials.');
} }
return MenuItems.insert({ return MenuItems.insertAsync({
itemName: itemName, itemName: itemName,
addedBy: this.userId, addedBy: this.userId,
dateAddedtoMenu: new Date(), dateAddedtoMenu: new Date(),
@ -34,7 +34,7 @@ Meteor.methods({
throw new Meteor.Error('You are not allowed to set this menu item as linked to products. Make sure you are logged in with valid user credentials.'); throw new Meteor.Error('You are not allowed to set this menu item as linked to products. Make sure you are logged in with valid user credentials.');
} }
return MenuItems.update({ _id: itemId }, { return MenuItems.updateAsync({ _id: itemId }, {
$set: { $set: {
isLinked: isLinked, isLinked: isLinked,
} }
@ -48,7 +48,7 @@ Meteor.methods({
throw new Meteor.Error('You are not allowed to edit menu items. Make sure you are logged in with valid user credentials.'); throw new Meteor.Error('You are not allowed to edit menu items. Make sure you are logged in with valid user credentials.');
} }
return MenuItems.update({ _id: itemId }, { return MenuItems.updateAsync({ _id: itemId }, {
$set: { $set: {
itemName: itemName, itemName: itemName,
} }
@ -61,7 +61,7 @@ Meteor.methods({
throw new Meteor.Error('You are not allowed to delete menu items. Make sure you are logged in with valid user credentials.'); throw new Meteor.Error('You are not allowed to delete menu items. Make sure you are logged in with valid user credentials.');
} }
return MenuItems.remove({ _id: itemId }); return MenuItems.removeAsync({ _id: itemId });
}, },
'shiftDate' (itemId, momentAddDay) { 'shiftDate' (itemId, momentAddDay) {
check(itemId, String); check(itemId, String);
@ -71,7 +71,7 @@ Meteor.methods({
throw new Meteor.Error('You are not allowed to shift menu item dates. Make sure you are logged in with valid user credentials.'); throw new Meteor.Error('You are not allowed to shift menu item dates. Make sure you are logged in with valid user credentials.');
} }
return MenuItems.update({ _id: itemId }, { return MenuItems.updateAsync({ _id: itemId }, {
$set: { $set: {
serveDate: momentAddDay, serveDate: momentAddDay,
} }

View file

@ -34,7 +34,7 @@ Meteor.methods({
} }
}); });
} else { } else {
return MenuProdLinks.insert({ return MenuProdLinks.insertAsync({
menuItemId: menuItemId, menuItemId: menuItemId,
menuItemName: menuItemName, menuItemName: menuItemName,
products: prodNameArray, products: prodNameArray,
@ -52,7 +52,7 @@ Meteor.methods({
throw new Meteor.Error('You are not allowed to add menu and product links. Make sure you are logged in with valid user credentials.'); throw new Meteor.Error('You are not allowed to add menu and product links. Make sure you are logged in with valid user credentials.');
}; };
return MenuProdLinks.update({ menuItemId: menuItemId }, { return MenuProdLinks.updateAsync({ menuItemId: menuItemId }, {
$set: { $set: {
products: prodNameArray, products: prodNameArray,
dateUpdated: Date(), dateUpdated: Date(),

View file

@ -24,15 +24,22 @@ Meteor.methods({
// first does this product already exist? // first does this product already exist?
let prodExists = Products.findOne({ prodName: pname }); const productIsIn = async() => {
let prodExists = await Products.findOneAsync({ prodName: pname });
if (!prodExists) { try {
return Products.insert({ if (!prodExists) {
prodName: pname, return Products.insertAsync({
prodOwner: this.userId, prodName: pname,
prodStore: prodStore, prodOwner: this.userId,
}); prodStore: prodStore,
});
}
} catch(error) {
console.log(" ERROR adding Pdocut: " + error);
}
} }
let prodIn = productIsIn();
return prodIn;
}, },
'edit.product' (prodId, prodName, prodStore) { 'edit.product' (prodId, prodName, prodStore) {
check(prodId, String); check(prodId, String);
@ -45,7 +52,7 @@ Meteor.methods({
let pname = prodName.charAt(0).toUpperCase() + prodName.slice(1); let pname = prodName.charAt(0).toUpperCase() + prodName.slice(1);
return Products.update({ _id: prodId }, { return Products.updateAsync({ _id: prodId }, {
$set: { $set: {
prodName: pname, prodName: pname,
prodStore: prodStore, prodStore: prodStore,
@ -59,6 +66,6 @@ Meteor.methods({
throw new Meteor.Error('You are not allowed to delete products. Make sure you are logged in with valid user credentials.'); throw new Meteor.Error('You are not allowed to delete products. Make sure you are logged in with valid user credentials.');
} }
return Products.remove({ _id: prodId }); return Products.removeAsync({ _id: prodId });
} }
}); });

View file

@ -21,7 +21,7 @@ Meteor.methods({
throw new Meteor.Error('You are not allowed to add recipe items. Make sure you are logged in with valid user credentials.'); throw new Meteor.Error('You are not allowed to add recipe items. Make sure you are logged in with valid user credentials.');
} }
return RecipeItems.insert({ return RecipeItems.insertAsync({
recipeId: recipeId, recipeId: recipeId,
recipeItemType: recipeItemType, recipeItemType: recipeItemType,
recipeItem: recipeItem, recipeItem: recipeItem,
@ -37,7 +37,7 @@ Meteor.methods({
throw new Meteor.Error('You are not allowed to edit recipe items. Make sure you are logged in with valid user credentials.'); throw new Meteor.Error('You are not allowed to edit recipe items. Make sure you are logged in with valid user credentials.');
} }
return RecipeItems.update({ _id: recipeItemId }, { return RecipeItems.updateAsync({ _id: recipeItemId }, {
$set: { $set: {
recipeId: recipeId, recipeId: recipeId,
recipeItemType: recipeItemType, recipeItemType: recipeItemType,
@ -52,6 +52,6 @@ Meteor.methods({
throw new Meteor.Error('You are not allowed to delete recipe items. Make sure you are logged in with valid user credentials.'); throw new Meteor.Error('You are not allowed to delete recipe items. Make sure you are logged in with valid user credentials.');
} }
return RecipeItems.remove({ _id: recipeItemId }); return RecipeItems.removeAsync({ _id: recipeItemId });
} }
}); });

View file

@ -19,7 +19,7 @@ Meteor.methods({
throw new Meteor.Error('You are not allowed to add recipes. Make sure you are logged in with valid user credentials.'); throw new Meteor.Error('You are not allowed to add recipes. Make sure you are logged in with valid user credentials.');
} }
return Recipes.insert({ return Recipes.insertAsync({
recipeName: recipeName, recipeName: recipeName,
addedBy: this.userId, addedBy: this.userId,
addedOn: new Date(), addedOn: new Date(),
@ -33,7 +33,7 @@ Meteor.methods({
throw new Meteor.Error('You are not allowed to add recipes. Make sure you are logged in with valid user credentials.'); throw new Meteor.Error('You are not allowed to add recipes. Make sure you are logged in with valid user credentials.');
} }
return Recipes.update({ _id: recipeId }, { return Recipes.updateAsync({ _id: recipeId }, {
$set: { $set: {
recipeName: recipeName, recipeName: recipeName,
updatedOn: new Date(), updatedOn: new Date(),
@ -48,6 +48,6 @@ Meteor.methods({
throw new Meteor.Error('You are not allowed to delete recipes. Make sure you are logged in with valid user credentials.'); throw new Meteor.Error('You are not allowed to delete recipes. Make sure you are logged in with valid user credentials.');
} }
return Recipes.remove({ _id: recipeId }); return Recipes.removeAsync({ _id: recipeId });
} }
}); });

View file

@ -19,7 +19,7 @@ Meteor.methods({
throw new Meteor.Error('You are not allowed to add stores. Make sure you are logged in with valid user credentials.'); throw new Meteor.Error('You are not allowed to add stores. Make sure you are logged in with valid user credentials.');
} }
return Stores.insert({ return Stores.insertAsync({
storeName: storeName, storeName: storeName,
owner: this.userId, owner: this.userId,
}); });
@ -32,7 +32,7 @@ Meteor.methods({
throw new Meteor.Error('You are not allowed to edit stores. Make sure you are logged in with valid user credentials.'); throw new Meteor.Error('You are not allowed to edit stores. Make sure you are logged in with valid user credentials.');
} }
return Stores.update({ _id: storeId }, { return Stores.updateAsync({ _id: storeId }, {
$set: { $set: {
storeName: storeName, storeName: storeName,
} }
@ -45,6 +45,6 @@ Meteor.methods({
throw new Meteor.Error('You are not allowed to delete stores. Make sure you are logged in with valid user credentials.'); throw new Meteor.Error('You are not allowed to delete stores. Make sure you are logged in with valid user credentials.');
} }
return Stores.remove({ _id: storeId }); return Stores.removeAsync({ _id: storeId });
}, },
}); });

View file

@ -20,23 +20,37 @@ Meteor.methods({
throw new Meteor.Error('Not able to change registration setting. Make sure you are logged in with valid system administrator credentials.'); throw new Meteor.Error('Not able to change registration setting. Make sure you are logged in with valid system administrator credentials.');
} }
let curr = SysConfig.findOne({}); const currConfig = async() => {
if (typeof curr != 'undefined') { let curr = await SysConfig.findOneAsync({});
let configId = curr._id; if (!curr) {
Meteor.call('edit.noSysAdminReg', configId, admReg, genReg, function(err, result) { try {
if (err) { return SysConfig.insertAsync({
console.log(" ERROR updating sys admin reg: " + err); SysAdminReg: admReg,
dateAdded: new Date(),
allowReg: genReg,
});
} catch(error) {
console.log(" ERROR trying to insert system config:");
console.log(error.message);
console.log(error.stack);
}
} else {
try {
let configId = curr._id;
const addNoSys = await Meteor.callAsync('edit.noSysAdminReg', configId, admReg, genReg);
if (!addNoSys) {
console.log(" Couldn't edit the system config.");
} else { } else {
console.log("Success updating sys admin reg."); console.log("Success updating sys admin reg.");
} }
}); } catch(error) {
} else { console.log(" ERROR trying to pull current system config:");
return SysConfig.insert({ console.log(error.message);
SysAdminReg: admReg, console.log(error.stack);
dateAdded: new Date(), }
allowReg: genReg,
});
} }
}
currConfig();
}, },
'edit.noSysAdminReg' (configId, canReg, genReg) { 'edit.noSysAdminReg' (configId, canReg, genReg) {
check(canReg, Boolean); check(canReg, Boolean);
@ -47,7 +61,7 @@ Meteor.methods({
throw new Meteor.Error('Not able to change registration setting. Make sure you are logged in with valid system administrator credentials.'); throw new Meteor.Error('Not able to change registration setting. Make sure you are logged in with valid system administrator credentials.');
} }
return SysConfig.update({ _id: configId }, { return SysConfig.updateAsync({ _id: configId }, {
$set: { $set: {
SysAdminReg: canReg, SysAdminReg: canReg,
allowReg: genReg, allowReg: genReg,
@ -66,7 +80,7 @@ Meteor.methods({
let configId = curr._id; let configId = curr._id;
return SysConfig.update({ _id: configId }, { return SysConfig.updateAsync({ _id: configId }, {
$set: { $set: {
allowUpdates: allowUpdate, allowUpdates: allowUpdate,
} }

View file

@ -27,16 +27,23 @@ Meteor.methods({
let username; let username;
if (assignedTo == "self") { if (assignedTo == "self") {
let userInfo = Meteor.users.findOne({ _id: this.userId }); const uInfo = async() => {
username = userInfo.profile.fullname; let userInfo = await Meteor.users.findOneAsync({ _id: this.userId });
assignedToId = this.userId; if (!userInfo) {
console.log("No matching user info found.")
} else {
username = userInfo.profile.fullname;
assignedToId = this.userId;
}
}
uInfo();
} else { } else {
username = assignedTo; username = assignedTo;
} }
for (i=0; i < taskDateArr.length; i++) { for (i=0; i < taskDateArr.length; i++) {
for (j=0; j < taskNameArr.length; j++) { for (j=0; j < taskNameArr.length; j++) {
TaskItems.insert({ TaskItems.insertAsync({
taskName: taskNameArr[j].id, taskName: taskNameArr[j].id,
taskDate: taskDateArr[i], taskDate: taskDateArr[i],
actualDate: actDate[i], actualDate: actDate[i],
@ -62,14 +69,21 @@ Meteor.methods({
let username; let username;
if (assignedTo == "self") { if (assignedTo == "self") {
let userInfo = Meteor.users.findOne({ _id: this.userId }); const uInfo = async() => {
username = userInfo.profile.fullname; let userInfo = await Meteor.users.findOneAsync({ _id: this.userId });
assignedToId = this.userId; if (!userInfo) {
console.log("No matching user info found.")
} else {
username = userInfo.profile.fullname;
assignedToId = this.userId;
}
}
uInfo();
} else { } else {
username = assignedTo; username = assignedTo;
} }
return TaskItems.insert({ return TaskItems.insertAsync({
taskName: taskName, taskName: taskName,
taskDate: taskDate, taskDate: taskDate,
actualDate: actDate, actualDate: actDate,
@ -91,7 +105,7 @@ Meteor.methods({
throw new Meteor.Error('You are not allowed to edit tasks. Make sure you are logged in with valid user credentials.'); throw new Meteor.Error('You are not allowed to edit tasks. Make sure you are logged in with valid user credentials.');
} }
return TaskItems.update({ _id: taskId }, { return TaskItems.updateAsync({ _id: taskId }, {
$set: { $set: {
taskName: taskName, taskName: taskName,
taskDate: taskDate, taskDate: taskDate,
@ -108,7 +122,7 @@ Meteor.methods({
throw new Meteor.Error('You are not allowed to delete tasks. Make sure you are logged in with valid user credentials.'); throw new Meteor.Error('You are not allowed to delete tasks. Make sure you are logged in with valid user credentials.');
} }
return TaskItems.remove({ _id: taskId }); return TaskItems.removeAsync({ _id: taskId });
}, },
'markTask.complete' (taskId) { 'markTask.complete' (taskId) {
check(taskId, String); check(taskId, String);
@ -117,7 +131,7 @@ Meteor.methods({
throw new Meteor.Error('You are not allowed to mark tasks complete. Make sure you are logged in with valid user credentials.'); throw new Meteor.Error('You are not allowed to mark tasks complete. Make sure you are logged in with valid user credentials.');
} }
return TaskItems.update({ _id: taskId }, { return TaskItems.updateAsync({ _id: taskId }, {
$set: { $set: {
isComplete: true, isComplete: true,
completedOn: new Date(), completedOn: new Date(),
@ -132,7 +146,7 @@ Meteor.methods({
throw new Meteor.Error('You are not allowed to mark tasks not complete. Make sure you are logged in with valid user credentials.'); throw new Meteor.Error('You are not allowed to mark tasks not complete. Make sure you are logged in with valid user credentials.');
} }
return TaskItems.update({ _id: taskId }, { return TaskItems.updateAsync({ _id: taskId }, {
$set: { $set: {
isComplete: false, isComplete: false,
markedUncomplteOn: new Date(), markedUncomplteOn: new Date(),
@ -174,6 +188,6 @@ Meteor.methods({
break; break;
} }
return TaskItems.remove({ actualDate: { $lt: new Date((new Date()) - upToDate )}}); return TaskItems.removeAsync({ actualDate: { $lt: new Date((new Date()) - upToDate )}});
} }
}); });

View file

@ -15,7 +15,7 @@ Meteor.methods({
'add.updateInfo' (updateObject) { 'add.updateInfo' (updateObject) {
check(updateObject, Object); check(updateObject, Object);
UpdateInfo.insert({ return UpdateInfo.insertAsync({
title: updateObject.title, title: updateObject.title,
description: updateObject.description, description: updateObject.description,
dateRelease: updateObject.date, dateRelease: updateObject.date,
@ -29,7 +29,7 @@ Meteor.methods({
throw new Meteor.Error('You are not allowed to mark updates as read. Make sure you are logged in with valid user credentials.'); throw new Meteor.Error('You are not allowed to mark updates as read. Make sure you are logged in with valid user credentials.');
} }
return UpdateInfo.update({ _id: updateId }, { return UpdateInfo.updateAsync({ _id: updateId }, {
$set: { $set: {
viewed: true viewed: true
} }

View file

@ -9,6 +9,10 @@ UserConfig.allow({
// if use id exists, allow insert // if use id exists, allow insert
return !!userId; return !!userId;
}, },
update: function(userId, doc){
// if use id exists, allow insert
return !!userId;
},
}); });
Meteor.methods({ Meteor.methods({
@ -16,10 +20,10 @@ Meteor.methods({
check(pref, String); check(pref, String);
if (!this.userId) { if (!this.userId) {
throw new Meteor.Error('Not able to change registration setting. Make sure you are logged in with valid system administrator credentials.'); throw new Meteor.Error('Not able to change theme setting. Make sure you are logged in with valid system administrator credentials.');
} }
return UserConfig.insert({ return UserConfig.insertAsync({
user: this.userId, user: this.userId,
darkMode: pref, darkMode: pref,
dateAdded: Date() dateAdded: Date()
@ -29,23 +33,14 @@ Meteor.methods({
check(pref, String); check(pref, String);
if (!this.userId) { if (!this.userId) {
throw new Meteor.Error('Not able to change registration setting. Make sure you are logged in with valid system administrator credentials.'); throw new Meteor.Error('Not able to change theme setting. Make sure you are logged in with valid system administrator credentials.');
} }
let myConfig = UserConfig.findOne({ user: this.userId }); return UserConfig.updateAsync({ user: this.userId }, {
if (typeof myConfig == 'undefined') { $set: {
Meteor.call('add.darkModePref', pref, function(err, result) { darkMode: pref,
if (err) { dateUpdate: Date()
console.log(" ERROR calling the add functioin for dark mode: " + err); }
} });
});
} else {
return UserConfig.update({ user: this.userId }, {
$set: {
darkMode: pref,
dateUpdate: Date()
}
});
}
} }
}); });

View file

@ -16,6 +16,6 @@ Meteor.methods({
check(usersId, String); check(usersId, String);
check(password, String); check(password, String);
return Accounts.setPassword(usersId, password); return Accounts.setPasswordAsync(usersId, password);
}, },
}); });

View file

@ -22,22 +22,34 @@ Meteor.methods({
// first let's find out if there's an entry for this user and view, and if so // first let's find out if there's an entry for this user and view, and if so
// we'll just edit that entry with updated information // we'll just edit that entry with updated information
let userListInfo = UserLast.findOne({ userId: this.userId, view: view }); const getUserLast = async() => {
if (typeof userListInfo != 'undefined' && userListInfo != "" && userListInfo != null) { let userListInfo = await UserLast.findOneAsync({ userId: this.userId, view: view });
// entry exists, call the edit function instead if (!userListInfo) {
Meteor.call('edit.userLast', view, viewId, function(err, result) { console.log("Adding new user last item.");
if (err) { return UserLast.insertAsync({
console.log(" ERROR moving user to edit for last view: " + err); userId: this.userId,
view: view,
viewId: viewId,
dateAdded: Date(),
});
} else {
console.log("Editing existing user last itme.");
// entry exists, call the edit function instead
let result = await Meteor.callAsync('edit.userLast', view, viewId);
if (!result) {
try {
console.log("Issue editing existing entry in userLast. Check the logs.");
} catch(error) {
console.log(" ERROR adding userLast item: " + error);
console.log(error.message);
console.log(error.stack);
}
} else {
return true;
} }
}); }
} else {
return UserLast.insert({
userId: this.userId,
view: view,
viewId: viewId,
dateAdded: Date(),
});
} }
return getUserLast();
}, },
'edit.userLast' (view, viewId) { 'edit.userLast' (view, viewId) {
check(view, String); check(view, String);
@ -47,7 +59,8 @@ Meteor.methods({
throw new Meteor.Error('Not able to change user view last setting. Make sure you are logged in with valid system administrator credentials.'); throw new Meteor.Error('Not able to change user view last setting. Make sure you are logged in with valid system administrator credentials.');
} }
return UserLast.update({ view: view, userId: this.userId }, { console.log("Edit in progress.");
return UserLast.updateAsync({ view: view, userId: this.userId }, {
$set: { $set: {
viewId: viewId, viewId: viewId,
dateLastUpdate: Date(), dateLastUpdate: Date(),

View file

@ -1,132 +1,134 @@
import { FlowRouter } from 'meteor/ostrio:flow-router-extra';
FlowRouter.route('/dashboard', { FlowRouter.route('/dashboard', {
name: 'home', name: 'home',
action() { action() {
BlazeLayout.render('MainLayout', { main: "dashboard" }); this.render('MainLayout', { main: "dashboard" });
} }
}); });
FlowRouter.route('/', { FlowRouter.route('/', {
name: 'homeNoRoute', name: 'homeNoRoute',
action() { action() {
BlazeLayout.render('MainLayout', { main: "dashboard" }); this.render('MainLayout', { main: "dashboard" });
} }
}); });
FlowRouter.route('/', { FlowRouter.route('/', {
name: 'homeNotLoggedIn', name: 'homeNotLoggedIn',
action() { action() {
BlazeLayout.render('MainLayout', { notLoggedIn: "login" }); this.render('MainLayout', { notLoggedIn: "login" });
} }
}); });
FlowRouter.route('/login', { FlowRouter.route('/login', {
name: 'login', name: 'login',
action() { action() {
BlazeLayout.render('MainLayout', { notLoggedIn: "login" }); this.render('MainLayout', { notLoggedIn: "login" });
} }
}); });
FlowRouter.route('/reg', { FlowRouter.route('/reg', {
name: 'reg', name: 'reg',
action() { action() {
BlazeLayout.render('MainLayout', { notLoggedIn: "reg" }); this.render('MainLayout', { notLoggedIn: "reg" });
} }
}); });
FlowRouter.route('/userMgmt', { FlowRouter.route('/userMgmt', {
name: 'userMgmt', name: 'userMgmt',
action() { action() {
BlazeLayout.render('MainLayout', { main: 'userMgmt' }); this.render('MainLayout', { main: 'userMgmt' });
} }
}); });
FlowRouter.route('/manageStore', { FlowRouter.route('/manageStore', {
name: 'storeMgmt', name: 'storeMgmt',
action() { action() {
BlazeLayout.render('MainLayout', { main: 'storeMgmt' }); this.render('MainLayout', { main: 'storeMgmt' });
} }
}); });
FlowRouter.route('/manage', { FlowRouter.route('/manage', {
name: 'mgmtPage', name: 'mgmtPage',
action() { action() {
BlazeLayout.render('MainLayout', { main: 'mgmtPage' }); this.render('MainLayout', { main: 'mgmtPage' });
} }
}); });
FlowRouter.route('/manageProduct', { FlowRouter.route('/manageProduct', {
name: 'manageProduct', name: 'manageProduct',
action() { action() {
BlazeLayout.render('MainLayout', { main: 'prodMgmt' }); this.render('MainLayout', { main: 'prodMgmt' });
} }
}); });
FlowRouter.route('/manageLists', { FlowRouter.route('/manageLists', {
name: 'manageLists', name: 'manageLists',
action() { action() {
BlazeLayout.render('MainLayout', { main: 'listMgmt' }); this.render('MainLayout', { main: 'listMgmt' });
} }
}); });
FlowRouter.route('/mylists', { FlowRouter.route('/mylists', {
name: 'mylists', name: 'mylists',
action() { action() {
BlazeLayout.render('MainLayout', { main: 'listsMain' }); this.render('MainLayout', { main: 'listsMain' });
} }
}); });
FlowRouter.route('/listItems', { FlowRouter.route('/listItems', {
name: 'listItems', name: 'listItems',
action() { action() {
BlazeLayout.render('MainLayout', { main: 'listItemsMain' }); this.render('MainLayout', { main: 'listItemsMain' });
} }
}); });
FlowRouter.route('/mymenus', { FlowRouter.route('/mymenus', {
name: 'mymenus', name: 'mymenus',
action() { action() {
BlazeLayout.render('MainLayout', { main: 'mainMenu' }); this.render('MainLayout', { main: 'mainMenu' });
} }
}); });
FlowRouter.route('/menuItems', { FlowRouter.route('/menuItems', {
name: 'menuItems', name: 'menuItems',
action() { action() {
BlazeLayout.render('MainLayout', { main: 'menuItems' }); this.render('MainLayout', { main: 'menuItems' });
} }
}); });
FlowRouter.route('/taskHome', { FlowRouter.route('/taskHome', {
name: 'taskHome', name: 'taskHome',
action() { action() {
BlazeLayout.render('MainLayout', { main: 'taskHome' }); this.render('MainLayout', { main: 'taskHome' });
} }
}); });
FlowRouter.route('/myTasks', { FlowRouter.route('/myTasks', {
name: 'myTasks', name: 'myTasks',
action() { action() {
BlazeLayout.render('MainLayout', { main: 'myTasks' }); this.render('MainLayout', { main: 'myTasks' });
} }
}); });
FlowRouter.route('/systemAdmin', { FlowRouter.route('/systemAdmin', {
name: 'systemAdmin', name: 'systemAdmin',
action() { action() {
BlazeLayout.render('MainLayout', { main: 'systemAdmin' }); this.render('MainLayout', { main: 'systemAdmin' });
} }
}); });
FlowRouter.route('/cleanUp', { FlowRouter.route('/cleanUp', {
name: 'cleanUp', name: 'cleanUp',
action() { action() {
BlazeLayout.render('MainLayout', { main: 'cleanUp'}); this.render('MainLayout', { main: 'cleanUp'});
} }
}); });
FlowRouter.route('/mySettings', { FlowRouter.route('/mySettings', {
name: 'mySettings', name: 'mySettings',
action() { action() {
BlazeLayout.render('MainLayout', { main: 'userConfig'}); this.render('MainLayout', { main: 'userConfig'});
} }
}); });

1993
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -1,5 +1,5 @@
{ {
"name": "pPickup", "name": "get-my",
"private": true, "private": true,
"scripts": { "scripts": {
"start": "meteor run", "start": "meteor run",

View file

@ -1,3 +1,5 @@
// this file has been converted for meteor 3 and later
import { Meteor } from 'meteor/meteor'; import { Meteor } from 'meteor/meteor';
import { SysConfig } from '../imports/api/systemConfig'; import { SysConfig } from '../imports/api/systemConfig';
import { MenuItems } from '../imports/api/menuItems'; import { MenuItems } from '../imports/api/menuItems';
@ -5,142 +7,178 @@ import { Products } from '../imports/api/products.js';
import { Menus } from '../imports/api/menu.js'; import { Menus } from '../imports/api/menu.js';
import { MScripts } from '../imports/api/mScripts.js'; import { MScripts } from '../imports/api/mScripts.js';
import { UpdateInfo } from '../imports/api/updateInfo.js'; import { UpdateInfo } from '../imports/api/updateInfo.js';
import { Roles } from 'meteor/roles';
Meteor.startup(() => { Meteor.startup(async() => {
// code to run on server at startup // code to run on server at startup
Roles.createRole("user", {unlessExists: true}); Roles.createRoleAsync("user", {unlessExists: true});
Roles.createRole("admin", {unlessExists: true}); Roles.createRoleAsync("admin", {unlessExists: true});
Roles.createRole("systemadmin", {unlessExists: true}); Roles.createRoleAsync("systemadmin", {unlessExists: true});
// set the systemconfig defaults for registration // set the systemconfig defaults for registration
// check if this has already been run // check if this has already been run
let regPolRun = MScripts.findOne({ scriptName: "DefaultRegPolicy", scriptRun: true }); let regPolRun = await MScripts.findOneAsync({ scriptName: "DefaultRegPolicy", scriptRun: true });
if (typeof regPolRun == "undefined" || regPolRun == null || regPolRun == "") { if (!regPolRun) {
let regPolicy = SysConfig.findOne({}); try {
if (typeof regPolicy == 'undefined') { let regPolicy = await SysConfig.findOneAsync({});
return SysConfig.insert({ if (!regPolicy) {
SysAdminReg: false, SysConfig.insertAsync({
dateAdded: new Date(), SysAdminReg: false,
allowReg: true, dateAdded: new Date(),
allowUpdates: true, allowReg: true,
}); allowUpdates: true,
} else { });
// console.log("Registration policy already set."); markScriptRun("DefaultRegPolicy");
markScriptRun("DefaultRegPolicy"); } else {
} // console.log("Registration policy already set.");
markScriptRun("DefaultRegPolicy");
}
} catch(error) {
console.log(" ERROR trying to check if registration policy was set.");
console.log(error.message);
console.log(error.stack);
}
} }
// check if the isLInked item exists on menuitems, and if not, add it (data cleanup task) // check if the isLInked item exists on menuitems, and if not, add it (data cleanup task)
// see if already updated // see if already updated
let linkUpdateRun = MScripts.findOne({ scriptName: "updateMenuItemLinks", scriptRun: true }); let linkUpdateRun = await MScripts.findOneAsync({ scriptName: "updateMenuItemLinks", scriptRun: true });
if (typeof linkUpdateRun == 'undefined' || linkUpdateRun == null || linkUpdateRun == "") { try {
let itemInfoNoLink = MenuItems.find({ isLinked: { $exists: false } }).fetch(); if (!linkUpdateRun) {
// console.log("No Ites with isLinked not set: " + itemInfoNoLink.length); let itemInfoNoLink = MenuItems.find({ isLinked: { $exists: false } }).fetch();
if (itemInfoNoLink.length > 0) { // console.log("No Ites with isLinked not set: " + itemInfoNoLink.length);
// console.log("found items with isLinked not set."); if (itemInfoNoLink.length > 0) {
// console.dir(itemInfoNoLink); // console.log("Found items with isLinked not set. Updating...");
let infoLength = itemInfoNoLink.length; // console.dir(itemInfoNoLink);
for (i=0; i < infoLength; i++) { let infoLength = itemInfoNoLink.length;
MenuItems.update({ _id: itemInfoNoLink[i]._id }, { for (i=0; i < infoLength; i++) {
$set: { MenuItems.updateAsync({ _id: itemInfoNoLink[i]._id }, {
isLinked: false, $set: {
isLinked: false,
}
});
if (i == (infoLength -1)) {
markScriptRun("updateMenuItemLinks");
} }
});
if (i == (infoLength -1)) {
markScriptRun("updateMenuItemLinks");
} }
} else {
// this will show if all items are found to have isLInked set.
// console.log("No items with isLinked not set.");
markScriptRun("updateMenuItemLinks");
} }
} else {
// this will show if all items are found to have isLInked set.
// console.log("No items with isLinked not set.");
markScriptRun("updateMenuItemLinks");
} }
} catch(error) {
console.log(" ERROR running check for isLinked items.");
console.log(error.message);
console.log(error.stack);
} }
// update Products to be able to have multiple stores in the document // update Products to be able to have multiple stores in the document
// check if update already run // check if update already run
let prodStoreArrayRun = MScripts.findOne({ scriptName: "changeProdStoreToArray", scriptRun: true }); let prodStoreArrayRun = await MScripts.findOneAsync({ scriptName: "changeProdStoreToArray", scriptRun: true });
if (!prodStoreArrayRun) { if (!prodStoreArrayRun) {
let prodInfo = Products.find({}).fetch(); try {
let prodCount = prodInfo.length; let prodInfo = Products.find({}).fetch();
console.log("Updating Products to allow multiple store assocation for " + prodCount + " products."); let prodCount = prodInfo.length;
for (j = 0; j < prodCount; j++) { // console.log("Updating Products to allow multiple store assocation for " + prodCount + " products.");
if (typeof prodInfo[j].prodStore == 'object') { for (let j = 0; j < prodCount; j++) {
// console.log(typeof prodInfo[j].prodStore); if (typeof prodInfo[j].prodStore == 'object') {
// console.log("Is Array already"); // console.log(typeof prodInfo[j].prodStore);
} else { // console.log("Is Array already");
let prodStoreArray = []; } else {
// console.log("---- ---- ----"); let prodStoreArray = [];
// console.log(typeof prodInfo[j].prodStore); // console.log("---- ---- ----");
// console.log("---- Is Not Array."); // console.log(typeof prodInfo[j].prodStore);
let prodStore = prodInfo[j].prodStore; // console.log("---- Is Not Array.");
let prodStore = prodInfo[j].prodStore;
prodStoreArray.push(prodStore); prodStoreArray.push(prodStore);
// console.dir(prodStoreArray); // console.dir(prodStoreArray);
Products.update({ _id: prodInfo[j]._id }, { Products.update({ _id: prodInfo[j]._id }, {
$set: { $set: {
prodStore: prodStoreArray, prodStore: prodStoreArray,
} }
}); });
}
if (j == (prodCount -1)) {
markScriptRun("changeProdStoreToArray");
}
} }
if (j == (prodCount -1)) { } catch(error) {
markScriptRun("changeProdStoreToArray"); console.log("Script to update product stores couldn't run.");
} console.log(error.message);
} console.log(error.stack);
}
} }
// update menu items to new format so they get the linked products // update menu items to new format so they get the linked products
// check if this update has run // check if this update has run
let menuItemUpdRun = MScripts.findOne({ scriptName: "updateMenuProdLinks", scriptRun: true }); let menuItemUpdRun = await MScripts.findOneAsync({ scriptName: "updateMenuProdLinks", scriptRun: true });
if (!menuItemUpdRun) { if (!menuItemUpdRun) {
let openMenus = Menus.find({ menuComplete: false }).fetch(); try {
let openMenuCount = openMenus.length; let openMenus = Menus.find({ menuComplete: false }).fetch();
// console.log("Open Menu count is: " + openMenuCount); let openMenuCount = openMenus.length;
for (k = 0; k < openMenuCount; k++) { // console.log("Open Menu count is: " + openMenuCount);
if (typeof openMenus.menuItems == 'object') { for (let k = 0; k < openMenuCount; k++) {
// console.log(openMenus.menuName + " appears to be converted."); if (typeof openMenus.menuItems == 'object') {
markScriptRun("updateMenuProdLinks"); // console.log(openMenus.menuName + " appears to be converted.");
} else { markScriptRun("updateMenuProdLinks");
let menuId = openMenus[k]._id; } else {
let menuId = openMenus[k]._id;
let thisMenuItems = MenuItems.find({ menuId: menuId }).fetch(); let thisMenuItems = MenuItems.find({ menuId: menuId }).fetch();
let itemCount = thisMenuItems.length; let itemCount = thisMenuItems.length;
for (l = 0; l < itemCount; l++) { for (l = 0; l < itemCount; l++) {
Menus.update({ _id: menuId }, { Menus.update({ _id: menuId }, {
$addToSet: { $addToSet: {
menuItems: menuItems:
{ {
menuItemId: thisMenuItems[l]._id, menuItemId: thisMenuItems[l]._id,
menuItemName: thisMenuItems[l].itemName, menuItemName: thisMenuItems[l].itemName,
serveDate: thisMenuItems[l].serveDate, serveDate: thisMenuItems[l].serveDate,
serveDateActual: thisMenuItems[l].serveDateActual, serveDateActual: thisMenuItems[l].serveDateActual,
isLinked: thisMenuItems[l].isLinked isLinked: thisMenuItems[l].isLinked
}, },
} }
}); });
}
}
if (k == (openMenuCount - 1)) {
markScriptRun("updateMenuProdLinks");
} }
} }
if (k == (openMenuCount - 1)) { } catch(error) {
markScriptRun("updateMenuProdLinks"); console.log(" ERROR updating the menu product links: ");
} console.log(error.message);
} console.log(error.stack);
}
} else {
// console.log("Menu Item updates have already been run.");
} }
// get update available information if enabled in system confiuration // get update available information if enabled in system confiuration
let currConfig = SysConfig.findOne({}); let currConfig = await SysConfig.findOneAsync({});
let feedurl = "https://gitlab.com/bmcgonag/get_my/-/releases.atom" if (!currConfig) {
if (currConfig.allowUpdates == true) { // console.log("No Current Config found.")
// console.log("Allow Updates is true"); } else {
startCronForUpdates(feedurl); try {
} else if (typeof currConfig.allowUpdates == 'undefined' || currConfig.allowUpdates == null) { let feedurl = "https://gitlab.com/bmcgonag/get_my/-/releases.atom"
SysConfig.update({ _id: currConfig._id }, { $set: { if (currConfig.allowUpdates == true) {
allowUpdates: true, // console.log("Allow Updates is true");
}}); startCronForUpdates(feedurl);
startCronForUpdates(feedurl); } else if (typeof currConfig.allowUpdates == 'undefined' || currConfig.allowUpdates == null) {
SysConfig.update({ _id: currConfig._id }, { $set: {
allowUpdates: true,
}});
startCronForUpdates(feedurl);
}
} catch(error) {
console.log(" ERROR checking current config for updates: " + error);
console.log(error.message);
console.log(error.stack);
}
} }
}); });
@ -152,18 +190,23 @@ var startCronForUpdates = function(feedurl) {
}); });
} }
var markScriptRun = function(scriptName) { var markScriptRun = async function(scriptName) {
// check if this is already set // check if this is already set
let scriptRun = MScripts.findOne({ scriptName: scriptName }); let scriptRun = await MScripts.findOneAsync({ scriptName: scriptName });
if (!scriptRun) {
if (scriptRun) { try {
console.log(scriptName + " already set as run on " + scriptRun.runOn); return MScripts.insertAsync({
scriptName: scriptName,
scriptRun: true,
runOn: new Date()
});
} catch(error) {
console.log(" ERROR inserting the script run log: " + error);
console.log(error.message);
console.log(error.stack);
}
} else { } else {
MScripts.insert({ // console.log(scriptName + " already set as run on " + scriptRun.runOn);
scriptName: scriptName,
scriptRun: true,
runOn: new Date()
});
} }
} }
@ -175,16 +218,22 @@ var getUpdateInfoNow = async function(feedurl) {
// console.dir(data[0].title); // console.dir(data[0].title);
// check if this title already exists in db // check if this title already exists in db
let updatesExist = UpdateInfo.findOne({ title: data[0].title }); let updatesExist = await UpdateInfo.findOneAsync({ title: data[0].title });
if (!updatesExist) { try {
UpdateInfo.insert({ if (!updatesExist) {
title: data[0].title, UpdateInfo.insertAsync({
description: data[0].description, title: data[0].title,
dateRelease: data[0].date, description: data[0].description,
releaseLink: data[0].link, dateRelease: data[0].date,
viewed: false releaseLink: data[0].link,
}); viewed: false
} else { });
console.log("No new updates available at this time."); } else {
console.log("No new updates available at this time.");
}
} catch(error) {
console.log(" ERROR checking for update: " + error);
console.log(error.message);
console.log(error.stack);
} }
} }

View file

@ -3,52 +3,60 @@ import { Mongo } from 'meteor/mongo';
import { check } from 'meteor/check'; import { check } from 'meteor/check';
import { TaskItems } from '../imports/api/tasks'; import { TaskItems } from '../imports/api/tasks';
import { SysConfig } from '../imports/api/systemConfig'; import { SysConfig } from '../imports/api/systemConfig';
import { Roles } from 'meteor/roles';
Meteor.methods({ Meteor.methods({
'addToRole' (role) { 'addToRole' (role) {
let countOfUsers = Meteor.users.find().count(); const getUserInfo = async() => {
try {
// if users = 1 - set to role passed in function call let countOfUsers = await Meteor.users.find().countAsync();
if (countOfUsers > 1) { const user = await Meteor.userAsync();
console.log("User id for role: " + Meteor.userId() ); if (user) {
let userId = Meteor.userId(); let userId = user._id;
Roles.addUsersToRoles(userId, role); if (countOfUsers > 1) {
Meteor.call('add.darkModePref', "light", function(err, result) { Roles.addUsersToRolesAsync(userId, role);
if (err) { const result = await Meteor.callAsync('add.darkModePref', "light");
console.log(" ERROR: can't set user dark mode preference: " + err); if (!result) {
console.log(" ERROR: can't set user dark mode preference: " + err);
} else {
// console.log(" SUCCESSFULLY set user dark mode preference.");
}
} else if (countOfUsers == 1) {
Roles.addUsersToRolesAsync(userId, "systemadmin");
const result = await Meteor.callAsync('add.darkModePref', "light");
if (!result) {
console.log(" ERROR: can't set user dark mode preference: " + err);
} else {
console.log(" SUCCESSFULLY set user dark mode preference.");
}
} else {
console.log("The count of users didn't seem to work when adding a new user.");
}
} else { } else {
// console.log(" SUCCESSFULLY set user dark mode preference."); console.log(" ---- No user info found.")
} }
}); } catch(error) {
} else if (countOfUsers == 1) { console.log(" ERROR getting user info on server: " + error);
console.log("Creating first system admin user: " + Meteor.userId() ); }
let userId = Meteor.userId();
Roles.addUsersToRoles(userId, "systemadmin");
Meteor.call('add.darkModePref', "light", function(err, result) {
if (err) {
console.log(" ERROR: can't set user dark mode preference: " + err);
} else {
// console.log(" SUCCESSFULLY set user dark mode preference.");
}
});
} }
getUserInfo();
}, },
'edit.userPass' (userId, newPassword) { 'edit.userPass' (userId, newPassword) {
check(userId, String); check(userId, String);
check(newPassword, String); check(newPassword, String);
return Accounts.setPassword(userId, newPassword); return Accounts.setPasswordAsync(userId, newPassword);
}, },
'delete.userFromSys' (userId) { 'delete.userFromSys' (userId) {
check(userId, String); check(userId, String);
return Meteor.users.remove({ _id: userId }); return Meteor.users.removeAsync({ _id: userId });
}, },
'update.userEmail' (userId, email) { 'update.userEmail' (userId, email) {
check(userId, String); check(userId, String);
check(email, String); check(email, String);
return Meteor.users.update({ _id: userId }, { return Meteor.users.updateAsync({ _id: userId }, {
$set: { $set: {
'emails.0.address': email, 'emails.0.address': email,
} }
@ -58,6 +66,6 @@ Meteor.methods({
check(userId, String); check(userId, String);
check(role, String); check(role, String);
return Roles.setUserRoles(userId, role); return Roles.setUserRolesAsync(userId, role);
}, },
}); });

View file

@ -13,6 +13,13 @@ import { MenuProdLinks } from '../imports/api/menuProdLinks.js';
import { UserLast } from '../imports/api/userLast.js'; import { UserLast } from '../imports/api/userLast.js';
import { UpdateInfo } from '../imports/api/updateInfo.js'; import { UpdateInfo } from '../imports/api/updateInfo.js';
Meteor.publish(null, function () {
if (this.userId) {
return Meteor.roleAssignment.find({ "user._id": this.userId });
}
this.ready();
});
Meteor.publish("SystemConfig", function() { Meteor.publish("SystemConfig", function() {
try { try {
return SysConfig.find({}); return SysConfig.find({});