Getting A better Log Entry Experience, and history setup
This commit is contained in:
parent
98a86ca6a8
commit
5d3396c333
15 changed files with 428 additions and 140 deletions
|
|
@ -1,6 +1,7 @@
|
|||
import { Meteor } from 'meteor/meteor';
|
||||
import { Mongo } from 'meteor/mongo';
|
||||
import { check } from 'meteor/check';
|
||||
import dayjs from 'dayjs';
|
||||
|
||||
export const LogEntry = new Mongo.Collection('logEntry');
|
||||
|
||||
|
|
@ -12,39 +13,45 @@ LogEntry.allow({
|
|||
});
|
||||
|
||||
Meteor.methods({
|
||||
async 'add.logEntry' (routineId, logId, exerciseName, measName1, measure1, measUnit1, measName2, measure2, measUnit2, measName3, measure3, measUnit3) {
|
||||
check(routineId, String);
|
||||
check(logId, String);
|
||||
async 'add.logEntry' (exerciseId, exerciseName, exerciseWeight) {
|
||||
check(exerciseId, String);
|
||||
check(exerciseName, String);
|
||||
check(measName1, String);
|
||||
check(measure1, Number);
|
||||
check(measUnit1, String);
|
||||
check(measName2, String);
|
||||
check(measure2, Number);
|
||||
check(measUnit2, String);
|
||||
check(measName3, String);
|
||||
check(measure3, Number);
|
||||
check(measUnit3, String);
|
||||
check(exerciseWeight, Number);
|
||||
|
||||
if (!this.userId) {
|
||||
throw new Meteor.Error('You are not allowed to add log entries. Make sure you are logged in with valid user credentials.');
|
||||
}
|
||||
|
||||
let rightNow = new Date();
|
||||
let dateAdded = dayjs(rightNow).format('YYYY-MM-DD');
|
||||
let timeAdded = dayjs(rightNow).format("HH:MM:SS");
|
||||
|
||||
return await LogEntry.insertAsync({
|
||||
routineId: routineId,
|
||||
logId: logId,
|
||||
exerciseId: exerciseId,
|
||||
exerciseName: exerciseName,
|
||||
measName1: measName1,
|
||||
measure1: measure1,
|
||||
measUnit1: measUnit1,
|
||||
measName2: measName2,
|
||||
measrue2: measure2,
|
||||
measUnit2: measUnit2,
|
||||
measName3: measName3,
|
||||
measure3: measure3,
|
||||
measUnit3: measUnit3,
|
||||
exerciseWeight: exerciseWeight,
|
||||
dateAdded: dateAdded,
|
||||
timeAdded: timeAdded,
|
||||
addedBy: this.userId,
|
||||
addedOn: new Date()
|
||||
});
|
||||
},
|
||||
async 'add.setToLog' (logId, setNo, repCount) {
|
||||
check(logId, String);
|
||||
check(setNo, Number);
|
||||
check(repCount, Number);
|
||||
|
||||
if (!this.userId) {
|
||||
throw new Meteor.Error('You are not allowed to add sets to log entries. Make sure you are logged in with valid user credentials.');
|
||||
}
|
||||
|
||||
return await LogEntry.updateAsync({ _id: logId }, {
|
||||
$addToSet: {
|
||||
sets:
|
||||
{
|
||||
setNumber: setNo,
|
||||
repCount: repCount,
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue