Giter Club home page Giter Club logo

smartplanter's Introduction

Smart Planter PWA Client

IoT Smart Planter PWA Client

Dependencies

nodejs and npm are required to run webpack to build the JavaScript client in this project. If you do not have node / npm installed you can install it with the following script.

curl -L https://gist.github.com/pdxjohnny/75dee455b7ddb7334b88/raw/9828b128a6d927e9457cd0d92c8b51660a79ffbe/node-user.sh | bash && source ${HOME}/.bashrc

Setup

cd ~/public_html/
git clone [email protected]:pdxjohnny/smartplanter smartplanterdev
cd smartplanterdev
./scripts/setup.sh

The smartplanter app is now accessible at echo https://web.cecs.pdx.edu/~$USER/smartplanter/dist/

VAPID Keys for Push Notifications

These are currently committed to the repo. To re-generate run the create-vapid script.

Keys are only committed to the repo now because storage of them in a secure way would be complex to manage. Under no circumstances should they become publicly available. If this application is to become production ready they must be stored in a secure location and deployment should account for their retrieval at time of application stand up.

./scripts/create-vapid

Favicons

Generated with RealFaviconGenerator

Force HTTPS with htaccess

Put this htaccess file in your public_html folder.

cat > ~/public_html/.htaccess <<'EOF'
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
EOF

API

Create User

Endpoint returns a JSON with user ID and a JWT which should be used in the Authorization header.

curl 'https://web.cecs.pdx.edu/~jsa3/smartplanter/api/createuser/?password=test'
# export TOKEN=`result of token in the above JSON reponse`

Login

curl 'https://web.cecs.pdx.edu/~jsa3/smartplanter/api/login/?id=42&password=test'
# export TOKEN=`result of token in the above JSON reponse`

Create Resource

curl -H "Authorization: Bearer $TOKEN" \
  -d 'Hello World'
  'https://web.cecs.pdx.edu/~jsa3/smartplanter/api/sync/'

Update Resource

curl -X PUT \
  -H "Authorization: Bearer $TOKEN" \
  -d 'Hello World'
  'https://web.cecs.pdx.edu/~jsa3/smartplanter/api/sync/?resource=<created ID>'

Get Resource

curl -H "Authorization: Bearer $TOKEN" \
  'https://web.cecs.pdx.edu/~jsa3/smartplanter/api/sync/?resource=<created ID>'

You should see Hello World

Create Planter

curl -H "Authorization: Bearer $TOKEN" \
  'https://web.cecs.pdx.edu/~jsa3/smartplanter/api/createplanter/'
# export PTOKEN=`result of token in the above JSON reponse`

Update Planter

curl -X PUT \
  -H "Authorization: Bearer $PTOKEN" \
  -d 'Hello World'
  'https://web.cecs.pdx.edu/~jsa3/smartplanter/api/sync/'

Get Planter

curl -H "Authorization: Bearer $PTOKEN" \
  'https://web.cecs.pdx.edu/~jsa3/smartplanter/api/sync/'

TODO

  • Push notifications (WebPush incompatibility with php 7.0 only compatible with 7.1 and above, fork and fix)
  • Offline compatibility (All libs use fetch and the mixed content hack doesn't work with that)
  • UX Improvements, notification of planter received changes
  • Increase bcrypt cost to something secure

smartplanter's People

Contributors

pdxjohnny avatar

Watchers

James Cloos avatar  avatar  avatar

smartplanter's Issues

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.