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

GNIP 77 - GetFeatureInfo Templating For GeoNode #6182

Closed
3 of 5 tasks
afabiani opened this issue Jun 9, 2020 · 22 comments
Closed
3 of 5 tasks

GNIP 77 - GetFeatureInfo Templating For GeoNode #6182

afabiani opened this issue Jun 9, 2020 · 22 comments
Assignees
Labels
feature A new feature to be added to the codebase gnip A GeoNodeImprovementProcess Issue
Milestone

Comments

@afabiani
Copy link
Member

afabiani commented Jun 9, 2020

GNIP 77 - GetFeatureInfo Templating For GeoNode

Overview

This proposal aims to improve the way GeoNode injects a “GetFeatureInfo” Template into the maps created with MapStore2.

What is a “GetFeatureInfo” Template and how is it working now?

When “clicking” over a feature of a Layer into a GeoNode Map, an info window popups showing a formatted representation of the raw data identified by the coordinates (see Fig. 1)

image

The way how such information is presented to the user is defined by what we call “GetFeatureInfo Template”. The latter is basically an HTML snippet containing some placeholders and special inline codes that instruct GeoServer on how to generate the raw data output.

The outcome is a rendered HTML snippet with the real values replacing the placeholders of the Template.

Currently, GeoNode allows a very simple mechanism to customize the “GetFeatureInfo Template” of a Layer.

It is possible, through the Layer Metadata Editor Wizard, to assign a name and a label to the attributes we want to display on the GetFeatureInfo output.

Notice that the attributes without a label and name, in case others are present, won’t be rendered at all.

As an instance, by using the example above, we can customize a bit the Layer Metadata as shown in Fig. 2

image

The “GetFeatureInfo” output will change accordingly as shown in Fig. 3

image

Proposed By

@afabiani

Assigned to Release

This proposal is for GeoNode 3.1.

State

  • Under Discussion
  • In Progress
  • Completed
  • Rejected
  • Deferred

Motivation

Current GetFeatureInfo Templates are limited to labels and order. The idea would be to allow GetFeatureInfo to be able to render also images, links, maybe other media in the future, and also to allow the user to customize the HTML template in a fancy way.

Proposal

Implement widget based visualization of attributes for GetFeatureInfo response

  1. Add a new "Widget" column to the Dataset Attributes step of the Metadata Wizard, where "Link" or "Image" widgets can be selected (see Fig. 4).

  2. GeoNode already inflates an HTML template if custom dataset attributes are defined. We need to extend this automatically created template to include HTML fragment to show the selected widget.

This is a simplified approach, which assumes that the specific attribute value is directly usable as a <a href="value"> or a <img src="value">.

In both cases, we assume absolute URLs.

image

Implement custom HTML template for visualization of GetFeatureInfo response

As an alternative to the use of aliases and widgets (see above) for the visualization of GetFeatureInfo response, we implement the option to configure a template as HTML code.

A textarea for the editing of the template will be placed below the table of attributes inside the Dataset Attributes step of the Metadata Wizard

In this case, GeoNode will not generate the GetFeatureInfo template for MapStore itself, rather the custom HTML will be used.

NOTICE: Attributes configurations and HTML templates are mutually exclusive options.

image

Backwards Compatibility

No backward compatibility.

Future evolution

  • Move the template editor on the GIS client in order to make easier the access to the UI.
  • Allow the GetFeatureInfo template to render other media types like videos and sounds.

Feedback

Update this section with relevant feedbacks, if any.

Voting

Project Steering Committee:

  • Alessio Fabiani: +1
  • Francesco Bartoli: +1 (mail in dev list)
  • Giovanni Allegri:
  • Simone Dalmasso:
  • Toni Schoenbuchner: +1
  • Florian Hoedt: +1

Links

Remove unused links below.

@afabiani afabiani added gnip A GeoNodeImprovementProcess Issue feature A new feature to be added to the codebase labels Jun 9, 2020
@afabiani afabiani added this to the 3.1 milestone Jun 9, 2020
@afabiani afabiani self-assigned this Jun 9, 2020
@t-book
Copy link
Contributor

t-book commented Jun 10, 2020

Great Feature.
Imho:

Implement widget based visualization of attributes for GetFeatureInfo response

is more user friendly where

Implement custom HTML template for visualization of GetFeatureInfo response

might suit better for users which can write at least a little HTML code. I'm a bit more in favor for the later but do not have an objective view

@afabiani
Copy link
Member Author

@t-book actually the idea is to implement both.

For the time being, I've implemented something like this:

image

image

image

t-book added a commit to csgis/geonode that referenced this issue Jun 10, 2020
@t-book
Copy link
Contributor

t-book commented Jun 10, 2020

@afabiani Nice even better!

@afabiani
Copy link
Member Author

Added video and audio too

image

@t-book
Copy link
Contributor

t-book commented Jun 10, 2020

@afabiani would it work with an iframe from vimeo or youtube or require the video to be uploaded to the server?

I like the improvement as this adds a further connection between layers and document section. One could upload a PDF or some image and show it with a layer

@giohappy
Copy link
Contributor

@t-book you can put whatever you want inside the HTML template, even completely unrelated to the attributes values :)

@afabiani
Copy link
Member Author

Added an iframe property too

image

it will render something like this

image

Otherwise, you can use the HTML editor

@gannebamm
Copy link
Contributor

This is great!

@gannebamm
Copy link
Contributor

Will these be enabled for the WMS GetFeature Infos, too? Like the GeoServer implementation described here: https://docs.geoserver.org/stable/en/user/tutorials/GetFeatureInfo/index.html

@giohappy
Copy link
Contributor

