Skip to content

camptocamp/featurereports-backend

Repository files navigation

DREAL Corse Reports

Create GIS features linked reports.

Create a development instance

git clone git@github.com:camptocamp/featurereports-backend.git
cd featurereports-backend
make meacoffee

Admin interface should be available at: http://localhost:8080/admin/

Note that you may need to add some headers (for example using Chrome extension ModHeader) to be able to play with data in the admin interface:

  • sec-username: testadmin
  • sec-roles: ROLE_REPORTS_ADMIN

To access the interface behind the georchestra proxy

  • create a new line in your /etc/hosts :
127.0.1.1 georchestra.mydomain.org
make cert

To display reports you need "read" access on corresponding layer. To create or edit reports you need "write" access on corresponding layer. To create or edit report models you need "admin" access on corresponding layer.

Generate a new alembic revision

Before the first release we will overwrite the first migration:

make regenerate-first-migration

Generate a new alembic migration:

docker-compose run --rm --user `id -u` \
  -v "${PWD}/app/drealcorsereports:/app/drealcorsereports" \
  app \
  alembic -c /app/alembic.ini revision --autogenerate -m 'Description'

Now you can try it:

make initdb

Frontend

Once the composition has started a production build is available at http://localhost:8080/admin/

A development instance can be started at http://localhost:3000 by adding front-server service from docker-compose.override.sample.yaml.

There are make targets for formatting and tests. Other npm tasks (like installing new dependencies) can be executed within the container that is mapped to the host:

docker-compose exec front-server bash

Run formatting:

make front-format

Run tests:

make front-test

Sources can be found in app/drealcorsereports/static/admin

This project was bootstrapped with Create React App

The React CLI allows to indicate the apps origin and a dev proxy to the API via the package.json

"homepage": ".",
"proxy": "http://app:8080",

Layers on which one user can create report models are layers on which he's admin according to rules in https://georchestra.mydomain.org/geoserver/web/wicket/bookmarkable/org.geoserver.security.web.data.DataSecurityPage

The following headers can be handy to access restricted parts of the API in dev via a browser plugin:

"sec-username": "testadmin"
"sec-roles": "ROLE_REPORTS_ADMIN"

MapStore Extension

Developement:

The MapStore extension is developed on the fork: https://github.com/camptocamp/featurereports-mapstoreextension It is developped using our MapStore2 fork as submodule, so to deploy it properly you need to have our custom camptocamp/mapstore2-georchestra image (who also references that fork) in your docker compo. (image is built from https://github.com/camptocamp/mapstore2-georchestra/tree/report-extension-mapstore-changeMapInfoUtils).

There is a debug mode available with: http://localhost:8081/?debug=true.

Redux dev tools are useful for dev as MapStore follows redux.

Note the current issues:

Deployment:

MapStoreExtension developement has not yet been integrated into the project, since the best practices for this are still unclear. To deploy the extension developed in the MapStoreExtension repo into the project the following steps are necessary:

  • run npm run ext:build in MapStoreExtension repo
  • copy MapStoreExtension/dist/ReportExtension.zip into georchestra_datadir/mapstore/dist/extensions/
  • extract ReportExtension.zip and remove zip (replace ReportExtension if exists)

--- or, in https://georchestra.mydomain.org/mapstore/#/admin create a new context in which you import the extension. Even if the context is later deleted, the extension will stay.

Note: MapStore finds the extension bundle via the config in georchestra_datadir/mapstore/extensions.json and loads it by default if indicated in georchestra_datadir/mapstore/localConfig.json.