Giter Site home page Giter Site logo

safeplaces-ct-frontend's Introduction

Safeplaces frontend

Technology used

  • react.js
  • redux
  • mapbox.gl
  • css modules with scss
  • jest for testing

Structure

  • use ducks scheme for redux implementation

Workflow

This project was bootstrapped with Create React App.

Install

clone the repository using the dev_react branch

Copy the .env.template file in the parent directory and rename it to .env file in the parent directory. In order to make the application work correctly you have to enter API keys for Mapbox and Google places. If you don't want to register new ones feel free to ask for working credentials in the Slack channel.

REACT_APP_GOOGLE_PLACES_KEY=GOOGLE_API_KEY_WITH_PLACES_ENABLED
REACT_APP_GOOGLE_PLACES_LANGUAGE=en
REACT_APP_MAPBOX_KEY=MAPBOX_API_KEY
REACT_APP_API_URL=REACT_APP_API_URL
PA11Y_LOGIN_EMAIL= any valid onboarded account login email for the current API. Ideally the account should be a super user.
PA11Y_LOGIN_PASSWORD= any valid onboarded account login password for the current API. Ideally the account should be a super user.

Available Scripts

In the project directory, you can run:

yarn start

Runs the app in the development mode.
Open http://localhost:3000 to view it in the browser.

The page will reload if you make edits.
You will also see any lint errors in the console.

yarn test

Launches the test runner in the interactive watch mode.
See the section about running tests for more information.

yarn test:e2e

