ConservationMetrics / guardianconnector-views

A Nuxt.js tool that reads data from a SQL database and renders it on different views (map, gallery, alerts dashboard)
MIT License
3 stars 0 forks source link

Support views for multiple tables #14

Closed rudokemper closed 9 months ago

rudokemper commented 9 months ago

Closes https://github.com/ConservationMetrics/guardianconnector-views/issues/13.

This is a much longer PR than I typically tend to strive for, a byproduct of having worked on this before and after going on leave for a month, and on one occasion, in an offline setting making a large amount of progress at once.

Writ large, I am changing the structure of the app to work with a multi-line config variable NUXT_ENV_VIEWS_CONFIG where multiple tables can be specified, and specific properties (like Mapbox or Filtering) applied to each one individually, rather than across the entire application for all views.

Routes for maps, galleries, and other views are now as follows: /{view_type}/{table_name}. For example, /maps/mapeo_data or /gallery/kobo_submissions.

There is also an index / route now which lists all of the available views per each table.

A few minor documentation changes unrelated to the scope of the PR have snuck their way in here, but I expect that they are not disruptive.

Something unexpected that I ran into is that Docker can't load multi-line config from a .env file. As a workaround, I wrote a small bash script that converts the user's .env file into a Docker-compatible .env.docker file with NUXT_ENV_VIEWS_CONFIG condensed into one line. (This same line can be used to feed application settings in hosting environments like Azure.)

As an upshot of this work, users can now leverage views for multiple tables in their data warehouse, and we can add a new dashboard view for change detection alerts.

rudokemper commented 9 months ago

No need - on this repo, I'm not expecting any code review, but am using PRs to provide an overview on what I'm adding/changing, and if I do have any questions I will ask those specifically and highlight any relevant code. Thanks!