Compare commits

..

No commits in common. "main" and "1.1.2" have entirely different histories.
main ... 1.1.2

70 changed files with 1906 additions and 3030 deletions

View file

@ -4,27 +4,29 @@
# '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.2 # Packages every Meteor app needs to have meteor-base@1.5.1 # Packages every Meteor app needs to have
mobile-experience@1.1.2 # Packages for a great mobile UX mobile-experience@1.1.1 # Packages for a great mobile UX
mongo@2.1.4 # The database Meteor supports right now mongo@1.16.10 # 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.13 # Reactive variable for tracker reactive-var@1.0.12 # Reactive variable for tracker
tracker@1.3.4 # Meteor's client-side reactive programming library tracker@1.3.3 # Meteor's client-side reactive programming library
standard-minifier-css@1.9.3 # CSS minifier run for production mode standard-minifier-css@1.9.2 # CSS minifier run for production mode
standard-minifier-js@3.1.1 # JS minifier run for production mode standard-minifier-js@2.8.1 # JS minifier run for production mode
es5-shim@4.8.1 # ECMAScript 5 compatibility for older browsers es5-shim@4.8.0 # ECMAScript 5 compatibility for older browsers
ecmascript@0.16.13 # Enable ECMAScript2015+ syntax in app code ecmascript@0.16.8 # Enable ECMAScript2015+ syntax in app code
typescript@5.6.6 # Enable TypeScript syntax in .ts and .tsx modules typescript@4.9.5 # Enable TypeScript syntax in .ts and .tsx modules
shell-server@0.6.2 # Server-side component of the `meteor shell` command shell-server@0.5.0 # Server-side component of the `meteor shell` command
hot-module-replacement@0.5.4 # Update code in development without reloading the page hot-module-replacement@0.5.3 # 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
roles@1.0.1 alanning:roles@2.2.0
session@1.2.2 email@2.2.6
email@3.1.2 session@1.2.1
arianjahiri:meteor-handlebars-helpers
ostrio:flow-router-extra raix:handlebar-helpers
accounts-password@3.2.1 kadira:flow-router
kadira:blaze-layout
accounts-password@2.4.0

View file

@ -1 +1 @@
METEOR@3.3.2 METEOR@2.16

View file

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

View file

@ -1,4 +1,8 @@
FROM node:22.16.0-alpine FROM alpine:3.17
ENV NODE_VERSION=14.21.4
ENV NODE_URL="https://static.meteor.com/dev-bundle-node-os/unofficial-builds/v${NODE_VERSION}/node-v${NODE_VERSION}-linux-x64.tar.gz"
ENV DIR_NODE=/usr/local
RUN apk add --no-cache \ RUN apk add --no-cache \
libstdc++ \ libstdc++ \
@ -16,6 +20,13 @@ RUN apk add --no-cache \
ccache \ ccache \
xz xz
RUN echo $NODE_URL
RUN curl -sSL "$NODE_URL" | tar -xz -C /usr/local/ && mv $DIR_NODE/node-v${NODE_VERSION}-linux-x64 $DIR_NODE/v$NODE_VERSION
# add node and npm to path so the commands are available
ENV NODE_PATH $DIR_NODE/v$NODE_VERSION/lib/node_modules
ENV PATH $DIR_NODE/v$NODE_VERSION/bin:$PATH
# confirm installation # confirm installation
RUN node -v RUN node -v
RUN npm -v RUN npm -v
@ -27,7 +38,7 @@ ENV MONGO_URL=mongodb://mongo:27017/get_my\
RUN mkdir -p /usr/src/get_my RUN mkdir -p /usr/src/get_my
WORKDIR /usr/src/get_my WORKDIR /usr/src/get_my
COPY ../bundle/ /usr/src/get_my/ COPY bundle/ /usr/src/get_my/
RUN cd /usr/src/get_my/programs/server/ \ RUN cd /usr/src/get_my/programs/server/ \
&& npm install && npm install

View file

