From dd7e4a493311c6f94abb2062f299745886467aa8 Mon Sep 17 00:00:00 2001 From: Brian McGonagill Date: Wed, 4 Feb 2026 17:05:47 -0600 Subject: [PATCH] Making improvements --- .meteor/packages | 14 +- .meteor/release | 2 +- .meteor/versions | 32 ++-- README.md | 44 ++++- .../Workouts/WorkoutLogs/workoutLog.html | 175 +++++++++++++++++- .../Workouts/WorkoutLogs/workoutLog.js | 85 ++++++++- client/General/Workouts/workouts.html | 2 +- client/General/Workouts/workouts.js | 8 +- imports/api/workoutLog.js | 20 +- lib/route.js | 7 + server/publish.js | 12 +- 11 files changed, 349 insertions(+), 52 deletions(-) diff --git a/.meteor/packages b/.meteor/packages index 1813e73..13ec01f 100644 --- a/.meteor/packages +++ b/.meteor/packages @@ -6,18 +6,18 @@ meteor-base@1.5.2 # Packages every Meteor app needs to have mobile-experience@1.1.2 # Packages for a great mobile UX -mongo@2.1.4 # The database Meteor supports right now +mongo@2.2.0 # The database Meteor supports right now blaze-html-templates # Compile .html files into Meteor Blaze views jquery # Wrapper package for npm-installed jquery reactive-var@1.0.13 # Reactive variable for tracker tracker@1.3.4 # Meteor's client-side reactive programming library -standard-minifier-css@1.9.3 # CSS minifier run for production mode -standard-minifier-js@3.1.1 # JS minifier run for production mode +standard-minifier-css@1.10.0 # CSS minifier run for production mode +standard-minifier-js@3.2.0 # JS minifier run for production mode es5-shim@4.8.1 # ECMAScript 5 compatibility for older browsers -ecmascript@0.16.13 # Enable ECMAScript2015+ syntax in app code -typescript@5.6.6 # Enable TypeScript syntax in .ts and .tsx modules -shell-server@0.6.2 # Server-side component of the `meteor shell` command +ecmascript@0.17.0 # Enable ECMAScript2015+ syntax in app code +typescript@5.9.3 # Enable TypeScript syntax in .ts and .tsx modules +shell-server@0.7.0 # Server-side component of the `meteor shell` command @@ -27,6 +27,6 @@ blaze-hot # Update files using Blaze's API with HMR session@1.2.2 ostrio:flow-router-extra email@3.1.2 -accounts-password@3.2.1 +accounts-password@3.2.2 roles@1.0.1 arianjahiri:meteor-handlebars-helpers diff --git a/.meteor/release b/.meteor/release index 4876d6f..703a722 100644 --- a/.meteor/release +++ b/.meteor/release @@ -1 +1 @@ -METEOR@3.3.2 +METEOR@3.4 diff --git a/.meteor/versions b/.meteor/versions index 15b6a08..62e199f 100644 --- a/.meteor/versions +++ b/.meteor/versions @@ -1,9 +1,9 @@ -accounts-base@3.1.2 -accounts-password@3.2.1 +accounts-base@3.2.0 +accounts-password@3.2.2 allow-deny@2.1.0 arianjahiri:meteor-handlebars-helpers@0.0.1 autoupdate@2.0.1 -babel-compiler@7.12.2 +babel-compiler@7.13.0 babel-runtime@1.5.2 base64@1.0.13 binary-heap@1.0.12 @@ -11,11 +11,11 @@ blaze@3.0.2 blaze-hot@2.0.0 blaze-html-templates@3.0.0 blaze-tools@2.0.0 -boilerplate-generator@2.0.2 +boilerplate-generator@2.1.0 caching-compiler@2.0.1 caching-html-compiler@2.0.0 callback-hook@1.6.1 -check@1.4.4 +check@1.5.0 core-runtime@1.0.0 ddp@1.4.2 ddp-client@3.1.1 @@ -25,7 +25,7 @@ ddp-server@3.1.2 deps@1.0.5-pre.1 diff-sequence@1.1.3 dynamic-import@0.7.4 -ecmascript@0.16.13 +ecmascript@0.17.0 ecmascript-runtime@0.8.3 ecmascript-runtime-client@0.12.3 ecmascript-runtime-server@0.11.1 @@ -45,18 +45,18 @@ jquery@3.0.2 launch-screen@2.0.1 localstorage@1.2.1 logging@1.3.6 -meteor@2.1.1 +meteor@2.2.0 meteor-base@1.5.2 minifier-css@2.0.1 -minifier-js@3.0.4 -minimongo@2.0.4 +minifier-js@3.1.0 +minimongo@2.0.5 mobile-experience@1.1.2 mobile-status-bar@1.1.1 modern-browsers@0.2.3 modules@0.20.3 modules-runtime@0.13.2 modules-runtime-hot@0.14.3 -mongo@2.1.4 +mongo@2.2.0 mongo-decimal@0.2.0 mongo-dev-server@1.1.1 mongo-id@1.0.9 @@ -67,7 +67,7 @@ ostrio:flow-router-extra@3.12.1 promise@1.0.0 random@1.2.2 rate-limit@1.1.2 -react-fast-refresh@0.2.9 +react-fast-refresh@0.3.0 reactive-dict@1.3.2 reactive-var@1.0.13 reload@1.3.2 @@ -76,19 +76,19 @@ roles@1.0.1 routepolicy@1.1.2 session@1.2.2 sha@1.0.10 -shell-server@0.6.2 +shell-server@0.7.0 socket-stream-client@0.6.1 spacebars@2.0.0 spacebars-compiler@2.0.0 -standard-minifier-css@1.9.3 -standard-minifier-js@3.1.1 +standard-minifier-css@1.10.0 +standard-minifier-js@3.2.0 templating@1.4.4 templating-compiler@2.0.0 templating-runtime@2.0.1 templating-tools@2.0.0 tracker@1.3.4 -typescript@5.6.6 +typescript@5.9.3 underscore@1.6.4 url@1.3.5 -webapp@2.0.7 +webapp@2.1.0 webapp-hashing@1.1.2 diff --git a/README.md b/README.md index a18bde4..a4b6b40 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,36 @@ -# This is a template to get started. +# Open Health -The template includes -- Registration -- Login / Authentication with username / password -- First person to register is the System Admin role and has full control over the installation. -- Initial roles are - - systemadmin - - tenantadmin (admin over a single tenant) - - user (non administrative role) +Workout Routines +- Routine Name +- Exercise Type + - Aerobic + - Strength + - Flexibility + - Endurance +- Exercise Measure + - Distance + - Weight + - Time + - Rate +- Exercise Units + - Distance + - Miles + - Kilometers + - Meters + - Yards + - Feet + - Weight + - KG + - LBS + - Time + - Hours + - Minutes + - Seconds + - Milliseconds + - Rate + - Miles per Hour + - Kilometers per Hour + - Beats Per Minute + - Steps per Minute +- Instructions -There are a few things built in already, like placeholders for the Site Name, App Name, etc, but the rest is a blank slate. diff --git a/client/General/Workouts/WorkoutLogs/workoutLog.html b/client/General/Workouts/WorkoutLogs/workoutLog.html index 54f2b2a..e2064aa 100644 --- a/client/General/Workouts/WorkoutLogs/workoutLog.html +++ b/client/General/Workouts/WorkoutLogs/workoutLog.html @@ -1,5 +1,174 @@ \ No newline at end of file diff --git a/client/General/Workouts/WorkoutLogs/workoutLog.js b/client/General/Workouts/WorkoutLogs/workoutLog.js index 8084758..ddac58f 100644 --- a/client/General/Workouts/WorkoutLogs/workoutLog.js +++ b/client/General/Workouts/WorkoutLogs/workoutLog.js @@ -1,18 +1,89 @@ import { FlowRouter } from 'meteor/ostrio:flow-router-extra'; -import { Workouts } from '../../../imports/api/workouts.js'; +import { Workouts } from '../../../../imports/api/workouts'; +import { WorkoutLog } from '../../../../imports/api/workoutLog'; -Template.workoutsLog.onCreated(function() { +Template.workoutLog.onCreated(function() { this.subscribe("myWorkoutRoutines"); + this.subscribe("myWorkoutLog"); }); -Template.workoutsLog.onRendered(function() { +Template.workoutLog.onRendered(function() { }); -Template.workoutsLog.helpers({ - +Template.workoutLog.helpers({ + exMeas1: function() { + return Session.get("exMeas1"); + }, + exMeas2: function() { + return Session.get("exMeas2"); + }, + exMeas3: function() { + return Session.get("exMeas3"); + }, + routine: function() { + let routineId = Session.get("routineId"); + let routine = Workouts.findOneAsync({ _id: routineId }); + return routine; + } }); -Template.workoutsLog.events({ - +Template.workoutLog.events({ + 'change #exerciseMeasure, change #exerciseMeasure2, change #exerciseMeasure3' (e) { + let fieldId = e.currentTarget.id; + if (fieldId == "exerciseMeasure") { + let exMeas = $("#exerciseMeasure").val(); + if (exMeas == "Sets" || exMeas == "Reps") { + exMeas = "Sets" + } + Session.set("exMeas1", exMeas); + } else if (fieldId == "exerciseMeasure2") { + let exMeas2 = $("#exerciseMeasure2").val(); + if (exMeas2 == "Sets" || exMeas2 == "Reps") { + exMeas2 = "Sets" + } + Session.set("exMeas2", exMeas2); + } else { + let exMeas3 = $("#exerciseMeasure3").val(); + if (exMeas3 == "Sets" || exMeas3 == "Reps") { + exMeas3 = "Sets" + } + Session.set("exMeas3", exMeas3); + } + }, + 'click #saveLogExercise' (e) { + let routineId = Session.get("routineId"); + let exerciseName = $("#exerciseName").val(); + let exerciseType = $("#exerciseType").val(); + let exerciseMeasure = $("#exerciseMeasure").val(); + let exerciseUnitMeasure = $("#exerciseUnitMeasure").val(); + let exerciseMeasure2 = $("#exerciseMeasure2").val(); + let exerciseUnitMeasure2 = $("#exerciseUnitMeasure2").val(); + let exerciseMeasure3 = $("#exerciseMeasure3").val(); + let exerciseUnitMeasure3 = $("#exerciseUnitMeasure3").val(); + let exerciseInstruction = $("#exerciseInstruction").val(); + + if (typeof routineId == 'undefined' || routineId == null || routineId == "") { + showSnackbar("Unable to get Workout!", "red"); + return; + } else if (exerciseName == "" || exerciseName == null) { + showSnackbar("Exercise Name is Required!", "red"); + return; + } else { + const addExercise = async() => { + try { + const result = await Meteor.callAsync('add.exerciseToLog', routineId, exerciseName, exerciseType, exerciseMeasure, exerciseUnitMeasure, exerciseMeasure2, exerciseUnitMeasure2, exerciseMeasure3, exerciseUnitMeasure3, exerciseInstruction); + if (!result) { + console.log(" ISSUE saving exercise info for loggin."); + showSnackbar("Exercise Not Saved!", "red"); + } else { + showSnackbar("Exercise Added!", "green"); + } + } catch(error) { + console.log(" ERROR trying to add an exercise to log: " + error); + } + } + addExercise(); + } + } }); \ No newline at end of file diff --git a/client/General/Workouts/workouts.html b/client/General/Workouts/workouts.html index 82cdd09..1b38292 100644 --- a/client/General/Workouts/workouts.html +++ b/client/General/Workouts/workouts.html @@ -17,7 +17,7 @@ {{/if}} diff --git a/client/General/Workouts/workouts.js b/client/General/Workouts/workouts.js index bed00e9..b255173 100644 --- a/client/General/Workouts/workouts.js +++ b/client/General/Workouts/workouts.js @@ -45,5 +45,11 @@ Template.workouts.events({ } addWorkout(); } - } + }, + 'click .routine' (e) { + let routineId = e.currentTarget.id; + console.log("Routine ID set: " + routineId); + Session.set("routineId", routineId); + FlowRouter.go('/workoutLog'); + }, }); \ No newline at end of file diff --git a/imports/api/workoutLog.js b/imports/api/workoutLog.js index c7a295f..c1927c2 100644 --- a/imports/api/workoutLog.js +++ b/imports/api/workoutLog.js @@ -12,12 +12,17 @@ WorkoutLog.allow({ }); Meteor.methods({ - async 'add.log' (routineId, exerciseName, exerciseType, measure, measureUnits) { + async 'add.exerciseToLog' (routineId, exerciseName, exerciseType, exerciseMeasure, exerciseUnitMeasure, exerciseMeasure2, exerciseUnitMeasure2, exerciseMeasure3, exerciseUnitMeasure3, exerciseInstruction) { check(routineId, String); check(exerciseName, String); check(exerciseType, String); - check(measure, String); - check(measureUnits, String); + check(exerciseMeasure, String); + check(exerciseUnitMeasure, String); + check(exerciseMeasure2, String); + check(exerciseUnitMeasure2, String); + check(exerciseMeasure3, String); + check(exerciseUnitMeasure3, String); + check(exerciseInstruction, 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.'); @@ -27,8 +32,13 @@ Meteor.methods({ routineId: routineId, exerciseName: exerciseName, exerciseType: exerciseType, - measure: measure, - measureUnits: measureUnits, + exerciseMeasure: exerciseMeasure, + exerciseUnitMeasure: exerciseUnitMeasure, + exerciseMeasure2: exerciseMeasure2, + exerciseUnitMeasure2: exerciseUnitMeasure2, + exerciseMeasure3: exerciseMeasure3, + exerciseUnitMeasure3: exerciseUnitMeasure3, + exerciseInstruction: exerciseInstruction, addedBy: this.userId, addedOn: new Date(), exerciseActive: true, diff --git a/lib/route.js b/lib/route.js index 53a89c3..97130e3 100644 --- a/lib/route.js +++ b/lib/route.js @@ -68,4 +68,11 @@ FlowRouter.route('/measurements', { action() { this.render('MainLayout', { main: "measurements"}); } +}); + +FlowRouter.route('/workoutLog', { + name: 'workoutLog', + action() { + this.render('MainLayout', { main: "workoutLog"}); + } }); \ No newline at end of file diff --git a/server/publish.js b/server/publish.js index 007b2db..537d767 100644 --- a/server/publish.js +++ b/server/publish.js @@ -4,6 +4,7 @@ import { MScripts } from "../imports/api/mScripts"; import { UserInfo } from "../imports/api/userInfo"; import { Roels } from "meteor/roles"; import { Workouts } from "../imports/api/workouts"; +import { WorkoutLog } from "../imports/api/workoutLog"; Meteor.publish("SystemConfig", function() { try { @@ -44,5 +45,14 @@ Meteor.publish("myWorkoutRoutines", function () { } catch(error) { console.log(" ERROR in pulling workout routines: " + error); } - +}); + +Meteor.publish("myWorkoutLog", function () { + try { + if (this.userId) { + return WorkoutLog.find({ "addedBy": this.userId, "exerciseActive": true }); + } + } catch(error) { + console.log(" ERROR in pulling workout routines: " + error); + } });