Initial commit

This commit is contained in:
Brian McGonagill 2026-02-03 16:03:34 -06:00
parent 9ed5089508
commit 78e0e82449
16 changed files with 317 additions and 15 deletions

View file

@ -0,0 +1,3 @@
.infoCard {
cursor: pointer;
}

View file

@ -1,6 +1,22 @@
<template name="home">
{{#if currentUser}}
<h1>This is Home.</h1>
<div class="grid">
<div>
<article class="infoCard" id="workouts">
<h3>Workouts</h3>
</article>
</div>
<div>
<article class="infoCard" id="meals">
<h3>Meals</h3>
</article>
</div>
<div>
<article class="infoCard" id="measurements">
<h3>Measurements</h3>
</article>
</div>
</div>
{{else}}
{{#if $eq loginOrReg 'login'}}
{{> login}}

View file

@ -1,11 +1,14 @@
import { FlowRouter } from 'meteor/ostrio:flow-router-extra';
Template.home.helpers({
loginOrReg: function() {
loginOrReg: function () {
return Session.get("loginOrReg");
},
});
Template.home.events({
'click .infoCard'(e) {
let route = e.currentTarget.id;
FlowRouter.go('/' + route);
},
});

View file

@ -0,0 +1,5 @@
<template name="workoutLog">
<h1>Workout Log</h1>
<h2>{{routineName}}</h2>
</template>

View file

@ -0,0 +1,18 @@
import { FlowRouter } from 'meteor/ostrio:flow-router-extra';
import { Workouts } from '../../../imports/api/workouts.js';
Template.workoutsLog.onCreated(function() {
this.subscribe("myWorkoutRoutines");
});
Template.workoutsLog.onRendered(function() {
});
Template.workoutsLog.helpers({
});
Template.workoutsLog.events({
});

View file

@ -0,0 +1,25 @@
<template name="workouts">
<h1>Workouts</h1>
{{#if $eq showAddRoutineForm true}}
<div id="addRouTineForm">
<div class="grid">
<div>
<label for="routineName">Workout Routine Name *</label>
<input type="text" required class="routineName" id="routineName" />
</div>
</div>
<div class="grid">
<div>
<button class="primary right" id="addRoutineForm">Save</button>
</div>
</div>
</div>
{{/if}}
<ul class="collection">
{{#each workoutRoutines}}
<li class="collection-item clickable" id="{{_id}}">{{routineName}}</li>
{{/each}}
<li class="collection-footer clickable" id="addRoutine"> + Add a Workout Routine</li>
</ul>
{{> snackbar}}
</template>

View file

@ -0,0 +1,49 @@
import { FlowRouter } from 'meteor/ostrio:flow-router-extra';
import { Workouts } from '../../../imports/api/workouts.js';
import { WorkoutLog } from '../../../imports/api/workoutLog.js';
Template.workouts.onCreated(function() {
this.subscribe("myWorkoutRoutines");
});
Template.workouts.onRendered(function() {
Session.set("showAddRoutineForm", false);
});
Template.workouts.helpers({
showAddRoutineForm: function() {
return Session.get("showAddRoutineForm");
},
workoutRoutines: function() {
return Workouts.find({});
},
});
Template.workouts.events({
'click #addRoutine' (e) {
Session.set("showAddRoutineForm", true);
},
'click #addRoutineForm' (e) {
let routineName = $("#routineName").val();
if (routineName == "" || routineName == null) {
showSnackbar("Routine Name is Required!", "red");
return;
} else {
console.log("Routine Name: " + routineName);
const addWorkout = async() => {
try {
const result = await Meteor.callAsync('add.workoutRoutine', routineName);
if (!result) {
console.log("An issue occurred adding the routing name.");
} else {
console.log("Routine added : " + result);
}
} catch(error) {
console.log(" ERROR adding routine nemae: " + error);
}
}
addWorkout();
}
}
});

View file

@ -1,7 +1,7 @@
<template name="headerBar">
<nav>
<ul>
<li><h2>[Project Name]</h2></li>
<li><h2>Get Healthy</h2></li>
</ul>
<ul>
{{#if currentUser}}

View file

@ -1,3 +1,59 @@
.right {
float: right;
}
}
.clickable {
cursor: pointer;
}
/* Collection container */
.collection {
width: 100%;
margin: 1rem 0;
padding: 0;
border-radius: 4px;
box-shadow: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24);
list-style: none;
background-color: #100f0f;
border: 1px solid #454444;
color: #dfdfdf;
}
/* Collection item */
.collection-item {
position: relative;
display: block;
padding: 16px 16px;
border-bottom: 1px solid #454444;
color: #dfdfdf;
transition: background-color 0.2s ease;
}
.collection-item:hover {
background-color: #282828
}
/* Remove bottom border from last item */
.collection-item:last-child {
border-bottom: none;
}
/* Collection header */
.collection-header {
padding: 16px 16px;
display: block;
background-color: #1b1b1b;
border-bottom: 1px solid #454444;
font-weight: 500;
color: #dfdfdf;
}
/* Collection footer */
.collection-footer {
padding: 16px 16px;
display: block;
background-color: #1b1b1b;
border-top: 1px solid #454444;
font-weight: 500;
color: #dfdfdf;
}

View file

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

View file

@ -12,7 +12,7 @@ SysConfig.allow({
});
Meteor.methods({
'add.noSysAdminReg' (admReg, genReg) {
async 'add.noSysAdminReg' (admReg, genReg) {
check(admReg, Boolean);
check(genReg, Boolean);
@ -22,7 +22,7 @@ Meteor.methods({
console.log("Got here...");
console.log("Adding new.");
return SysConfig.upsertAsync({ ruleNo: 1 }, {
return await SysConfig.upsertAsync({ ruleNo: 1 }, {
$set: {
ruleNo: 1,
SysAdminReg: admReg,
@ -32,14 +32,14 @@ Meteor.methods({
}
});
},
'allow.updateInfo' (allowUpdate) {
async 'allow.updateInfo' (allowUpdate) {
check(allowUpdate, Boolean);
if (!this.userId) {
throw new Meteor.Error('Not able to change system update notification settings. Make sure you are logged in with valid system administrator credentials.');
}
return SysConfig.updateAsync({ ruleNo: 1 }, {
return await SysConfig.updateAsync({ ruleNo: 1 }, {
$set: {
allowUpdates: allowUpdate,
}

View file

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

37
imports/api/workoutLog.js Normal file
View file

@ -0,0 +1,37 @@
import { Meteor } from 'meteor/meteor';
import { Mongo } from 'meteor/mongo';
import { check } from 'meteor/check';
export const WorkoutLog = new Mongo.Collection('workoutLog');
WorkoutLog.allow({
insert: function(userId, doc){
// if use id exists, allow insert
return !!userId;
},
});
Meteor.methods({
async 'add.log' (routineId, exerciseName, exerciseType, measure, measureUnits) {
check(routineId, String);
check(exerciseName, String);
check(exerciseType, String);
check(measure, String);
check(measureUnits, String);
if (!this.userId) {
throw new Meteor.Error('You are not allowed to add routines. Make sure you are logged in with valid user credentials.');
}
return await WorkoutLog.insertAsync({
routineId: routineId,
exerciseName: exerciseName,
exerciseType: exerciseType,
measure: measure,
measureUnits: measureUnits,
addedBy: this.userId,
addedOn: new Date(),
exerciseActive: true,
});
},
});

57
imports/api/workouts.js Normal file
View file

@ -0,0 +1,57 @@
import { Meteor } from 'meteor/meteor';
import { Mongo } from 'meteor/mongo';
import { check } from 'meteor/check';
export const Workouts = new Mongo.Collection('workouts');
Workouts.allow({
insert: function(userId, doc){
// if use id exists, allow insert
return !!userId;
},
});
Meteor.methods({
async 'add.workoutRoutine' (routineName) {
check(routineName, String);
if (!this.userId) {
throw new Meteor.Error('You are not allowed to add routines. Make sure you are logged in with valid user credentials.');
}
return await Workouts.insertAsync({
routineName: routineName,
addedBy: this.userId,
addedOn: new Date(),
routineActive: true,
});
},
async 'edit.workoutRoutine' (routineId, routineName) {
check(routineId, String);
check(routineName, String);
if (!this.userId) {
throw new Meteor.Error('You are not allowed to edit routines. Make sure you are logged in with valid user credentials.');
}
return await Workouts.updateAsync({ _id: routineId }, {
$set: {
routineName: routineName,
dateModified: new Date(),
}
});
},
async 'deactivate.workoutRoutine' (routineId) {
check(routineId, String);
if (!this.userId) {
throw new Meteor.Error('You are not allowed to deactivate routines. Make sure you are logged in with valid user credentials.');
}
return await Workouts.updateAsync({ _id: routineId }, {
$set: {
routineActive: false,
}
});
}
});

View file

@ -47,4 +47,25 @@ FlowRouter.route('/userMgmt', {
action() {
this.render('MainLayout', { main: "userMgmt" });
}
});
FlowRouter.route('/workouts', {
name: 'workouts',
action() {
this.render('MainLayout', { main: "workouts"});
}
});
FlowRouter.route('/meals', {
name: 'meals',
action() {
this.render('MainLayout', { main: "meals"});
}
});
FlowRouter.route('/measurements', {
name: 'measurements',
action() {
this.render('MainLayout', { main: "measurements"});
}
});

View file

@ -3,6 +3,7 @@ import { UpdateInfo } from "../imports/api/updateInfo";
import { MScripts } from "../imports/api/mScripts";
import { UserInfo } from "../imports/api/userInfo";
import { Roels } from "meteor/roles";
import { Workouts } from "../imports/api/workouts";
Meteor.publish("SystemConfig", function() {
try {
@ -34,3 +35,14 @@ Meteor.publish(null, function () {
}
this.ready();
});
Meteor.publish("myWorkoutRoutines", function () {
try {
if (this.userId) {
return Workouts.find({ "addedBy": this.userId, "routineActive": true });
}
} catch(error) {
console.log(" ERROR in pulling workout routines: " + error);
}
});