Code Monkey home page Code Monkey logo

dashboard's Introduction

Community Air Quality Dashboard

This project is a collaboration between the Harvey Mudd College Clinic Program and the South Gate Community Environmental Health Action Team (CEHAT). This repository has all the code for the front and back end of a community air quality monitoring dashboard, accessible at https://sg-cehat-air-quality.web.app. All sensor data is gathered using affordable PurpleAir sensors owned by the CEHAT. This website is tailored for the South Gate community, but it can be used as a template for other communities with the appropriate modifications. For more information about creating this website for another community, see CLONING.md. One important feature of the website is its availability in both English and Spanish, which is relevant to the community of South Gate, but other languages can be added with some code changes and by translating the website content into the other desired languages.

Disclaimer

This repository was worked on by students at Harvey Mudd College from August 2020 until May 2021 and will not be maintained afterwards. It is not likely that this project will be expanded, though it is possible if the CEHAT pursues extensions of this work in the future. Since there are no maintainers of the repository, do not attempt to make any changes or submit any pull requests, as they will never be reviewed. If you clone this repository for your own work, note that any major changes to the frameworks used in this project will not be reflected in the code.

Scripts

See SCRIPTS.md for scripts that can be run with this app.

React and Create React App

This project was bootstrapped with Create React App. You can learn more in the Create React App documentation. To learn React, check out the React documentation.

TypeScript

The main programming language used in this project is TypeScript. TypeScript is an object oriented language built on top of JavaScript, adding static type checking at compile time. To learn TypeScript, check out the TypeScript documentation.

Code Style

This repository uses gts (Google's TypeScript style code) for code style. gts enforces TypeScript code style in the repository and allows some formatting issues to be automatically fixed by running npm run fix (see SCRIPTS.md for more information). Under the hood, gts uses ESLint and Prettier. See the linter configuration settings in the prettierrc.js, .eslintignore, .eslintrc.json and tsconfig.json files in the root directory for the front end code and in the functions directory for the back end code.

Database

See DATABASE.md for a description of how the Google Firestore database is structured.

Libaries Used

Chakra UI

Chakra UI is an accessible component library for React applications. All of the front end code in the src directory heavily depends on components from this library. To learn how to use Chakra UI, check out the documentation or the GitHub.

HERE Maps

HERE Maps is a mapping library that is compatible with JavaScript and TypeScript. We use this library for the map of our sensors that appears on the home page of the website. The only files with code dependent on HERE maps are src/components/Map/Map.tsx and public/index.html (where the scripts are included). We use their JavaScript API using an API key.

react-i18next

react-i18next is an internationalization-framework for React and React Native based off of the i18next library. In our project, we use this library to write English (en) and Spanish (es) versions of all text that appears on the site. Our translations are used throughout the front end code in the src directory, but the translations themselves are found in public/locales/. To learn how to use i18next, check out their documentation.

axios

Axios is a promise-based lightweight HTTP client that allows users to make HTTP requests including GET requests and POST requests. This framework is used to communicate with the PurpleAir API in both the front end code in the src directory and in the Cloud Functions code in the functions/src directory. For more information, check out the documentation or the GitHub.

Other Packages

For a complete list of the packages used in this project check out the package.json file for packages used by the front end and the functions/package.json file for packages used by the Cloud Functions.

dashboard's People

Contributors

acgrobman avatar akampen avatar carsonherness avatar dependabot[bot] avatar

Watchers

 avatar

dashboard's Issues

Reduce Firebase reads for AQI calculations

The current implementation means every reading (from every 2 minutes) is read 72 separate times, and there are currently about 650,000 reads per day (well beyond free tier), whereas writes are still within reasonable values. This is expensive and the reads are redundant, so creative database structure can improve this.

Update README from default create-react-app

  • Project description
  • Will not expand disclaimer
  • NPM scripts (front end and functions)
  • Description of major development frameworks and links to documentation (React, TypeScript, Prettier/Eslint/gts)
  • Description of major libraries and links to documentation (Chakra UI, i18next, Firebase, axios...)
  • How to clone (maybe on a separate markdown file?)
    • API Keys (HERE maps, PurpleAir, Firebase)
    • Setting up GitHub (GitHub secrets, continuous deployment, etc.)
    • Setting up Firebase (Firestore, Cloud Functions, Authentication)
    • Setting up initial admin users
    • Local content (static content, HERE maps location, PurpleAir group)
  • Database structure

Hosting

  • Get live dashboard online
  • Determine how to automatically update deployed website with new master branch code

Rename master branch to main

In GitHub

  • From code view, click on branch button (upper left) and then View All Branches.
  • On branch page, click edit on the right side of the master branch (under default)
  • Use pop up to rename master to main

Locally

git branch -m master main
git fetch origin
git branch -u origin/main main

GitHub Actions

Rename all references to master to main in the .github directory

  • deploy.yml
  • node.js.yml

Add AQI block to UI

The representation of the UI for a given sensor (i.e. the dial representation)

Uncaught Errors from async calls to Firebase

Chrome Dev Tools is showing "Uncaught exception" for async calls to Firebase in the front-end code, even though the errors are caught and being handled. This is likely related to how promises are handled, but it is not clear why the current implementation is not working. It could be because the error is being thrown in another call stack, per this documentation.

Converting the async/await in try/catch statements to then/catch statements seems to fix the issue.

Make Selected Sensor Larger on Map

When a sensor is clicked, make it look similar to the hovered sensors (enlarged icon) so that it's more clear what sensor's information you are viewing.

Add 404 Page

Will need to add default page to Routers as well as a component to be displayed

Allow users to update their accounts

This includes

  • Sending a password reset email for a forgotten password
  • Changing a password for a signed in user
  • Changing an email for a signed in user
  • Deleting an account

Combine or remove duplicate sensor reading doc

There are two sensor docs with purpleAirId="39019". One is older, and I believe they are both now being populated with the same readings. The 39019 sensor was likely re-added in November when we added more sensors. Thus, I think once all old data docs are converted to the new format, we can probably just delete the newer collection.

Transition hamburger menu to Chakra IconButton

Chakra has a built in IconButton feature that we should probably be taking advantage of instead of a manual image, but it was not super quick to implement due to icon hiding and sizing. Since it is low-pri, I am going to open this issue as opposed to fixing now.

Store dashboard colors centrally

Right now the colors for the markers and the dial (which are the same) are hard coded in markerStyle.tsx and AQIDial.tsx. We should store these colors in one place, and use them in both files. This should also accommodate the fact that the colors are different with the color blind toggle on.

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.