lizmap-web-client icon indicating copy to clipboard operation
lizmap-web-client copied to clipboard

[Bug]: data - table, virtual field with expression to show small image preview

Open josemvm opened this issue 1 year ago • 18 comments

What is the bug? (in English)

this expression here https://docs.lizmap.com/next/en/publish/lizmap_plugin/attribute_table.html#tips stop working on 3.7.7-pre.7395

Steps to reproduce the issue

try to use this expression between 3.7.6 and 3.7.7-pre versions

Versions, safeguards, check summary etc

Versions :

  • Lizmap Web Client : 3.7.7-pre.7395
  • Lizmap plugin : 4.3.5
  • QGIS Desktop : 3.28.15
  • QGIS Server : 3.28.15
  • Py-QGIS-Server : not used
  • QGIS Server plugin atlasprint : 3.3.2
  • QGIS Server plugin lizmap_server : 2.8.6
  • QGIS Server plugin wfsOutputExtension : 1.8.0
List of safeguards :
  • Mode : normal
  • Allow parent folder : no
  • Prevent other drive : no
  • Prevent PG service : no
  • Prevent PG Auth DB : no
  • Force PG user&pass : no
  • Prevent ECW : no

Check Lizmap plugin

  • [X] I have done the step just before in the Lizmap QGIS desktop plugin before opening this ticket. Otherwise, my ticket is not considered valid and might get closed.

Operating system

Ubuntu 22.04

Browsers

Firefox

Browsers version

122.0.1

Relevant log output

No response

josemvm avatar Apr 29 '24 10:04 josemvm

Can you elaborate ? What is is not working ? What is the error in the console ? Any picture ?

Gustry avatar Apr 29 '24 10:04 Gustry

@Gustry the table is not displayd at all on data tool

josemvm avatar Apr 29 '24 11:04 josemvm

Any error message displayed in the console ? (F12)

Gustry avatar Apr 29 '24 11:04 Gustry

no, no errors displayed in the console, just 11:31:07 WARNING Server[15550]: Error parsing post data as XML: at line 1, column 1: error occurred while parsing element. Assuming urlencoded query string sent in the post body. in qgis server log file...

josemvm avatar Apr 29 '24 11:04 josemvm

Please describe your issue @josemvm

this expression here [URL] stop working on 3.7.7-pre.7395

is very vague.

Is the panel empty ? Is the table there but empty (table headers) ? Does it work if you remove the virtual field ? (maybe try to not expose it with WMS/WFS?) Is the button to open the "Attribute table" panel OK ? Is the button to choose the layer to display in the panel OK ? Is-there any error in the console when pressing one of these buttons ? (Check both "console" and "networks" tab) There must be a WFS requests sent to get the data ? Is the content of the request empty or is there an HTTP error code ?

Your first description and title mention that the expression is not working (so I understand only the tip preview is not working, then later you say : "the table is not displayd at all on data tool", so it means nothing is displayed at all ?

Gustry avatar Apr 29 '24 12:04 Gustry

@Gustry sorry

Is the panel empty ? Is the table there but empty (table headers) ?

the panel is not empty, the panel has de name of the table but the table doesn´t appears (no headers)

Does it work if you remove the virtual field ? (maybe try to not expose it with WMS/WFS?)

yes, it works if i remove the virtual field (just expose with WFS)

Is the button to open the "Attribute table" panel OK ? Is the button to choose the layer to display in the panel OK ?

yes

Is-there any error in the console when pressing one of these buttons ? (Check both "console" and "networks" tab) There must be a WFS requests sent to get the data ? Is the content of the request empty or is there an HTTP error code ?

no errors in the console nor in the network inspector this is the request in apache access.log file 127.0.0.1 - - [29/Apr/2024:14:26:00 +0100] "GET /cgi-bin/qgis_mapserv.fcgi?map=%2Fvar%2Fwww%2Fhtml%2Flizmap%5Fweb%5Fclient%2Flizmap%2Finstall%2Fma%2FsigRedesA%2Eqgs&outputformat=XMLSCHEMA&request=describefeaturetype&service=WFS&typename=valvulasCorte&version=1%2E0%2E0&Lizmap%5FUser=xx%5Fxxxxx&Lizmap%5FUser%5FGroups=admins%2C%20giig%2C%20users&Lizmap%5FOverride%5FFilter=1 HTTP/1.1" 200 1742 "-" "3.7.7-pre" 10.27.10.58 - - [29/Apr/2024:14:26:00 +0100] "POST /index.php/lizmap/service HTTP/1.1" 200 1672 "http://xxxxx.xxxxx.xx/index.php/view/map?repository=ma&project=sigRedesA" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:124.0) Gecko/20100101 Firefox/124.0"

josemvm avatar Apr 29 '24 13:04 josemvm

no errors in the console nor in the network inspector

Do you have data inside ? (with the virtual field enabled)

Gustry avatar Apr 29 '24 13:04 Gustry

i have no the request in the console inspector like this if the virtual field is enabled: http://xxxxx.xxxxx.xx/index.php/lizmap/service?repository=ma&project=sigRedesA&REQUEST=GetMap&SERVICE=WMS&VERSION=1.3.0&FORMAT=image%2Fpng&STYLES=1%20-%20s%2F%20Etiquetas&TRANSPARENT=true&LAYERS=bocasIncendio&DPI=96&WIDTH=2080&HEIGHT=537&CRS=EPSG%3A3763&BBOX=-49717.39180027518%2C-116553.26722038354%2C87866.21670027517%2C-81032.88367961647&ts=1714398035229

josemvm avatar Apr 29 '24 13:04 josemvm

Your comment above is a REQUEST=GetMap related to WMS, so not linked to WFS.

When you open the attribute table, all the data is fetched with WFS.

Gustry avatar Apr 30 '24 10:04 Gustry

@Gustry i can provide to you an url for inspector

josemvm avatar Apr 30 '24 11:04 josemvm

Yes, you can, with the virtual field enabled.

Gustry avatar Apr 30 '24 15:04 Gustry

@josemvm I was expecting you to see the request made to QGIS server to fetch the data :

image

And we can see you got data from the server in the web browser :

image

But due to recent PR about security, this Javascript injection has been disabled.

There is still a bug that the table should have been loaded but only the content of the field should have been disabled.

CC @laurentj and @nboisteault

Gustry avatar May 02 '24 09:05 Gustry

the DOMPurify call return a string that can't be handled by JSON.parse function

SyntaxError: JSON.parse: expected ',' or '}' after property value in object at line 1 column 374 of the JSON data Maybe because the content is json formatted and contain escaped " and ' ?

image

PR #4409 to fix it

Another one will fix the thumbnail creation

nworr avatar May 03 '24 14:05 nworr

@nworr many thanks!

josemvm avatar May 03 '24 14:05 josemvm

but... it means that the thumbnail will appear in the table (or not)?

josemvm avatar May 03 '24 14:05 josemvm

yes that's the goal ( onload= are now prohibited, but the expression may be like concat('<img src="foo" data-src=',"virtual_field" , ' class="attrirbute-thumbnal" ') , doc will be updated )

nworr avatar May 03 '24 15:05 nworr

ok, thanks again, i will try ;-)

josemvm avatar May 03 '24 15:05 josemvm

with #4414 the data table will no longer be empty when using HTML tag with attributes in field content (virtual or not)

PR still needed for displaying a thumbnail

nworr avatar May 07 '24 09:05 nworr

Documentation updated and fixed in source code. I'm closing

Gustry avatar May 24 '24 15:05 Gustry