Lots of changes and additions to the project. Still early, and not usable.

This commit is contained in:
Brian McGonagill 2022-08-15 18:07:39 -05:00
parent 8636f8cf9b
commit 266dbd0856
41 changed files with 836 additions and 67 deletions

View file

@ -1,7 +1,7 @@
Template.userMgmt.onCreated(function() {
this.subscribe("userList");
});
Template.userMgmt.onRendered(function() {

View file

@ -0,0 +1,6 @@
<template name="catMgmt">
<h4>Category Management</h4>
{{> catMgmtForm}}
<hr>
{{> catMgmtTbl}}
</template>

View file

@ -0,0 +1,17 @@
import { Categories } from '../../../imports/api/category.js';
Template.catMgmt.onCreated(function() {
this.subscribe("myCategories");
});
Template.catMgmt.onRendered(function() {
});
Template.catMgmt.helpers({
});
Template.catMgmt.events({
});

View file

@ -0,0 +1,16 @@
<template name="catMgmtForm">
<div class="row">
<div class="col s12 m6 l6 input-field">
<input type="text" class="catNameInp" id="catNameInp" style="{{#if $eq catNameErr true}}border: 2px solid red;{{/if}}" />
<label for="catNameInp">Name*</label>
</div>
</div>
<div class="row">
<div class="col s6 m6 l6">
<a class="waves-effect waves-light btn cancelCatMgmt orange">Cancel</a>
</div>
<div class="col s6 m6 l6">
<a class="waves-effect waves-light btn saveCatMgmt green right">Add</a>
</div>
</div>
</template>

View file

@ -0,0 +1,39 @@
import { Categories } from '../../../imports/api/category.js';
Template.catMgmtForm.onCreated(function() {
this.subscribe("myCategories");
});
Template.catMgmtForm.onRendered(function() {
Session.set("catNameMiss", false);
});
Template.catMgmtForm.helpers({
catNameErr: function() {
return Session.get("catNameMiss");
},
});
Template.catMgmtForm.events({
'click .saveCatMgmt' (event) {
event.preventDefault();
let catName = $("#catNameInp").val();
if (catName == null || catName == "") {
Session.set("catNameMiss", true);
return;
} else {
Meteor.call('add.category', catName, function(err, result) {
if (err) {
// console.log(" ERROR: Can't add category: " + err);
} else {
// console.log(" SUCCESS adding category.");
$("#catNameInp").val("");
}
});
}
},
'click .cancelCatMgmt' (event) {
event.preventDefault();
$("#catNameInp").val("");
}
});

View file

@ -0,0 +1,21 @@
<template name="catMgmtTbl">
<table class="highlight striped responsive-table">
<thead>
<tr>
<th>Name</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
{{#each cats}}
<tr>
<td>{{categoryName}}</td>
<td>
<i class="material-icons clickable deleteCategory">delete</i>
<i class="material-icons clickable editCategory">edit</i>
</td>
</tr>
{{/each}}
</tbody>
</table>
</template>

View file

@ -0,0 +1,19 @@
import { Categories } from '../../../imports/api/category.js';
Template.catMgmtTbl.onCreated(function() {
this.subscribe("myCategories");
});
Template.catMgmtTbl.onRendered(function() {
});
Template.catMgmtTbl.helpers({
cats: function() {
return Categories.find({});
}
});
Template.catMgmtTbl.events({
});

View file

@ -0,0 +1,5 @@
<template name="locMgmt">
{{> locMgmtForm}}
<hr>
{{> locMgmtTbl}}
</template>

View file

@ -0,0 +1,15 @@
Template.locMgmt.onCreated(function() {
});
Template.locMgmt.onRendered(function() {
});
Template.locMgmt.helpers({
});
Template.locMgmt.events({
});

View file

@ -0,0 +1,16 @@
<template name="locMgmtForm">
<div class="row">
<div class="col s12 m6 l6 input-field">
<input type="text" class="locNameInp" id="locNameInp" style="{{#if $eq locNameErr true}}border: 2px solid red;{{/if}}" />
<label for="locNameInp">Name*</label>
</div>
</div>
<div class="row">
<div class="col s6 m6 l6">
<a class="waves-effect waves-light btn cancelLocMgmt orange">Cancel</a>
</div>
<div class="col s6 m6 l6">
<a class="waves-effect waves-light btn saveLocMgmt green right">Add</a>
</div>
</div>
</template>

View file

@ -0,0 +1,39 @@
import { Locations } from '../../../imports/api/location.js';
Template.locMgmtForm.onCreated(function() {
this.subscribe("myLocations");
});
Template.locMgmtForm.onRendered(function() {
Session.set("locNameMiss", false);
});
Template.locMgmtForm.helpers({
locNameErr: function() {
return Session.get("locNameMiss");
},
});
Template.locMgmtForm.events({
'click .saveLocMgmt' (event) {
event.preventDefault();
let locName = $("#locNameInp").val();
if (locName == null || locName == "") {
Session.set("locNameMiss", true);
return;
} else {
Meteor.call('add.location', locName, function(err, result) {
if (err) {
// console.log(" ERROR: Can't add category: " + err);
} else {
// console.log(" SUCCESS adding category.");
$("#locNameInp").val("");
}
});
}
},
'click .cancelLocMgmt' (event) {
event.preventDefault();
$("#locNameInp").val("");
}
});

View file

@ -0,0 +1,21 @@
<template name="locMgmtTbl">
<table class="highlight striped responsive-table">
<thead>
<tr>
<th>Name</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
{{#each locs}}
<tr>
<td>{{locationName}}</td>
<td>
<i class="material-icons clickable deleteCategory">delete</i>
<i class="material-icons clickable editCategory">edit</i>
</td>
</tr>
{{/each}}
</tbody>
</table>
</template>

View file

@ -0,0 +1,19 @@
import { Locations } from '../../../imports/api/location.js';
Template.locMgmtTbl.onCreated(function() {
this.subscribe("myLocations");
});
Template.locMgmtTbl.onRendered(function() {
});
Template.locMgmtTbl.helpers({
locs: function() {
return Locations.find({});
}
});
Template.locMgmtTbl.events([
]);

View file

@ -0,0 +1,20 @@
<template name="mgmtPage">
<div class="row">
<div class="col s12 m6 l6">
<ul class="collection with-header">
<li class="collection-header"><h4>Management</h4></li>
{{#if isInRole "systemadmin"}}
<li><a href="#!" id="userMgmt" class="collection-item">User Management</a></li>
{{/if}}
<li><a href="#!" id="manageList" class="collection-item">List</a></li>
<li><a href="#!" id="manageCategory" class="collection-item">Category</a></li>
<li><a href="#!" id="manageProduct" class="collection-item">Product</a></li>
<li><a href="#!" id="manageLocation" class="collection-item">Location</a></li>
<li><a href="#!" id="manageStore" class="collection-item">Store</a></li>
<li><a href="#!" id="manageCabinet" class="collection-item">Cabinet</a></li>
<li><a href="#!" id="manageShelf" class="collection-item">Shelf</a></li>
<li><a href="#!" id="manageBin" class="collection-item">Bin</a></li>
</ul>
</div>
</div>
</template>

View file

@ -0,0 +1,21 @@
Template.mgmtPage.onCreated(function() {
});
Template.mgmtPage.onRendered(function() {
});
Template.mgmtPage.helpers ({
});
Template.mgmtPage.events ({
'click .collection-item' (event) {
event.preventDefault();
var clickedTarget = event.target.id;
// console.log("should be going to /" + clickedTarget);
FlowRouter.go('/' + clickedTarget);
},
});

View file

@ -0,0 +1,5 @@
<template name="prodMgmt">
{{> prodMgmtForm}}
<hr>
{{> prodMgmtTbl}}
</template>

View file

@ -0,0 +1,17 @@
import { Products } from '../../../imports/api/products.js';
Template.prodMgmt.onCreated(function() {
this.subscribe("myProducts");
});
Template.prodMgmt.onRendered(function() {
});
Template.prodMgmt.helpers({
});
Template.prodMgmt.events({
});

View file

@ -0,0 +1,59 @@
<template name="prodMgmtForm">
<h4>Product Management</h4>
<div class="row">
<div class="col s12 m6 l6 input-field">
<input type="text" class="prodName" style="{{#if $eq prodNameErr true}}border: 2px solid red;{{/if}}" id="prodName" />
<label for="prodName">Name*</label>
</div>
<div class="col s12 m6 l6 input-field">
<select name="prodCategory" id="prodCategory" class="prodCategory">
<option value="" disabled selected></option>
{{#each category}}
<option value="{{categoryName}}">{{categoryName}}</option>
{{/each}}
<option id="addNewCategory" value="addNewCat">Add New Category</option>
</select>
<label for="prodCategory">Category</label>
</div>
</div>
<div class="row">
<div class="col s12 m6 l6 input-field">
<select name="prodStore" id="prodStore" class="prodStore">
<option value="" disabled selected></option>
{{#each stores}}
<option value="{{storeName}}">{{storeName}}</option>
{{/each}}
<option id="addNewStore" class="modal-trigger" href="modalStore" value="addNewStore">Add New Store</option>
</select>
<label for="prodStore">Store</label>
</div>
<div class="col s12 m6 l6 input-field">
<select name="prodLocation" id="prodLocation" class="prodLocation {{#if $eq darkmode true}}dark-mode{{/if}}">
<option value="" disabled selected></option>
{{#each locations}}
<option value="{{locationName}}">{{locationName}}</option>
{{/each}}
<option id="addNewLocation" value="addNewLocation">Add New Location</option>
</select>
<label for="prodLocation">Location</label>
</div>
</div>
<div class="row">
<div class="col s6 m6 l6">
<a class="waves-effect waves-light btn cancelProdMgmt orange">Cancel</a>
</div>
<div class="col s6 m6 l6">
<a class="waves-effect waves-light btn saveProdMgmt green right">Add</a>
</div>
</div>
<!-- Modal Structure -->
<div id="modalStore" class="modal">
<div class="modal-content">
<h4>Add New Store</h4>
{{> storeMgmtForm}}
</div>
<div class="modal-footer">
<a href="#!" class="modal-close waves-effect waves-green btn-flat">Done</a>
</div>
</div>
</template>

View file

@ -0,0 +1,107 @@
import { Products } from '../../../imports/api/products.js';
import { Stores } from '../../../imports/api/stores.js';
import { Categories } from '../../../imports/api/category.js';
import { Locations } from '../../../imports/api/location.js';
Template.prodMgmtForm.onCreated(function() {
this.subscribe("myProducts");
this.subscribe("storeInfo");
this.subscribe("myCategories");
this.subscribe("myLocations");
});
Template.prodMgmtForm.onRendered(function() {
Meteor.setTimeout(function() {
$('select').formSelect();
}, 200);
$('select').formSelect();
$('.modal').modal();
});
Template.prodMgmtForm.helpers({
stores: function() {
return Stores.find({});
},
prodNameErr: function() {
return Session.get("prodNameRed");
},
category: function() {
return Categories.find({});
},
locations: function() {
return Locations.find({});
},
});
Template.prodMgmtForm.events({
'click .saveProdMgmt' (event) {
event.preventDefault();
let name=$("#prodName").val();
let cat = $("#prodCategory").val();
let store = $("#prodStore").val();
let location = $("#prodLocation").val();
if (cat == null) {
cat = "";
}
if (location == null) {
location = "";
}
if (store == null) {
store = "";
}
if (name == "" || name == null) {
Session.set("prodNameRed", true);
return;
} else {
Meteor.call('add.product', name, cat, store, location, function(err, result) {
if (err) {
// console.log(" ERROR: can't add product: " + err);
} else {
// console.log(" SUCCESS adding product.");
}
});
}
},
'click .cancelProdMgmt' (event) {
event.preventDefault();
$("#prodName").val("");
$("#prodCategory").val("");
$("#prodStore").val("");
$("#prodLocation").val("")
},
'change #prodStore' (event) {
event.preventDefault();
let val = $("#prodStore").val();
if (val == "addNewStore") {
$("#prodStore").val("");
// open a modal to enter store information.
$('#modalStore').modal('open');
}
},
'change #prodLocation' (event) {
event.preventDefault();
let val = $("#prodLocation").val();
if (val == "addNewLocation") {
$("#prodLocation").val("");
// open a modal to enter store information.
$('#modalLocation').modal('open');
}
},
'change #prodCategory' (event) {
event.preventDefault();
let val = $("#prodCategory").val();
if (val == "addNewCategory") {
$("#prodCategory").val("");
// open a modal to enter store information.
$('#modalCategory').modal('open');
}
},
});

View file

@ -0,0 +1,31 @@
<template name="prodMgmtTbl">
<div class="row">
<div class="col s12 m12 l12">
<table class="highlight striped responsive-table">
<thead>
<tr>
<th>Product Name</th>
<th>Category</th>
<th>Store</th>
<th>Location</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
{{#each products}}
<tr>
<td>{{prodName}}</td>
<td>{{prodCategory}}</td>
<td>{{prodStore}}</td>
<td>{{prodLocation}}</td>
<td>
<i class="material-icons clickable deleteProduct">delete</i>
<i class="material-icons clickable editProduct">edit</i>
</td>
</tr>
{{/each}}
</tbody>
</table>
</div>
</div>
</template>

View file

@ -0,0 +1,19 @@
import { Products } from '../../../imports/api/products.js';
Template.prodMgmtTbl.onCreated(function() {
this.subscribe("myProducts");
});
Template.prodMgmtTbl.onRendered(function() {
});
Template.prodMgmtTbl.helpers({
products: function() {
return Products.find({});
},
});
Template.prodMgmtTbl.events({
});

View file

@ -0,0 +1,11 @@
<template name="storeMgmt">
<!-- Store Management Entry / Edit -->
<h4>Store Management</h4>
<p>Add Stores you commonly make lists for here.</p>
{{> storeMgmtForm}}
<!-- Store Management Table List -->
<hr>
{{> storeMgmtTbl}}
</template>

View file

@ -0,0 +1,17 @@
import { Stores } from '../../../imports/api/stores';
Template.storeMgmt.onCreated(function() {
});
Template.storeMgmt.onRendered(function() {
});
Template.storeMgmt.helpers({
});
Template.storeMgmt.events({
});

View file

@ -0,0 +1,20 @@
<template name="storeMgmtForm">
<div class="row">
<div class="col s12 m6 l6 input-field">
<input type="text" class="storeName" id="storeName" />
<label for="storeName">Name</label>
</div>
<div class="col s12 m6 l6 input-field">
<input type="text" class="storeType" id="storeType" />
<label for="storeType">Type</label>
</div>
</div>
<div class="row">
<div class="col s6 m6 l6">
<a class="waves-effect waves-light btn cancelStoreMgmt orange">Cancel</a>
</div>
<div class="col s6 m6 l6">
<a class="waves-effect waves-light btn saveStoreMgmt green right">Add</a>
</div>
</div>
</template>

View file

@ -0,0 +1,35 @@
import { Stores } from '../../../imports/api/stores';
Template.storeMgmtForm.onCreated(function() {
this.subscribe("storeInfo");
});
Template.storeMgmtForm.onRendered(function() {
Session.set("borderRed", false);
});
Template.storeMgmtForm.helpers({
});
Template.storeMgmtForm.events({
'click .saveStoreMgmt' (event) {
event.preventDefault();
let storeName = $("#storeName").val();
let storeType = $("#storeType").val();
if (storeName == "" || storeName == null) {
Session.set("borderRed", true);
return;
} else {
Meteor.call("add.store", storeName, storeType, function(err, result) {
if (err) {
// console.log("ERROR: Store add failed: " + err);
} else {
// console.log("Success adding store!");
$("#storeName").val("");
$("#storeType").val("");
}
});
}
}
});

View file

@ -0,0 +1,27 @@
<template name="storeMgmtTbl">
<table class="highlight striped responsive-table">
<thead>
<tr>
<th>Store Name</th>
<th>Type</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
{{#each mgmtStoreInfo}}
<tr>
<td>
{{storeName}}
</td>
<td>
{{storeType}}
</td>
<td>
<i class="material-icons clickable deleteStore">delete</i>
<i class="material-icons clickable editStore">edit</i>
</td>
</tr>
{{/each}}
</tbody>
</table>
</template>

View file

@ -0,0 +1,26 @@
import { Stores } from '../../../imports/api/stores';
Template.storeMgmtTbl.onCreated(function() {
this.subscribe("storeInfo");
});
Template.storeMgmtTbl.onRendered(function() {
});
Template.storeMgmtTbl.helpers({
mgmtStoreInfo: function() {
return Stores.find({});
},
});
Template.storeMgmtTbl.events({
'click .deleteStore' (event) {
event.preventDefault();
// console.log("Delete Store Clicked");
},
'click .editStore' (event) {
event.preventDefault();
// console.log("Edit Store Clicked");
},
});

View file

@ -1,7 +1,7 @@
Template.dashboard.onCreated(function() {
this.subscribe("userList");
});
Template.dashboard.onRendered(function() {

View file

@ -1,28 +1,16 @@
<template name="headerBar">
<ul id="drop-manage" class="dropdown-content">
{{#if isInRole "systemadmin"}}
<li><a href="#!" id="userMgmt" class="navBtn">User Management</a></li>
{{/if}}
<li><a href="#!" id="manageList" class="navBtn">List</a></li>
<li><a href="#!" id="manageCategory" class="navBtn">Category</a></li>
<li><a href="#!" id="manageProduct" class="navBtn">Product</a></li>
<li><a href="#!" id="manageLocation" class="navBtn">Location</a></li>
<li><a href="#!" id="manageStore" class="navBtn">Store</a></li>
<li><a href="#!" id="manageCabinet" class="navBtn">Cabinet</a></li>
<li><a href="#!" id="manageShelf" class="navBtn">Shelf</a></li>
<li><a href="#!" id="manageBin" class="navBtn">Bin</a></li>
</ul>
<nav>
<div class="nav-wrapper blue darken-4">
<a href="#" class="brand-logo" id="brandLogo">Get My</a>
<a href="#" class="brand-logo center" id="brandLogo">Get My</a>
<a href="#" data-target="mobile-demo" class="sidenav-trigger"><i class="material-icons">menu</i></a>
<ul class="right hide-on-med-and-down">
{{#if currentUser}}
<li><a href="#" id="mylists" class="navBtn">My Lists</a></li>
{{#if isInRole "admin,systemadmin"}}
<li><a class="dropdown-trigger" href="#!" data-target="drop-manage">Manage<i class="material-icons right">arrow_drop_down</i></a></li>
{{/if}}
<li class="signOut"><a href="#" class="signOut">Log Out</a></li>
<li><a href="#" id="manage" class="navBtn">Manage</a></li>
<li class="signOut"><a href="#" class="signOut">Log Out</a></li>
{{else}}
<li><a href="#!" id="login" class="navBtn">Login</a></li>
{{/if}}
@ -31,34 +19,9 @@
</nav>
<ul class="sidenav" id="mobile-demo">
{{#if currentUser}}
<ul class="collapsible">
<li>
<div class="collapsible-header" id="mylists">My Lists</div>
</li>
{{#if isInRole "admin,systemadmin"}}
<li>
<div class="collapsible-header">Manage<i class="material-icons">down-arrow</i></div>
<div class="collapsible-body">
<ul>
{{#if isInRole "systemadmin"}}
<li><a href="#" id="userMgmt">User Management</a></li>
{{/if}}
<li><a href="#" id="manageList">List</a></li>
<li><a href="#" id="manageCategory">Category</a></li>
<li><a href="#" id="manageProduct">Product</a></li>
<li><a href="#" id="manageLocation">Location</a></li>
<li><a href="#" id="manageStore">Store</a></li>
<li><a href="#" id="manageCabinet">Cabinet</a></li>
<li><a href="#" id="manageShelf">Shelf</a></li>
<li><a href="#" id="manageBin">Bin</a></li>
</ul>
</div>
</li>
{{/if}}
<li>
<div class="collapsible-header signOut">Sign Out</div>
</li>
</ul>
<li><a href="#!" id="mylists">My Lists</a></li>
<li><a href="#!" id="manage">Manage</a></li>
<li><a href="#!" class="signOut">Sign Out</a></li>
{{else}}
<li><a href="#!" id="login" class="navBtn">Login</a></li>
{{/if}}

View file

@ -12,6 +12,8 @@ Template.headerBar.onRendered(function() {
}, 200)
$(".dropdown-trigger").dropdown();
$('.collapsible').collapsible();
});
Template.headerBar.helpers({

17
client/MainLayout.js Normal file
View file

@ -0,0 +1,17 @@
Template.MainLayout.onCreated(function() {
});
Template.MainLayout.onRendered(function() {
});
Template.MainLayout.helpers({
});
Template.MainLayout.events({
});

View file

@ -8,3 +8,15 @@ body {
cursor: pointer;
}
.dark-mode {
background: #191818;
color: #fcfcfc;
}
input.dark-mode {
color: #fcfcfc;
}
select.dark-mode {
color: #fcfcfc;
}

View file

@ -1,5 +1,5 @@
<head>
<title>Parent Pickup</title>
<title>Get My</title>
<link id="favicon" rel="shortcut icon" type="image/png" href="favicon.png" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">

View file

@ -12,16 +12,16 @@ Categories.allow({
});
Meteor.methods({
'add.category' (name) {
check(name, String);
'add.category' (categoryName) {
check(categoryName, String);
if (!this.userId) {
throw new Meteor.Error('You are not allowed to add categories. Make sure you are logged in with valid user credentials.');
}
return Categories.insert({
categoryName: name,
categroyOwner: this.userid,
categoryName: categoryName,
categoryOwner: this.userId,
});
},
'edit.category' (categoryId, categoryName,) {

View file

@ -12,9 +12,8 @@ Locations.allow({
});
Meteor.methods({
'add.location' (name, type) {
'add.location' (name) {
check(name, String);
check(type, String);
if (!this.userId) {
throw new Meteor.Error('You are not allowed to add locations. Make sure you are logged in with valid user credentials.');
@ -22,14 +21,12 @@ Meteor.methods({
return Locations.insert({
locationName: name,
locationType: type,
owner: this.userid,
owner: this.userId,
});
},
'edit.location' (locationId, locationName, locationType) {
'edit.location' (locationId, locationName) {
check(locationId, String);
check(locationName, String);
check(locationType, String);
if (!this.userId) {
throw new Meteor.Error('You are not allowed to edit locations. Make sure you are logged in with valid user credentials.');
@ -38,7 +35,6 @@ Meteor.methods({
return Locations.update({ _id: locationId }, {
$set: {
locationName: locationName,
locationType: locationType,
}
});
},

View file

@ -20,10 +20,12 @@ Meteor.methods({
throw new Meteor.Error('You are not allowed to add stores. Make sure you are logged in with valid user credentials.');
}
console.log(" ---- userid: " + Meteor.user()._id);
return Stores.insert({
storeName: storeName,
storeType: storeType,
owner: this.userid,
owner: Meteor.user()._id,
});
},
'edit.store' (storeId, storeName, storeType) {

View file

@ -0,0 +1,32 @@
import { Meteor } from 'meteor/meteor';
import { Mongo } from 'meteor/mongo';
import { check } from 'meteor/check';
export const UserConfigOptions = new Mongo.Collection('userConfigOptions');
UserConfigOptions.allow({
insert: function(userId, doc){
// if use id exists, allow insert
return !!userId;
},
});
Meteor.methods({
'add.darkPref' (darkPref) {
check(darkPref, Boolean);
return UserConfigOptions.insert({
darkPref: darkPref,
owner: this.userId
});
},
'edit.darkPref' (darkPref) {
check(darkPref, Boolean);
return UserConfigOptions.update({ owner: this.userId }, {
$set: {
darkPref: darkPref
}
});
},
});

View file

@ -1,10 +1,3 @@
FlowRouter.route('/', {
name: 'home',
action() {
BlazeLayout.render('MainLayout', { notLoggedIn: "home" });
}
});
FlowRouter.route('/dashboard', {
name: 'home',
action() {
@ -12,6 +5,20 @@ FlowRouter.route('/dashboard', {
}
});
FlowRouter.route('/', {
name: 'homeNoRoute',
action() {
BlazeLayout.render('MainLayout', { main: "dashboard" });
}
});
FlowRouter.route('/', {
name: 'homeNotLoggedIn',
action() {
BlazeLayout.render('MainLayout', { notLoggedIn: "login" });
}
});
FlowRouter.route('/login', {
name: 'login',
action() {
@ -32,3 +39,38 @@ FlowRouter.route('/userMgmt', {
BlazeLayout.render('MainLayout', { main: 'userMgmt' });
}
});
FlowRouter.route('/manageStore', {
name: 'storeMgmt',
action() {
BlazeLayout.render('MainLayout', { main: 'storeMgmt' });
}
});
FlowRouter.route('/manage', {
name: 'mgmtPage',
action() {
BlazeLayout.render('MainLayout', { main: 'mgmtPage' });
}
});
FlowRouter.route('/manageProduct', {
name: 'manageProduct',
action() {
BlazeLayout.render('MainLayout', { main: 'prodMgmt' });
}
});
FlowRouter.route('/manageCategory', {
name: 'manageCategory',
action() {
BlazeLayout.render('MainLayout', { main: 'catMgmt' });
}
});
FlowRouter.route('/manageLocation', {
name: 'manageLocation',
action() {
BlazeLayout.render('MainLayout', { main: 'locMgmt' });
}
});

View file

@ -11,10 +11,24 @@ Meteor.methods({
console.log("User id for role: " + Meteor.userId() );
let userId = Meteor.userId();
Roles.addUsersToRoles(userId, role);
Meteor.call('add.darkPref', false, function(err, result) {
if (err) {
console.log(" ERROR: can't set user dark mode preference: " + err);
} else {
console.log(" SUCCESSFULLY set user dark mode preference.");
}
});
} else if (countOfUsers == 1) {
console.log("Creating first system admin user: " + Meteor.userId() );
let userId = Meteor.userId();
Roles.addUsersToRoles(userId, "systemadmin");
Meteor.call('add.darkPref', false, function(err, result) {
if (err) {
console.log(" ERROR: can't set user dark mode preference: " + err);
} else {
console.log(" SUCCESSFULLY set user dark mode preference.");
}
});
}
},
});

View file

@ -1,4 +1,9 @@
import { SysConfig } from '../imports/api/systemConfig.js';
import { Stores } from '../imports/api/stores.js';
import { UserConfigOptions } from '../imports/api/userConfigOptions.js';
import { Products } from '../imports/api/products.js';
import { Categories } from '../imports/api/category.js';
import { Locations } from '../imports/api/location.js';
Meteor.publish("SystemConfig", function() {
try {
@ -7,3 +12,39 @@ Meteor.publish("SystemConfig", function() {
console.log(" ERROR pulling system config data: " + error);
}
});
Meteor.publish('userList', function() {
return Meteor.users.find({});
});
Meteor.publish("storeInfo", function() {
try {
return Stores.find({ owner: this.userId });
} catch (error) {
console.log(" ERROR pulling store data: " + error);
}
});
Meteor.publish("myProducts", function() {
try {
return Products.find({ prodOwner: this.userId });
} catch (error) {
console.log(" ERROR pulling product data: " + error);
}
});
Meteor.publish("myCategories", function() {
try {
return Categories.find({ categoryOwner: this.userId });
} catch (error) {
console.log(" ERROR pulling category data: " + error);
}
});
Meteor.publish("myLocations", function() {
try {
return Locations.find({ owner: this.userId });
} catch (error) {
console.log(" ERROR pulling location data: " + error);
}
});