miketimofeev / e-mission-phone

The frontend (phone) code for the e-mission server

Home Page:https://e-mission.eecs.berkeley.edu

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

e-mission phone app

This is the phone component of the e-mission system.

✨ This has now been upgraded to cordova android@9.0.0 and iOS@6.0.1 (details). It has also been upgraded to android API 29, cordova-lib@10.0.0 and the most recent node and npm versionsIt also now supports CI, so we should not have any build issues in the future. The limitations from the previous upgrade have all been resolved. This should be ready to build out of the box, after all the configuration files are changed.

Additional Documentation

Additional documentation has been moved to its own repository e-mission-docs. Specific e-mission-phone wikis can be found here: https://github.com/e-mission/e-mission-docs/tree/master/docs/e-mission-phone

Issues: Since this repository is part of a larger project, all issues are tracked in the central docs repository. If you have a question, as suggested by the open source guide, please file an issue instead of sending an email. Since issues are public, other contributors can try to answer the question and benefit from the answer.

Updating the UI only

osx-serve-install

If you want to make only UI changes, (as opposed to modifying the existing plugins, adding new plugins, etc), you can use the new and improved (as of June 2018) e-mission dev app.

Installing (one-time)

Run the setup script

$ bash setup/setup_serve.sh

(optional) Configure by changing the files in www/json. Defaults are in www/json/*.sample

$ ls www/json/*.sample
$ cp www/json/startupConfig.json.sample www/json/startupConfig.json
$ cp ..... www/json/connectionConfig.json

Activation (after install, and in every new shell)

$ source setup/activate_serve.sh

Running

  1. Start the phonegap deployment server and note the URL(s) that the server is listening to.

    $ npm run serve
    ....
    [phonegap] listening on 10.0.0.14:3000
    [phonegap] listening on 192.168.162.1:3000
    [phonegap]
    [phonegap] ctrl-c to stop the server
    [phonegap]
    ....
    
  2. Change the devapp connection URL to one of these (e.g. 192.168.162.1:3000) and press "Connect"

  3. The app will now display the version of e-mission app that is in your local directory

  4. The console logs will be displayed back in the server window (prefaced by [console])

  5. Breakpoints can be added by connecting through the browser - Safari (enable develop menu): Develop -> Simulator -> index.html - Chrome: chrome://inspect -> Remote target (emulator)

Ta-da! 🎁 If you change any of the files in the www directory, the app will automatically be re-loaded without manually restarting either the server or the app 🎉

Note1: You may need to scroll up, past all the warnings about Content Security Policy has been added to find the port that the server is listening to.

End to end testing

A lot of the visualizations that we display in the phone client come from the server. In order to do end to end testing, we need to run a local server and connect to it. Instructions for:

  1. installing a local server,
  2. running it,
  3. loading it with test data, and
  4. running analysis on it

are available in the e-mission-server README.

In order to make end to end testing easy, if the local server is started on a HTTP (versus HTTPS port), it is in development mode. By default, the phone app connects to the local server (localhost on iOS, 10.0.2.2 on android) with the prompted-auth authentication method. To connect to a different server, or to use a different authentication method, you need to create a www/json/connectionConfig.json file. More details on configuring authentication can be found in the docs.

One advantage of using skip authentication in development mode is that any user email can be entered without a password. Developers can use one of the emails that they loaded test data for in step (3) above. So if the test data loaded was with -u shankari@eecs.berkeley.edu, then the login email for the phone app would also be shankari@eecs.berkeley.edu.

Updating the e-mission-* plugins or adding new plugins

osx-build-ios osx-ubuntu-build-android

Pre-requisites

  • the version of xcode used by the CI
  • git
  • the most recent version of android studio
    • NOTE: although Catalina has a /usr/bin/java, trying to run it gives the error No Java runtime present, requesting install.. Installed OpenJDK 1.8 using AdoptOpenJDK to be consistent with the CI.

Important

Most of the recent issues encountered have been due to incompatible setup. We have now:

  • locked down the dependencies,
  • created setup and teardown scripts to setup self-contained environments with those dependencies, and
  • CI enabled to validate that they continue work.

If you have setup failures, please compare the configuration in the passing CI builds with your configuration. That is almost certainly the source of the error.

Installing (one time only)

Run the setup script for the platform you want to build

$ bash setup/setup_android_native.sh
AND/OR
$ bash setup/setup_ios_native.sh

(optional) Configure by changing the files in www/json. Defaults are in www/json/*.sample

$ ls www/json/*.sample
$ cp www/json/startupConfig.json.sample www/json/startupConfig.json
$ cp ..... www/json/connectionConfig.json

Activation (after install, and in every new shell)

$ source setup/activate_native.sh

Run in the emulator

$ npx cordova emulate ios
AND/OR
$ npx cordova emulate android

Creating logos

If you are building your own version of the app, you must have your own logo to avoid app store conficts. Updating the logo is very simple using the ionic cordova resources command.

Note: You may have to install the cordova-res package for the command to work

Troubleshooting

  • Make sure to use npx ionic and npx cordova. This is because the setup script installs all the modules locally in a self-contained environment using npm install and not npm install -g
  • Check the CI to see whether there is a known issue
  • Run the commands from the script one by one and see which fails
    • compare the failed command with the CI logs
  • Another workaround is to delete the local environment and recreate it
    • javascript errors: rm -rf node_modules && npm install
    • native code compile errors: rm -rf plugins && rm -rf platforms && npx cordova prepare

Beta-testing debugging

If users run into problems, they have the ability to email logs to the maintainer. These logs are in the form of an sqlite3 database, so they have to be opened using sqlite3. Alternatively, you can export it to a csv with dates using the bin/csv_export_add_date.py script.

<download the log file>
$ mv ~/Downloads/loggerDB /tmp/logger.<issue>
$ pwd
.../e-mission-phone
$ python bin/csv_export_add_date.py /tmp/loggerDB.<issue>
$ less /tmp/loggerDB.<issue>.withdate.log

Contributing

Add the main repo as upstream

$ git remote add upstream https://github.com/covid19database/phone-app.git

Create a new branch (IMPORTANT). Please do not submit pull requests from master

$ git checkout -b mybranch

Make changes to the branch and commit them

$ git commit

Push the changes to your local fork

$ git push origin mybranch

Generate a pull request from the UI

Address my review comments

Once I merge the pull request, pull the changes to your fork and delete the branch

$ git checkout master
$ git pull upstream master
$ git push origin master
$ git branch -d mybranch

About

The frontend (phone) code for the e-mission server

https://e-mission.eecs.berkeley.edu

License:BSD 3-Clause "New" or "Revised" License


Languages

Language:JavaScript 76.8%Language:CSS 13.7%Language:SCSS 6.3%Language:HTML 3.0%Language:Shell 0.1%Language:Python 0.1%