This repository contains the dashboard component of the CCIS system, along with the dashboard's database. For a complete deployment including a webserver, an ODK-X sync endpoint, and ODK-X authentication server, see one of the server setup repositories:
It is recommended to use the dashboard on Chrome/Chromium. We also test on Edge, with experimental support for Firefox and Safari.
Supported browsers:
- Chrome/Chromium 84+ (tested on 99.0.4844.74-1)
- Edge 84+ (tested on 99.0.1150.39)
Experimental support:
- Firefox 63+ (tested on 98.0-2)
- Safari 13+ (tested on 13.1 and 15.3)
- Install Docker and git
- Clone this repository and
cd
into it - Get a Mapbox token
- Setup your
.env
file (instructions below) - Build the dashboard's database
docker build -t ccis/dashboard-database docker-database/ -f docker-database/deploymentDB/Dockerfile
- Build the dashboard docker container (this uses the
MAPBOX_API_TOKEN
environment variable)
docker build -t ccis/dashboard .
- Start the database, providing an admin password of your choice
docker run -p 5432:5432 -e POSTGRES_PASSWORD=ReplaceMe -e POSTGRES_DB=coldchain ccis/dashboard-database
- Start the application, replacing
80
with the port where the application should be available
docker run -p 80:8000 ccis/dashboard
- Application should now be available from outside the docker container at
localhost:80
. Setup a webserver (e.g. nginx) to expose the application to the internet and run with https
To use the Mapbox API, you must have an API key. The API key is used as an identifier for billing purposes. To create a Mabox API Key, first make a Mapbox account, then generate a new one or use your default public token.
Once the key is created, place it in a .env
file as specified below.
Create a file named .env
in the top level, and fill in the following fields
for your deployment.
DB_SERVER=
DB_NAME=
DB_USER=
DB_PASS=
DB_SSL=
MAPBOX_API_TOKEN=
COOKIE_KEY=
ODKX_AUTH_URL=
ODKX_TEST_USER=
ODKX_TEST_PASSWORD=
DB_SERVER
is the URL of a Postgres server. Uselocalhost
to connect to a local dockerized databaseDB_NAME
is the name of a database on that server. Usecoldchain
if using thedeploymentDB
databaseDB_USER
andDB_PASS
are the login credentials for a (read-only) user on that database. Usedashboard
andEnsureFirewallConfigured
with thedeploymentDB
databaseDB_SSL
is an optional boolean which should be left out when connecting to a local database. To connect to a remote database server,DB_SSL=true
may be requiredMAPBOX_API_TOKEN
is the token generated above. This is the only environment variable needed at build timeCOOKIE_KEY
should be newly-generated, a strong random secret which is used to encrypt authentication detailsODKX_AUTH_URL
is the URL of an ODK-X sync endpointODKX_TEST_USER
andODKX_TEST_PASSWORD
are only required for testing. These are credentials for a user on that ODK-X server
For a new deployment, update the files in the config
folder with your GeoJSON for geographic boundaries, intended visualizations, and tab structure.
Additional documentation in the docs/
folder describes how to use these config files.
visualizations.md
describes the format of thevisualizations.js
config filegeographicBoundaries.md
describes the format of thegeographicBoundaries.js
config filetabVisualizations.md
describes the format of thetabVisualizations.js
config file
The config files are also checked at runtime by the code in src/util/configSchemas.js
.
Install node.js, which will come with the npm
command.
Clone the repository and cd
into it. Set up your .env
file.
From there run:
npm install
npm run build
npm start
The dashboard will be available at localhost:8000
You can log in to the dashboard using any user from the connected ODK-X server.
To exit, type Ctrl+C
in the terminal
The dashboard has a suite of tests in the __tests__
folder. Some of these run
in the Firefox browser, and some of them use a local test database configured
with Docker. To run the tests, you'll need to install these dependencies.
- Confirm that you have a
.env
file in the top level of the project. - Install docker (this is used by the
pretest
step to run a local PostgreSQL server) - Install docker-compose if not installed by step 1
- Install firefox
- From the directory of this repository, run
npm install
- Run
npm test
. Runnpm run linux-test
if permission issues occur.
To run a single test file:
- Run
sudo docker-compose up
, or justdocker-compose up
depending on your user permissions. This starts a local PostgreSQL server. Note: you must only have one local SQL server running at a time. This step is only necessary for some test files; if your tests pass without it, it is not necessary. - Run
npx jest __tests__/<name of test file>
(thenpx
command is part of npm, and jest is the test environment we use)
There are a few changes to run the tests on Windows:
- Confirm that you have a
.env
file in the top level of the project. - Install docker (this is used by the
pretest
step to run a local PostgreSQL server) - Install docker-compose if not installed by step 1
- Install firefox developer edition
- Download the latest geckodriver release and extract the folder. Add the folder to your PATH through these steps. Open a new PowerShell window and run "geckodriver" to confirm it has been installed.
- From the directory of this repository in a PowerShell window, run
npm install
- Run
npm test
in the same PowerShell window.
Steps to run a single test file remain the same.
Notes:
- If you run into an issue with your BIOS on Windows, check out this SO post
- Some tests may inconsistently pass due to timeout errors. Run the tests individually for clarity.
See CONTRIBUTING.md
for a detailed summary of how to contribute good code to this project.
Information on the code review process is described in docs/codeReview.md
, and information on the release process is in docs/releases.md
.
Some notes to support end users of the dashboard are included in docs/END_USER_DOCUMENTATION.md
The dashboard architecture is described in more detail in docs/architecture.md
The following dependency graphs describe the internal structure of the files here--it's gotten a little complicated.
The server-side:
The client-side:
To update these images, make sure you have graphviz installed (we need the dot
command) and run npm run dependency-graph