2022-08-16 16:46:14 -05:00
|
|
|
import { Lists } from "../../imports/api/lists";
|
|
|
|
|
import { Products } from "../../imports/api/products";
|
|
|
|
|
import { Stores } from "../../imports/api/stores";
|
2022-08-27 16:59:01 -05:00
|
|
|
import { Menus } from '../../imports/api/menu.js';
|
|
|
|
|
import { MenuItems } from '../../imports/api/menuItems.js';
|
|
|
|
|
import moment from 'moment';
|
2022-09-05 16:22:56 -05:00
|
|
|
import { TaskItems } from "../../imports/api/tasks";
|
2024-08-21 07:01:36 -05:00
|
|
|
import { UpdateInfo } from '../../imports/api/updateInfo.js';
|
|
|
|
|
import { SysConfig } from '../../imports/api/systemConfig.js';
|
2022-08-04 19:50:18 -05:00
|
|
|
|
|
|
|
|
Template.dashboard.onCreated(function() {
|
2022-08-15 18:07:39 -05:00
|
|
|
this.subscribe("userList");
|
2022-08-16 16:46:14 -05:00
|
|
|
this.subscribe("myLists");
|
|
|
|
|
this.subscribe("myCategories");
|
|
|
|
|
this.subscribe("storeInfo");
|
|
|
|
|
this.subscribe("myProducts");
|
2022-08-23 13:41:21 -05:00
|
|
|
this.subscribe("myLocations");
|
2024-08-14 11:38:13 -05:00
|
|
|
// this.subscribe("myMenus");
|
2022-08-27 16:59:01 -05:00
|
|
|
this.subscribe("todayMenuItems");
|
2022-09-05 16:22:56 -05:00
|
|
|
this.subscribe("myTasks");
|
2024-08-21 07:01:36 -05:00
|
|
|
this.subscribe("UpdateVersion");
|
|
|
|
|
this.subscribe("SystemConfig");
|
2022-08-04 19:50:18 -05:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
Template.dashboard.onRendered(function() {
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
Template.dashboard.helpers({
|
2022-08-05 16:55:56 -05:00
|
|
|
userCount: function() {
|
|
|
|
|
return Meteor.users.find().count();
|
2022-08-16 16:46:14 -05:00
|
|
|
},
|
|
|
|
|
listCount: function() {
|
|
|
|
|
return Lists.find().count();
|
|
|
|
|
},
|
|
|
|
|
storeCount: function() {
|
|
|
|
|
return Stores.find().count();
|
|
|
|
|
},
|
|
|
|
|
productCount: function() {
|
|
|
|
|
return Products.find().count();
|
|
|
|
|
},
|
|
|
|
|
catCount: function() {
|
|
|
|
|
return Categories.find().count();
|
2022-08-23 13:41:21 -05:00
|
|
|
},
|
|
|
|
|
locCount: function() {
|
|
|
|
|
return Locations.find().count();
|
2022-08-27 16:59:01 -05:00
|
|
|
},
|
2022-09-05 16:22:56 -05:00
|
|
|
mytaskitems: function() {
|
|
|
|
|
let today = moment(new Date()).format("MMM DD, YYYY");
|
|
|
|
|
return TaskItems.find({ isComplete: false, taskDate: today });
|
|
|
|
|
},
|
2022-08-27 16:59:01 -05:00
|
|
|
todayMenuItem: function() {
|
2024-08-14 11:38:13 -05:00
|
|
|
let myMenus = Menus.find({}).fetch();
|
|
|
|
|
console.dir(myMenus);
|
|
|
|
|
return myMenus;
|
2022-08-27 16:59:01 -05:00
|
|
|
},
|
|
|
|
|
todayDate: function() {
|
|
|
|
|
let now = new Date();
|
2022-09-01 09:54:23 -05:00
|
|
|
let todayDate = moment(now).format("MMM DD, YYYY");
|
2022-08-27 16:59:01 -05:00
|
|
|
return todayDate;
|
2022-08-30 16:17:53 -05:00
|
|
|
},
|
2024-08-21 07:01:36 -05:00
|
|
|
updates: function() {
|
|
|
|
|
return UpdateInfo.find({});
|
|
|
|
|
},
|
|
|
|
|
updatesExist: function() {
|
|
|
|
|
let updateExists = UpdateInfo.find({ viewed: false }).fetch();
|
|
|
|
|
if (updateExists.length > 0) {
|
|
|
|
|
return true;
|
|
|
|
|
} else {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
currConfig: function() {
|
|
|
|
|
return SysConfig.findOne({});
|
|
|
|
|
},
|
|
|
|
|
descriptionSinHTML: function() {
|
|
|
|
|
let desc = this.description;
|
|
|
|
|
let sinH = $(desc).text();
|
|
|
|
|
return sinH;
|
|
|
|
|
},
|
|
|
|
|
niceDate: function() {
|
|
|
|
|
let rDateNorm = this.date;
|
|
|
|
|
let rDate = moment(rDateNorm).format('LL');
|
|
|
|
|
return rDate;
|
|
|
|
|
}
|
2022-08-04 19:50:18 -05:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
Template.dashboard.events({
|
2022-08-23 13:41:21 -05:00
|
|
|
"click .cardLink" (event) {
|
|
|
|
|
let link = event.currentTarget.id;
|
|
|
|
|
switch(link) {
|
|
|
|
|
case "userMgmtLink":
|
|
|
|
|
FlowRouter.go('/userMgmt');
|
|
|
|
|
break;
|
|
|
|
|
case "listMgmtLink":
|
|
|
|
|
FlowRouter.go('/manageLists');
|
|
|
|
|
break;
|
|
|
|
|
case "storeMgmtLink":
|
|
|
|
|
FlowRouter.go('/manageStore');
|
|
|
|
|
break;
|
|
|
|
|
case "prodMgmtLink":
|
|
|
|
|
FlowRouter.go('/manageProduct');
|
|
|
|
|
break;
|
2022-08-27 16:59:01 -05:00
|
|
|
case "myMenuLink":
|
|
|
|
|
FlowRouter.go('/mymenus');
|
|
|
|
|
break;
|
2022-09-05 16:22:56 -05:00
|
|
|
case "taskMgmtLink":
|
|
|
|
|
FlowRouter.go('/taskHome');
|
|
|
|
|
break;
|
2022-08-23 13:41:21 -05:00
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
2022-08-05 16:55:56 -05:00
|
|
|
},
|
2022-08-23 13:41:21 -05:00
|
|
|
'click .card' (event) {
|
|
|
|
|
let cardId = event.currentTarget.id;
|
|
|
|
|
|
|
|
|
|
switch(cardId) {
|
|
|
|
|
case "userInfoCard":
|
|
|
|
|
FlowRouter.go('/userMgmt');
|
|
|
|
|
break;
|
|
|
|
|
case "listInfoCard":
|
|
|
|
|
FlowRouter.go("/mylists");
|
|
|
|
|
break;
|
|
|
|
|
case "storeInfoCard":
|
|
|
|
|
FlowRouter.go('/manageStore');
|
|
|
|
|
break;
|
|
|
|
|
case "prodInfoCard":
|
|
|
|
|
FlowRouter.go("/manageProduct");
|
|
|
|
|
break;
|
2022-08-27 16:59:01 -05:00
|
|
|
case "menuInfoCard":
|
|
|
|
|
FlowRouter.go('/mymenus');
|
2022-09-05 16:22:56 -05:00
|
|
|
break;
|
|
|
|
|
case "taskInfoCard":
|
|
|
|
|
FlowRouter.go('/myTasks');
|
|
|
|
|
break;
|
2022-08-23 13:41:21 -05:00
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
2024-08-21 07:01:36 -05:00
|
|
|
},
|
|
|
|
|
'click .readLink' (event) {
|
|
|
|
|
let eventId = event.currentTarget.id;
|
|
|
|
|
|
|
|
|
|
Meteor.call('markUpdate.read', eventId, function(err, result) {
|
|
|
|
|
if (err) {
|
|
|
|
|
console.log(" ERROR marking update as 'read': " + err);
|
|
|
|
|
} else {
|
|
|
|
|
console.log("marked read successfully!");
|
|
|
|
|
}
|
|
|
|
|
});
|
2022-08-23 13:41:21 -05:00
|
|
|
}
|
2024-08-14 11:38:13 -05:00
|
|
|
});
|