@ -60,8 +60,6 @@ The documentation is being done in the amazing open source software [Bookstack](
If you'd like to contribute by writing some documentation, please contact me me with an, and I'll see about getting you access to contribute. If you'd like to contribute by writing some documentation, please contact me me with an, and I'll see about getting you access to contribute.
I have a video introduction on my YouTube channel here as well: https://youtu.be/hbGNTzU24hI?si=K5mcb8FuzSWNCueB
## Keeping it Simple ## Keeping it Simple
- Registration / Login System built in - Registration / Login System built in
- 1st user to register is the system admin by default. - 1st user to register is the system admin by default.

View file

@ -1,5 +1,4 @@
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");
@ -26,7 +25,7 @@ Template.login.helpers({
Template.login.events({ Template.login.events({
'click #logmein' (event) { 'click #logmein' (event) {
event.preventDefault(); event.preventDefault();
// console.log("clicked login"); console.log("clicked login");
let email = $("#email").val(); let email = $("#email").val();
let pass = $("#password").val(); let pass = $("#password").val();

View file

@ -1,5 +1,4 @@
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");
@ -30,17 +29,13 @@ Template.reg.helpers({
return Session.get("missingReq"); return Session.get("missingReq");
}, },
allowReg: function() { allowReg: function() {
const sysConf = async() => { let conf = SysConfig.findOne();
let conf = await SysConfig.findOneAsync(); if (typeof conf != 'undefined') {
if (!conf) {
return true;
} else {
return conf.allowReg; return conf.allowReg;
} else {
return true
} }
} }
let sysConfig = sysConf();
return sysConfig;
}
}); });
Template.reg.events({ Template.reg.events({
@ -88,17 +83,15 @@ Template.reg.events({
}); });
let userId = Meteor.userId(); let userId = Meteor.userId();
// console.log("User ID: " + userId); console.log("User ID: " + userId);
const addRole = async() => { Meteor.call("addToRole", "user", function(err, result) {
let result = await Meteor.callAsync("addToRole", "user"); if (err) {
if (!result) { console.log(" ERROR: ROLES - Error adding user to role: " + err);
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"> <div class="col s12 m6 l6 input-field outlined">
<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,34 +35,19 @@ 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) {
const uIn = async() => { let usersInfo = Meteor.users.findOne({ _id: usersId });
let usersInfo = await Meteor.users.findOneAsync({ _id: usersId }); // console.dir(usersInfo);
if (!usersInfo) {
console.log("No information found for this user.");
return;
} else {
Session.set("usersInfo", usersInfo); Session.set("usersInfo", usersInfo);
return usersInfo; return usersInfo;
}
// console.dir(usersInfo);
}
uIn();
} else { } else {
return; return;
} }
}, },
userRole: function() { userRole: function() {
const getRole = async() => { let userRole = Roles.getRolesForUser( Session.get("usersId"));
let userRole = Roles.getRolesForUserAsync( Session.get("usersId"));
if (!userRole) {
return;
} else {
Session.set("usersRole", userRole); Session.set("usersRole", userRole);
console.log(userRole); console.log(userRole);
return userRole; return userRole;
}
}
getRole();
}, },
rolesOptions: function() { rolesOptions: function() {
return Roles.find(); return Roles.find();
@ -136,33 +121,36 @@ Template.userInfoModal.events({
} }
}); });
changePassword = async function(userId, passwd) { changePassword = function(userId, passwd) {
console.log("would change password."); console.log("would change password.");
let result = await Meteor.callAsync('edit.userPass', userId, passwd); Meteor.call('edit.userPass', userId, passwd, function(err, result) {
if (!result) { if (err) {
console.log(" ERROR changing user passwrod:"); console.log(" ERROR changing user passwrod:" + err);
} else { } else {
showSnackbar("Successfully Saved Changes!", "green"); showSnackbar("Successfully Saved Changes!", "green");
console.log(" Password changed successfully!"); console.log(" Password changed successfully!");
} }
});
} }
changeUserEmail = async function(usersId, usersEmail) { changeUserEmail = function(usersId, usersEmail) {
console.log("Would change user email"); console.log("Would change user email");
let result = await Meteor.callAsync('update.userEmail', usersId, usersEmail); Meteor.call('update.userEmail', usersId, usersEmail, function(err, result) {
if (!result) { if (err) {
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 = async function(userId, role) { changeUserRole = function(userId, role) {
console.log("Would change user Role."); console.log("Would change user Role.");
let result = await Meteor.callAsync('edit.userRole', userId, role); Meteor.call('edit.userRole', userId, role, function(err, result) {
if (!result) { if (err) {
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.getRolesForUserAsync( this._id ); return Roles.getRolesForUser( this._id );
} }
}); });

View file

@ -29,7 +29,7 @@ Template.cleanUpModalConfirm.events({
case "Menus": case "Menus":
cleanUp("clean.Menus", whatItems); cleanUp("clean.Menus", whatItems);
case "Products": case "Products":
cleanUp("clean.Products", whatItems); // cleanUp("clean.Products", whatItems);
case "Stores": case "Stores":
// cleanUp("clean.Stores", whatItems); // cleanUp("clean.Stores", whatItems);
case "Tasks": case "Tasks":
@ -40,34 +40,27 @@ Template.cleanUpModalConfirm.events({
} }
}); });
cleanUp = async function(methodName, whatItems) { cleanUp = function(methodName, whatItems) {
let result = Meteor.callAsync(methodName); Meteor.call(methodName, function(err, result) {
if (!result) { if (err) {
console.log(" ERROR cleaning " + whatItems);
} else {
showSnackbar(whatItems + " have been cleaned up!", "green");
let confirmModal = document.getElementById('cleanUpConfirm');
M.Modal.getInstance(confirmModal).close();
}
}
cleanProducts = async function(methodName, whatItems) {
let result = await Meteor.call(methodName, whatItems);
if (!result) {
console.log(" ERROR cleaning " + whatItems);
} else {
showSnackbar(whatItems + " have been cleaned up.", "green");
}
}
cleanTasks = async function(methodName, whatItems) {
let timeFrame = Session.get("overdueVal");
let result = await Meteor.call(methodName, timeFrame);
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) {
let timeFrame = Session.get("overdueVal");
Meteor.call(methodName, timeFrame, function(err, result) {
if (err) {
console.log(" ERROR cleaning " + whatItems + ": " + err);
} else {
showSnackbar(whatItems + " have been cleaned up!", "green");
let confirmModal = document.getElementById('cleanUpConfirm');
M.Modal.getInstance(confirmModal).close();
}
});
} }

View file

@ -2,11 +2,11 @@
<h4>Lists</h4> <h4>Lists</h4>
<form action="submit" class="listAdd"> <form action="submit" class="listAdd">
<div class="row"> <div class="row">
<div class="col s12 m8 l8 input-field"> <div class="col s8 m8 l10 input-field">
<input type="text" class="listNameInp" style="{{#if $eq listNameErr true}}border: 2px solid red{{/if}}" id="listNameInp" /> <input type="text" class="listNameInp" style="{{#if $eq listNameErr true}}border: 2px solid red{{/if}}" id="listNameInp" />
<label for="listNameInp">List Name</label> <label for="listNameInp">List Name</label>
</div> </div>
<div class="col s12 m2 l2 input-field"> <div class="col s4 m4 l2 input-field">
<p> <p>
<label> <label>
<input type="checkbox" id="isShared"/> <input type="checkbox" id="isShared"/>
@ -14,14 +14,6 @@
</label> </label>
</p> </p>
</div> </div>
<div class="col s12 m2 l2 input-field">
<p>
<label>
<input type="checkbox" id="isCompleted"/>
<span>Show Completed</span>
</label>
</p>
</div>
</div> </div>
<div class="row"> <div class="row">
<div class="col s12 m12 l12"> <div class="col s12 m12 l12">

View file

@ -7,7 +7,6 @@ Template.listMgmtForm.onCreated(function() {
Template.listMgmtForm.onRendered(function() { Template.listMgmtForm.onRendered(function() {
Session.set("listNameMiss", false); Session.set("listNameMiss", false);
Session.set("listNameEditMode", false); Session.set("listNameEditMode", false);
Session.set("showCompletedLists", false);
}); });
Template.listMgmtForm.helpers({ Template.listMgmtForm.helpers({
@ -29,7 +28,15 @@ Template.listMgmtForm.events({
Session.set("listNameMiss", true); Session.set("listNameMiss", true);
return; return;
} else { } else {
addList(listName, shared); Meteor.call('add.list', listName, shared, function(err, result) {
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) {
@ -42,7 +49,16 @@ Template.listMgmtForm.events({
Session.set("listNameMiss", true); Session.set("listNameMiss", true);
return; return;
} else { } else {
editList(listId, listName, shared); Meteor.call('edit.list', listId, listName, shared, function(err, result) {
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) {
@ -57,34 +73,27 @@ Template.listMgmtForm.events({
return; return;
} else { } else {
if (editMode == false) { if (editMode == false) {
addList(listName, shared); Meteor.call('add.list', listName, shared, function(err, result) {
} else { if (err) {
editList(listId, listName, shared); // console.log(" ERROR adding list name: " + err);
}
}
},
'change #isCompleted' (event) {
Session.set("showCompletedLists", true);
},
});
const addList = async(listName, shared) => {
let result = await Meteor.callAsync('add.list', listName, shared);
if (!result) {
console.log("Nothing returned from method call add.list");
} else { } else {
// console.log(" SUCCESS adding list name.");
$("#listNameInp").val(""); $("#listNameInp").val("");
$("#isShared").prop("checked", false); $("#isShared").prop("checked", false);
} }
} });
const editList = async(listId, listName, shared) => {
let result = await Meteor.callAsync('edit.list', listId, listName, shared);
if (!result) {
// console.log("Nothing returned from method call edit.list");
} else { } else {
Meteor.call('edit.list', listId, listName, shared, function(err, result) {
if (err) {
// console.log(" ERROR editing list name: " + err);
} else {
// console.log(" SUCCESS editing list name.");
$("#listNameInp").val(""); $("#listNameInp").val("");
$("#isShared").prop("checked", false); $("#isShared").prop("checked", false);
Session.set("listNameEditMode", false); Session.set("listNameEditMode", false);
} }
} });
}
}
}
});

View file

@ -8,7 +8,6 @@
<i class="material-icons clickable deleteListName tooltipped right modal-trigger" data-position="top" data-tooltip-id="deleteListIcon" data-target="modalDelete">delete</i> <i class="material-icons clickable deleteListName tooltipped right modal-trigger" data-position="top" data-tooltip-id="deleteListIcon" data-target="modalDelete">delete</i>
<i class="material-icons clickable editListName tooltipped right" data-position="top" data-tooltip-id="editThisListIcon">edit</i> <i class="material-icons clickable editListName tooltipped right" data-position="top" data-tooltip-id="editThisListIcon">edit</i>
<i class="material-icons clickable markListComplete tooltipped right" data-position="top" data-tooltip-id="markCompleteIcon">check</i> <i class="material-icons clickable markListComplete tooltipped right" data-position="top" data-tooltip-id="markCompleteIcon">check</i>
<i class="material-icons clickable markListNotComplete tooltipped right" data-position="top" data-tooltip-id="markIncompleteIcon">refresh</i>
</li> </li>
{{/each}} {{/each}}
</ul> </ul>
@ -22,9 +21,6 @@
<div id="markCompleteIcon" style="display: none;"> <div id="markCompleteIcon" style="display: none;">
Mark list complete Mark list complete
</div> </div>
<div id="markIncompleteIcon" style="display: none;">
Restore Completed List
</div>
</div> </div>
{{> deleteConfirmationModal}} {{> deleteConfirmationModal}}
</template> </template>

View file

@ -2,7 +2,7 @@ import { Lists } from '../../../imports/api/lists.js';
import { M } from '../../lib/assets/materialize.js'; import { M } from '../../lib/assets/materialize.js';
Template.listMgmtTbl.onCreated(function() { Template.listMgmtTbl.onCreated(function() {
this.subscribe("allLists"); this.subscribe("myLists");
}); });
Template.listMgmtTbl.onRendered(function() { Template.listMgmtTbl.onRendered(function() {
@ -14,13 +14,7 @@ Template.listMgmtTbl.onRendered(function() {
Template.listMgmtTbl.helpers({ Template.listMgmtTbl.helpers({
lists: function() { lists: function() {
let showComplete = Session.get("showCompletedLists");
// console.log("Show Complete Lists: " + showComplete);
if (showComplete) {
return Lists.find({}); return Lists.find({});
} else {
return Lists.find({ listComplete: false });
}
} }
}); });
@ -35,14 +29,9 @@ Template.listMgmtTbl.events({
}, },
'click .editListName' (event) { 'click .editListName' (event) {
event.preventDefault(); event.preventDefault();
const lInfo = async() => { let listInfo = Lists.findOne({ _id: this._id });
let listInfo = await Lists.findOneAsync({ _id: this._id }); let listName = listInfo.listName;
return listInfo; let listShared = listInfo.listShared;
}
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);
@ -55,27 +44,12 @@ Template.listMgmtTbl.events({
'click .markListComplete' (event) { 'click .markListComplete' (event) {
event.preventDefault(); event.preventDefault();
let listId = this._id; let listId = this._id;
const markComp = async() => { Meteor.call('mark.complete', listId, function(err, result) {
let result = await Meteor.callAsync('mark.complete', listId); if (err) {
if (!result) { // console.log(" ERROR marking complete: " + err);
console.log(" ERROR marking complete.");
} else { } else {
// console.log(" SUCCESS marking complete."); // console.log(" SUCCESS marking complete.");
} }
} });
markComp();
},
'click .markListNotComplete' (event) {
event.preventDefault();
let listId = this._id;
const markInc = async() => {
let result = await Meteor.callAsync('mark.incomplete', listId);
if (!result) {
console.log("Issue marking list incomplete.");
} else {
// console.log("List marked incomplete.");
}
}
markInc();
} }
}); });

View file

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

View file

@ -2,21 +2,13 @@
<h4>Product Management</h4> <h4>Product Management</h4>
{{#if Template.subscriptionsReady}} {{#if Template.subscriptionsReady}}
<form action="submit" class="row prodInputForm" style="gap: 1em;"> <form action="submit" class="row prodInputForm" style="gap: 1em;">
<div class="col l4 m6 s12"> <div class="col s12">
<p> <p>
<label> <label>
<input type="checkbox" id="showNoStoreSet" /> <input type="checkbox" id="showNoStoreSet" />
<span>Show Products without Store Assigned</span> <span>Show Products without Store Assigned</span>
</label> </label>
</p> </p>
</div>
<div class="col l4 m6 s12">
<p>
<label>
<input type="checkbox" id="showNoList" />
<span>Show Products Never Used in a List</span>
</label>
</p>
</div> </div>
<div class="col s12 m6 l6 input-field outlined"> <div class="col s12 m6 l6 input-field outlined">
<input type="text" class="prodName" style="{{#if $eq prodNameErr true}}border: 2px solid red;{{/if}}" id="prodName" /> <input type="text" class="prodName" style="{{#if $eq prodNameErr true}}border: 2px solid red;{{/if}}" id="prodName" />

View file

@ -35,65 +35,46 @@ 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) {
editProd(prodId, name, store); Meteor.call('edit.product', prodId, name, store, function(err, result) {
} else { if (err) {
newProd(name, store);
}
}
},
'click #showNoStoreSet' (event) {
let noStoreSet = $("#showNoStoreSet").prop('checked');
// console.log("Clicked: " + noStoreSet);
if (noStoreSet == true) {
Session.set("noStoreSet", true);
} else {
Session.set("noStoreSet", false);
}
},
'click #showNoList' (event) {
let notUsedInList = $("#showNoList").prop('checked');
if (notUsedInList == true) {
Session.set("noListUsed", true);
} else {
Session.set("noListUsed", 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); console.log(" ERROR: can't add product: " + err);
} else { } else {
$("#prodName").val(""); $("#prodName").val("");
showSnackbar("Successfully Edited Product!", "green"); showSnackbar("Successfully Edited Product!", "green");
} }
} });
} else {
Meteor.call('add.product', name, store, function(err, result) {
if (err) {
console.log(" ERROR: can't add product: " + err);
} else {
$("#prodName").val("");
showSnackbar("Product Added Succssfully!", "green");
}
});
}
}
},
'click #showNoStoreSet' (event) {
let noStoreSet = $("#showNoStoreSet").prop('checked');
console.log("Clicked: " + noStoreSet);
if (noStoreSet == true) {
Session.set("noStoreSet", true);
} else {
Session.set("noStoreSet", false);
}
}
});

View file

@ -1,17 +1,14 @@
import { Products } from '../../../imports/api/products.js'; import { Products } from '../../../imports/api/products.js';
import { ListItems } from '../../../imports/api/listItems.js';
import { M } from '../../lib/assets/materialize.js'; import { M } from '../../lib/assets/materialize.js';
Template.prodMgmtTbl.onCreated(function() { Template.prodMgmtTbl.onCreated(function() {
this.subscribe("myProducts"); this.subscribe("myProducts");
this.subscribe("allListItems");
}); });
Template.prodMgmtTbl.onRendered(function() { Template.prodMgmtTbl.onRendered(function() {
Session.set("searchProds", false); Session.set("searchProds", false);
Session.set("searchStore", false); Session.set("searchStore", false);
Session.set("noStoreSet", false); Session.set("noStoreSet", false);
Session.set("noListUsed", false);
}); });
Template.prodMgmtTbl.helpers({ Template.prodMgmtTbl.helpers({
@ -19,7 +16,6 @@ Template.prodMgmtTbl.helpers({
let searchProd = Session.get("searchProds"); let searchProd = Session.get("searchProds");
let searchStore = Session.get("searchStore"); let searchStore = Session.get("searchStore");
let noStoreSet = Session.get("noStoreSet"); let noStoreSet = Session.get("noStoreSet");
let noListUsed = Session.get("noListUsed");
if (searchProd == true) { if (searchProd == true) {
let searchVal = Session.get("searchVal"); let searchVal = Session.get("searchVal");
@ -37,17 +33,6 @@ Template.prodMgmtTbl.helpers({
} }
} else if (noStoreSet == true) { } else if (noStoreSet == true) {
return Products.find({ prodStore: '' }, { sort: { prodName: 1 }}); return Products.find({ prodStore: '' }, { sort: { prodName: 1 }});
} else if (noListUsed == true) {
let i;
let idList = [];
let idsInLists = ListItems.find({}).fetch();
for (i=0; i < idsInLists.length; i++) {
idList.push(idsInLists[i].prodId);
}
if (i > idsInLists.length - 1) {
let noProdsNot = Products.find({ _id: { $nin: idList }}).count();
return Products.find({ _id: { $nin: idList }}, { sort: { prodName: 1 }});
}
} else { } else {
return Products.find({}, { sort: { prodName: 1 }}); return Products.find({}, { sort: { prodName: 1 }});
} }
@ -72,17 +57,10 @@ 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);
const getProds = async() => { let prodInfo = Products.findOne({ _id: this._id });
let prodInfo = await Products.findOneAsync({ _id: this._id });
if (!prodInfo) {
// console.log("No Product Returned.");
} else {
$("#prodName").val(prodInfo.prodName); $("#prodName").val(prodInfo.prodName);
$("#prodStore").val(prodInfo.prodStore); $("#prodStore").val(prodInfo.prodStore);
} // $('select').formSelect();
}
getProds();
}, },
'click #filterProds' (event) { 'click #filterProds' (event) {
event.preventDefault(); event.preventDefault();

View file

@ -23,7 +23,14 @@ Template.storeMgmtForm.events({
Session.set("borderRed", true); Session.set("borderRed", true);
return; return;
} else { } else {
addStore(storeName); Meteor.call("add.store", storeName, function(err, result) {
if (err) {
console.log("ERROR: Store add failed: " + err);
} else {
$("#storeName").val("");
showSnackbar("Store Added Successfully!", "green");
}
});
} }
}, },
'click .cancelStoreMgmt' (event) { 'click .cancelStoreMgmt' (event) {
@ -31,22 +38,35 @@ 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) {
addStore(storeName); // Meteor.call("add.store", storeName, function(err, result) {
} else { // if (err) {
let storeId = Session.get("storeIdEdit"); // console.log("ERROR: Store add failed: " + err);
editStore(storeId, storeName); // } else {
} // $("#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");
@ -54,28 +74,15 @@ Template.storeMgmtForm.events({
Session.set("borderRed", true); Session.set("borderRed", true);
return; return;
} else { } else {
editStore(storeId, storeName); Meteor.call("edit.store", storeId, storeName, function(err, result) {
} if (err) {
} console.log("ERROR: Store add failed: " + err);
});
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 { } else {
$("#storeName").val(""); $("#storeName").val("");
Session.set("editModeStore", false); Session.set("editModeStore", false);
showSnackbar("Store Updated Successfully!", "green"); showSnackbar("Store Updated Successfully!", "green");
} }
} });
}
}
});

View file

@ -14,7 +14,7 @@ Template.systemAdmin.onRendered(function() {
$("#allAdmReg").prop('checked', curr.SysAdminReg); $("#allAdmReg").prop('checked', curr.SysAdminReg);
$("#recvUpdateMsgs").prop('checked', curr.allowUpdates); $("#recvUpdateMsgs").prop('checked', curr.allowUpdates);
} else { } else {
// console.log(" ---- unable to find current system configuration."); console.log(" ---- unable to find current system configuration.");
} }
}); });
@ -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');
const addNoSysReg = async() => { // console.log("General Reg set to: " + genReg);
let result = await Meteor.callAsync("add.noSysAdminReg", admReg, genReg); Meteor.call("add.noSysAdminReg", admReg, genReg, function(err, result) {
if (!result) { if (err) {
showSnackbar("Registration Permission Change Failed.", "red"); // console.log(" ERROR updating permission to allow general registration: " + err);
// 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');
const allowUpdateInfo = async() => { Meteor.call('allow.updateInfo', updSet, function(err, result) {
let result = await Meteor.callAsync('allow.updateInfo', updSet); if (err) {
if (!result) { console.log(" ERROR changing update setting: " + err);
// 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

@ -3,7 +3,7 @@
<form class="row" style="gap: 1em;"> <form class="row" style="gap: 1em;">
<div class="col s12 m6 l4 chips chips-placeholder" id="taskName"> <div class="col s12 m6 l4 chips chips-placeholder" id="taskName">
</div> </div>
<div class="col s12 m6 l4 input-field"> <div class="col s12 m6 l4 input-field outlined">
<select name="taskUser" id="taskUser" class="taskUser"> <select name="taskUser" id="taskUser" class="taskUser">
<option value="" disabled selected>Assign to user...</option> <option value="" disabled selected>Assign to user...</option>
{{#each taskUsers}} {{#each taskUsers}}
@ -11,7 +11,7 @@
{{/each}} {{/each}}
</select> </select>
</div> </div>
<div class="col s12 m6 l4 input-field"> <div class="col s12 m6 l4 input-field outlined">
<input type="text" class="datepicker" id="taskDate" /> <input type="text" class="datepicker" id="taskDate" />
<label for="taskDate">Task Date (multiple entries)</label> <label for="taskDate">Task Date (multiple entries)</label>
<div class="row"> <div class="row">

View file

@ -50,7 +50,7 @@ Template.taskForm.events({
event.preventDefault(); event.preventDefault();
let elemcc = document.getElementById('taskName'); let elemcc = document.getElementById('taskName');
let taskName = M.Chips.getInstance(elemcc).chipsData; let taskName = M.Chips.getInstance(elemcc).chipsData;
// console.log(taskName); console.log(taskName);
}, },
'change #taskDate' (event) { 'change #taskDate' (event) {
let taskDate = $("#taskDate").val(); let taskDate = $("#taskDate").val();
@ -69,6 +69,7 @@ Template.taskForm.events({
let taskDateErr = false; let taskDateErr = false;
let userInfo; let userInfo;
let actDate = []; let actDate = [];
// console.dir(taskNameArr);
if (taskNameArr == null || taskNameArr == []) { if (taskNameArr == null || taskNameArr == []) {
taskNameErr = true; taskNameErr = true;
@ -91,19 +92,17 @@ Template.taskForm.events({
} }
if (taskUserErr == false && taskDateErr == false && taskNameErr == false) { if (taskUserErr == false && taskDateErr == false && taskNameErr == false) {
const addTask = async() => { Meteor.call("add.task", taskNameArr, userInfo[0], userInfo[1], taskDateArr, actDate, function(err, result) {
let result = await Meteor.callAsync("add.task", taskNameArr, userInfo[0], userInfo[1], taskDateArr, actDate); if (err) {
if (!result) { console.log(" ERROR adding the new task: " + err);
// 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", []);
$("#taskDate").val(""); $("#taskDate").val("");
$("#taskUser").val(""); $("#taskUser").val("");
$('select').formSelect(); $('select').formSelect();
} }
} });
addTask();
} else { } else {
showSnackbar("ERROR: Missing Required Fields!", "red"); showSnackbar("ERROR: Missing Required Fields!", "red");
} }
@ -115,5 +114,6 @@ Template.taskForm.events({
} else { } else {
Session.set("hideCompletedTasks", false); Session.set("hideCompletedTasks", false);
} }
} }
}); });

View file

@ -43,15 +43,13 @@ Template.taskTbl.events({
'click .markTaskComplete' (event) { 'click .markTaskComplete' (event) {
event.preventDefault(); event.preventDefault();
let taskId = this._id; let taskId = this._id;
const markComp = async() => { Meteor.call("markTask.complete", taskId, function(err, result) {
let result = await Meteor.callAsync("markTask.complete", taskId); if (err) {
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,11 @@
<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 $eq updatesExist true}} {{#if updatesExist}}
<div class="col s12"> <div class="col s12">
<ul class="collapsible green darken-3 white-text"> <div class="card green darken-3" id="updateInfoCard">
<li> <div class="card-content white-text">
<div class="collapsible-header"><strong>Update Available</strong></div> <div class="card-title">Update Available</div>
<div class="collapsible-body">
<div class="row"> <div class="row">
{{#each updates}} {{#each updates}}
<div class="col s12"> <div class="col s12">
@ -17,7 +16,7 @@
</div> </div>
<div class="col s12"> <div class="col s12">
Release Notes: Release Notes:
<p class="flow-text">{{{descriptionSinHTML}}}</p> <p class="flow-text">{{descriptionSinHTML}}</p>
</div> </div>
<div class="col s12"> <div class="col s12">
Release Date: Release Date:
@ -35,8 +34,7 @@
{{/each}} {{/each}}
</div> </div>
</div> </div>
</li> </div>
</ul>
</div> </div>
{{/if}} {{/if}}
{{/if}} {{/if}}

View file

@ -7,8 +7,6 @@ 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");
@ -25,10 +23,7 @@ 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({
@ -65,53 +60,23 @@ Template.dashboard.helpers({
return todayDate; return todayDate;
}, },
updates: function() { updates: function() {
let updateAvail = UpdateInfo.find({}); return UpdateInfo.find({});
try {
if (!updateAvail) {
// console.log("No update info found.");
return false;
} else {
// console.dir(updateAvail);
return updateAvail;
}
} catch(error) {
console.log(" ERROR trying to grab update info: " + error);
}
}, },
updatesExist: function() { updatesExist: function() {
const ifUpdate = async() => { let updateExists = UpdateInfo.find({ viewed: false }).fetch();
let updateExists = await UpdateInfo.findOneAsync({ viewed: false }); if (updateExists.length > 0) {
if (!updateExists) {
// console.log("Update doesn't exist as false.");
return false;
} else {
// console.log("Update found with false.");
return true; return true;
} else {
return false;
} }
}
let updateAvail = ifUpdate();
return updateAvail;
}, },
currConfig: function() { currConfig: function() {
const getSys = async() => { return SysConfig.findOne({});
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;
let sinH = $(desc).text(); let sinH = $(desc).text();
return desc; return sinH;
}, },
niceDate: function() { niceDate: function() {
let rDateNorm = this.date; let rDateNorm = this.date;
@ -175,19 +140,12 @@ Template.dashboard.events({
'click .readLink' (event) { 'click .readLink' (event) {
let eventId = event.currentTarget.id; let eventId = event.currentTarget.id;
const markUpdate = async() => { Meteor.call('markUpdate.read', eventId, function(err, result) {
let result = await Meteor.callAsync('markUpdate.read', eventId); if (err) {
try { console.log(" ERROR marking update as 'read': " + err);
if (!result) {
// console.log(" Error marking this read.");
showSnackbar("Error Marking Read!", "red");
} else { } else {
showSnackbar("Successfully Marked as Read.", "green"); console.log("marked read successfully!");
} }
} catch(error) { });
console.log(" ERROR trying to mark this update as read: " + error);
}
}
markUpdate();
} }
}); });

View file

@ -22,16 +22,14 @@ Template.deleteConfirmationModal.events({
let deleteId = Session.get("deleteId"); let deleteId = Session.get("deleteId");
let method = Session.get("method"); let method = Session.get("method");
const delItem = async() => { Meteor.call(method, deleteId, function(err, result) {
let result = await Meteor.callAsync(method, deleteId); if (err) {
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

@ -11,8 +11,8 @@
<li><a href="#" id="mylists" class="navBtn {{#if $eq myTheme 'dark'}}white-text{{/if}}">My Lists</a></li> <li><a href="#" id="mylists" class="navBtn {{#if $eq myTheme 'dark'}}white-text{{/if}}">My Lists</a></li>
<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="#" id="mySettings" class="navBtn {{#if $eq myTheme 'dark'}}white-text{{/if}}">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>
@ -30,12 +30,10 @@
<li><a href="#!" id="mylists" class="navBtn {{#if $eq myTheme 'dark'}}white-text{{/if}}">My Lists</a></li> <li><a href="#!" id="mylists" class="navBtn {{#if $eq myTheme 'dark'}}white-text{{/if}}">My Lists</a></li>
<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="#!" id="mySettings" class="navBtn {{#if $eq myTheme 'dark'}}white-text{{/if}}">My Settings</a></li> <li><a href="#!" class="navBtn" id="mySettings {{#if $eq myTheme 'dark'}}white-text{{/if}}">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 $eq updateExists true}} <li><a href="#!"><i class="material-icons">notifications</i></a></li>
<li><a href="#!"><i class="material-icons navBtn" id="dashboard">notifications</i></a></li>
{{/if}}
{{/if}} {{/if}}
<li><a href="#!" class="signOut {{#if $eq myTheme 'dark'}}white-text{{/if}}">Sign Out</a></li> <li><a href="#!" class="signOut {{#if $eq myTheme 'dark'}}white-text{{/if}}">Sign Out</a></li>
{{else}} {{else}}

View file

@ -1,12 +1,8 @@
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() {
@ -14,25 +10,6 @@ Template.headerBar.onRendered(function() {
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

@ -1,26 +1,9 @@
<template name="listItemTblByStore"> <template name="listItemTblByStore">
<div class="row"> <div class="row">
<div class="col s12"> <div class="col s12">
<span>Products with no assigned store, will not be displayed on this version of the list.</span>
<ul class="collection with-header"> <ul class="collection with-header">
{{#each stores}} <li class="collection-header"><h4>First Names</h4></li>
{{#if $eq storeInList true}} <li class="collection-item">Alvin</li>
<li class="collection-header"><h4>{{storeName}}</h4></li>
{{#each thisListItems}}
<li class="collection-item" id="{{_id}}-{{itemOrdered}}">
<span>
{{#if $eq itemOrdered true}}
<strike>{{itemName}}</strike>
{{else}}
{{itemName}}
{{/if}}
</span>
<i class="material-icons clickable deleteListItem right modal-trigger" href="#modalDelete">delete</i>
<i class="material-icons clickable markListItemReceived right">check</i>
</li>
{{/each}}
{{/if}}
{{/each}}
</ul> </ul>
</div> </div>
</div> </div>

View file

@ -17,73 +17,14 @@ Template.listItemTblByStore.onRendered(function() {
}); });
Template.listItemTblByStore.helpers({ Template.listItemTblByStore.helpers({
stores: function() {
let storeList = Stores.find({});
return storeList;
},
thisListItems: function() { thisListItems: function() {
let showReceived = Session.get("showReceivedItems"); let showReceved = Session.get("showReceivedItems");
let searchVal = Session.get("searchVal"); let searchVal = Session.get("searchVal");
let store = this.storeName; let stores = Stores.find({}).fetch();
if (showReceived == false) {
if (typeof searchVal == 'undefined' || searchVal.length === 0) {
return ListItems.find({ itemStore: store, itemReceived: false });
} else {
return ListItems.find({ itemStore: store, itemReceived: false, itemName: { $regex: searchVal + '.*', $options: 'i' }})
} }
} else {
if (typeof searchVal == 'undefined' || searchVal.length == 0) {
return ListItems.find({ itemStore: store });
} else {
return ListItems.find({ itemStore: store, itemName: { $regex: searchVal + '.*', $options: 'i' } });
}
}
},
storeInList: function() {
let noStoresInList = ListItems.find({ itemStore: this.storeName }).count();
if (noStoresInList > 0) {
return true;
} else {
return false;
}
},
}); });
Template.listItemTblByStore.events({ Template.listItemTblByStore.events({
'click li' (event) {
let itemSel = (event.currentTarget.id).split('-');
let itemId = itemSel[0];
let itemOrder = itemSel[1];
if (typeof itemOrder == 'undefined' || itemOrder == "" || itemOrder == false) {
Meteor.call("setOrdered.listItem", itemId, function(err, result) {
if (err) {
// console.log(" ERROR updating order status to ordered: " + err);
}
});
} else {
Meteor.call("setNotOrdered.listItem", itemId, function(err, result) {
if (err) {
// console.log(" ERROR updating order status to unordered: " + err);
}
});
}
},
'click .markListItemReceived' (event) {
event.preventDefault();
Meteor.call('setReceived.listItem', this._id, function(err, result) {
if (err) {
// console.log(" ERROR setting item as received: " + err);
} else {
// console.log(" SUCCESS setting item received.");
}
});
},
'click .deleteListItem' (event) {
event.preventDefault();
Session.set("deleteId", this._id);
Session.set("method", "delete.listItem");
Session.set("item", this.itemName);
Session.set("view", "List Items");
},
}); });

View file

@ -39,7 +39,7 @@ Template.listItemsForm.helpers({
selListId = selListInfo.viewId; selListId = selListInfo.viewId;
Session.set("listId", selListId); Session.set("listId", selListId);
} else { } else {
// console.log("not finding any value for viewId."); console.log("not finding any value for viewId.");
} }
} }
let listInfo = Lists.findOne({ _id: selListId }); let listInfo = Lists.findOne({ _id: selListId });
@ -48,7 +48,6 @@ Template.listItemsForm.helpers({
} }
}, },
itemProdName: function() { itemProdName: function() {
return Products.find({}); return Products.find({});
}, },
editMode: function() { editMode: function() {
@ -67,7 +66,14 @@ Template.listItemsForm.events({
if (item == null || item == "") { if (item == null || item == "") {
Session.set("itemReqErr", true); Session.set("itemReqErr", true);
} else { } else {
addItem(item, listId); Meteor.call("add.listItem", item, listId, function(err, result) {
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) {
@ -77,7 +83,14 @@ Template.listItemsForm.events({
if (item == null || item == "") { if (item == null || item == "") {
Session.set("itemReqErr", true); Session.set("itemReqErr", true);
} else { } else {
addItem(item, listId); Meteor.call("add.listItem", item, listId, function(err, result) {
if (err) {
console.log(" ERROR adding item to list: " + err);
} else {
console.log(" SUCCESS adding item to list.");
$("#findListItems").val("");
}
});
} }
} }
}, },
@ -97,11 +110,8 @@ 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 (!listItemInfo) { if (typeof listItemInfo != 'undefined' && listItemInfo != "" && listItemInfo != null) {
// console.log("No data for key input.");
} else {
getDataList(listItemInfo); getDataList(listItemInfo);
} }
} }
@ -118,21 +128,7 @@ 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

@ -1,22 +1,5 @@
<template name="listItemsMain"> <template name="listItemsMain">
{{> listItemsForm}} {{> listItemsForm}}
<hr> <hr>
<div class="row">
<div class="col s12">
<ul class="tabs">
<li class="tab col s6">
<a href="#listOnly" class='active'>List</a>
</li>
<li class="tab col s6">
<a href="#listByStore">List by Store</a>
</li>
</ul>
</div>
<div id="listOnly" class="col s12">
{{> listItemsTbl}} {{> listItemsTbl}}
</div>
<div id="listByStore" class="col s12">
{{> listItemTblByStore}}
</div>
</div>
</template> </template>

View file

@ -1,12 +1,9 @@
import { M } from '../lib/assets/materialize.js';
Template.listItemsMain.onCreated(function() { Template.listItemsMain.onCreated(function() {
}); });
Template.listItemsMain.onRendered(function() { Template.listItemsMain.onRendered(function() {
var elems = document.querySelectorAll('.tabs');
var instance = M.Tabs.init(elems, {});
}); });
Template.listItemsMain.helpers({ Template.listItemsMain.helpers({

View file

@ -20,15 +20,15 @@ Template.listItemsTbl.onRendered(function() {
Template.listItemsTbl.helpers({ Template.listItemsTbl.helpers({
'thisListItems': function() { 'thisListItems': function() {
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 (!searchVal) { if (typeof searchVal == 'undefined' || searchVal.length === 0) {
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 (!searchVal) { if (typeof searchVal == 'undefined' || searchVal.length == 0) {
return ListItems.find({}); return ListItems.find({});
} else { } else {
return ListItems.find({ itemName: { $regex: searchVal + '.*', $options: 'i' } }); return ListItems.find({ itemName: { $regex: searchVal + '.*', $options: 'i' } });
@ -40,37 +40,34 @@ Template.listItemsTbl.helpers({
Template.listItemsTbl.events({ Template.listItemsTbl.events({
'click li' (event) { 'click li' (event) {
event.preventDefault(); event.preventDefault();
const setOrd = async() => { let itemInfo = ListItems.findOne({ _id: this._id });
let itemInfo = await ListItems.findOneAsync({ _id: this._id });
if (itemInfo.itemOrdered == true) { if (itemInfo.itemOrdered == true) {
let result = await Meteor.callAsync('setNotOrdered.listItem', this._id); Meteor.call('setNotOrdered.listItem', this._id, function(err, result) {
if (!result) { if (err) {
// console.log(" ERROR seeting item as not ordered."); console.log(" ERROR setting this item as NOT ordered: " + err);
} else { } else {
// console.log(" SUCCESS setting item as ordered."); // console.log(" SUCCESS setting this item as NOT ordered.");
} }
});
} else { } else {
let result = Meteor.callAsync('setOrdered.listItem', this._id); Meteor.call('setOrdered.listItem', this._id, function(err, result) {
if (!result) { if (err) {
// console.log(" ERROR marking item ordered: " + err); console.log(" ERROR marking item ordered: " + err);
} else { } else {
// console.log(" SUCCESS marking this item ordered."); // console.log(" SUCCESS marking this item ordered.");
} }
});
} }
}
setOrd();
}, },
'click .markListItemReceived' (event) { 'click .markListItemReceived' (event) {
event.preventDefault(); event.preventDefault();
const setRcvd = async() => { Meteor.call('setReceived.listItem', this._id, function(err, result) {
let result = await Meteor.callAsync('setReceived.listItem', this._id); if (err) {
if (!result) { console.log(" ERROR setting item as received: " + err);
// console.log("Item not marked properly - why?");
} else { } else {
// console.log("Item Marked Received."); // console.log(" SUCCESS setting item received.");
} }
} });
setRcvd();
}, },
'click .deleteListItem' (event) { 'click .deleteListItem' (event) {
event.preventDefault(); event.preventDefault();

View file

@ -1,6 +1,5 @@
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");
@ -28,17 +27,15 @@ Template.listsTbl.events({
} else { } else {
// console.log("listId is: " + listId); // console.log("listId is: " + listId);
Session.set("listId", listId); Session.set("listId", listId);
const addUserLast = async() => { Meteor.call('add.userLast', "List", listId, function(err, result) {
let result = await Meteor.callAsync('add.userLast', "List", listId); if (err) {
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 {
setTimeout(function() { Meteor.setTimeout(function() {
FlowRouter.go('/listitems'); FlowRouter.go('/listitems');
}, 100); }, 100);
} }
} });
addUserLast();
} }
} }
}, },
@ -50,17 +47,15 @@ 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);
const markComp = async() => { Meteor.call("mark.complete", listId, function(err, result){
let result = await Meteor.callAsync("mark.complete", listId); if (err) {
if (!result) { console.log(" ERROR marking list complete! " + err);
// 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,27 +7,20 @@ Template.MainLayout.onCreated(function() {
Template.MainLayout.onRendered(function() { Template.MainLayout.onRendered(function() {
this.autorun(() => { this.autorun(() => {
let myId = Meteor.userId(); let myId = Meteor.userId();
const getConfig = async() => { let myprefs = UserConfig.findOne({ user: myId });
let myprefs = await UserConfig.findOneAsync({ user: myId }); if (typeof myprefs != 'undefined') {
try {
if (!myprefs) {
// console.log("User Prefs appear undefined.");
} else {
if (myprefs.darkMode == "light") { if (myprefs.darkMode == "light") {
// console.log("Found theme as light"); console.log("Found theme as light");
Session.set("myTheme", "light"); Session.set("myTheme", "light");
document.documentElement.setAttribute('theme', "light"); document.documentElement.setAttribute('theme', "light");
} else { } else {
// console.log("Found theme as dark"); console.log("Found theme as dark");
Session.set("myTheme", "dark"); Session.set("myTheme", "dark");
document.documentElement.setAttribute('theme', "dark"); document.documentElement.setAttribute('theme', "dark");
} }
} else {
console.log("User Prefs appear undefined.");
} }
} catch(error) {
console.log(" ERROR getting user preferences: " + error);
}
}
getConfig();
}); });
}); });

View file

@ -39,9 +39,10 @@
<a class="left btn waves-effect waves-light orange white-text modal-close">Cancel</a> <a class="left btn waves-effect waves-light orange white-text modal-close">Cancel</a>
</div> </div>
<div class="col s6 m6 l6"> <div class="col s6 m6 l6">
<a class="right btn waves-effect waves-light green white-text saveProdsToList modal-close" id="saveProdsToList">Save to List</a> <a class="right btn waves-effect waves-light green white-text saveProdsToList" id="saveProdsToList">Save to List</a>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
{{> snackbar}} {{> snackbar}}

View file

@ -31,9 +31,9 @@ Template.addProdToListModal.helpers({
}, },
productToChoose: function() { productToChoose: function() {
let menuItemId = Session.get("menuItemId"); let menuItemId = Session.get("menuItemId");
// console.log("Menu Item Id received is: " + menuItemId); console.log("Menu Item Id received is: " + menuItemId);
let prodLinkLIst = MenuProdLinks.find({ menuItemId: menuItemId}); let prodLinkLIst = MenuProdLinks.find({ menuItemId: menuItemId});
// console.dir(prodLinkLIst); console.dir(prodLinkLIst);
if (typeof prodLinkLIst != 'undefined' && prodLinkLIst != "" && prodLinkLIst != null) { if (typeof prodLinkLIst != 'undefined' && prodLinkLIst != "" && prodLinkLIst != null) {
return prodLinkLIst; return prodLinkLIst;
} }
@ -44,23 +44,21 @@ Template.addProdToListModal.events({
'click .productListing' (event) { 'click .productListing' (event) {
let itemId = event.currentTarget.id; let itemId = event.currentTarget.id;
let selected = Session.get("itemsSelected"); let selected = Session.get("itemsSelected");
// console.log("Item clicked: " + itemId); console.log("Item clicked: " + itemId);
selected.push(itemId); selected.push(itemId);
// console.dir(selected); console.dir(selected);
Session.set("itemsSelected", selected); Session.set("itemsSelected", selected);
}, },
'click #saveProdsToList' (event) { 'click #saveProdsToList' (event) {
event.preventDefault(); event.preventDefault();
let selectedItems = Session.get("itemsSelected"); let selectedItems = Session.get("itemsSelected");
let listId = $("#chooseList").val(); let listId = $("#chooseList").val();
const addItemsFromMenu = async() => { Meteor.call('add.itemsFromMenuItem', selectedItems, listId, function(err, result) {
let result = await Meteor.callAsync('add.itemsFromMenuItem', selectedItems, listId); if (err) {
if (!result) { console.log(" ERROR adding menu components to list: " + err);
console.log(" ERROR adding menu components to list: ");
} else { } else {
showSnackbar("Items Added to List!", "green"); showSnackbar("Items Added to List!", "green");
} }
} });
addItemsFromMenu();
} }
}); });

View file

@ -38,28 +38,14 @@ Template.menuItemsForm.helpers({
if (Session.get("menuId")) { if (Session.get("menuId")) {
menuId = Session.get("menuId"); menuId = Session.get("menuId");
} else { } else {
const menuInfor = async() => { menuId = UserLast.findOne({ view: "Menu" }).viewId;
let result = await UserLast.findOneAsync({ view: "Menu" }).viewId;
if (!result) {
} else {
return result;
}
}
let menuId = menuInfor();
} }
const menuData = async() => { let menuInfo = Menus.findOne({ _id: menuId });
let menuInfo = await Menus.findOneAsync({ _id: menuId }); if (menuInfo) {
if (!menuInfo) {
return;
} else {
return menuInfo.menuName; return menuInfo.menuName;
} }
} }
let menuInformation = menuData();
return menuInformation;
}
}); });
Template.menuItemsForm.events({ Template.menuItemsForm.events({
@ -69,77 +55,49 @@ Template.menuItemsForm.events({
let dateSrv = $("#dateServed").val(); let dateSrv = $("#dateServed").val();
let menuId = Session.get("menuId"); let menuId = Session.get("menuId");
if (menuId == null || menuId == "") {
console.log(" ---- NO MENU ID! ----");
}
const mie = async() => { let menuItemExists = MenuItems.findOne({ itemName: menuItem });
let menuItemExists = await MenuItems.findOneAsync({ itemName: menuItem });
if (!menuItemExists) {
// call to add it
notExists();
} else {
// call to add it to the menu only
console.dir(menuItemExists);
itExists(menuItemExists);
}
}
mie();
const notExists = async() => { if (typeof menuItemExists != 'undefined' && menuItemExists != null && menuItemExists != "") {
// 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. Result is: " + result);
return result;
}
}
let addedItem = await addMenuItem();
if (!addedItem) {
// console.log("Item was not added.");
} else {
// now add this item to the menu
// console.log("Added Item = " + addedItem);
const addToMenu = async() => {
let result2 = await Meteor.callAsync('addto.Menu', menuId, menuItem, addedItem, dateSrv, false);
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;
if (menuItem == null || menuItem == "") { if (menuItem == null || menuItem == "") {
Session.set("menuItemErr", true); Session.set("menuItemErr", true);
} else { } else {
const addToMenu = async() => { Meteor.call('addto.Menu', menuId, menuItem, menuItemId, dateSrv, isLinked, function(error, nresult) {
let result = await Meteor.callAsync('addto.Menu', menuId, menuItem, menuItemId, dateSrv, isLinked); if (error) {
if (!result) { console.log(" ERROR adding menuitem to menu: " + error);
// console.log(" ERROR adding menuitem to menu: " + error);
} else { } else {
// console.log("Added item to menu - no problem."); // console.log("Added item to menu - no problem.");
$("#menuItemInp").val(""); $("#menuItemInp").val("");
$("#dateServed").val(""); $("#dateServed").val("");
} }
});
} }
addToMenu(); } 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.");
}
});
}
});
} }
} }
}, },
@ -152,25 +110,20 @@ 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);
const shiftDay = async() => { Meteor.call('shiftDate', menuItemId, momentAddDay, function(err,result) {
let result = await Meteor.callAsync('shiftDate', menuItemId, momentAddDay); if (err) {
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) {
if (event.which != 13) { if (event.which != 13) {
let findMenuItem = $("#menuItemInp").val(); let findMenuItem = $("#menuItemInp").val();
let menuItemInfo = MenuItems.find({ itemName: {$regex: findMenuItem + '.*', $options: 'i' }}).fetch(); let menuItemInfo = MenuItems.find({ itemName: {$regex: findMenuItem + '.*', $options: 'i' }}).fetch();
if (!menuItemInfo) { if (typeof menuItemInfo != 'undefined' && menuItemInfo != '' && menuItemInfo != null) {
console.log("Nothing found in menu items:");
console.dir(menuItemInfo);
} else {
console.dir(menuItemInfo)
getMenuItemList(menuItemInfo); getMenuItemList(menuItemInfo);
} }
} }

View file

@ -30,21 +30,11 @@ Template.menuItemsTbl.helpers({
if (Session.get("menuId")) { if (Session.get("menuId")) {
menuId = Session.get("menuId"); menuId = Session.get("menuId");
} else { } else {
const menu = async() => { menuId = UserLast.findOne({ view: "Menu" }).viewId;
let menId = await UserLast.findOneAsync({ view: "Menu" }).viewId;
if (!menId) {
} else {
return menId;
} }
}
menuId = menu();
}
if (menuId) {
let menuInfo = Menus.find({ _id: menuId }, { sort: { serveDateActual: 1 }}); let menuInfo = Menus.find({ _id: menuId }, { sort: { serveDateActual: 1 }});
if (menuInfo) { if (menuInfo) {
return menuInfo; return menuInfo
}
} }
} }
}); });
@ -53,7 +43,7 @@ Template.menuItemsTbl.events({
'click .deleteMenuItem' (event) { 'click .deleteMenuItem' (event) {
event.preventDefault(); event.preventDefault();
let theseIds = Session.get("menuId") + "_" + this.menuItemId; let theseIds = Session.get("menuId") + "_" + this.menuItemId;
// console.log("These Ids: " + theseIds); console.log("These Ids: " + theseIds);
Session.set("deleteId", theseIds); Session.set("deleteId", theseIds);
Session.set("method", "delete.itemFromMenu"); Session.set("method", "delete.itemFromMenu");
Session.set("item", this.menuItemName); Session.set("item", this.menuItemName);
@ -63,7 +53,7 @@ Template.menuItemsTbl.events({
event.preventDefault(); event.preventDefault();
Session.set("menuItemId", this.menuItemId); Session.set("menuItemId", this.menuItemId);
Session.set("menuItemName", this.menuItemName); Session.set("menuItemName", this.menuItemName);
// console.log("menu item name = " + this.menuItemName); console.log("menu item name = " + this.menuItemName);
}, },
'click .addProdsToList' (event) { 'click .addProdsToList' (event) {
event.preventDefault(); event.preventDefault();

View file

@ -18,29 +18,17 @@ Template.modalLinkProducts.onRendered(function() {
dropdownOptions: 4, dropdownOptions: 4,
}); });
this.autorun(() => { setTimeout(function() {
if (this.subscriptionsReady()) { var instances = M.Modal.init(elems, {});
// setTimeout(function() {
// var instances = M.Modal.init(elems, {});
var elemse = document.querySelectorAll('select');
var instancese = M.FormSelect.init(elemse, { var instancese = M.FormSelect.init(elemse, {
dropdownOptions: 4, dropdownOptions: 4,
}); });
// }, 250); }, 250);
}
});
}); });
Template.modalLinkProducts.helpers({ Template.modalLinkProducts.helpers({
products: function() { products: function() {
let prodInfo = Products.find({}, { sort: { prodName:1 }}); return Products.find({}, {sort: { prodName:1 }});
// return Products.find({}, {sort: { prodName:1 }});
if (!prodInfo) {
console.log("no product info yet.");
} else {
console.log("prod info found.");
return prodInfo;
}
} }
}); });
@ -54,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 (let i=0; i<links.length; i++) { for (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];
@ -62,33 +50,25 @@ Template.modalLinkProducts.events({
linkObjArray.push(linkObj); linkObjArray.push(linkObj);
} }
const addMenuProdLinks = async() => { Meteor.call("add.menuProdLinks", menuItemId, menuItemName, linkObjArray, function(err, result) {
let result = await Meteor.callAsync("add.menuProdLinks", menuItemId, menuItemName, linkObjArray); if (err) {
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 {
updMenuItemLinks(); Meteor.call('update.menuItemLinked', menuItemId, true, function(err, result) {
} if (err) {
} console.log(" ERROR adding link to menu item: " + err);
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 { } else {
linkInMenu(); Meteor.call('link.inMenu', menuItemId, true, function(error, nresult) {
} if (error) {
}
const linkInMenu = async() => {
let result = await Meteor.callAsync('link.inMenu', menuItemId, true);
if (!result) {
console.log(" ERROR adding link to menu sub-item: " + error); console.log(" ERROR adding link to menu sub-item: " + error);
} else { } else {
showSnackbar("Products added to Menu Item successfully!", "green"); showSnackbar("Products added to Menu Item successfully!", "green");
} }
});
} }
});
}
});
} }
} }
}); });

View file

@ -27,16 +27,14 @@ Template.addMenuModal.events({
if (menuName == "" || menuName == null) { if (menuName == "" || menuName == null) {
Session.set("menuNameErr", true); Session.set("menuNameErr", true);
} else { } else {
const addMenu = async() => { Meteor.call("add.menu", menuName, function(err, result) {
let result = await Meteor.callAsync("add.menu", menuName); if (err) {
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,6 +1,5 @@
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");
@ -22,7 +21,7 @@ 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 originated from: "); // console.log("Sender origination 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;
@ -30,38 +29,33 @@ Template.mainMenuTbl.events({
// console.log("add menu clicked"); // console.log("add menu clicked");
} else { } else {
// console.log("menuId is: " + menuId); // console.log("menuId is: " + menuId);
const addUserLast = async() => { Meteor.call('add.userLast', "Menu", menuId, function(err, result) {
Session.set("menuId", menuId); 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);
Meteor.setTimeout(function() {
FlowRouter.go('/menuitems'); FlowRouter.go('/menuitems');
}, 100);
} }
} });
addUserLast();
} }
} else if (sender.localName == "i") { } else if (sender.localName == "i") {
let menuId = this._id; let menuId = this._id;
const makrMenuComp = async() => { Meteor.call("markMenu.complete", menuId, function(err, result) {
let result = await Meteor.callAsync("markMenu.complete", menuId); if (err) {
if (!result) { console.log(" ERROR: can't mark menu complete: " + err);
// console.log(" ERROR: can't mark menu complete.");
} else { } else {
// console.log(" SUCCESS marking menu complete."); console.log(" SUCCESS marking menu complete.");
setAllMade(); Meteor.call('setAllMade.menuItem', menuId, function(err, result) {
} if (err) {
} console.log(" ERROR: cannot set all items as made: " + err);
makrMenuComp();
const setAllMade = async() => {
let result = await Meteor.callAsync('setAllMade.menuItem', menuId);
if (!result) {
// console.log(" ERROR: cannot set all items as made.");
} else { } else {
// console.log(" SUCCESS setting all items made."); console.log(" SUCCESS setting all items made.");
} }
});
} }
});
} }
}, },
}); });

View file

@ -33,26 +33,34 @@ Template.myTasksForm.events({
let taskDateArray = Session.get("taskDateArr"); let taskDateArray = Session.get("taskDateArr");
let actDate = []; let actDate = [];
console.dir(taskNameArray);
console.dir(taskDateArray);
if (taskNameArray == null || taskNameArray == [] || taskNameArray == "") { if (taskNameArray == null || taskNameArray == [] || taskNameArray == "") {
taskNameErr = true; taskNameErr = true;
} }
if (taskDateArray == null || taskDateArray == []|| taskDateArray == "") { if (taskDateArray == null || taskDateArray == []|| taskDateArray == "") {
taskDateErr = true; taskDateErr = true;
} else {
for (i = 0; i < taskDateArray.length; i++) {
// console.log(taskDateArray[i]);
let actDateTask = new Date(taskDateArray[i]);
actDate.push(actDateTask);
}
} }
// 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) {
for (const task of taskNameArray) { Meteor.call("add.task", taskNameArray, "self", "selfId", taskDateArray, actDate, function(err, result) {
for (const date of taskDateArray) { if (err) {
let actDate = new Date(date); console.log(" ERROR adding task for self: " + err);
showSnackbar("ERROR adding task for self!", "red");
addTask(task.id, date, actDate); } else {
} console.log(" SUCCESS adding task for self.");
Session.set("taskDateArr", []);
$("#myTaskName").val("");
$("#myTaskDate").val("");
showSnackbar("Added Tasks Successfully!", "green");
} }
});
} else { } else {
showSnackbar("Error! Both Task & Date are Required!", "red"); showSnackbar("Error! Both Task & Date are Required!", "red");
} }
@ -84,17 +92,3 @@ Template.myTasksForm.events({
Session.set("taskDateArr", taskDateArr); Session.set("taskDateArr", taskDateArr);
}, },
}); });
const addTask = async(task, date, actDate) => {
let result = await Meteor.callAsync("add.myTask", task, date, actDate);
if (!result) {
// console.log(" ERROR adding task for self: ");
showSnackbar("Error adding task for self!", "red");
} else {
// console.log(" SUCCESS adding task for self.");
// Session.set("taskDateArr", []);
// $("#myTaskName").val("");
// $("#myTaskDate").val("");
showSnackbar("Added Tasks Successfully!", "green");
}
}

View file

@ -55,19 +55,19 @@ Template.myTasksTbl.events({
'click .markMyTaskComplete' (event) { 'click .markMyTaskComplete' (event) {
event.preventDefault(); event.preventDefault();
let taskId = this._id; let taskId = this._id;
const makrTaskComp = async() => { Meteor.call("markTask.complete", taskId, function(err, result) {
let result = await Meteor.callAsync("markTask.complete", taskId); if (err) {
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();
// console.log("detected click"); console.log("detected click");
Session.set("deleteId", this._id); Session.set("deleteId", this._id);
Session.set("method", "delete.task"); Session.set("method", "delete.task");
Session.set("item", this.taskName); Session.set("item", this.taskName);

View file

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

@ -14,7 +14,7 @@ ListItems.allow({
}); });
Meteor.methods({ Meteor.methods({
async 'add.listItem' (itemName, listId) { 'add.listItem' (itemName, listId) {
check(itemName, String); check(itemName, String);
check(listId, String); check(listId, String);
@ -25,21 +25,18 @@ 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 });
let prodInfo = await Products.findOneAsync({ prodName: iname });
try {
if (!prodInfo) { if (!prodInfo) {
// add product info first Meteor.call("add.product", itemName, [""], function(err, result) {
let added = await Meteor.callAsync("add.product", itemName, [""]); if (err) {
if (!added) { console.log(" ERROR adding item to products: " + err);
// console.log(" ERROR adding item to products: " + err);
} else { } else {
// console.log(" SUCCESS adding item to Products."); // console.log(" SUCCESS adding item to Products.");
return await ListItems.insertAsync({ return ListItems.insert({
itemName: iname, itemName: iname,
listId: listId, listId: listId,
prodId: added, prodId: result,
addedBy: this.userId, addedBy: this.userId,
itemStore: "", itemStore: "",
itemOrdered: false, itemOrdered: false,
@ -47,8 +44,9 @@ Meteor.methods({
dateAddedToList: new Date(), dateAddedToList: new Date(),
}); });
} }
});
} else { } else {
return await ListItems.insertAsync({ return ListItems.insert({
itemName: iname, itemName: iname,
listId: listId, listId: listId,
prodId: prodInfo._id, prodId: prodInfo._id,
@ -59,11 +57,8 @@ Meteor.methods({
dateAddedToList: new Date(), dateAddedToList: new Date(),
}); });
} }
} catch(error) {
console.log(" ERROR adding new product and item: " + error);
}
}, },
async 'add.itemsFromMenuItem' (itemIds, listId) { 'add.itemsFromMenuItem' (itemIds, listId) {
check(itemIds, [String]); check(itemIds, [String]);
check(listId, String); check(listId, String);
@ -72,21 +67,15 @@ Meteor.methods({
} }
console.dir(itemIds); console.dir(itemIds);
let noitems = itemIds.length;
let i;
for (i=0; i < noitems; i++) { for (i=0; i < itemIds.length; i++) {
// let's check and make sure the product isn't already on the list // let's check and make sure the product isn't already on the list
let onList = await ListItems.find({ listId: listId, prodId: itemIds[i] }).countAsync(); let onList = ListItems.find({ listId: listId, prodId: itemIds[i] }).count();
// console.log("Number On List: " + onList); console.log("Number On List: " + onList);
if (onList == 0) { if (onList == 0) {
// now pull the product // now pull the product
let prodInfo = await Products.findOneAsync({ _id: itemIds[i] }); let prodInfo = Products.findOne({ _id: itemIds[i] });
if (!prodInfo) { ListItems.insert({
console.log("Unable to load product info.");
} else {
console.log("Run " + i);
ListItems.insertAsync({
itemName: prodInfo.prodName, itemName: prodInfo.prodName,
listId: listId, listId: listId,
prodId: prodInfo._id, prodId: prodInfo._id,
@ -96,57 +85,52 @@ Meteor.methods({
itemReceived: false, itemReceived: false,
dateAddedToList: new Date(), dateAddedToList: new Date(),
}); });
}
} else { } else {
// product exists on list, move on to next // product exists on list, move on to next
console.log("Product Exists on Selected List."); console.log("Product Exists on Selected List.");
} }
if (i == (noitems - 1)) {
console.log("Returning now.");
return true;
}
} }
}, },
async 'setOrdered.listItem' (itemId) { 'setOrdered.listItem' (itemId) {
check(itemId, String); check(itemId, String);
if (!this.userId) { if (!this.userId) {
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 await ListItems.updateAsync({ _id: itemId }, { return ListItems.update({ _id: itemId }, {
$set: { $set: {
itemOrdered: true, itemOrdered: true,
dateOrdered: new Date(), dateOrdered: new Date(),
} }
}); });
}, },
async 'setAllOrdered.listItem' (shopListId) { 'setAllOrdered.listItem' (shopListId) {
// set all items that are not already set as ordered, or set as received to ordered on this list // set all items that are not already set as ordered, or set as received to ordered on this list
}, },
async 'setNotOrdered.listItem' (itemId) { 'setNotOrdered.listItem' (itemId) {
check(itemId, String); check(itemId, String);
if (!this.userId) { if (!this.userId) {
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 await ListItems.updateAsync({ _id: itemId }, { return ListItems.update({ _id: itemId }, {
$set: { $set: {
itemOrdered: false, itemOrdered: false,
dateUnOrdered: new Date(), dateUnOrdered: new Date(),
} }
}); });
}, },
async 'setReceived.listItem' (itemId) { 'setReceived.listItem' (itemId) {
check(itemId, String); check(itemId, String);
if (!this.userId) { if (!this.userId) {
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 await ListItems.updateAsync({ _id: itemId }, { return ListItems.update({ _id: itemId }, {
$set: { $set: {
itemReceived: true, itemReceived: true,
dateReceived: new Date(), dateReceived: new Date(),
@ -154,25 +138,25 @@ Meteor.methods({
}); });
}, },
async 'setNotReceived.listItem' (shopListId) { 'setNotReceived.listItem' (shopListId) {
check(itemId, String); check(itemId, String);
if (!this.userId) { if (!this.userId) {
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 await ListItems.updateAsync({ _id: itemId }, { return ListItems.update({ _id: itemId }, {
$set: { $set: {
itemReceived: false, itemReceived: false,
dateNotReceived: new Date(), dateNotReceived: new Date(),
} }
}); });
}, },
async 'setAllReceived.listItem' () { 'setAllReceived.listItem' () {
// set all items that are not already listed as received to received on this list // set all items that are not already listed as received to received on this list
}, },
async 'edit.listItem' (itemId, itemName) { 'edit.listItem' (itemId, itemName) {
check(itemId, String); check(itemId, String);
check(itemName, String); check(itemName, String);
@ -180,19 +164,19 @@ 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 await ListItems.updateAsync({ _id: itemId }, { return ListItems.update({ _id: itemId }, {
$set: { $set: {
itemName: itemName, itemName: itemName,
} }
}); });
}, },
async 'delete.listItem' (itemId) { 'delete.listItem' (itemId) {
check(itemId, String); check(itemId, String);
if (!this.userId) { if (!this.userId) {
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 await ListItems.removeAsync({ _id: itemId }); return ListItems.remove({ _id: itemId });
} }
}); });

View file

@ -12,7 +12,7 @@ Lists.allow({
}); });
Meteor.methods({ Meteor.methods({
async 'add.list' (listName, isShared) { 'add.list' (listName, isShared) {
check(listName, String); check(listName, String);
check(isShared, Boolean); check(isShared, Boolean);
@ -20,14 +20,14 @@ 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 await Lists.insertAsync({ return Lists.insert({
listName: listName, listName: listName,
listShared: isShared, listShared: isShared,
listOwner: this.userId, listOwner: this.userId,
listComplete: false, listComplete: false,
}); });
}, },
async 'edit.list' (listId, listName, isShared) { 'edit.list' (listId, listName, isShared) {
check(listId, String); check(listId, String);
check(listName, String); check(listName, String);
check(isShared, Boolean); check(isShared, Boolean);
@ -36,55 +36,41 @@ 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 await Lists.updateAsync({ _id: listId }, { return Lists.update({ _id: listId }, {
$set: { $set: {
listName: listName, listName: listName,
listShared: isShared, listShared: isShared,
} }
}); });
}, },
async 'delete.list' (listId) { 'delete.list' (listId) {
check(listId, String); check(listId, String);
if (!this.userId) { if (!this.userId) {
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 await Lists.removeAsync({ _id: listId }); return Lists.remove({ _id: listId });
}, },
async 'mark.complete' (listId) { 'mark.complete' (listId) {
check(listId, String); check(listId, String);
if (!this.userId) { if (!this.userId) {
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 await Lists.updateAsync({ _id: listId }, { return Lists.update({ _id: listId }, {
$set: { $set: {
listComplete: true, listComplete: true,
completedOn: new Date() completedOn: new Date()
} }
}); });;
}, },
async 'mark.incomplete' (listId) { 'clean.Lists' () {
check(listId, String);
if (!this.userId) {
throw new Meteor.Error('You are not allowed to restore completed lists. Make sure you are logged in with valid user credentials.');
}
return await Lists.updateAsync({ _id: listId }, {
$set: {
listComplete: false,
completedOn: new Date()
}
});
},
async 'clean.Lists' () {
if (!this.userId) { if (!this.userId) {
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 await Lists.removeAsync({ listComplete: true }); return Lists.remove({ listComplete: true });
}, },
}); });

View file

@ -12,10 +12,10 @@ MScripts.allow({
}); });
Meteor.methods({ Meteor.methods({
async 'set.ScriptRun' (scriptName) { 'set.ScriptRun' (scriptName) {
check(scriptName, String); check(scriptName, String);
return await MScripts.insertAsync({ MScripts.insert({
scriptName: scriptName, scriptName: scriptName,
hasRun: true, hasRun: true,
runOn: new Date(), runOn: new Date(),

View file

@ -15,20 +15,20 @@ Menus.allow({
}); });
Meteor.methods({ Meteor.methods({
async 'add.menu' (menuName) { 'add.menu' (menuName) {
check(menuName, String); check(menuName, String);
if (!this.userId) { if (!this.userId) {
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 await Menus.insertAsync({ return Menus.insert({
menuName: menuName, menuName: menuName,
menuOwner: this.userId, menuOwner: this.userId,
menuComplete: false, menuComplete: false,
}); });
}, },
async 'edit.menu' (menuId, menuName) { 'edit.menu' (menuId, menuName) {
check(menuId, String); check(menuId, String);
check(menuName, String); check(menuName, String);
@ -36,55 +36,88 @@ 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 await Menus.updateAsync({ _id: menuId }, { return Menus.update({ _id: menuId }, {
$set: { $set: {
menuName: menuName, menuName: menuName,
} }
}); });
}, },
async 'delete.menu' (menuId) { 'delete.menu' (menuId) {
check(menuId, String); check(menuId, String);
if (!this.userId) { if (!this.userId) {
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 await Menus.removeAsync({ _id: menuId }); return Menus.remove({ _id: menuId });
}, },
async 'markMenu.complete' (menuId) { 'markMenu.complete' (menuId) {
check(menuId, String); check(menuId, String);
if (!this.userId) { if (!this.userId) {
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 await Menus.updateAsync({ _id: menuId }, { return Menus.update({ _id: menuId }, {
$set: { $set: {
menuComplete: true, menuComplete: true,
} }
}); });
}, },
async 'markMenu.notComplete' (menuId) { 'markMenu.notComplete' (menuId) {
check(menuId, String); check(menuId, String);
if (!this.userId) { if (!this.userId) {
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 await Menus.updateAsync({ _id: menuId }, { return Menus.update({ _id: menuId }, {
$set: { $set: {
menuComplete: false, menuComplete: false,
} }
}); });
}, },
async 'clean.Menus' () { 'clean.Menus' () {
if (!this.userId) { if (!this.userId) {
throw new Meteor.Error('You are not allowed to clean up old Menus. Make sure you are logged in with valid user credentials.'); throw new Meteor.Error('You are not allowed to clean up old Menus. Make sure you are logged in with valid user credentials.');
} }
return await Menus.removeAsync({ menuComplete: true }); let removeMenuIds = [];
// let's find all the menus with menu items that are past their date.
let menuList = Menus.find({ menuComplete: false }).fetch();
for (i=0; i < menuList.length; i++) {
let removeMenu = true;
let items = MenuItems.find({ menuId: menuList[i]._id }).fetch();
for (j=0; j < items.length; j++) {
let srvDate = moment(items[j].serveDateActual);
let today = moment();
let expired = moment(today).isAfter(srvDate);
if (expired != true) {
removeMenu = false;
}
if (j == items.length - 1) {
if (removeMenu == true) {
removeMenuIds.push(menuList[i]._id);
}
}
}
}
// next let's add the ids of any menus that are marked complete
let markedComplete = Menus.find({ menuComplete: true }).fetch();
for (k = 0; k < markedComplete.length; k++) {
let menuId = markedComplete[k]._id;
removeMenuIds.push(menuId);
}
// finally we'll cycle through the ids and remove the items we collected up.
for (l = 0; l < removeMenuIds.length; l++) {
Menus.remove({ _id: removeMenuIds[l] });
}
}, },
async 'addto.Menu' (menuId, menuItem, menuItemId, dateSrv, isLinked) { 'addto.Menu' (menuId, menuItem, menuItemId, dateSrv, isLinked) {
check(menuId, String); check(menuId, String);
check(menuItem, String); check(menuItem, String);
check(menuItemId, String); check(menuItemId, String);
@ -95,9 +128,9 @@ Meteor.methods({
throw new Meteor.Error('You are not allowed to add items to menus. Make sure you are logged in with valid user credentials.'); throw new Meteor.Error('You are not allowed to add items to menus. Make sure you are logged in with valid user credentials.');
} }
let serveDateActual = new Date(dateSrv); serveDateActual = new Date(dateSrv);
return await Menus.updateAsync({ _id: menuId }, { return Menus.update({ _id: menuId }, {
$addToSet: { $addToSet: {
menuItems: menuItems:
{ {
@ -110,7 +143,7 @@ Meteor.methods({
} }
}); });
}, },
async 'link.inMenu' (menuItemId, isLinked) { 'link.inMenu' (menuItemId, isLinked) {
check(menuItemId, String); check(menuItemId, String);
check(isLinked, Boolean); check(isLinked, Boolean);
@ -118,13 +151,13 @@ 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 await Menus.updateAsync({ 'menuItems.menuItemId': menuItemId }, { return Menus.update({ 'menuItems.menuItemId': menuItemId }, {
$set: { $set: {
"menuItems.$.isLinked": isLinked "menuItems.$.isLinked": isLinked
} }
}); });
}, },
async 'delete.itemFromMenu' (itemIds) { 'delete.itemFromMenu' (itemIds) {
check(itemIds, String); check(itemIds, String);
if (!this.userId) { if (!this.userId) {
@ -132,9 +165,9 @@ 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 await Menus.updateAsync({ _id: ids[0] }, { return Menus.update({ _id: ids[0] }, {
$pull: { $pull: {
menuItems: { menuItems: {
menuItemId: ids[1], menuItemId: ids[1],

View file

@ -12,21 +12,21 @@ MenuItems.allow({
}); });
Meteor.methods({ Meteor.methods({
async 'add.menuItem' (itemName) { 'add.menuItem' (itemName) {
check(itemName, String); check(itemName, String);
if (!this.userId) { if (!this.userId) {
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 await MenuItems.insertAsync({ return MenuItems.insert({
itemName: itemName, itemName: itemName,
addedBy: this.userId, addedBy: this.userId,
dateAddedtoMenu: new Date(), dateAddedtoMenu: new Date(),
isLinked: false, isLinked: false,
}); });
}, },
async 'update.menuItemLinked' (itemId, isLinked) { 'update.menuItemLinked' (itemId, isLinked) {
check(itemId, String); check(itemId, String);
check(isLinked, Boolean); check(isLinked, Boolean);
@ -34,13 +34,13 @@ 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 await MenuItems.updateAsync({ _id: itemId }, { return MenuItems.update({ _id: itemId }, {
$set: { $set: {
isLinked: isLinked, isLinked: isLinked,
} }
}); });
}, },
async 'edit.madeItem' (itemId, itemName) { 'edit.madeItem' (itemId, itemName) {
check(itemId, String); check(itemId, String);
check(itemName, String); check(itemName, String);
@ -48,22 +48,22 @@ 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 await MenuItems.updateAsync({ _id: itemId }, { return MenuItems.update({ _id: itemId }, {
$set: { $set: {
itemName: itemName, itemName: itemName,
} }
}); });
}, },
async 'delete.menuItem' (itemId) { 'delete.menuItem' (itemId) {
check(itemId, String); check(itemId, String);
if (!this.userId) { if (!this.userId) {
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 await MenuItems.removeAsync({ _id: itemId }); return MenuItems.remove({ _id: itemId });
}, },
async 'shiftDate' (itemId, momentAddDay) { 'shiftDate' (itemId, momentAddDay) {
check(itemId, String); check(itemId, String);
check(momentAddDay, String); check(momentAddDay, 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 await MenuItems.updateAsync({ _id: itemId }, { return MenuItems.update({ _id: itemId }, {
$set: { $set: {
serveDate: momentAddDay, serveDate: momentAddDay,
} }

View file

@ -13,7 +13,7 @@ MenuProdLinks.allow({
}); });
Meteor.methods({ Meteor.methods({
async 'add.menuProdLinks' (menuItemId, menuItemName, prodNameArray) { 'add.menuProdLinks' (menuItemId, menuItemName, prodNameArray) {
check(menuItemId, String); check(menuItemId, String);
check(menuItemName, String); check(menuItemName, String);
check(prodNameArray, [Object]); check(prodNameArray, [Object]);
@ -22,19 +22,19 @@ 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.');
}; };
let linkExists = await MenuProdLinks.findOneAsync({ menuItemId: menuItemId }); let linkExists = MenuProdLinks.findOne({ menuItemId: menuItemId });
if (linkExists) { if (linkExists) {
// console.log("sending to update method instead."); console.log("sending to update method instead.");
await Meteor.callAsync('update.menuPordLInks', menuItemId, menuItemName, prodNameArray, function(err, result) { Meteor.call('update.menuPordLInks', menuItemId, menuItemName, prodNameArray, function(err, result) {
if (err) { if (err) {
// console.log(" ERROR moving to the update method: " + err); console.log(" ERROR moving to the update method: " + err);
} else { } else {
// console.log("Successfully updated the menu prod links.") console.log("Successfully updated the menu prod links.")
} }
}); });
} else { } else {
return await MenuProdLinks.insertAsync({ return MenuProdLinks.insert({
menuItemId: menuItemId, menuItemId: menuItemId,
menuItemName: menuItemName, menuItemName: menuItemName,
products: prodNameArray, products: prodNameArray,
@ -43,7 +43,7 @@ Meteor.methods({
}); });
} }
}, },
async 'update.menuPordLInks' (menuItemId, menuItemName, prodNameArray) { 'update.menuPordLInks' (menuItemId, menuItemName, prodNameArray) {
check(menuItemId, String); check(menuItemId, String);
check(menuItemName, String); check(menuItemName, String);
check(prodNameArray, [Object]); check(prodNameArray, [Object]);
@ -52,8 +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.');
}; };
console.log(" ---- Doing an Update instead! ---- "); return MenuProdLinks.update({ menuItemId: menuItemId }, {
return await MenuProdLinks.updateAsync({ menuItemId: menuItemId }, {
$set: { $set: {
products: prodNameArray, products: prodNameArray,
dateUpdated: Date(), dateUpdated: Date(),

View file

@ -12,7 +12,7 @@ Products.allow({
}); });
Meteor.methods({ Meteor.methods({
async 'add.product' (prodName, prodStore) { 'add.product' (prodName, prodStore) {
check(prodName, String); check(prodName, String);
check(prodStore, [String]); check(prodStore, [String]);
@ -24,20 +24,17 @@ Meteor.methods({
// first does this product already exist? // first does this product already exist?
let prodExists = await Products.findOneAsync({ prodName: pname }); let prodExists = Products.findOne({ prodName: pname });
try {
if (!prodExists) { if (!prodExists) {
return await Products.insertAsync({ return Products.insert({
prodName: pname, prodName: pname,
prodOwner: this.userId, prodOwner: this.userId,
prodStore: prodStore, prodStore: prodStore,
}); });
} }
} catch(error) {
console.log(" ERROR adding Pdocut: " + error);
}
}, },
async 'edit.product' (prodId, prodName, prodStore) { 'edit.product' (prodId, prodName, prodStore) {
check(prodId, String); check(prodId, String);
check(prodName, String); check(prodName, String);
check(prodStore, [String]); check(prodStore, [String]);
@ -48,30 +45,20 @@ Meteor.methods({
let pname = prodName.charAt(0).toUpperCase() + prodName.slice(1); let pname = prodName.charAt(0).toUpperCase() + prodName.slice(1);
return await Products.updateAsync({ _id: prodId }, { return Products.update({ _id: prodId }, {
$set: { $set: {
prodName: pname, prodName: pname,
prodStore: prodStore, prodStore: prodStore,
} }
}); });
}, },
async 'delete.product' (prodId) { 'delete.product' (prodId) {
check(prodId, String); check(prodId, String);
if (!this.userId) { if (!this.userId) {
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 await Products.removeAsync({ _id: prodId }); return Products.remove({ _id: prodId });
},
async 'clean.Products' () {
if (!this.userId) {
throw new Meteor.Error('You are not allowed to delete products. Make sure you are logged in with valid user credentials.');
}
// first we need to find potential duplicate products
// next we need to see which of those are on incomplete lists
// Then we'll update those to use the main products ID instead
// finally we'll delete the duplicates
} }
}); });

View file

@ -12,7 +12,7 @@ RecipeItems.allow({
}); });
Meteor.methods({ Meteor.methods({
async 'add.recipeItem' (recipeId, recipeItemType, recipeItem) { 'add.recipeItem' (recipeId, recipeItemType, recipeItem) {
check(recipeId, String); check(recipeId, String);
check(recipeItemType, String); check(recipeItemType, String);
check(recipeItem, String); check(recipeItem, String);
@ -21,13 +21,13 @@ 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 await RecipeItems.insertAsync({ return RecipeItems.insert({
recipeId: recipeId, recipeId: recipeId,
recipeItemType: recipeItemType, recipeItemType: recipeItemType,
recipeItem: recipeItem, recipeItem: recipeItem,
}); });
}, },
async 'edit.recipeItem' (recipeItemId, recipeId, recipeItemType, recipeItem) { 'edit.recipeItem' (recipeItemId, recipeId, recipeItemType, recipeItem) {
check(recipeItemId, String); check(recipeItemId, String);
check(recipeId, String); check(recipeId, String);
check(recipeItemType, String); check(recipeItemType, String);
@ -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 await RecipeItems.updateAsync({ _id: recipeItemId }, { return RecipeItems.update({ _id: recipeItemId }, {
$set: { $set: {
recipeId: recipeId, recipeId: recipeId,
recipeItemType: recipeItemType, recipeItemType: recipeItemType,
@ -45,13 +45,13 @@ Meteor.methods({
} }
}); });
}, },
async 'delete.recipeItem' (recipeItemId) { 'delete.recipeItem' (recipeItemId) {
check(recipeItemId, String); check(recipeItemId, String);
if (!this.userId) { if (!this.userId) {
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 await RecipeItems.removeAsync({ _id: recipeItemId }); return RecipeItems.remove({ _id: recipeItemId });
} }
}); });

View file

@ -12,20 +12,20 @@ Recipes.allow({
}); });
Meteor.methods({ Meteor.methods({
async 'add.recipe' (recipeName) { 'add.recipe' (recipeName) {
check(recipeName, String); check(recipeName, String);
if (!this.userId) { if (!this.userId) {
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 await Recipes.insertAsync({ return Recipes.insert({
recipeName: recipeName, recipeName: recipeName,
addedBy: this.userId, addedBy: this.userId,
addedOn: new Date(), addedOn: new Date(),
}); });
}, },
async 'edit.recipe' (recipeId, recipeName) { 'edit.recipe' (recipeId, recipeName) {
check(recipeId, String); check(recipeId, String);
check(recipeName, String); check(recipeName, String);
@ -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 await Recipes.updateAsync({ _id: recipeId }, { return Recipes.update({ _id: recipeId }, {
$set: { $set: {
recipeName: recipeName, recipeName: recipeName,
updatedOn: new Date(), updatedOn: new Date(),
@ -41,13 +41,13 @@ Meteor.methods({
} }
}); });
}, },
async 'delete.recipe' (recipeId) { 'delete.recipe' (recipeId) {
check(recipeId, String); check(recipeId, String);
if (!this.userId) { if (!this.userId) {
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 await Recipes.removeAsync({ _id: recipeId }); return Recipes.remove({ _id: recipeId });
} }
}); });

View file

@ -12,19 +12,19 @@ ShopLists.allow({
}); });
Meteor.methods({ Meteor.methods({
async 'add.shopList' (shopName) { 'add.shopList' (shopName) {
check(shopName, Sring); check(shopName, Sring);
if (!this.userId) { if (!this.userId) {
throw new Meteor.Error('You are not allowed to add shopping lists. Make sure you are logged in with valid user credentials.'); throw new Meteor.Error('You are not allowed to add shopping lists. Make sure you are logged in with valid user credentials.');
} }
return await ShopLists.insert({ return ShopLists.insert({
shopName: shopName, shopName: shopName,
shopOwner: this.userId, shopOwner: this.userId,
}); });
}, },
async 'edit.shopList' (shopId, shopName) { 'edit.shopList' (shopId, shopName) {
check(shopId, String); check(shopId, String);
check(shopName, String); check(shopName, String);
@ -32,19 +32,19 @@ Meteor.methods({
throw new Meteor.Error('You are not allowed to edit shopping lists. Make sure you are logged in with valid user credentials.'); throw new Meteor.Error('You are not allowed to edit shopping lists. Make sure you are logged in with valid user credentials.');
} }
return await ShopLists.update({ _id: shopId }, { return ShopLists.update({ _id: shopId }, {
$set: { $set: {
shopName: shopName, shopName: shopName,
} }
}); });
}, },
async 'delete.shopList' (shopId) { 'delete.shopList' (shopId) {
check(shopId, String); check(shopId, String);
if (!this.userId) { if (!this.userId) {
throw new Meteor.Error('You are not allowed to delete shopping lists. Make sure you are logged in with valid user credentials.'); throw new Meteor.Error('You are not allowed to delete shopping lists. Make sure you are logged in with valid user credentials.');
} }
return await ShopLists.remove({ _id: shopId }); return ShopLists.remove({ _id: shopId });
}, },
}); });

View file

@ -12,19 +12,19 @@ Stores.allow({
}); });
Meteor.methods({ Meteor.methods({
async 'add.store' (storeName) { 'add.store' (storeName) {
check(storeName, String); check(storeName, String);
if (!this.userId) { if (!this.userId) {
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 await Stores.insertAsync({ return Stores.insert({
storeName: storeName, storeName: storeName,
owner: this.userId, owner: this.userId,
}); });
}, },
async 'edit.store' (storeId, storeName) { 'edit.store' (storeId, storeName) {
check(storeId, String); check(storeId, String);
check(storeName, String); check(storeName, String);
@ -32,19 +32,19 @@ 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 await Stores.updateAsync({ _id: storeId }, { return Stores.update({ _id: storeId }, {
$set: { $set: {
storeName: storeName, storeName: storeName,
} }
}); });
}, },
async 'delete.store' (storeId) { 'delete.store' (storeId) {
check(storeId, String); check(storeId, String);
if (!this.userId) { if (!this.userId) {
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 await Stores.removeAsync({ _id: storeId }); return Stores.remove({ _id: storeId });
}, },
}); });

View file

@ -12,7 +12,7 @@ SysConfig.allow({
}); });
Meteor.methods({ Meteor.methods({
async 'add.noSysAdminReg' (admReg, genReg) { 'add.noSysAdminReg' (admReg, genReg) {
check(admReg, Boolean); check(admReg, Boolean);
check(genReg, Boolean); check(genReg, Boolean);
@ -20,39 +20,25 @@ 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.');
} }
const currConfig = async() => { let curr = SysConfig.findOne({});
let curr = await SysConfig.findOneAsync({}); if (typeof curr != 'undefined') {
if (!curr) { let configId = curr._id;
try { Meteor.call('edit.noSysAdminReg', configId, admReg, genReg, function(err, result) {
return await SysConfig.insertAsync({ if (err) {
console.log(" ERROR updating sys admin reg: " + err);
} else {
console.log("Success updating sys admin reg.");
}
});
} else {
return SysConfig.insert({
SysAdminReg: admReg, SysAdminReg: admReg,
dateAdded: new Date(), dateAdded: new Date(),
allowReg: genReg, 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 {
// console.log("Success updating sys admin reg.");
}
} catch(error) {
console.log(" ERROR trying to pull current system config:");
console.log(error.message);
console.log(error.stack);
}
}
}
currConfig();
}, },
async 'edit.noSysAdminReg' (configId, canReg, genReg) { 'edit.noSysAdminReg' (configId, canReg, genReg) {
check(canReg, Boolean); check(canReg, Boolean);
check(configId, String); check(configId, String);
check(genReg, Boolean); check(genReg, Boolean);
@ -61,7 +47,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 await SysConfig.updateAsync({ _id: configId }, { return SysConfig.update({ _id: configId }, {
$set: { $set: {
SysAdminReg: canReg, SysAdminReg: canReg,
allowReg: genReg, allowReg: genReg,
@ -69,7 +55,7 @@ Meteor.methods({
} }
}); });
}, },
async 'allow.updateInfo' (allowUpdate) { 'allow.updateInfo' (allowUpdate) {
check(allowUpdate, Boolean); check(allowUpdate, Boolean);
if (!this.userId) { if (!this.userId) {
@ -80,7 +66,7 @@ Meteor.methods({
let configId = curr._id; let configId = curr._id;
return await SysConfig.updateAsync({ _id: configId }, { return SysConfig.update({ _id: configId }, {
$set: { $set: {
allowUpdates: allowUpdate, allowUpdates: allowUpdate,
} }

View file

@ -13,7 +13,7 @@ TaskItems.allow({
}); });
Meteor.methods({ Meteor.methods({
async 'add.task' (taskNameArr, assignedTo, assignedToId, taskDateArr, actDate) { 'add.task' (taskNameArr, assignedTo, assignedToId, taskDateArr, actDate) {
check(taskNameArr, [Object]); check(taskNameArr, [Object]);
check(assignedTo, String); check(assignedTo, String);
check(taskDateArr, [String]); check(taskDateArr, [String]);
@ -24,13 +24,23 @@ Meteor.methods({
throw new Meteor.Error('You are not allowed to add tasks. Make sure you are logged in with valid user credentials.'); throw new Meteor.Error('You are not allowed to add tasks. Make sure you are logged in with valid user credentials.');
} }
for (let i=0; i < taskDateArr.length; i++) { let username;
for (let j=0; j < taskNameArr.length; j++) {
await TaskItems.insertAsync({ if (assignedTo == "self") {
let userInfo = Meteor.users.findOne({ _id: this.userId });
username = userInfo.profile.fullname;
assignedToId = this.userId;
} else {
username = assignedTo;
}
for (i=0; i < taskDateArr.length; i++) {
for (j=0; j < taskNameArr.length; j++) {
TaskItems.insert({
taskName: taskNameArr[j].id, taskName: taskNameArr[j].id,
taskDate: taskDateArr[i], taskDate: taskDateArr[i],
actualDate: actDate[i], actualDate: actDate[i],
assignedTo: assignedTo, assignedTo: username,
assignedToId: assignedToId, assignedToId: assignedToId,
isComplete: false, isComplete: false,
completedOn: null, completedOn: null,
@ -40,7 +50,7 @@ Meteor.methods({
} }
} }
}, },
async 'add.myTask' (taskName, taskDate, actDate) { 'add.mytask' (taskName, assignedTo, assignedToId, taskDate, actDate) {
check(taskName, String); check(taskName, String);
check(taskDate, String); check(taskDate, String);
check(actDate, Date); check(actDate, Date);
@ -49,28 +59,29 @@ Meteor.methods({
throw new Meteor.Error('You are not allowed to add tasks. Make sure you are logged in with valid user credentials.'); throw new Meteor.Error('You are not allowed to add tasks. Make sure you are logged in with valid user credentials.');
} }
let userInfo = await Meteor.users.findOneAsync({ _id: this.userId }); let username;
if (!userInfo) {
// console.log("No matching user info found.") if (assignedTo == "self") {
let userInfo = Meteor.users.findOne({ _id: this.userId });
username = userInfo.profile.fullname;
assignedToId = this.userId;
} else { } else {
try { username = assignedTo;
return await TaskItems.insertAsync({ }
return TaskItems.insert({
taskName: taskName, taskName: taskName,
taskDate: taskDate, taskDate: taskDate,
actualDate: actDate, actualDate: actDate,
assignedTo: userInfo.profile.fullname, assignedTo: username,
assignedToId: this.userId, assignedToId: assignedToId,
isComplete: false, isComplete: false,
completedOn: null, completedOn: null,
assignedOn: new Date(), assignedOn: new Date(),
assignedBy: this.userId, assignedBy: this.userId,
}); });
} catch(error) {
console.log(" ERROR adding tasksL " + error.message);
}
}
}, },
async 'edit.task' (taskId, taskName, assignedTo, taskDate) { 'edit.task' (taskId, taskName, assignedTo, taskDate) {
check(taskId, String); check(taskId, String);
check(taskName, String); check(taskName, String);
check(assignedTo, String); check(assignedTo, String);
@ -80,7 +91,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 await TaskItems.updateAsync({ _id: taskId }, { return TaskItems.update({ _id: taskId }, {
$set: { $set: {
taskName: taskName, taskName: taskName,
taskDate: taskDate, taskDate: taskDate,
@ -90,23 +101,23 @@ Meteor.methods({
} }
}); });
}, },
async 'delete.task' (taskId) { 'delete.task' (taskId) {
check(taskId, String); check(taskId, String);
if (!this.userId) { if (!this.userId) {
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 await TaskItems.removeAsync({ _id: taskId }); return TaskItems.remove({ _id: taskId });
}, },
async 'markTask.complete' (taskId) { 'markTask.complete' (taskId) {
check(taskId, String); check(taskId, String);
if (!this.userId) { if (!this.userId) {
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 await TaskItems.updateAsync({ _id: taskId }, { return TaskItems.update({ _id: taskId }, {
$set: { $set: {
isComplete: true, isComplete: true,
completedOn: new Date(), completedOn: new Date(),
@ -114,14 +125,14 @@ Meteor.methods({
} }
}); });
}, },
async 'markTask.notComplete' (taskId) { 'markTask.notComplete' (taskId) {
check(taskId, String); check(taskId, String);
if (!this.userId) { if (!this.userId) {
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 await TaskItems.updateAsync({ _id: taskId }, { return TaskItems.update({ _id: taskId }, {
$set: { $set: {
isComplete: false, isComplete: false,
markedUncomplteOn: new Date(), markedUncomplteOn: new Date(),
@ -129,7 +140,7 @@ Meteor.methods({
} }
}); });
}, },
async 'clean.Tasks' (timeFrame) { 'clean.Tasks' (timeFrame) {
check(timeFrame, String); check(timeFrame, String);
if (!this.userId) { if (!this.userId) {
@ -140,29 +151,29 @@ Meteor.methods({
let upToDate = ""; let upToDate = "";
switch(timeFrame) { switch(timeFrame) {
case "1-week": case "1-week":
// console.log("1 Week"); console.log("1 Week");
upToDate = 7 * 24 * 60 * 60 * 1000; upToDate = 7 * 24 * 60 * 60 * 1000;
break; break;
case "2-weeks": case "2-weeks":
// console.log("2 Week"); console.log("2 Week");
upToDate = 14 * 24 * 60 * 60 * 1000; upToDate = 14 * 24 * 60 * 60 * 1000;
break; break;
case '1-month': case '1-month':
// console.log("1 month"); console.log("1 month");
upToDate = 30 * 24 * 60 * 60 * 1000; upToDate = 30 * 24 * 60 * 60 * 1000;
break; break;
case '3-months': case '3-months':
// console.log("3 months"); console.log("3 months");
upToDate = 90 * 24 * 60 * 60 * 1000; upToDate = 90 * 24 * 60 * 60 * 1000;
break; break;
case 'all': case 'all':
// console.log("all"); console.log("all");
upToDate = 1 * 24 * 60 * 60 * 1000; upToDate = 1 * 24 * 60 * 60 * 1000;
break; break;
default: default:
break; break;
} }
return await TaskItems.removeAsync({ actualDate: { $lt: new Date((new Date()) - upToDate )}}); return TaskItems.remove({ actualDate: { $lt: new Date((new Date()) - upToDate )}});
} }
}); });

View file

@ -12,24 +12,24 @@ UpdateInfo.allow({
}); });
Meteor.methods({ Meteor.methods({
async 'add.updateInfo' (updateObject) { 'add.updateInfo' (updateObject) {
check(updateObject, Object); check(updateObject, Object);
return await UpdateInfo.insertAsync({ UpdateInfo.insert({
title: updateObject.title, title: updateObject.title,
description: updateObject.description, description: updateObject.description,
dateRelease: updateObject.date, dateRelease: updateObject.date,
releaseLink: updateObject.link releaseLink: updateObject.link
}); });
}, },
async 'markUpdate.read' (updateId) { 'markUpdate.read' (updateId) {
check(updateId, String); check(updateId, String);
if (!this.userId) { if (!this.userId) {
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 await UpdateInfo.updateAsync({ _id: updateId }, { return UpdateInfo.update({ _id: updateId }, {
$set: { $set: {
viewed: true viewed: true
} }

View file

@ -9,38 +9,43 @@ 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({
async 'add.darkModePref' (pref) { 'add.darkModePref' (pref) {
check(pref, String); check(pref, String);
if (!this.userId) { if (!this.userId) {
throw new Meteor.Error('Not able to change theme 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 await UserConfig.insertAsync({ return UserConfig.insert({
user: this.userId, user: this.userId,
darkMode: pref, darkMode: pref,
dateAdded: Date() dateAdded: Date()
}); });
}, },
async 'update.darkModePref' (pref) { 'update.darkModePref' (pref) {
check(pref, String); check(pref, String);
if (!this.userId) { if (!this.userId) {
throw new Meteor.Error('Not able to change theme 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 await UserConfig.updateAsync({ user: this.userId }, { let myConfig = UserConfig.findOne({ user: this.userId });
if (typeof myConfig == 'undefined') {
Meteor.call('add.darkModePref', pref, function(err, result) {
if (err) {
console.log(" ERROR calling the add functioin for dark mode: " + err);
}
});
} else {
return UserConfig.update({ user: this.userId }, {
$set: { $set: {
darkMode: pref, darkMode: pref,
dateUpdate: Date() dateUpdate: Date()
} }
}); });
} }
}
}); });

View file

@ -12,10 +12,10 @@ UserConfigOptions.allow({
}); });
Meteor.methods({ Meteor.methods({
async 'change.userPass' (usersId, password) { 'change.userPass' (usersId, password) {
check(usersId, String); check(usersId, String);
check(password, String); check(password, String);
return await Accounts.setPasswordAsync(usersId, password); return Accounts.setPassword(usersId, password);
}, },
}); });

View file

@ -12,7 +12,7 @@ UserLast.allow({
}); });
Meteor.methods({ Meteor.methods({
async 'add.userLast' (view, viewId) { 'add.userLast' (view, viewId) {
check(view, String); check(view, String);
check(viewId, String); check(viewId, String);
@ -22,33 +22,24 @@ 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 = await UserLast.findOneAsync({ userId: this.userId, view: view }); let userListInfo = UserLast.findOne({ userId: this.userId, view: view });
if (!userListInfo) { if (typeof userListInfo != 'undefined' && userListInfo != "" && userListInfo != null) {
// console.log("Adding new user last item."); // entry exists, call the edit function instead
return await UserLast.insertAsync({ Meteor.call('edit.userLast', view, viewId, function(err, result) {
if (err) {
console.log(" ERROR moving user to edit for last view: " + err);
}
});
} else {
return UserLast.insert({
userId: this.userId, userId: this.userId,
view: view, view: view,
viewId: viewId, viewId: viewId,
dateAdded: Date(), 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;
}
} }
}, },
async 'edit.userLast' (view, viewId) { 'edit.userLast' (view, viewId) {
check(view, String); check(view, String);
check(viewId, String); check(viewId, String);
@ -56,8 +47,7 @@ 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.');
} }
// console.log("Edit in progress."); return UserLast.update({ view: view, userId: this.userId }, {
return await UserLast.updateAsync({ view: view, userId: this.userId }, {
$set: { $set: {
viewId: viewId, viewId: viewId,
dateLastUpdate: Date(), dateLastUpdate: Date(),

View file

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

1784
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

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

View file

@ -1,5 +1,3 @@
// 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';
@ -7,52 +5,44 @@ 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(async() => { Meteor.startup(() => {
// code to run on server at startup // code to run on server at startup
Roles.createRoleAsync("user", {unlessExists: true}); Roles.createRole("user", {unlessExists: true});
Roles.createRoleAsync("admin", {unlessExists: true}); Roles.createRole("admin", {unlessExists: true});
Roles.createRoleAsync("systemadmin", {unlessExists: true}); Roles.createRole("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 = await MScripts.findOneAsync({ scriptName: "DefaultRegPolicy", scriptRun: true }); let regPolRun = MScripts.findOne({ scriptName: "DefaultRegPolicy", scriptRun: true });
if (!regPolRun) { if (typeof regPolRun == "undefined" || regPolRun == null || regPolRun == "") {
try { let regPolicy = SysConfig.findOne({});
let regPolicy = await SysConfig.findOneAsync({}); if (typeof regPolicy == 'undefined') {
if (!regPolicy) { return SysConfig.insert({
SysConfig.insertAsync({
SysAdminReg: false, SysAdminReg: false,
dateAdded: new Date(), dateAdded: new Date(),
allowReg: true, allowReg: true,
allowUpdates: true, allowUpdates: true,
}); });
markScriptRun("DefaultRegPolicy");
} else { } else {
// console.log("Registration policy already set."); // console.log("Registration policy already set.");
markScriptRun("DefaultRegPolicy"); 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 = await MScripts.findOneAsync({ scriptName: "updateMenuItemLinks", scriptRun: true }); let linkUpdateRun = MScripts.findOne({ scriptName: "updateMenuItemLinks", scriptRun: true });
try { if (typeof linkUpdateRun == 'undefined' || linkUpdateRun == null || linkUpdateRun == "") {
if (!linkUpdateRun) {
let itemInfoNoLink = MenuItems.find({ isLinked: { $exists: false } }).fetch(); let itemInfoNoLink = MenuItems.find({ isLinked: { $exists: false } }).fetch();
// console.log("No Ites with isLinked not set: " + itemInfoNoLink.length); // console.log("No Ites with isLinked not set: " + itemInfoNoLink.length);
if (itemInfoNoLink.length > 0) { if (itemInfoNoLink.length > 0) {
// console.log("Found items with isLinked not set. Updating..."); // console.log("found items with isLinked not set.");
// console.dir(itemInfoNoLink); // console.dir(itemInfoNoLink);
let infoLength = itemInfoNoLink.length; let infoLength = itemInfoNoLink.length;
for (i=0; i < infoLength; i++) { for (i=0; i < infoLength; i++) {
MenuItems.updateAsync({ _id: itemInfoNoLink[i]._id }, { MenuItems.update({ _id: itemInfoNoLink[i]._id }, {
$set: { $set: {
isLinked: false, isLinked: false,
} }
@ -67,21 +57,16 @@ Meteor.startup(async() => {
markScriptRun("updateMenuItemLinks"); 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 = await MScripts.findOneAsync({ scriptName: "changeProdStoreToArray", scriptRun: true }); let prodStoreArrayRun = MScripts.findOne({ scriptName: "changeProdStoreToArray", scriptRun: true });
if (!prodStoreArrayRun) { if (!prodStoreArrayRun) {
try {
let prodInfo = Products.find({}).fetch(); let prodInfo = Products.find({}).fetch();
let prodCount = prodInfo.length; let prodCount = prodInfo.length;
// console.log("Updating Products to allow multiple store assocation for " + prodCount + " products."); console.log("Updating Products to allow multiple store assocation for " + prodCount + " products.");
for (let j = 0; j < prodCount; j++) { for (j = 0; j < prodCount; j++) {
if (typeof prodInfo[j].prodStore == 'object') { if (typeof prodInfo[j].prodStore == 'object') {
// console.log(typeof prodInfo[j].prodStore); // console.log(typeof prodInfo[j].prodStore);
// console.log("Is Array already"); // console.log("Is Array already");
@ -104,22 +89,16 @@ Meteor.startup(async() => {
markScriptRun("changeProdStoreToArray"); markScriptRun("changeProdStoreToArray");
} }
} }
} catch(error) {
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 = await MScripts.findOneAsync({ scriptName: "updateMenuProdLinks", scriptRun: true }); let menuItemUpdRun = MScripts.findOne({ scriptName: "updateMenuProdLinks", scriptRun: true });
if (!menuItemUpdRun) { if (!menuItemUpdRun) {
try {
let openMenus = Menus.find({ menuComplete: false }).fetch(); let openMenus = Menus.find({ menuComplete: false }).fetch();
let openMenuCount = openMenus.length; let openMenuCount = openMenus.length;
// console.log("Open Menu count is: " + openMenuCount); // console.log("Open Menu count is: " + openMenuCount);
for (let k = 0; k < openMenuCount; k++) { for (k = 0; k < openMenuCount; k++) {
if (typeof openMenus.menuItems == 'object') { if (typeof openMenus.menuItems == 'object') {
// console.log(openMenus.menuName + " appears to be converted."); // console.log(openMenus.menuName + " appears to be converted.");
markScriptRun("updateMenuProdLinks"); markScriptRun("updateMenuProdLinks");
@ -149,21 +128,10 @@ Meteor.startup(async() => {
markScriptRun("updateMenuProdLinks"); markScriptRun("updateMenuProdLinks");
} }
} }
} catch(error) {
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 = await SysConfig.findOneAsync({}); let currConfig = SysConfig.findOne({});
if (!currConfig) {
// console.log("No Current Config found.")
} else {
try {
let feedurl = "https://gitlab.com/bmcgonag/get_my/-/releases.atom" let feedurl = "https://gitlab.com/bmcgonag/get_my/-/releases.atom"
if (currConfig.allowUpdates == true) { if (currConfig.allowUpdates == true) {
// console.log("Allow Updates is true"); // console.log("Allow Updates is true");
@ -174,12 +142,6 @@ Meteor.startup(async() => {
}}); }});
startCronForUpdates(feedurl); startCronForUpdates(feedurl);
} }
} catch(error) {
console.log(" ERROR checking current config for updates: " + error);
console.log(error.message);
console.log(error.stack);
}
}
}); });
var startCronForUpdates = function(feedurl) { var startCronForUpdates = function(feedurl) {
@ -190,23 +152,18 @@ var startCronForUpdates = function(feedurl) {
}); });
} }
var markScriptRun = async function(scriptName) { var markScriptRun = function(scriptName) {
// check if this is already set // check if this is already set
let scriptRun = await MScripts.findOneAsync({ scriptName: scriptName }); let scriptRun = MScripts.findOne({ scriptName: scriptName });
if (!scriptRun) {
try { if (scriptRun) {
return MScripts.insertAsync({ console.log(scriptName + " already set as run on " + scriptRun.runOn);
} else {
MScripts.insert({
scriptName: scriptName, scriptName: scriptName,
scriptRun: true, scriptRun: true,
runOn: new Date() runOn: new Date()
}); });
} catch(error) {
console.log(" ERROR inserting the script run log: " + error);
console.log(error.message);
console.log(error.stack);
}
} else {
// console.log(scriptName + " already set as run on " + scriptRun.runOn);
} }
} }
@ -218,10 +175,9 @@ 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 = await UpdateInfo.findOneAsync({ title: data[0].title }); let updatesExist = UpdateInfo.findOne({ title: data[0].title });
try {
if (!updatesExist) { if (!updatesExist) {
UpdateInfo.insertAsync({ UpdateInfo.insert({
title: data[0].title, title: data[0].title,
description: data[0].description, description: data[0].description,
dateRelease: data[0].date, dateRelease: data[0].date,
@ -231,9 +187,4 @@ var getUpdateInfoNow = async function(feedurl) {
} else { } else {
console.log("No new updates available at this time."); 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,66 +3,61 @@ 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({
async 'addToRole' (role) { 'addToRole' (role) {
try { let countOfUsers = Meteor.users.find().count();
let countOfUsers = await Meteor.users.find().countAsync();
const user = await Meteor.userAsync(); // if users = 1 - set to role passed in function call
if (user) {
let userId = user._id;
if (countOfUsers > 1) { if (countOfUsers > 1) {
await Roles.addUsersToRolesAsync(userId, role); console.log("User id for role: " + Meteor.userId() );
const result = await Meteor.callAsync('add.darkModePref', "light"); let userId = Meteor.userId();
if (!result) { Roles.addUsersToRoles(userId, role);
Meteor.call('add.darkModePref', "light", function(err, result) {
if (err) {
console.log(" ERROR: can't set user dark mode preference: " + err); console.log(" ERROR: can't set user dark mode preference: " + err);
} else { } else {
// console.log(" SUCCESSFULLY set user dark mode preference."); // console.log(" SUCCESSFULLY set user dark mode preference.");
} }
});
} else if (countOfUsers == 1) { } else if (countOfUsers == 1) {
await Roles.addUsersToRolesAsync(userId, "systemadmin"); console.log("Creating first system admin user: " + Meteor.userId() );
const result = await Meteor.callAsync('add.darkModePref', "light"); let userId = Meteor.userId();
if (!result) { 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); console.log(" ERROR: can't set user dark mode preference: " + err);
} else { } else {
console.log(" SUCCESSFULLY set user dark mode preference."); // 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 {
console.log(" ---- No user info found.")
}
} catch(error) {
console.log(" ERROR getting user info on server: " + error);
} }
}, },
async 'edit.userPass' (userId, newPassword) { 'edit.userPass' (userId, newPassword) {
check(userId, String); check(userId, String);
check(newPassword, String); check(newPassword, String);
return await Accounts.setPasswordAsync(userId, newPassword); return Accounts.setPassword(userId, newPassword);
}, },
async 'delete.userFromSys' (userId) { 'delete.userFromSys' (userId) {
check(userId, String); check(userId, String);
return await Meteor.users.removeAsync({ _id: userId }); return Meteor.users.remove({ _id: userId });
}, },
async 'update.userEmail' (userId, email) { 'update.userEmail' (userId, email) {
check(userId, String); check(userId, String);
check(email, String); check(email, String);
return await Meteor.users.updateAsync({ _id: userId }, { return Meteor.users.update({ _id: userId }, {
$set: { $set: {
'emails.0.address': email, 'emails.0.address': email,
} }
}); });
}, },
async 'edit.userRole' (userId, role) { 'edit.userRole' (userId, role) {
check(userId, String); check(userId, String);
check(role, String); check(role, String);
return await Roles.setUserRolesAsync(userId, role); return Roles.setUserRoles(userId, role);
}, },
}); });

View file

@ -13,13 +13,6 @@ 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({});
@ -30,7 +23,7 @@ Meteor.publish("SystemConfig", function() {
Meteor.publish("UserConfigPrefs", function() { Meteor.publish("UserConfigPrefs", function() {
try { try {
return UserConfig.find({ user: this.userId }); return UserConfig.find({});
} catch (error) { } catch (error) {
console.log(" ERROR: Error accessing user config: " + error); console.log(" ERROR: Error accessing user config: " + error);
} }
@ -96,14 +89,6 @@ Meteor.publish("myListItems", function(listId) {
} }
}); });
Meteor.publish("allListItems", function() {
try {
return ListItems.find({});
} catch (error) {
console.log(" ERROR pulling all list items.");
}
});
Meteor.publish("myStoreListItems", function(listId) { Meteor.publish("myStoreListItems", function(listId) {
try { try {
let stores = Store.find({}); let stores = Store.find({});