Runs the Nightwatch WebDriver tests using Google Chrome against a locally running instance of the UI on port 3000 (e.g. http://localhost:3000/). You MUST have already started the dev server using npm run start in another terminal/console.

yarn test:cucumber

Runs the Nightwatch WebDriver tests using Google Chrome against a locally running instance of the UI on port 3000. The difference between this and the test:e2e is that it uses cucumber-js, feature files, and step definitions to do the test using Behavior Driven Development (BDD). See the features/login.feature file and the features/step-definitions/steps.js files.

yarn run a11y-check

Runs the current accessibility tests in /a11y-tests/index.js This file will have to be updates whenever new routes are created.
Requires PA11Y_LOGIN_EMAIL and PA11Y_LOGIN_PASSWORD
The script will output accessibility errors to the console and also generate html files with the error lists in /a11y-tests/errors
Corresponding screenshots of the pages with errors will be generated in /a11y-tests/screenshots

yarn build

Builds the app for production to the build folder.
It correctly bundles React in production mode and optimizes the build for the best performance.

The build is minified and the filenames include the hashes.
Your app is ready to be deployed!

See the section about deployment for more information.

yarn eject

Note: this is a one-way operation. Once you eject, you can’t go back!

If you aren’t satisfied with the build tool and configuration choices, you can eject at any time. This command will remove the single build dependency from your project.

Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except eject will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.

You don’t have to ever use eject. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.

Learn More

You can learn more in the Create React App documentation.

To learn React, check out the React documentation.

safeplaces-ct-frontend's People

Contributors

adamleonsmith avatar adityatr-paytm avatar aiyan avatar chrismichaelperezsantiago avatar facundomalgieri avatar iamdcj avatar infosec812 avatar justinanderson avatar kevinmcd-mitsdm18 avatar krishnadurai avatar kylemtowle avatar lynngazis avatar marshallmccoy avatar munna avatar penrods avatar sadekhm avatar sanjeevkkansal avatar sherifkozman avatar utzel-butzel avatar yonatanmk avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

safeplaces-ct-frontend's Issues

[dev_react] Critical bug in use of Redux toolkit

Expected behavior

The site should load properly.

Current behavior

An error is thrown, interrupting the app's execution.

error

Steps to reproduce

Checkout 8b7e125, the latest commit in dev_react, and run yarn start.

Possible explanation

The previous commit, b90b411, runs properly. @Utzel-Butzel, can you reproduce this error?

Environment

Context Details
Google Chrome 81.0.4044.138 (Official Build) (64-bit) (cohort: Stable)
OS Windows 10 OS Version 1909 (Build 18363.778)
JavaScript V8 8.1.307.32

Store and Auto population of Health Authority attributes (new field notification URL)

Has_Backend

Change API spec and publisher form to include the new following fields: Notification URL to safe_paths.json
Save Notification URL via API Spec
On Load of Redacted trails, retrieve Notification URL

No_Backend

Change publisher form to include the new following field: Notification URL to safe_paths.json
Add "Load safe_paths.json" option in the Publisher tool to specify the location of an existing safe_paths.json.
Still support "loading redacted" to add to the lat/long/time data points prior to publishing a new safe_paths.json

Update API Spec to reflect new attribute: Notification UR
Update backend to store/retrieve new attribute: Notification UR

Add new web app - manual entry of GPS lat/long/time - to Safe Places suite

Add a 3rd web app to the Safe Places mix that allows a contact tracer to conduct a patient interview with no location history.

Allow GPS Long/Lat/Time to be entered manually using a Google Maps interface and then:

If (has_backend)
Publish via API spec to backend similar to the outcome of the Redaction tool
else
Publish to a json file similar to the outcome of the Redaction tool.

Slack interaction with Steve P on this to give context and some ideas of where to start:

Kyle Towle
Enable infected carriers to provide manually entered location data to a Health Authority (edited)
This one is big because it allows HAP's to start using the tool immediately, even before massive mobile app adoption

Steve Penrod 4 hours ago
I was picturing this as a an independent web app, the Builder.
Geocode a place/address, then get a start time and duration. Drop 5 minute coordinates to match

Kyle Towle 3 hours ago
Yeah, I think you are correct. It would be a separate app, but in the same "SPL suite", right?

Kyle Towle 3 hours ago
I just think prior to massive adoption, this would be a good thing to get started with and several HA's have asked about it

Steve Penrod 3 hours ago
Yup!
I think it could be built in just a few hours, I bet. Just use the Google geocoding API and hack up the reaction tool a little. At least that's my Dr Hackenstein approach.

Add Entry fails with empty Redux store

Screen Shot 2020-05-06 at 9 50 44 PM

Get the above error when trying to "Add entry" to the map

Steps to reproduce:

  • Open app
  • Open Inspect -> Application tab
  • Right-Click Storage -> Local storage
  • Select "Clear"
  • Click "Add Entry" button in UI
  • Enter GPS Coordinates
  • Click "Add to Tracks" button

Is the Content-Type for XMLHttpRequests supposed to be application/x-www-form-urlencoded?

I'm not sure about marking this as a bug yet.

As I tried to connect the frontend to my backend, I encountered a problem.
I set the has_backend var to true and tried the '/login' endpoint.

My backend is receiving this body:

{ "{ username: 'hi', password: 'hi' }'": "" }

(Which is not the payload found in the spec)

I looked around the client code and it seems like the Request’s Content-Type Header is set to "application/x-www-form-urlencoded" instead of "application/json"

Setting it to "application/json" sends the payload as expected:

{ "username": "hi", "password": "hi" }

Is this intentional? If so, I could have the server code work around this, but I believe that most front-end http libraries are expecting the latter for sending payloads.

This is hardcoded to be "application/x-www-form-urlencoded" in both of the index.html files, inside of the doXHR function.

Curious about viability of changing this now to use the Content-Type: application/json header.

function doXHR(method, url, param, auth, creds) {
  ...
    // Make the request
    if (method === "POST" && isDefined(param)) {
      var data = param;
      if (isDefined(creds)) {
        req.setRequestHeader("Authorization", creds);
      }
      req.setRequestHeader(
        "Content-type",
        "application/x-www-form-urlencoded"
      );
      req.send(data);
    } else {
      req.setRequestHeader("Authorization", "Basic " + auth);
      req.send();
    }
  });
}

[dev_mvp] Cookie issue

When using publisher, I see the following warning in the console:

A cookie associated with a cross-site resource at https://google.com/ was set without the SameSiteattribute. A future release of Chrome will only deliver cookies with cross-site requests if they are set withSameSite=NoneandSecure. You can review cookies in developer tools under Application>Storage>Cookies and see more details at https://www.chromestatus.com/feature/5088147346030592 and https://www.chromestatus.com/feature/5633521622188032.

