Skip to content

Commit

Permalink
Merge pull request #354 from Terralego/add-measure-control-to-config
Browse files Browse the repository at this point in the history
Add measure control to constance config
  • Loading branch information
submarcos authored Sep 12, 2023
2 parents e08bb84 + 241fcd7 commit 2ca4601
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 0 deletions.
8 changes: 8 additions & 0 deletions docs/source/others/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@ Changelog
==========


XXXX.X.X (XXXX-XX-XX)
---------------------------

**New features:**

- Add distance measurement map control (draw on the map and return the distance measured of the drawing)


2023.8.3 (2023-08-29)
---------------------------

Expand Down
13 changes: 13 additions & 0 deletions project/settings/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,7 @@
"django.forms.CharField",
{"widget": "tinymce.widgets.TinyMCE", "required": False},
],
"json_field": ["django.forms.JSONField", {"required": False}],
}
CONSTANCE_CONFIG = {
"INSTANCE_TITLE": ("TerraVisu", _("Instance title"), str),
Expand Down Expand Up @@ -289,6 +290,16 @@
_("Content of info tab in frontend"),
"tinymce_field",
),
"MEASURE_CONTROL": (
False,
_("Activate MapboxDraw Control to measure distance on the map"),
bool,
),
"MEASURE_DRAW_STYLES": (
[],
_("Define custom MapboxDraw style for the distance measure control"),
"json_field",
),
}

CONSTANCE_CONFIG_FIELDSETS = {
Expand Down Expand Up @@ -330,6 +341,8 @@
"VIEW_ROOT_PATH",
"OPENID_SSO_LOGIN_BUTTON_TEXT",
"OPENID_DEFAULT_LOGIN_BUTTON_TEXT",
"MEASURE_CONTROL",
"MEASURE_DRAW_STYLES",
),
"collapse": True,
},
Expand Down
6 changes: 6 additions & 0 deletions project/visu/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,12 @@ def get(self, request, *args, **kwargs):
"user": user,
"token": token,
"ssoAuth": self.get_sso_auth_config(),
"frontendTools": {
"measureControl": {
"enable": config.MEASURE_CONTROL,
"styles": config.MEASURE_DRAW_STYLES,
},
},
}
)

Expand Down
12 changes: 12 additions & 0 deletions project/visu/tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ def test_default_values(self):
{
"allowUserRegistration": False,
"credits": "Source: TerraVisu",
"frontendTools": {
"measureControl": {
"enable": False,
"styles": [],
},
},
"ssoAuth": {},
"extraMenuItems": [],
"favicon": "http://testserver/static_dj/img/favicon.ico",
Expand Down Expand Up @@ -80,6 +86,12 @@ def test_custom(self):
"allowUserRegistration": False,
"credits": "My Credits",
"extraMenuItems": [],
"frontendTools": {
"measureControl": {
"enable": False,
"styles": [],
},
},
"ssoAuth": {
"defaultButtonText": "Login via internal",
"loginUrl": "/api/auth/login/",
Expand Down

0 comments on commit 2ca4601

Please sign in to comment.