Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev #7

Merged
merged 94 commits into from
Apr 17, 2023
Merged
Show file tree
Hide file tree
Changes from 80 commits
Commits
Show all changes
94 commits
Select commit Hold shift + click to select a range
6622769
refactor: put all dashboard codes and data under the dashboard folder.
asiripanich Dec 19, 2022
054132c
feat: use e-mission-server as the base image of the dashboard.
asiripanich Dec 20, 2022
04ff895
doc: fix comments
asiripanich Dec 20, 2022
6cf3d74
feat: use Dash's pages and added a collapsible sidebar.
asiripanich Dec 22, 2022
68be7c7
gitignore .DS_Store
asiripanich Dec 22, 2022
ef9442e
feat: add dummy info boxes to the home page. (#1)
asiripanich Dec 30, 2022
4d1a909
feat: add OpenPATH logo to the side bar.
asiripanich Dec 30, 2022
94661fa
patch: remove random texts in the pages.
asiripanich Dec 30, 2022
330ca39
feat: add an app data path and global data modules.
asiripanich Dec 30, 2022
18c9bcf
patch: renamed 'SERVER_PORT' to 'DASH_SERVER_POST'.
asiripanich Dec 30, 2022
70d5716
feat: add the three basic tables to the 'data' page. (#2)
asiripanich Dec 30, 2022
a4b016a
feat: add pylint to requirements.txt.
asiripanich Dec 30, 2022
ed6fb9b
feat(app): save confirmed trips and uuids tables as Stores.
asiripanich Jan 15, 2023
a78b1d8
feat(data): use callbacks to update the tables. (#2)
asiripanich Jan 15, 2023
cad1661
feat(home): Add plots and boxes. (#1)
asiripanich Jan 15, 2023
b51dfba
refactor(data): clean up.
asiripanich Jan 16, 2023
ca8ac39
feat(home): use callbacks to update all figures and cards. (#1)
asiripanich Jan 16, 2023
ae92042
patch: increase the refresh interval to 60 seconds.
asiripanich Jan 16, 2023
fa0980d
Implemented date time picker filter.
AlirezaRa94 Jan 18, 2023
892d9c3
Added create map for a specific user function.
AlirezaRa94 Jan 19, 2023
502cfef
Converted type of user id from binary to string.
AlirezaRa94 Jan 19, 2023
4e927a5
Changed the legend position and refactored the code.
AlirezaRa94 Jan 19, 2023
8c40599
Added necessary fields to trip data for map page.
AlirezaRa94 Jan 22, 2023
873523c
Added the layout of the push notification page.
AlirezaRa94 Jan 24, 2023
d479406
Added global date picker filter.
AlirezaRa94 Jan 25, 2023
b918107
Added log options and dry run push.
AlirezaRa94 Jan 27, 2023
bd532d6
Basic functionality to generate random tokens and QR codes
shankari Jan 27, 2023
cf36118
Added user emails dropdown list to the map page.
AlirezaRa94 Jan 27, 2023
3bf03b3
Merge branch 'add_qrcode_scripts' into token-feat
AlirezaRa94 Jan 27, 2023
ea8585e
Added create user token feature.
AlirezaRa94 Jan 27, 2023
554e1e7
Seperated the tokens page from the data page.
AlirezaRa94 Jan 30, 2023
0f63d2e
Added tokens data table
AlirezaRa94 Jan 30, 2023
947f489
Fixed some minor bugs.
AlirezaRa94 Jan 30, 2023
c0a2152
Changed the QR code path and the image size.
AlirezaRa94 Jan 30, 2023
09d7d30
Added the first draft of the haet map and start and end points of tri…
AlirezaRa94 Jan 31, 2023
024fec3
Added downloading QR codes as a zip file.
AlirezaRa94 Feb 1, 2023
03bbf1f
Merge branch 'dev' into push-page
AlirezaRa94 Feb 1, 2023
54236ae
Merge pull request #12 from e-mission/push-page
AlirezaRa94 Feb 1, 2023
69849d8
Merge pull request #9 from e-mission/token-feat
AlirezaRa94 Feb 1, 2023
ec9c012
Merge pull request #10 from e-mission/map-feat
AlirezaRa94 Feb 1, 2023
fa5f468
chore(docker-compose): bind `opadmindash` folder to the dashboard's v…
asiripanich Feb 1, 2023
6562338
fix: Extract UUIDs as hex. `as_uuid()` method no longer works with th…
asiripanich Feb 1, 2023
2c264ca
Changed hex method to str to extract uuids.
AlirezaRa94 Feb 3, 2023
2be8241
Implemented first version of dynamic config.
AlirezaRa94 Feb 9, 2023
1ddaee2
Fixed problems related to trip and uuid tables.
AlirezaRa94 Feb 14, 2023
148d2fa
Changed the token and push pages permission behavior.
AlirezaRa94 Feb 15, 2023
a73c632
Added study config to environment variables.
AlirezaRa94 Feb 17, 2023
95b6a15
Merge pull request #13 from e-mission/dynamic_config
AlirezaRa94 Feb 22, 2023
80f16be
Implemented Authentication using AWS Cognito.
AlirezaRa94 Feb 28, 2023
3089bc9
Added config-fake file.
AlirezaRa94 Feb 28, 2023
e285a01
Merge pull request #15 from e-mission/authentication
AlirezaRa94 Mar 3, 2023
4cb5512
Added creation of the qrcodes directory to the docker file.
AlirezaRa94 Mar 6, 2023
c09f0ab
Hiding tabs for users with no access.
AlirezaRa94 Mar 6, 2023
0dddd3d
Implemented Dash basic authentication.
AlirezaRa94 Mar 6, 2023
1681195
Added token prefix to tokens.
AlirezaRa94 Mar 6, 2023
3ba50a8
Added tset tokens to tokens.
AlirezaRa94 Mar 6, 2023
bf21494
Merge pull request #17 from e-mission/token_enhancement
AlirezaRa94 Mar 7, 2023
7103f35
Merge pull request #16 from e-mission/basic_auth
AlirezaRa94 Mar 7, 2023
f6a5f7a
Added is loading to the dashboard.
AlirezaRa94 Mar 14, 2023
a62595e
Added tokens table export button.
AlirezaRa94 Mar 14, 2023
1d52e0f
Resolved the conflict.
AlirezaRa94 Mar 14, 2023
cc465c8
Merge pull request #19 from e-mission/hide_no_access
AlirezaRa94 Mar 14, 2023
418d671
Improved some performance related issues.
AlirezaRa94 Mar 15, 2023
d703fa5
Added some comments to the 'config-fake.py' file.
AlirezaRa94 Mar 16, 2023
178c961
Fixed server failing when you don't have AWS cognito credentials.
AlirezaRa94 Mar 16, 2023
bd05f4a
Converted inputs of callbacks to states in the push page.
AlirezaRa94 Mar 16, 2023
238d567
Added dynamic config docs to the readme file.
AlirezaRa94 Mar 17, 2023
318ff0c
Added authentication docs to the readme file.
AlirezaRa94 Mar 17, 2023
ccf0693
Cleaned constants.py file.
AlirezaRa94 Mar 20, 2023
8f44f8f
Fixed map page errors when there is no data.
AlirezaRa94 Mar 20, 2023
b02745b
Added the description for the AUTH_TYPE environment variable.
AlirezaRa94 Mar 20, 2023
dbae8f9
Moved the dynamic config path to the docker-compose.
AlirezaRa94 Mar 20, 2023
f6fac50
Added the description for dynamic config environment variables.
AlirezaRa94 Mar 21, 2023
d6cae38
Merge pull request #22 from e-mission/documentation
AlirezaRa94 Mar 22, 2023
29d9e52
Show try again when there is a problem with authentication.
AlirezaRa94 Mar 22, 2023
4829fbd
Updated Readme file: more description for Cognito data.
AlirezaRa94 Mar 22, 2023
f0a5fe7
Removed unnecessary items from the .gitignore file.
AlirezaRa94 Mar 23, 2023
9c6035a
Added exact versions to all dependencies.
AlirezaRa94 Mar 23, 2023
185e5e9
Some minor changes
AlirezaRa94 Mar 23, 2023
e4c533e
Added production version of docker compose.
AlirezaRa94 Mar 23, 2023
62307f8
Fixed minor problems of docker compose files.
AlirezaRa94 Mar 24, 2023
6f37359
Fixed production docker-compose: added utils directory to the container
AlirezaRa94 Mar 30, 2023
8a3c37d
Added additional trip columns to dynamic config.
AlirezaRa94 Mar 30, 2023
fdd3c5d
Changed dynamic config to the stage-program.
AlirezaRa94 Apr 6, 2023
18c97c0
Convert all files to unix format to make code reviews easier in the f…
shankari Apr 14, 2023
3f58def
Merge pull request #26 from e-mission/fix_crlf
shankari Apr 14, 2023
7808f3e
One more crlf fix
shankari Apr 15, 2023
b7433e8
Merge pull request #27 from e-mission/fix_more_crlf
shankari Apr 15, 2023
712cb98
Check in a simple docker-compose to run the app behind an nginx proxy
shankari Apr 15, 2023
e19dd49
Set the relative path prefix to `/admin/`
shankari Apr 15, 2023
d6cfdd2
Change all the hrefs to relative paths
shankari Apr 15, 2023
ac266f3
Merge pull request #28 from e-mission/support_reverse_proxy
shankari Apr 15, 2023
8bba028
Hack to use the timeseries calls to retrieve the data
shankari Apr 15, 2023
834be13
Merge pull request #30 from e-mission/outline_for_ali_to_fill_in
shankari Apr 15, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
**/*/Dockerfile
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
__pycache__
.idea/
assets/qrcodes
data/tokens.csv
config.py
17 changes: 0 additions & 17 deletions Dockerfile

This file was deleted.

171 changes: 170 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ source myvenv/bin/activate
Install the requirements:

```
pip install -r requirements.txt
pip install -r dashboard/requirements.txt
```

Run the app:
Expand Down Expand Up @@ -67,3 +67,172 @@ To learn more about Dash, please visit [documentation](https://plot.ly/dash).
`docker compose -f docker-compose-dash-app.yml build`

`docker compose -f docker-compose-dash-app.yml up`

# Dynamic Config

## Set Variables

### CONFIG_PATH

The `CONFIG_PATH` environment variable is used to specify the location of the configuration files that are required for
a Docker container to run properly. This means that the Docker container will attempt to download the configuration
files from the specified URL. The current path to the raw format of nrel configs is:

https://raw.githubusercontent.com/e-mission/nrel-openpath-deploy-configs/main/configs/


### STUDY_NAME

The `STUDY_NAME` environment variable is used to specify the name of the study or program that is being run inside the
Docker container. This variable is typically used by the application running inside the container to differentiate
between different studies or programs.

Note that the `STUDY_NAME` variable can be set to any string value, and should be set to a unique value for each
separate study or program.
Comment on lines +91 to +98
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't want to use the STUDY_NAME variable. This is a webapp; it can automatically infer the name from the URL. Having two sources of truth is asking for corner case issues.
Please see #7 (comment)


## User Permissions

The following document outlines the permissions that a user can have within the dashboard application. The permission
is specified as a key-value pair, where the key is the name of the permission and the value is either `true` or `false`.
If the value is `true`, the user has access to the corresponding feature or data, and if the value is `false`, the user
does not have access. You need to place these key-value pairs within the `admin_dashboard` key in one of the configs of
the emission.

These are all the permissions that you can specify:

### Overview Page
- `overview_users`: User can see the total number of users in the Overview page.
- `overview_active_users`: User can see the number of active users in the Overview page.
- `overview_trips`: User can see the number of trips in the Overview page.
- `overview_signup_trends`: User can view the signup trend graph in the Overview page.
- `overview_trips_trend`: User can view the trip trend graph in the Overview page.

### Data Page
- `data_uuids`: User can view the UUIDs data in the Data page.
- `data_trips`: User can view the trips data in the Data page.
- `data_trips_columns_exclude`: It used to specify a list of column names that should be excluded from the trips data
that is displayed on the Data page. It includes valid columns from the **Stage_analysis_timeseries** collection. Valid
columns are specified in the following sections.
- `data_uuids_columns_exclude`: It used to specify a list of column names that should be excluded from the uuids data
that is displayed on the Data page. It includes valid columns from the **Stage_uuids** collection. Valid columns are
specified in the following sections.

### Token Page
- `token_generate`: User can generate new tokens in the Token page.
- `token_prefix`: The prefix that will be added to all tokens when creating new tokens.

### Map Page
- `map_heatmap`: User can view the heatmap in the Map page.
- `map_bubble`: User can view the bubble map in the Map page.
- `map_trip_lines`: User can view the trip lines map in the Map page.

### Push Notification Page
- `push_send`: User can send push notifications in the Push Notification page.

### Dropdown Options
- `options_uuids`: User can see the UUIDs of users in dropdowns and choose between them.
- `options_emails`: User can see the emails of users in dropdowns and choose between them.
<br><br><br>


## Stage_uuids

This document represents a single row in a MongoDB collection. The document contains a single object of a uuid with the
following fields that you can provide in `data_uuids_columns_exlude`:

```python
valid_uuids_columns = [
'user_token',
'user_id',
'update_ts',
]
```


## Stage_analysis_timeseries

It contains information about a segmentation trip. It has the following fields that you can provide in
`data_trips_columns_exclude`.

```python
valid_trip_columns = [
"data.source",
"data.start_ts",
"data.start_local_dt",
"data.start_fmt_tm",
"data.start_place",
"data.start_loc",
"data.end_ts",
"data.end_local_dt",
"data.end_fmt_time",
"data.end_place",
"data.end_loc",
"data.duration",
"data.distance",
"metadata.key",
"metadata.platform",
"metadata.write_ts",
"metadata.time_zone",
"metadata.write_local_dt",
"metadata.write_fmt_time",
"user_id",
]
```


# Authentication

## Specify Authentication Type

The AUTH_TYPE environment variable is used to specify the authentication type for the dashboard, and it is defined in
the Docker Compose file. It has two possible values: "basic" and "cognito". The "basic" option refers to basic
authentication, which is a simple way to authenticate users using a username and password. The "cognito" option refers
to Amazon Cognito, which is a user authentication service that can be used with AWS services.

## `config.py`

The `config.py` file is a Python module that contains configuration settings for an application that uses
authentication. To use this file, first make a copy of the provided `config-fake.py` file and rename it to `config.py`.
Then, fill in the necessary variables with your own valid data.

### CognitoConfig Class

The `CognitoConfig` class contains variables used for authentication when using AWS Cognito. To use this authentication
method, fill in the following variables with your credential data from your AWS Cognito panel in `config.py`:

- `CLIENT_ID`: This is a string that represents the client ID of the app that is registered with the user pool. When an
app wants to authenticate with a user pool, it must provide its client_id to the user pool's authentication server.
- `CLIENT_SECRET`: This is a string that represents the client secret of the app that is registered with the user pool.
The client_secret is a secret key that is used to authenticate the app with the user pool's authentication server. It
must be kept secure and not shared with anyone who should not have access to it.
- `REDIRECT_URL`: This is a string that represents the URL that users should be redirected to after they have
authenticated with the user pool's authentication server.
- `TOKEN_ENDPOINT`: This is a string that represents the endpoint for retrieving access tokens from the user pool's
authentication server. Access tokens are used by the app to access protected resources on behalf of the authenticated
user. It is your user pool's domain plus `/oauth2/token`.
- `USER_POOL_ID`: This is a string that represents the ID of the user pool that the app is registered with. The user
pool is a collection of users who can authenticate with the app.
- `REGION`: This is a string that represents the AWS region where the user pool is located. For example, "us-east-1" or
"eu-west-2".
- `AUTH_URL`: This is a string that represents the URL for initiating authentication requests with the user pool's
authentication server. It is the `Hosted UI` of your user pool.

### VALID_USERNAME_PASSWORD_PAIRS

The `VALID_USERNAME_PASSWORD_PAIRS` dictionary contains all the valid usernames and passwords that users can
authenticate with when using basic authentication. To use this authentication method, fill in the dictionary with your
own valid usernames and passwords in `config.py`.

### Usage

To use the configuration settings defined in `config.py`, import the module at the beginning of your Python script, and
access the variables using dot notation. For example:

```python
from config import CognitoConfig, VALID_USERNAME_PASSWORD_PAIRS

# Access the CLIENT_ID variable in CognitoConfig
client_id = CognitoConfig.CLIENT_ID

# Access the valid username and password pairs
valid_pairs = VALID_USERNAME_PASSWORD_PAIRS
2 changes: 1 addition & 1 deletion app.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@

# For data that lives within the application.
# Set the path to the data directory
DATA_PATH = pathlib.Path(__file__).parent.joinpath("data/").resolve()
DATA_PATH = pathlib.Path(__file__).parent.joinpath("./data/").resolve()

#------------------------------------------------#
# DASH LAYOUT ROOT
Expand Down
Loading