GithubHelp home page GithubHelp logo

cloudant-labs / location-tracker-nodejs Goto Github PK

View Code? Open in Web Editor NEW
42.0 11.0 40.0 2.33 MB

Demo web application which records a device's location and saves this information to IBM Cloudant

License: Apache License 2.0

HTML 3.69% JavaScript 86.25% CSS 10.06%
ibm-bluemix ibm-cloudant mobile-web geolocation

location-tracker-nodejs's Introduction

Cloudant Location Tracker

The Cloudant Location Tracker is a demo web application which records a device's location and saves this information to IBM Cloudant.

UPDATE June, 2016: We have several sample apps covering location tracking with Cloudant. Use the one that fits your coding needs best. There's a bare-bones couchapp, this one for Angular (version 1)/NodeJS developers, and the latest using Swift/iOS on the client-side with a NodeJS back-end.

Cloning

Get the project and change into the project directory:

$ git clone https://github.com/cloudant-labs/location-tracker-nodejs.git
$ cd location-tracker-nodejs

Configuring IBM Bluemix

Complete these steps first if you have not already:

  1. Install the Cloud Foundry command line interface.
  2. Follow the instructions at the above link to connect to Bluemix.
  3. Follow the instructions at the above link to log in to Bluemix.

Create a Cloudant service within Bluemix if one has not already been created:

$ cf create-service cloudantNoSQLDB Lite cloudant-location-tracker-db

Configuring Local Development

Local configuration is done through a .env file. One environment variable, VCAP_SERVICES, is needed in order to configure your local development environment. The value of the VCAP_SERVICES is a string representation of a JSON object. Here is an example .env file:

VCAP_SERVICES={"cloudantNoSQLDB": [{"name": "cloudant-location-tracker-db","label": "cloudantNoSQLDB","plan": "Shared","credentials": {"username": "your-username","password": "your-password","host": "your-host","port": 443,"url": "https://your-username:your-password@your-host"}}]}

Note: Services created within Bluemix are automatically added to the VCAP_SERVICES environment variable. Therefore, no configuration is needed for Bluemix.

Installing

Install the project's dependencies and initialize the database:

$ npm install

Running

  1. Run the project through Foreman:

     $ foreman start
    
  2. Authenticate by clicking the sign up link. Iif this is your first time logging in, enter your email address and a password. If not, click the "Go Sign In" link.

  3. Track locations by simply doing nothing or moving around by foot, bike or vehicle. Location data is saved in your browser in a PouchDB database.

  4. Persist the data to the cloud by clicking "Stop & Save Location Data". Everything is saved to the Cloudant database you created earlier, with your username included in each location reading.

Deploying

To deploy to Bluemix, simply:

$ cf push

Note: You may notice that Bluemix assigns a URL to your app containing a random word. This is defined in the manifest.yml file. The host key in this file contains the value cloudant-location-tracker-${random-word}. The random word is there to ensure that multiple people deploying the Location Tracker application to Bluemix do not run into naming collisions. However, this will cause a new route to be created for your application each time you deploy to Bluemix. To prevent this from happening, replace ${random-word} with a hard coded (but unique) value.

Privacy Notice

The Location Tracker sample web application includes code to track deployments to IBM Bluemix and other Cloud Foundry platforms. The following information is sent to a Deployment Tracker service on each deployment:

  • Application Name (application_name)
  • Space ID (space_id)
  • Application Version (application_version)
  • Application URIs (application_uris)

This data is collected from the VCAP_APPLICATION environment variable in IBM Bluemix and other Cloud Foundry platforms. This data is used by IBM to track metrics around deployments of sample applications to IBM Bluemix to measure the usefulness of our examples, so that we can continuously improve the content we offer to you. Only deployments of sample applications that include code to ping the Deployment Tracker service will be tracked.

Disabling Deployment Tracking

Deployment tracking can be disabled by removing ./admin.js track && from the install script line of the scripts section within package.json.

License

Licensed under the Apache License, Version 2.0.

location-tracker-nodejs's People

Contributors

bradley-holt avatar jessmantaro avatar rajrsingh avatar seanbarclay avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  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

location-tracker-nodejs's Issues

CouchDB to Cloudant Security Model Mapper as npm Package

Consider creating an npm package that maps the CouchDB security model to the Cloudant security model. This package would replace the code in this application which maps the requests from PouchDB Authentication in the frontend to Cloudant on the backend.

`npm install` Fails Inititially

Running npm install fails when first run as there is no database configured yet. Either make this fail more gracefully or update the README and tutorial accordingly.