[dev_mvp] cannot publish data due to date issues

image

I successfully redacted data, saved it, loaded in the publishing tool. When I try and publish, I get an invalid date issue.

It looks like a strange datetime_created value is being sent to the back end:

{"datetime_created":"Fri, 27 Mar 2020 04:32:12 GMT","organization_id":"a88309c2-26cd-4d2b-8923-af0779e423a3","safe_path":{"authority_name":"Fake Organization","concern_points":[{"latitude":12.34,"longitude":12.34,"time":123},{"latitude":12.34,"longitude":12.34,"time":456}],"info_website":"https://www.something.gov/path/to/info/website","publish_date_utc":1584924583},"user_id":"a88309c1-26cd-4d2b-8923-af0779e423a3"}

It looks a lot like hardcoded date above!

Implement API Authentication

Design requirements:

  • Tokens should persist in redux store
  • Need to implement logout button
  • Design flexibly to allow HA to switch out Auth schemes including:
    • Bearer Auth (Priority)
    • OAUTH2
    • LDAP

User case for multiple Contact Tracer inputs

@kylemtowle @penrods

Here is my understanding of the use cases for has_backend false and true cases

has_backend = false

  1. Contact Tracer (CT) receives file from the patient
  2. CT opens Location Scrubber tool
  3. CT clicks "Load" and selects file from dialogue
  4. CT redacts data
  5. CT clicks "Save" and enters filename in dialogue
  6. CT sends file to Health Authority Admin (HAA)
  7. HAA opens Publisher tool
  8. HAA clicks "Load" and selects file from dialogue
  9. HAA reviews data
  10. HAA clicks "Publish" and enters filename in dialogue

has_backend = true AS-IS

  1. Contact Tracer (CT) receives file from the patient
  2. CT opens Location Scrubber tool
  3. CT clicks "Load" and selects file from dialogue
  4. CT redacts data
  5. CT clicks "Save" and data is transmitted to BE
  6. HAA opens Publisher tool
  7. HAA clicks "Load" which loads redacted data
  8. HAA reviews data
  9. HAA clicks "Publish"

Question: What happens at step 6 if there are a dozen contract tracers who all saved data in the BE at the same time? Does s/he open all redacted data? Latest data?

My understanding is that the HAA is an authority figure who reviews the CTs work by approving/disapproving of the publishing of data. Current UI seems to support this use-case in has_backend = false mode since a single CT passes the HAA a single file. Unclear how the UI is supposed to support this in has_backend = true mode.

Here is how I propose we modify the UI for dev_mvp. Please let me know if this sound right to you

has_backend = true TO-BE

  1. Contact Tracer (CT) receives file from the patient
  2. CT opens Location Scrubber tool
  3. CT clicks "Load" and selects file from dialogue
  4. CT redacts data
  5. CT clicks "Save" and data is transmitted to BE
  6. Location scrubber tool spits out an ID number onto the screen
  7. CT shares this ID number to HAA
  8. HAA opens Publisher tool
  9. HAA enters ID number clicks "Load" which loads redacted data associated with ID
  10. HAA reviews data
  11. HAA clicks "Publish"

[dev-mvp]: concern_points are not being passed through POST /safe_paths

Steps to reproduce:

  1. Set backend to true
  2. Load data and save in redaction tool
  3. Load data and save in publishing tool

Expected results:
Data POST /safe_paths contains an array of concern_points

Actual result:
concern_points is not passed

Possible solution:

in saveText(), move the code that creates the concern_points from the code handling no backend to just before the check for the backend. This way both publishing to a backend or file contains the concern_points.

Found in 369a47

The algorithm for identifying travel is too sensitive

I was gardening on a 3m by 3m balcony for an hour and quite a few of the data points are showing as travel, with speeds between 0.1 and 0.3 mph. Can we set a floor for the speed that the algorithm considers as travel?

Note this is on the MASTER branch.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.