diff --git a/plugins/MapFilter.jsx b/plugins/MapFilter.jsx index b2b5291ae..73969797f 100644 --- a/plugins/MapFilter.jsx +++ b/plugins/MapFilter.jsx @@ -9,6 +9,7 @@ import React from 'react'; import PropTypes from 'prop-types'; import {connect} from 'react-redux'; +import axios from 'axios'; import classNames from 'classnames'; import isEmpty from 'lodash.isempty'; import {v1 as uuidv1} from 'uuid'; @@ -105,7 +106,8 @@ class MapFilter extends React.Component { filters: {}, geomFilter: {}, customFilters: {}, - filterEditor: null + filterEditor: null, + filterInvalid: false }; componentDidUpdate(prevProps, prevState) { if (this.props.theme !== prevProps.theme) { @@ -210,6 +212,27 @@ class MapFilter extends React.Component { } }); this.props.setFilter(layerExpressions, this.state.geomFilter.geom); + // Validate parameters with test request + const themeLayer = this.props.layers.find(layer => layer.role === LayerRole.THEME); + const wmsParams = LayerUtils.buildWMSLayerParams({...themeLayer, filterParams: layerExpressions, filterGeom: this.state.geomFilter.geom}).params; + const wmsLayers = wmsParams.LAYERS.split(","); + const reqParams = { + SERVICE: 'WMS', + REQUEST: 'GetMap', + VERSION: '1.3.0', + CRS: 'EPSG:4326', + WIDTH: 10, + HEIGHT: 10, + BBOX: "-0.5,-0.5,0.5,0.5", + FILTER: wmsParams.FILTER, + FILTER_GEOM: wmsParams.FILTER_GEOM, + LAYERS: Object.keys(layerExpressions).filter(layer => wmsLayers.includes(layer)).join(",") + }; + axios.get(themeLayer.url, {params: reqParams}).then(() => { + this.setState({filterInvalid: false}); + }).catch(() => { + this.setState({filterInvalid: true}); + }); const permalinkState = Object.entries(this.state.filters).reduce((res, [key, value]) => { if (value.active) { return {...res, [key]: value.values}; @@ -264,7 +287,8 @@ class MapFilter extends React.Component { const classes = classNames({ "map-button": true, "map-button-active": taskActive, - "map-button-engaged": filterActive + "map-button-engaged": filterActive && !this.state.filterInvalid, + "filter-map-button-error": filterActive && this.state.filterInvalid }); const title = LocaleUtils.tr("appmenu.items.MapFilter"); button = ( @@ -317,6 +341,7 @@ class MapFilter extends React.Component { return this.renderFilterEditor(); } else { return [ + this.renderInvalidWarning(), ...this.renderPredefinedFilters(), this.props.allowFilterByTime ? this.renderTimeFilter() : null, this.props.allowFilterByGeom ? this.renderGeomFilter() : null, @@ -324,6 +349,16 @@ class MapFilter extends React.Component { ]; } }; + renderInvalidWarning = () => { + if (this.state.filterInvalid) { + return ( +
+
{LocaleUtils.tr("mapfilter.brokenrendering")}
+
+ ); + } + return null; + }; renderFilterEditor = () => { const commitButtons = [ {key: 'Save', icon: 'ok', label: LocaleUtils.trmsg("mapfilter.save"), extraClasses: "button-accept"}, diff --git a/plugins/style/MapFilter.css b/plugins/style/MapFilter.css index 9fae4aded..e3dc346c1 100644 --- a/plugins/style/MapFilter.css +++ b/plugins/style/MapFilter.css @@ -29,6 +29,18 @@ padding: 0.25em; } +#MapFilter div.map-filter-invalid-warning { + background-color: orange; + display: flex; + align-items: center; + padding: 0.25em 0.5em; + margin: 0.25em; +} + +#MapFilter div.map-filter-invalid-warning > div { + margin-left: 0.25em; +} + #MapFilter table.map-filter-entry-fields { border-collapse: collapse; width: 100%; @@ -81,4 +93,9 @@ #MapFilter div.map-filter-editor-invalid { background-color: rgba(255, 127, 127); +} + +button.filter-map-button-error { + background-color: orange; + } \ No newline at end of file diff --git a/translations/ca-ES.json b/translations/ca-ES.json index 1cec55c40..0bd761127 100644 --- a/translations/ca-ES.json +++ b/translations/ca-ES.json @@ -260,6 +260,7 @@ }, "mapfilter": { "addcustomfilter": "", + "brokenrendering": "", "cancel": "", "geomfilter": "", "invalidfilter": "", diff --git a/translations/cs-CZ.json b/translations/cs-CZ.json index 6be9a7f37..5079fb8af 100644 --- a/translations/cs-CZ.json +++ b/translations/cs-CZ.json @@ -260,6 +260,7 @@ }, "mapfilter": { "addcustomfilter": "", + "brokenrendering": "", "cancel": "", "geomfilter": "", "invalidfilter": "", diff --git a/translations/de-CH.json b/translations/de-CH.json index 02c69a913..6cba8f3c0 100644 --- a/translations/de-CH.json +++ b/translations/de-CH.json @@ -260,6 +260,7 @@ }, "mapfilter": { "addcustomfilter": "Benutzerdef. filter hinzufügen", + "brokenrendering": "Die Kartendarstellung könnte aufgrund eines ungültigen Filterausdrucks fehlerhaft sein", "cancel": "Abbrechen", "geomfilter": "Geometrie", "invalidfilter": "Ungültiger Filterausdruck", diff --git a/translations/de-DE.json b/translations/de-DE.json index 0c85972aa..6d0d6bd33 100644 --- a/translations/de-DE.json +++ b/translations/de-DE.json @@ -260,6 +260,7 @@ }, "mapfilter": { "addcustomfilter": "Benutzerdef. filter hinzufügen", + "brokenrendering": "Die Kartendarstellung könnte aufgrund eines ungültigen Filterausdrucks fehlerhaft sein", "cancel": "Abbrechen", "geomfilter": "Geometrie", "invalidfilter": "Ungültiger Filterausdruck", diff --git a/translations/en-US.json b/translations/en-US.json index 947195b7c..c610182ff 100644 --- a/translations/en-US.json +++ b/translations/en-US.json @@ -260,6 +260,7 @@ }, "mapfilter": { "addcustomfilter": "Add custom filter", + "brokenrendering": "Map rendering may be broken due to an invalid filter expression", "cancel": "Cancel", "geomfilter": "Geometry", "invalidfilter": "Invalid filter expression", diff --git a/translations/es-ES.json b/translations/es-ES.json index 0ce47f5aa..4b8b947b1 100644 --- a/translations/es-ES.json +++ b/translations/es-ES.json @@ -260,6 +260,7 @@ }, "mapfilter": { "addcustomfilter": "", + "brokenrendering": "", "cancel": "", "geomfilter": "", "invalidfilter": "", diff --git a/translations/fi-FI.json b/translations/fi-FI.json index 7e60ebfb7..6193ee3cc 100644 --- a/translations/fi-FI.json +++ b/translations/fi-FI.json @@ -260,6 +260,7 @@ }, "mapfilter": { "addcustomfilter": "", + "brokenrendering": "", "cancel": "", "geomfilter": "", "invalidfilter": "", diff --git a/translations/fr-FR.json b/translations/fr-FR.json index d19c13e79..9fc046dca 100644 --- a/translations/fr-FR.json +++ b/translations/fr-FR.json @@ -260,6 +260,7 @@ }, "mapfilter": { "addcustomfilter": "Ajouter filtre personnalisé", + "brokenrendering": "Le rendu de la carte peut être interrompu à cause d'une expression filtre invalide", "cancel": "Annuler", "geomfilter": "Géométrique", "invalidfilter": "Expression de filtre non valide", diff --git a/translations/hu-HU.json b/translations/hu-HU.json index a20c385be..f9a3a5345 100644 --- a/translations/hu-HU.json +++ b/translations/hu-HU.json @@ -260,6 +260,7 @@ }, "mapfilter": { "addcustomfilter": "", + "brokenrendering": "", "cancel": "", "geomfilter": "", "invalidfilter": "", diff --git a/translations/it-IT.json b/translations/it-IT.json index 4a5e0f28a..6936da3f9 100644 --- a/translations/it-IT.json +++ b/translations/it-IT.json @@ -260,6 +260,7 @@ }, "mapfilter": { "addcustomfilter": "Aggiungi filtro personalizzato", + "brokenrendering": "Il rendering della mappa potrebbe essere interrotto a causa di un'espressione filtro invalida", "cancel": "Annulla", "geomfilter": "Geometrico", "invalidfilter": "Espressione filtro non valida", diff --git a/translations/no-NO.json b/translations/no-NO.json index 7f3b89e7a..6d51b3594 100644 --- a/translations/no-NO.json +++ b/translations/no-NO.json @@ -260,6 +260,7 @@ }, "mapfilter": { "addcustomfilter": "", + "brokenrendering": "", "cancel": "", "geomfilter": "", "invalidfilter": "", diff --git a/translations/pl-PL.json b/translations/pl-PL.json index dcfcd719f..486a95116 100644 --- a/translations/pl-PL.json +++ b/translations/pl-PL.json @@ -260,6 +260,7 @@ }, "mapfilter": { "addcustomfilter": "", + "brokenrendering": "", "cancel": "", "geomfilter": "", "invalidfilter": "", diff --git a/translations/pt-BR.json b/translations/pt-BR.json index 441624b3e..cd1980f95 100644 --- a/translations/pt-BR.json +++ b/translations/pt-BR.json @@ -260,6 +260,7 @@ }, "mapfilter": { "addcustomfilter": "", + "brokenrendering": "", "cancel": "", "geomfilter": "", "invalidfilter": "", diff --git a/translations/pt-PT.json b/translations/pt-PT.json index c2f29ec51..742fd3651 100644 --- a/translations/pt-PT.json +++ b/translations/pt-PT.json @@ -260,6 +260,7 @@ }, "mapfilter": { "addcustomfilter": "", + "brokenrendering": "", "cancel": "", "geomfilter": "", "invalidfilter": "", diff --git a/translations/ro-RO.json b/translations/ro-RO.json index da34eeaa5..461cd094b 100644 --- a/translations/ro-RO.json +++ b/translations/ro-RO.json @@ -260,6 +260,7 @@ }, "mapfilter": { "addcustomfilter": "", + "brokenrendering": "", "cancel": "", "geomfilter": "", "invalidfilter": "", diff --git a/translations/ru-RU.json b/translations/ru-RU.json index 508a3e0e4..e47a81c9e 100644 --- a/translations/ru-RU.json +++ b/translations/ru-RU.json @@ -260,6 +260,7 @@ }, "mapfilter": { "addcustomfilter": "", + "brokenrendering": "", "cancel": "", "geomfilter": "", "invalidfilter": "", diff --git a/translations/sv-SE.json b/translations/sv-SE.json index 94412361d..3ad9836bb 100644 --- a/translations/sv-SE.json +++ b/translations/sv-SE.json @@ -260,6 +260,7 @@ }, "mapfilter": { "addcustomfilter": "", + "brokenrendering": "", "cancel": "", "geomfilter": "", "invalidfilter": "", diff --git a/translations/tr-TR.json b/translations/tr-TR.json index 0f5ba2fc8..dfbfa22be 100644 --- a/translations/tr-TR.json +++ b/translations/tr-TR.json @@ -260,6 +260,7 @@ }, "mapfilter": { "addcustomfilter": "", + "brokenrendering": "", "cancel": "", "geomfilter": "", "invalidfilter": "", diff --git a/translations/tsconfig.json b/translations/tsconfig.json index e373908c4..c16f4f3f7 100644 --- a/translations/tsconfig.json +++ b/translations/tsconfig.json @@ -227,6 +227,7 @@ "mapexport.usersize", "mapexport.wait", "mapfilter.addcustomfilter", + "mapfilter.brokenrendering", "mapfilter.cancel", "mapfilter.geomfilter", "mapfilter.invalidfilter",