Consistent User Colors

Use a consistent color for a user and that user's path throughout. This can be done via a hash of the username.

The "globe" is scrollable

The div containing the spinning globe (class="globe-mask") is scrollable. Please can be make it not scrollable?

following README instructions, npm install doesn't work

Here's the full error message:

[email protected] prepublish /Users/rajrsingh/workspace/locationtracker/location-tracker-nodejs
./admin.js db put && ./admin.js api set_permissions

Error creating location tracker database
Error creating users database

/Users/rajrsingh/workspace/locationtracker/location-tracker-nodejs/node_modules/cloudant/cloudant.js:93
throw new Error('set_permissions requires an "password" parameter during i
^
Error: set_permissions requires an "password" parameter during initialization
at Object.set_permissions (/Users/rajrsingh/workspace/locationtracker/location-tracker-nodejs/node_modules/cloudant/cloudant.js:93:11)
at Command. (/Users/rajrsingh/workspace/locationtracker/location-tracker-nodejs/admin.js:162:18)
at Command.listener (/Users/rajrsingh/workspace/locationtracker/location-tracker-nodejs/node_modules/commander/index.js:301:8)
at Command.emit (events.js:98:17)
at Command.parseArgs (/Users/rajrsingh/workspace/locationtracker/location-tracker-nodejs/node_modules/commander/index.js:610:12)
at Command.parse (/Users/rajrsingh/workspace/locationtracker/location-tracker-nodejs/node_modules/commander/index.js:458:21)
at Object. (/Users/rajrsingh/workspace/locationtracker/location-tracker-nodejs/admin.js:182:9)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)

npm ERR! Darwin 14.3.0
npm ERR! argv "node" "/usr/local/bin/npm" "install"
npm ERR! node v0.10.33
npm ERR! npm v2.1.12
npm ERR! code ELIFECYCLE
npm ERR! [email protected] prepublish: ./admin.js db put && ./admin.js api set_permissions
npm ERR! Exit status 8
npm ERR!
npm ERR! Failed at the [email protected] prepublish script './admin.js db put && ./admin.js api set_permissions'.
npm ERR! This is most likely a problem with the cloudant-location-tracker package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! ./admin.js db put && ./admin.js api set_permissions
npm ERR! You can get their info via:
npm ERR! npm owner ls cloudant-location-tracker
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR! /Users/rajrsingh/workspace/locationtracker/location-tracker-nodejs/npm-debug.log

Location Tracker Part 2 and Part 3 document issues

1)In the document:
"All the code for this tutorial can be forked from GitHub from this repository".
click "this repository." and point to a wrong web page.(part 1 location).
2)After download the locationtracker-angular. Got the error when you run the application:
POST ERROR:{"status":500,"name":"error","message":"VersionError"}.
The PouchDB version need to be changed in index.html as below:

<script src="//cdn.jsdelivr.net/pouchdb/3.3.0/pouchdb.min.js"></script>
  1. The document does not have a Windows environment setting.
  2. The commands: "npm install" and "note admin.js db put" do not work. Any steps is missing?
  3. The document for finding the "Show Credentials" way that can not find a Credentials.

API KEY PERMISSIONS not setting on database

I have been testing this repo since six weeks ago, during that time i created a couple of bluemix account,
the first one i created 6 weeks ago had until my trial ended a functioning copy of this repository i deployed from the tutorial "deploy to bluemix" button. After that the accounts i created 2 or 3 weeks ago did not have the same luck, the deployment was successful but the web app did not work correctly, the documents with the locations was not uploading the docs to cloudant and the error page appeared. I checked and encounter that the problem relates to the api keys created on the module.exports.putUser on https://github.com/cloudant-labs/location-tracker-nodejs/blob/master/routes/api.js, they are created and some how it execute this on line 33:

usersDb.insert(user, user._id, function(err, body) {
if (!err) {
res.status(201).json({
ok: true,
id: user._id,
rev: body.rev
});

But the code line 22 that sets the permissions for the api key on the database:

"cloudantService.set_permissions({database:'location-tracker', username:api.key, roles:['_reader', '_writer']}, function(err, result) {..."

Does not what is supposed to do as you can see on the images below.

captura de pantalla 2015-07-17 a las 18 36 55
captura de pantalla 2015-07-17 a las 18 37 17

Credentials

We need to make it obvious in the README.md to inform people where to add usernames and password.

Also, a quick note on how to create API keys for the angular part.

Add .cfignore

Clone the .gitignore to create a cfignore file. It improves code pushes to bluemix using the cf6 cli tool.

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.