Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions amplify/backend/api/wellbeeing/schema.graphql
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
type Reminder @model @auth(rules: [{ allow: owner }]) {
id: ID!
category: Category!
goal: Goal @belongsTo(fields: ["goalId"])
goalId: ID @index(name: "byGoal")
goals: [Goal] @manyToMany(relationName: "GoalReminders")
level: Level!
@index(
name: "remindersByLevel"
Expand All @@ -21,7 +20,7 @@ type Goal @model @auth(rules: [{ allow: owner }]) {
id: ID!
title: String!
category: Category!
reminders: [Reminder] @hasMany(indexName: "byGoal",fields: ["id"])
reminders: [Reminder] @manyToMany(relationName: "GoalReminders")
progress: Int!
stepCount: Int
dueDate: AWSDate!
Expand Down
6 changes: 0 additions & 6 deletions amplify/backend/function/S3Trigger9c40585d/src/index.js

This file was deleted.

13 changes: 0 additions & 13 deletions amplify/backend/function/S3Trigger9c40585d/src/package-lock.json

This file was deleted.

7 changes: 0 additions & 7 deletions amplify/backend/function/S3Trigger9c40585d/src/package.json

This file was deleted.

4 changes: 0 additions & 4 deletions amplify/backend/function/S3Trigger9c40585d/src/yarn.lock

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"pluginId": "amplify-nodejs-function-runtime-provider",
"functionRuntime": "nodejs",
"defaultEditorFile": "src/index.js",
"useLegacyBuild": true
"useLegacyBuild": true,
"defaultEditorFile": "src/index.js"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[
{
"Action": [],
"Resource": []
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"permissions": {},
"lambdaLayers": []
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/* Amplify Params - DO NOT EDIT
ENV
REGION
Amplify Params - DO NOT EDIT */

/**
* @type {import('@types/aws-lambda').APIGatewayProxyHandler}
*/
const AWS = require("aws-sdk");
const dynamo = new AWS.DynamoDB.DocumentClient({ region: `us-east-1` });
exports.handler = async (event) => {

console.log("Processing event: %j", JSON.stringify(event));
const GoalReminderObjectTableName = "GoalReminders-vumo7bou3fbg3fulexi2s26k7i-sandboxtwo";
const IndexName = 'byGoal'
let goalIDs = []
let reminderID = '';
if (event.queryStringParameters && event.queryStringParameters.goalReminder) {
console.log("Received name: " + event.queryStringParameters.goalReminder);
goalIDs = event.queryStringParameters.goalReminder.goalIDs;
reminderID = event.queryStringParameters.goalReminder.reminderID;
}else{
goalIDs = event.goalReminder.goalIDs
reminderID = event.goalReminder.reminderID;
}

console.log("event params: ", goalIDs, reminderID);

// Not working
// var queryParams = {
// TableName: GoalReminderObjectTableName,
// IndexName: IndexName,
// KeyConditionExpression: '#goalID = :vGoalID and #reminderID = :vReminderID',
// ExpressionAttributeValues: { ':vGoalID': goalID, ":vReminderID": reminderID },
// ExpressionAttributeNames: { '#goalID': 'goalID', "#reminderID": 'reminderID' }
// };

// Not working
// var queryParams = {
// TableName: GoalReminderObjectTableName,
// KeyConditionExpression: 'goalID = :vGoalID and reminderID = :vReminderID',
// ExpressionAttributeValues: { ':vGoalID': {"S": goalID}, ":vReminderID": {"S": reminderID} }
// };
let goalReminders = []
goalIDs.forEach(async(gid) => {

var queryParams = {
TableName: GoalReminderObjectTableName,
IndexName: IndexName,
KeyConditionExpression: 'goalID = :vGoalID',
ExpressionAttributeValues: { ':vGoalID': gid,':vReminderID': reminderID },
FilterExpression: "reminderID = :vReminderID"
};
const res = await dynamo.query(queryParams).promise();
if (res.Items.length == 0) {
goalReminders.push({goalID: gid, reminderID: reminderID});
}
});


// const res = await dynamo.query(queryParams).promise();
if (goalReminders.length > 0) {
return {statusCode: 200, message: "Success", goalReminders: goalReminders}
}else{
return {statusCode: 400, message: "Already associated with same goal!", goalReminders: []}
}

};

Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"name": "uniquevalidationgoalreminderfunction",
"version": "2.0.0",
"description": "Lambda function generated by Amplify",
"main": "index.js",
"license": "Apache-2.0",
"devDependencies": {
"@types/aws-lambda": "^8.10.92"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1


"@types/aws-lambda@^8.10.92":
version "8.10.104"
resolved "https://registry.yarnpkg.com/@types/aws-lambda/-/aws-lambda-8.10.104.tgz#01ec1d55a08bdf1201150d9ecae39ff7cca9ff4a"
integrity sha512-HXZJH8aBa06re9NCtFudOr21izYZycgXIVjd8vFBSNSf6Ca4GYD77TfKqwYgcDqv4olqj5KK+Ks7Xi5IXFbNGA==
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,17 @@
"AWSTemplateFormatVersion": "2010-09-09",
"Description": "{\"createdOn\":\"Linux\",\"createdBy\":\"Amplify\",\"createdWith\":\"9.2.1\",\"stackType\":\"function-Lambda\",\"metadata\":{}}",
"Parameters": {
"env": {
"Type": "String"
"CloudWatchRule": {
"Type": "String",
"Default": "NONE",
"Description": " Schedule Expression"
},
"deploymentBucketName": {
"Type": "String"
},
"env": {
"Type": "String"
},
"s3Key": {
"Type": "String"
}
Expand All @@ -30,16 +35,24 @@
"aws:asset:property": "Code"
},
"Properties": {
"Code": {
"S3Bucket": {
"Ref": "deploymentBucketName"
},
"S3Key": {
"Ref": "s3Key"
}
},
"Handler": "index.handler",
"FunctionName": {
"Fn::If": [
"ShouldNotCreateEnvResources",
"S3Trigger9c40585d",
"uniqueValidationGoalReminderFunction",
{
"Fn::Join": [
"",
[
"S3Trigger9c40585d",
"uniqueValidationGoalReminderFunction",
"-",
{
"Ref": "env"
Expand All @@ -53,6 +66,9 @@
"Variables": {
"ENV": {
"Ref": "env"
},
"REGION": {
"Ref": "AWS::Region"
}
}
},
Expand All @@ -63,15 +79,8 @@
]
},
"Runtime": "nodejs14.x",
"Timeout": 25,
"Code": {
"S3Bucket": {
"Ref": "deploymentBucketName"
},
"S3Key": {
"Ref": "s3Key"
}
}
"Layers": [],
"Timeout": 25
}
},
"LambdaExecutionRole": {
Expand All @@ -80,12 +89,12 @@
"RoleName": {
"Fn::If": [
"ShouldNotCreateEnvResources",
"S3Trigger9c40585dLambdaRole9c40585d",
"bewellLambdaRole24d31853",
{
"Fn::Join": [
"",
[
"S3Trigger9c40585dLambdaRole9c40585d",
"bewellLambdaRole24d31853",
"-",
{
"Ref": "env"
Expand Down
54 changes: 37 additions & 17 deletions src/components/ReminderForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,14 @@
</v-card-title>
<v-card-text>
<v-form ref="form" v-model="valid" v-if="associatedGoal">
<v-select v-model="reminder.goalId" :items="[...incompleteGoals, 'None']" item-text="title" item-value="id"
label="Select Goal"></v-select>
<v-select
v-model="goalIds"
:items="incompleteGoals"
item-text="title"
item-value="id"
label="Select Goal"
:multiple="true"
></v-select>
</v-form>
<v-list disabled v-else-if="reminder.isComplete">
<v-list-item two-line>
Expand Down Expand Up @@ -112,11 +118,22 @@
<v-text-field v-model="reminder.time" label="Schedule A Reminder" prepend-icon="mdi-clock-time-four-outline"
readonly v-bind="attrs" v-on="on" :rules="[(v) => !!v || 'Time is required']" required></v-text-field>
</template>
<v-time-picker v-model="reminder.time" format="ampm" ampm-in-title
@click:minute="$refs.menu.save(reminder.time)" header-color="var(--mh-blue)"></v-time-picker>
<v-time-picker
v-model="reminder.time"
format="ampm"
ampm-in-title
@click:minute="$refs.menu.save(reminder.time)"
header-color="var(--mh-blue)"
></v-time-picker>
</v-menu>
<v-select v-model="reminder.goalId" :items="[...incompleteGoals, 'None']" item-text="title" item-value="id"
label="Associate with Goal?"></v-select>
<v-select
v-model="goalIds"
:items="incompleteGoals"
item-text="title"
item-value="id"
label="Associate with Goal?"
:multiple="true"
></v-select>
</v-form>
</v-card-text>

Expand Down Expand Up @@ -163,12 +180,14 @@ export default {
reminder: {
type: Object,
},

// goal: {
// type: Object
// },
},
data() {
return {
goalIds: [],
dialog: false,
intervalId: 60000,
valid: true,
Expand All @@ -192,7 +211,7 @@ export default {
]),
...mapMutations(["SET_ASSOCIATED_GOAL"]),
log(e) {
console.log(e)
console.log(e);
},
freqStringToArray() {
this.freqArr = this.reminder.frequency.split(",")
Expand All @@ -217,7 +236,6 @@ export default {
this.freqStringToArray()
// this.SET_ASSOCIATED_GOAL(false)
},

async saveReminder() {
if (!this.$refs.form.validate()) {
return;
Expand All @@ -236,22 +254,24 @@ export default {
try {
if (this.reminder.id) {
await this.updateReminderById({
id: this.reminder.id,
category: this.reminder.category,
level: this.reminder.level,
activity: this.reminder.activity,
frequency: this.reminder.frequency,
contentType: this.reminder.contentType,
time: this.reminder.time,
goalId: this.reminder.goalId,
reminder: {
id: this.reminder.id,
category: this.reminder.category,
level: this.reminder.level,
activity: this.reminder.activity,
frequency: this.reminder.frequency,
contentType: this.reminder.contentType,
time: this.reminder.time,
},
goalIds: this.goalIds,
});
} else {
this.reminder.contentType = "Videos";
// this.reminder.category = this.activities.filter(t => t && t.title == this.reminder.activity)[0].category;
this.reminder.level = this.userPrefLevel;
// Call Vuex action to add reminder
//console.log(this.reminder)
await this.addReminder(this.reminder);
await this.addReminder({reminder: this.reminder, goalIds: this.goalIds});
}
// Close form and reset form values
this.toggleReminderFormDialog();
Expand Down
Loading