Initial commit
This commit is contained in:
parent
9ed5089508
commit
78e0e82449
16 changed files with 317 additions and 15 deletions
|
|
@ -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(),
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
37
imports/api/workoutLog.js
Normal 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
57
imports/api/workouts.js
Normal 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,
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue