/didactic-lamp

Memoria web programming project

Primary LanguageJavaScript

Memoria

This web application aims to helps users monitor and deal with their mental well-being and mental health during our current pandemic.

Instructions for Use

Regular User View

1.a.Login Page

LoginPage

A user can login to an existing account. For regular users input "user" for username field and "user" for password field and click the "LOGIN" button to login. If a user does not have an account, click "CREATE ACCOUNT BUTTON" on the bottom right side.

1.b.Create an Account

CreateAccountPage

A user can enter their email address, username, password name and region. Once create is selected, a confirmation appears and takes the user back to the login page to sign in.

2.Home Page

HomePage

After signing in, it takes the user to the homepage. The user has the option of selecting any of the 4 features.

  1. See your region in the map

  2. Go to your profile

  3. View the table

  4. Get Mental Health Resources

To go to any of the four pages above, click on the image corresponding to the feature.

3.Navigation Bar

MenuBar2

The user is able to access the homepage by selecting "Memoria" logo on the top left corner in the navigation bar or can access any of the pages in the web app by clicking the menu bar icon in the top right corner. When clicked, the menu will drop down giving the user options what will redirect them to different pages.

The user is only able to access the survey from the menu bar.

4.Survey

Survey

To access the survey, go to the navigation bar, click on the menu icon on the top right and then click on "Survey".

To submit a survey answer each question by clicking on the "select" drop down field and choosing an option. After all the questions have been answered, click on "SUBMIT SURVEY" to submit the survey.

5.Map

Map

The Map Page can be accessed through either the Home Page (see Home Page) or the menu in the navigation bar.

The Map shows the average mental-well being across the GTA. Selecting a marker shows the average mental well being ratings. For more information about maps, the user can click on the "i" icon above the map which will produce a pop-up with more information, as seen in section 5.b. below. For how to use the map, the user can click on the "?" button which will produce a pop-up with instructions, as seen in the picture below in section 5.a.

5.a.More Information in Map

InfoButtonMap

To exit this pop-up simply click anywhere outside of the pop-up.

5.b.Instructions in Map

InstructionButtonMap

To exit this pop-up simply click anywhere outside of the pop-up.

6.Profile

ProfilePage

The Profile Page can be accessed through either the Home Page (see Home Page) or the menu in the navigation bar.

6.a.Mood Rating and Edit User Info

Moodrating EditInfo

  • The user's daily mood rating is shown in the profile page. After a user submits a survey, the rating will be updated. This can be completed by going to the menu on the right-hand side and selecting survey.

  • A user can also edit their information by selecting the edit button. The user will then be able to edit each field as seen below.

 EditInfo

  • After the user has edited their information, they can click "Save" to save the changes.

6.b.Add a Journal Entry**

NewEntry

  • In the Profile Page, users can express their thoughts and reflect by writing journal entries. This can be done by selecting the "New Entry Button", which will open a pop-up. The user can type in their entry in the pop-up and then click "SUBMIT" to submit their entry.

7.Table Page

The Table Page can be accessed through either the Home Page (see Home Page) or the menu in the navigation bar.

Table

This shows the average mental-health well-being of Memoria users across the GTA.

8.Mental Health Resources

The Resources Page can be accessed through either the Home Page (see Home Page) or the menu in the navigation bar.

MentalHealthResources

This provides a list of mental health resources with links and phone numbers (some do not have links). For resources with links, the user can click on the resource row and the website will open up in a new window or tab.

Admin View

1.Logging In

LoginPage

An admin can login to an existing admin account. Input "admin" for username field and "admin" for password field and click the "LOGIN" button to login. If an admin does not have an account, they must create a regular user account (see Regular User Login) and an existing admin must give them permissions.

After logging in, the admin should see a regular user homepage but with a different admin menu. To see the menu click on the top right menu bar icon which will drop down a menu list. The admin will have an extra menu item Admin Resources.

MenuBar

Note: Admin has access to all features regular users have but in their navigation bar, has additional access to Admin Resources. For information and instructions on how to use other pages/features please see the corresponding sections in Regular User View

2. Admin Resources

Selecting Admin Resources, the admin is able to manage users which consists of editing, deleting and adding users. The admin is also able to export data from the Home Page Table as a csv file.

2.a.Edit/Delete Users

To edit users click on the "Manage Users" tab on the right side of the Admin Resources Page.

AdminPage

To edit a user Click the edit icon under the 'Edit' column. This will change the view to:

edit user

The user fields can be edited and to submit changes click "SUBMIT" or to cancel click "CANCEL".

To delete a user click the delete button under the "Delete" column.

2.b. Add Users

To add users click on the "Add User" tab on the left side of the Admin Resources Page.

add users

To add a new user, fill out the form and click the "CREATE" button.

2.c.Export Table Data

To export table data as a CSV file click on the "Export Region Data" tab on the left side of the Admin Resources Page.

export data

Click on the "EXPORT AS CSV FILE" button on the bottom of the page. This will produce a link under the "EXPORT AS CSV FILE" button.

export data link

To download the exported CSV file, click on the "Download for CSV file" link.

2.d. Edit/Delete/Add Mental Health Resources

To edit/delete/add mental health resources click on the "Mental Health Resources" tab on the left side of the Admin Resources Page.

resources admin

  • To delete a resource click the delete button icon under the "Delete" column for the corresponding resources row.

  • To edit a resource click on the edit button icon under the "Edit" column for the corresponding resource. The row should become editable:

resources admin

Input edits and click submit to save changes.

  • To create a new resource scroll to the bottom of the page to the last row of the table:

resources admin

Click on the add button icon "+":

resources admin

Input the new resource information and click on submit to add and save the resource.

Routes Description

create account:

  • Creates a new account in the database from the create account form information from the front-end.
  • method: POST
  • route: https://memoria1.herokuapp.com/api/createaccount
  • input data: a JSON object with key/value pairs for username (string), name (string), password (string), region (string), email (string),
    • For example: {"username": "user7", "password": "user7", "email": "user7@gmail.com", "region": "King", "name": "user7"}
  • Expected output: The created and saved user document object with key/value pairs for _id (string), email (string), password (string), region (string), name (string), username (string), rating (string), admin (boolean), journalEntries (array) and __v (number). For example:
    • {"_id":"5f36eaa6400cdc001785b1f5", "email":"user7@gmail.com", "password":"$2b$10$KiLBuuUeRe0zCBt7zZwy8u./jqNASN3yJ9UW3.uR4SdJvkGtR0Tbm", "region":"King", "name":"user7","username":"user7", "rating":"", "admin":false, "journalEntries":[],"__v":0}

login:

  • Checks login credentials in database inputed from the front-end login form.
  • method: POST
  • route: https://memoria1.herokuapp.com/api/login
  • input data: a JSON object with key/value pairs for username (string) and password (string). For example:
    • {"username": "user7", "password": "user7"}
  • expected output: The corresponding user document object with key/value pairs for _id (string), email (string), password (string), region (string), name (string), username (string), rating (string), admin (boolean), journalEntries (array) and __v (number). For example:
    • {"_id":"5f36eaa6400cdc001785b1f5", "email":"user7@gmail.com", "password":"$2b$10$KiLBuuUeRe0zCBt7zZwy8u./jqNASN3yJ9UW3.uR4SdJvkGtR0Tbm", "region":"King", "name":"user7","username":"user7", "rating":"", "admin":false, "journalEntries":[],"__v":0}

get resources:

  • Get all the resources for the mental health resources page table.
  • method: GET
  • route: https://memoria1.herokuapp.com/api/getresources
  • input data: none
  • expected output: An array of resource document objects where the resource document object has key/pair values for _id (string), name (string), url (string), phoneNumber (string) and __v (number). For example:
    • [{"_id":"5f36103b795dad64027abf17","name":"U of T My Student Support Program","url":"https://studentlife.utoronto.ca/service/myssp/","phoneNumber":"1-844-451-9700"},{"_id":"5f36168c795dad64027abf18","name":"Good2Talk Student Helpline","url":"http://www.good2talk.ca/","phoneNumber":"1-866-925-5454"}]

update user mood rating

  • Update the user document in the database with new mood rating.
  • method: POST
  • route: https://memoria1.herokuapp.com/api/updateUserRating
  • input data: A JSON object with key/value pairs for username (string) and rating (number). For example:
    • {"username": "user7", "rating": 7}
  • expected output: A user document for the corresponding inputted username and updated rating with key/value pairs for _id (string), email (string), password (string), region (string), name (string), username (string), rating (string), admin (boolean), journalEntries (array) and __v (number). For example:
    • {"_id":"5f36eaa6400cdc001785b1f5", "email":"user7@gmail.com", "password":"$2b$10$KiLBuuUeRe0zCBt7zZwy8u./jqNASN3yJ9UW3.uR4SdJvkGtR0Tbm", "region":"King", "name":"user7", "username":"user7", "rating":"7", "admin":false, "journalEntries":[],"__v":0}

update region rating average

  • Update the region rating average for a region's Rating document.
  • method: POST
  • route: https://memoria1.herokuapp.com/api/updateRatings
  • input data: A JSON object with key/value pairs for region (string) and q6 (number), for example:
    • {"region": "King", "q6": 7}
  • expected output: A ratings document for the region with updated ratings (average rating) in the form with key/value pairs for _id (string), location (string), lat (number), lng (number), ratings (number), numOfRatings (number) and __v (number). For example:
    • {"_id":"5f2d886ae607ec02d87fb7d5", "location":"King", "lat":43.972174, "lng":-79.607418, "ratings":7, "numOfRatings":1, "__v":0}

create and save new survey document

  • Create a new document based on input from survey form in front-end and save to database.
  • method: POST
  • route:
  • input data: A JSON object with key/value pairs for q1 (string), q2 (boolean), q3 (boolean), q4 (boolean), q5 (boolean), q6 (number), and region (string).
    • For example: {"q1": "0", "q2": false, "q3": false, "q4": false, "q5": false, "q6": 7, "region": "King"}
  • expected output: The survey document that was created and saved with key/value pairs _id (string), q1 (string), q2 (boolean), q3 (boolean), q4 (boolean), q5 (boolean), q6 (number), region (string), and __v (number). For example:
    • {"_id":"5f36f9fb815d0700179aabf3", "q1":"0", "q2":false, "q3":false, "q4":false, "q5":false, "q6":7, "region":"King", "__v":0}

get Journal Entries

  • Gets all users entries from database to appear on journal history on the front-end
  • method: GET
  • route: https://memoria1.herokuapp.com/api/getprofile
  • Expected output: Returns an array of objects containing the journal entries. For example:
    • "journalEntries": [{"entry": "This a journal entry"},{"entry" : "This is another entry"}]

add a new journal entry

  • Creates a new journal in the database from the add entry pop-up form on the front-end
  • method: POST
  • route: https://memoria1.herokuapp.com/api/profile
  • input data: A JSON object with the key/value pair for entry (string). For example:
    • {"entry": "This a journal entry"}
  • Expected Output: Returns users document with updated journal entries array with key/value pairs for _id (string), email (string), password (string), region (string), name (string), username (string), rating (string), admin (boolean), journalEntries (array) and __v (number). For example:
    • {"_id":"5f36eaa6400cdc001785b1f5", "email":"ichangedMyEmail@gmail", "password":"$2b$10$KiLBuuUeRe0zCBt7zZwy8SS/jqNASN3yJ9UW3.uR4SdJvkGtRgggY", "region":"King", "name":"user7","username":"user7", "rating":"", "admin":false, "journalEntries":[{"entry": "Just added this"}],"__v":0}

