Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Required Dependencies

...

Admin Web App

Requirements

  • Git version >= 2.0.0

  • NodeJS version >= 10.0.0 < 15.0.0

  • Yarn version == 1.22.x

Installation

  1. Navigate to project root directory

    Code Block
    cd ~/dev/docker-projects/hiv/admin-web-app
  2. Run yarn to install node packages

    Code Block
    yarn install
  3. start your web client

    Code Block
    yarn start

Patient Service

Requirements

...

  • 20.0

  • JDK OpenJDK or Standard Edition version >= 8 (10 is recommended)

  • Configure Android environment variables

    Code Block
    vi ~/.zshrc.local
    # vi ~/.bash_profile

    Add the following lines

    Code Block
    export ANDROID_HOME=$HOME/Android/Sdk
    export PATH=$PATH:$ANDROID_HOME/emulator
    export PATH=$PATH:$ANDROID_HOME/tools
    export PATH=$PATH:$ANDROID_HOME/tools/bin
    export PATH=$PATH:$ANDROID_HOME/platform-tools

    Reload bash configuration (restart your terminal or run below command)

    Code Block
    source ~/.zshrc.local
    # source ~/.bash_profile
  • Configure iOS environment [TODO]

Note: If you previously installed a global react-native-cli, please remove it as it may cause unexpected issues: [sudo] npm remove -g react-native-cli

Development Setup

  1. Clone project to your development workspace

    Code Block
    git clone git@git.web-essentials.asia:hiv-tra-20/

...

  1. patient-app.git ~/dev/docker-projects/hiv/

...

  1. patient-app
  2. Navigate to

...

  1. project root directory

    Code Block
    cd ~/dev/docker-projects/hiv/

...

Verify with your Docker host on the browser.

Configure Keycloak

  • Try login through web browser from Docker with credentials from docker-compose.yml

    If it does not work, copy all content from file docker-compose-dev.yml (expose static port) to replace docker-compose.yml and restart all containers docker-compose up -d

    Re-try login through http://localhost:8080/auth/ with same credentials

  • Import and update Realm Settings

    1. Export Realm from Latest or Demo hi and hi-therapist

    2. Import those two Realm into your local running Keycloak

    3. Update Frontend URL of each Realm Settings to http://local-rehabilitation.wehost.asia/auth or http://localhost:8080/auth/ (depend on which URL you have logged in success)

  • Create default user to generate access token (DO NOT DELETE these users)

    Note: These users should have primary client roles: manager-users, query-groups, and query-users (Client Roles -> realm-management)

    1. Create hi_backend with password hi_backendDBPWD on hi Realm

    2. Create therapist_backend with password therapist_backendDBPWD on therapist Realm

Configure environment variables

Code Block
cp ../admin-service/.env.example ../admin-service/.env
cp ../therapist-service/.env.example ../therapist-service/.env
cp ../patient-service/.env.example ../patient-service/.env

Edit vi ../admin-service/.env by replacing value for KEYCLOAK_BACKEND_SECRET getting from hi Realm -> Clients

Edit vi ../therapist-service/.env by replacing value for KEYCLOAK_BACKEND_SECRET getting from hi-therapist Realm -> Clients

Migrate database tables

Code Block
docker-compose run --rm admin_service php artisan migrate
docker-compose run --rm therapist_service php artisan migrate
docker-compose run --rm patient_service php artisan migrate

Access database via user interface: http://localhost:8060/

Enjoy your development on admin-web-app or therapist-web-app

Useful docker command

...

Manually up docker

Code Block
docker-compose up -d

Manually kill running docker

...

  1. patient-app
  2. Run yarn to install node packages

    Code Block

...

chmod u+x local_setup/setup.sh
./local_setup/setup.sh

Note: Actually, the script is trying to kill all conflict ports but sometimes it could not. So if there are conflict ports, you have to kill it first then rerun the script. Here is the command to kill the port in Linux: sudo kill $(sudo lsof -t -i:PORT_TO_FREE).

  1. yarn install
  2. Configure settings.js

    Code Block
    cp config/ansible/roles/deploy/templates/settings.js.j2 config/settings.js

    Edit file and replace/add value for:

    • isDebugMode = true // or false if you want to disable redux log print out

    • Set patient api URL apiBaseURL: 'http://your-computer-ip:8084/api'

    • Set admin api URL adminApiBaseURL: 'http://your-computer-ip:8082/api'

    • appVersion = '1.0.0-local'

  3. Start JS server with Metro Bundler

    Code Block
    yarn start
  4. Start your local emulator or plug with real mobile device

Android

  1. Configure build.gradle

    Code Block
    cp config/ansible/roles/deploy/templates/build.gradle.j2 android/build.gradle

    Edit file and replace value for:

    • majorApkVersion = 1

    • minorApkVersion = 0

    • patchApkVersion = 0

    • classifierApkVersion = "local"

  2. Start your local emulator or plug with real mobile device

  3. Deploy development app to online testing device(s): adb devices

    Code Block
    yarn android

    Note: if you have problem with missing ndk, please follow this instruction: Install NDK and check required version in file android/build.gradle

Build released app

Android (.apk)

It is an automated build on Jenkins, in which you can find the apk file(s) for each stage via: Download APK

iOS (.ipa)

It is manually built on Mac, in which you can find the ipa file(s) for each stage via: Download IPA

Release Android app to Play Store

Release iOS app to App Store

  • Navigate to

    Code Block
    cd ~/dev/docker-projects/hiv/patient-app/ios
  • Run pod install

    Code Block
    arch -x86_64 pod install
  • Build the app in Xcode

    • Now open project folder in Xcode and then navigate to ios directory and select the file which has extension .xcworkspace.

    • Click on General tab and navigate to identity and update the version.

    • It is time to archive the project so before an archive the project makes sure you have selected Generic iOS device in the top left corner of your window once you have done then navigate to Product → Archive once the app is successfully archived you will automatically get redirected to the Xcode Organizer window.

    • Once the app is successfully archived you will see a list of apps with the version in Xcode Organizer select this app click on the Distribute App.

    • You will see methods of distribution select iOS App Store and click on next.

    • You will see two method Upload or Export as we are going to upload app so select upload and click to next.

    • You will see two more options which are by default selected leave them as it is and click to next.

    • Once you clicked next it will take little time to identify your certificates and after that, you will see little details of your app which we are going to upload on the app store.

    • Now click Upload to upload your app on App Store, and it will take a little time to upload the app on app store. Once the app is an uploaded click on done and now it is time to login to App store.

    • Once your app is uploaded on test flight after that login to your app store account and click My Apps and navigate to Your app → Test Flight and here you will see your app with processing tag.

    • Once the processing is complete then you will see a warning icon like mentioned in image click on this icon and click again on Provide Export Compliance Information.

    • Now a pop up will appear which will ask you about Export Compliance Information in our case we did not have any encryption features so select No and click on Start Internal Testing and the app is going to be available on testing mode. You can test the app with test flight app available on App store and to test this app you need to add testers for this particular app on your App store account after that you can test your app.

Note: Go to config → setting.js and switch settings based on stage release.

Code check styles ESLint

We inherited code styles base from react native community

  • Overall check styles

    Code Block
    yarn lint
  • Check style for specific file

    Code Block
    yarn eslint /path/to/file/HomeTab.js

Useful commands

Android

  • Check connected authorized or unauthorized device(s)

    Code Block
    adb devices
  • Uninstall Android debug app from device(s)

    Code Block
    adb uninstall org.hi.patient