@gannebamm unfortunately not at this stage. It's in our plans to refactor this side and improve the integration with MapStore's client to align GetFeatureInfo and GetFeature (attributes table) responses.

@t-book
Copy link
Contributor

t-book commented Jun 10, 2020

@giohappy @afabiani As this allows a vast variety of user-added content we should double-check bulletproof server-side validation to prevent xss. The used tiny-mce has two known vulnerabilities, which I, fortunately -even if tampering the request- could not reproduce.

Where I am unsure is if allowing iframe is a good thing at all. You could not stop users to spoil maps with porn or other things. Here are more reasons.

@giohappy
Copy link
Contributor

I agree with you @t-book, I was having the same concerns.
@afabiani I would remove the iframe option from the widgets.
For the free html template I guess we could to a bit of static analysis of the submitted markup, and refuse to save code containing <script> and <iframe> elements. Is it doable @afabiani ?

Regarding the actual contents, it's out of our responsability. They could even store the link of a porn video / image in a vector feature.

@afabiani
Copy link
Member Author

I'll see what we can do, but I agree with @giohappy
This is a server, the responsibility of the setup, contents and security is on users when speaking about contents of course.

@t-book
Copy link
Contributor

t-book commented Jun 10, 2020

thanks to both of you for your answers.

Regarding the actual contents, it's out of our responsability. They could even store the link of a porn video / image in a vector feature.

yes and now as I do think iframes open security issues links do not.

refuse to save code containing <script> and

I think this is already happening. Even after trying hard I could not inject code in my tests.

From other Content management systems, I know a common workaround is to let the admin decide if iframe should be allowed for users or not. If he/she takes the risk it's his/her decision.

Besides, from my tests, this new feature looks very well tailored and is working fine.

@ahmednosman
Copy link

I suggest a different take on this, I would like to suggest the getfeatureinfo template(identify popup template) to apply at the presentation level and not the layer meta data level (so we can have more than one template defined). A user can have multiple presentations (SLDs) for the same layer, for each presentation the user wants a different featureInfo template so a good place to host the featureInfo template will be the layer details page at the editing tools dialog, right next to the metadata, styles, thumbnails..., from here you launch a custom dialog to add/edit popup dialogs for each layer, in this dialog the user can have an multiple choices to create/delete/modify

  1. a featureinfo template derived from a dialog similar to the layer meta data field form
  2. use a form for advanced templating (for advanced users)

Additional features to consider to the template popup

  • URLs, image video, voice, charts, expressions..

@giohappy
Copy link
Contributor

@ahmednosman as mentioned before we have plans to extend the management of layer presets, including those regarding getfeatureinfo and getfeature response. It won't happen very soon but the plans are on our tables and will be shared with the community as soon they're in a good shape.

@achorivai
Copy link

image

right now i try add/show picture and link manually from edit data table with simple <img src=> for show image and <a href=> for the link. I hope there is new update feature for GetFeatureInfo on next Geonode version :) without manual edit.

@afabiani
Copy link
Member Author

The tynimce html editor seems to be able to escape code already

image

image

@gannebamm
Copy link
Contributor

gannebamm commented Jun 11, 2020

@ahmednosman #6182 (comment)

I suggest a different take on this, I would like to suggest the getfeatureinfo template(identify popup template) to apply at the presentation level and not the layer meta data level (so we can have more than one template defined). A user can have multiple presentations (SLDs) for the same layer, for each presentation the user wants a different featureInfo template [...]

This is a good point though. One layer may have several SLDs to actually render the information. We for example have monitoring data with a great number of attributes. These usually get hosted as one layer and displayed with many different SLDs. I would not know how to create one single feature-info to cover them all.

afabiani pushed a commit that referenced this issue Jun 11, 2020
(cherry picked from commit 1703c61)
@t-book
Copy link
Contributor

t-book commented Jun 11, 2020

@afabiani It looks this issue has been accidently closed? I do reopen it.

@t-book t-book reopened this Jun 11, 2020
github-actions bot pushed a commit that referenced this issue Jun 12, 2020
* [Fixes #6182] GNIP 77 - GetFeatureInfo Templating For GeoNode

* - Adding iframe media type

* - Bump django_mapstore_adapter to version 2.0.4

* - Test cases on attributes_config

* - Externalize TINYMCE_DEFAULT_CONFIG on settings.py
afabiani pushed a commit that referenced this issue Jun 12, 2020
afabiani pushed a commit that referenced this issue Jun 15, 2020
…#6188)

* [Fixes #6182] GNIP 77 - GetFeatureInfo Templating For GeoNode

* - Adding iframe media type

* - Bump django_mapstore_adapter to version 2.0.4

* - Test cases on attributes_config

* - Externalize TINYMCE_DEFAULT_CONFIG on settings.py

Co-authored-by: Alessio Fabiani <alessio.fabiani@geo-solutions.it>
afabiani pushed a commit that referenced this issue Jun 15, 2020
 * Some minor improvements

(cherry picked from commit b720ab2)

# Conflicts:
#	geonode/proxy/views.py
@ayushman00sri
Copy link

The outcome is a rendered HTML snippet with the real values replacing the placeholders of the Template.

hello sir ,
I'm not able to find this option (dataset Attributes) . can you pleas suggest me how to find this option, so that I can resole the issue I am facing , while clicking on any point it shows codes instead of the information, here is the screenshot
metadata
error
s

@giohappy
Copy link
Contributor

@ayushman00sri please use the ML or the Gitter channel for requests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature A new feature to be added to the codebase gnip A GeoNodeImprovementProcess Issue
Projects
None yet
Development

No branches or pull requests

7 participants