edit user and update

  • Edits the user information based on front-end input and saves the user in the database.
  • method: PATCH
  • route: https://memoria1.herokuapp.com/api/edit-user
  • input data: A JSON object with the key/value pairs for name (string), username (string), password (string), email (string) and region (string). For example:
    • {"name": "user7", "username": "user7", "password": "newpassword", email: "ichangedMyEmail@gmail", "region": "Toronto"}
  • Expected output: Returns updated user document with the necessary changes with key/value pairs for _id (string), email (string), password (string), region (string), name (string), username (string), rating (string), admin (boolean), journalEntries (array) and __v (number). For example:
    • {"_id":"5f36eaa6400cdc001785b1f5", "email":"ichangedMyEmail@gmail", "password":"$2b$10$KiLBuuUeRe0zCBt7zZwy8SS/jqNASN3yJ9UW3.uR4SdJvkGtRgggY", "region":"King", "name":"user7","username":"user7", "rating":"", "admin":false, "journalEntries":[],"__v":0}

get ratings

  • Gets daily ratings from all users specifically the region and rating field. This is used for the CSV file.
  • method: GET
  • route: https://memoria1.herokuapp.com/api/getRatings
  • Expected output: Array of ratings objects containing the average ratings in each location with the key/value pairs for location (string) and ratings (number). For example:
    • rating:[{"location": "Toronto, "ratings": 5}, {"location": "King, "ratings": 10}]

get users

  • Gets a list of all users on application.
  • method: GET
  • route: https://memoria1.herokuapp.com/api/admin/edit
  • Expected Output: An array of all user documents with key/value pairs for _id (string), email (string), password (string), region (string), name (string), username (string), rating (string), admin (boolean), journalEntries (array) and __v (number). For Example:
    • users: [{"_id":"5f36eaa6400cdc001785b1f5", "email":"user7@gmail.com", "password":"$2b$10$KiLBuuUeRe0zCBt7zZwy8u./jqNASN3yJ9UW3.uR4SdJvkGtR0Tbm", "region":"King", "name":"user7","username":"user7", "rating":"", "admin":false, "journalEntries":[],"__v":0},{"_id":"5f36eaa640fcdc001785b1f6", "email":"user8@gmail.com", "password":"$2b$10$KiLBuuUeRe0zCBt7zZwy8u./jqNASN3yJ9UW3.uR4SdJvkGtR0Tbm", "region":"Toronto", "name":"user8","username":"user8", "rating":"5", "admin":false, "journalEntries":[],"__v":0}]

delete user

  • Deletes a selected user from the database.
  • method: PATCH
  • route: https://memoria1.herokuapp.com/api/admin/delete-user
  • input data: A user object with key/value pairs for _id (string), email (string), password (string), region (string), name (string), username (string), rating (string), admin (boolean), journalEntries (array) and __v (number). For example:
    • {"_id":"5f36eaa6400cdc001785b1f5", "email":"user7@gmail.com", "password":"$2b$10$KiLBuuUeRe0zCBt7zZwy8u./jqNASN3yJ9UW3.uR4SdJvkGtR0Tbm", "region":"King", "name":"user7","username":"user7", "rating":"", "admin":false, "journalEntries":[],"__v":0}
  • expected output: The deleted user document object. For example:
    • {"_id":"5f36eaa6400cdc001785b1f5", "email":"user7@gmail.com", "password":"$2b$10$KiLBuuUeRe0zCBt7zZwy8u./jqNASN3yJ9UW3.uR4SdJvkGtR0Tbm", "region":"King", "name":"user7","username":"user7", "rating":"", "admin":false, "journalEntries":[],"__v":0}

get all average ratings

  • Get all the ratings documents for existing regions in database.
  • method: GET
  • route: https://memoria1.herokuapp.com/api/homepage-ratings
  • expected output: An object with key "ratings" and value - an array of ratings document objects which has key/value pairs for _id (string), location (string), lat (number), lng (number), ratings (number), numOfRatings (number) and __v (number). For example:
    • {"ratings":[{"_id":"5f2d486a8821ac84696b433b", "location":"Toronto", "lat":43.6532, "lng":-79.3832, "ratings":0, "numOfRatings":0, "__v":0},{"_id":"5f2d48eb8821ac84696b433d", "location":"Scarborough", "lat":43.7764,"lng":-79.2318, "ratings":0, "numOfRatings":0, "__v":0}]}