import { Categories } from "../../imports/api/category"; import { Lists } from "../../imports/api/lists"; import { Locations } from "../../imports/api/location"; import { Products } from "../../imports/api/products"; import { Stores } from "../../imports/api/stores"; import { Menus } from '../../imports/api/menu.js'; import { MenuItems } from '../../imports/api/menuItems.js'; import moment from 'moment'; Template.dashboard.onCreated(function() { this.subscribe("userList"); this.subscribe("myLists"); this.subscribe("myCategories"); this.subscribe("storeInfo"); this.subscribe("myProducts"); this.subscribe("myLocations"); this.subscribe("myMenus"); this.subscribe("todayMenuItems"); }); Template.dashboard.onRendered(function() { }); Template.dashboard.helpers({ userCount: function() { return Meteor.users.find().count(); }, listCount: function() { return Lists.find().count(); }, storeCount: function() { return Stores.find().count(); }, productCount: function() { return Products.find().count(); }, catCount: function() { return Categories.find().count(); }, locCount: function() { return Locations.find().count(); }, todayMenuItem: function() { return MenuItems.find({}); }, todayDate: function() { let now = new Date(); let todayDate = moment(now).format("MMM D, YYYY"); return todayDate; }, nextDays: function() { let now = new Date(); let nowDate = moment(now).add(1, 'day').format("MM D, YYYY"); console.log("nowDate = " + nowDate); return MenuItems.find({ serveDate: nowDate }); } }); Template.dashboard.events({ "click .cardLink" (event) { event.preventDefault(); 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; case "catMgmtLink": FlowRouter.go('/manageCategory'); break; case "locationMgmtLink": FlowRouter.go('/manageLocation'); break; case "myMenuLink": FlowRouter.go('/mymenus'); break; default: break; } }, 'click .card' (event) { event.preventDefault(); 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 "catInfoCard": FlowRouter.go('/manageCategory'); break; case "locInfoCard": FlowRouter.go('/manageLocation'); break; case "prodInfoCard": FlowRouter.go("/manageProduct"); break; case "menuInfoCard": FlowRouter.go('/mymenus'); default: break; } } });