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

#8545 LayerDownload: service selector #8607

Merged
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions web/client/actions/layerdownload.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export const DOWNLOAD_OPTIONS_CHANGE = "LAYERDOWNLOAD:FORMAT_SELECTED";
export const CLEAR_DOWNLOAD_OPTIONS = "LAYERDOWNLOAD:CLEAR_DOWNLOAD_OPTIONS";
export const FORMAT_OPTIONS_FETCH = "LAYERDOWNLOAD:FORMAT_FETCH";
export const FORMAT_OPTIONS_UPDATE = "LAYERDOWNLOAD:FORMAT_UPDATE";
export const SET_WPS_AVAILABILITY = "LAYERDOWNLOAD:SET_WPS_AVAILABLE";
export const SET_SERVICE = "LAYERDOWNLOAD:SET_SERVICE";
export const SET_EXPORT_DATA_RESULTS = "LAYERDOWNLOAD:SET_EXPORT_DATA_RESULTS";
export const ADD_EXPORT_DATA_RESULT = "LAYERDOWNLOAD:ADD_EXPORT_DATA_RESULT";
Expand All @@ -33,9 +34,10 @@ export const SET_INFO_BUBBLE_MESSAGE = "LAYERDOWNLOAD:SET_INFO_BUBBLE_MESSAGE";
* @name layerdownload
* @type {Object}
*/
export const checkWPSAvailability = (url) => ({
export const checkWPSAvailability = (url, selectedService) => ({
type: CHECK_WPS_AVAILABILITY,
url
url,
selectedService
});
export const checkingWPSAvailability = (checking) => ({
type: CHECKING_WPS_AVAILABILITY,
Expand Down Expand Up @@ -104,6 +106,11 @@ export const onDownloadFinished = () => ({
type: DOWNLOAD_FINISHED
});

export const setWPSAvailability = (value) => ({
type: SET_WPS_AVAILABILITY,
value
});

/**
* set service to use for layer download(wfs or wps)
* @memberof actions.layerdownload
Expand Down
12 changes: 11 additions & 1 deletion web/client/components/data/download/DownloadDialog.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,15 @@ class DownloadDialog extends React.Component {
filterObj: PropTypes.object,
closeGlyph: PropTypes.string,
url: PropTypes.string,
wpsAvailable: PropTypes.bool,
service: PropTypes.string,
enabled: PropTypes.bool,
loading: PropTypes.bool,
checkingWPSAvailability: PropTypes.bool,
onClose: PropTypes.func,
onExport: PropTypes.func,
onCheckWPSAvailability: PropTypes.func,
setService: PropTypes.func,
onDownloadOptionChange: PropTypes.func,
onClearDownloadOptions: PropTypes.func,
onFormatOptionsFetch: PropTypes.func,
Expand All @@ -53,12 +55,14 @@ class DownloadDialog extends React.Component {
onExport: () => {},
onClose: () => {},
onCheckWPSAvailability: () => {},
setService: () => {},
onDownloadOptionChange: () => {},
onClearDownloadOptions: () => {},
onFormatOptionsFetch: () => {},
checkingWPSAvailability: false,
layer: {},
closeGlyph: "1-close",
wpsAvailable: false,
service: 'wfs',
wfsFormats: [],
formats: [
Expand All @@ -85,7 +89,10 @@ class DownloadDialog extends React.Component {
if (this.props.enabled !== oldProps.enabled && this.props.enabled) {
this.props.onClearDownloadOptions();
if (this.props.layer.type === 'wms') {
this.props.onCheckWPSAvailability(this.props.url || this.props.layer.url);
this.props.onCheckWPSAvailability(
this.props.url || this.props.layer.url,
this.props.defaultSelectedService || 'wps'
Copy link
Contributor

@allyoucanmap allyoucanmap Sep 29, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add defaultSelectedService to propTypes and the default value wps in defaultProps

);
}
}
}
Expand Down Expand Up @@ -119,7 +126,10 @@ class DownloadDialog extends React.Component {
this.props.service === 'wfs' && !this.props.layer.search?.url ?
<EmptyView title={<Message msgId="layerdownload.noSupportedServiceFound"/>}/> :
<DownloadOptions
wpsAvailable={this.props.wpsAvailable}
service={this.props.service}
downloadOptions={this.props.downloadOptions}
setService={this.props.setService}
onChange={this.props.onDownloadOptionChange}
formatOptionsFetch={this.props.service === 'wfs' ? this.props.onFormatOptionsFetch : () => {}}
formatsLoading={this.props.formatsLoading}
Expand Down
28 changes: 26 additions & 2 deletions web/client/components/data/download/DownloadOptions.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,31 +26,45 @@ import DownloadWPSOptions from './DownloadWPSOptions';
*/
class DownloadOptions extends React.Component {
static propTypes = {
wpsAvailable: PropTypes.bool,
service: PropTypes.string,
downloadOptions: PropTypes.object,
formatOptionsFetch: PropTypes.func,
formats: PropTypes.array,
srsList: PropTypes.array,
setService: PropTypes.func,
onChange: PropTypes.func,
defaultSrs: PropTypes.string,
wpsOptionsVisible: PropTypes.bool,
wpsAdvancedOptionsVisible: PropTypes.bool,
downloadFilteredVisible: PropTypes.bool,
layer: PropTypes.object,
formatsLoading: PropTypes.bool,
virtualScroll: PropTypes.bool
virtualScroll: PropTypes.bool,
services: PropTypes.arrayOf(PropTypes.object)
};

static defaultProps = {
wpsAvailable: false,
service: 'wps',
downloadOptions: {},
formatsLoading: false,
formats: [],
srsList: [],
wpsOptionsVisible: false,
wpsAdvancedOptionsVisible: false,
downloadFilteredVisible: false,
virtualScroll: true
virtualScroll: true,
services: [
{ value: "wps", label: "WPS" },
{ value: "wfs", label: "WFS" }
]
};

constructor(props) {
super(props);
}

getSelectedFormat = () => {
return get(this.props, "downloadOptions.selectedFormat");
};
Expand All @@ -60,6 +74,16 @@ class DownloadOptions extends React.Component {

render() {
return (<form>
{this.props.wpsAvailable &&
<>
<label><Message msgId="layerdownload.service" /></label>
<Select
clearable={false}
value={this.props.service}
onChange={(sel) => this.props.setService(sel.value)}
options={this.props.services} />
</>
}
<label><Message msgId="layerdownload.format" /></label>
<Select
clearable={false}
Expand Down
7 changes: 6 additions & 1 deletion web/client/configs/localConfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,12 @@
}
}
}, "Home", "FeatureEditor",
"LayerDownload",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please restore "LayerDownload" config because by default is already "wps"

{
"name": "LayerDownload",
"cfg": {
"defaultSelectedService": "wps"
}
},
{
"name": "QueryPanel",
"cfg": {
Expand Down
11 changes: 7 additions & 4 deletions web/client/epics/layerdownload.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ import {
serializeCookie,
addExportDataResult,
updateExportDataResult,
showInfoBubbleMessage
showInfoBubbleMessage,
setWPSAvailability
} from '../actions/layerdownload';
import { TOGGLE_CONTROL, toggleControl } from '../actions/controls';
import { DOWNLOAD } from '../actions/layers';
Expand Down Expand Up @@ -199,20 +200,22 @@ const str2bytes = (str) => {
*/
export const checkWPSAvailabilityEpic = (action$) => action$
.ofType(CHECK_WPS_AVAILABILITY)
.switchMap(({url}) => {
.switchMap(({url, selectedService}) => {
return describeProcess(url, 'gs:DownloadEstimator,gs:Download')
.switchMap(response => Rx.Observable.defer(() => new Promise((resolve, reject) => parseString(response.data, {tagNameProcessors: [stripPrefix]}, (err, res) => err ? reject(err) : resolve(res)))))
.flatMap(xmlObj => {
const ids = [
xmlObj?.ProcessDescriptions?.ProcessDescription?.[0]?.Identifier?.[0],
xmlObj?.ProcessDescriptions?.ProcessDescription?.[1]?.Identifier?.[0]
];
const isWpsAvailable = findIndex(ids, x => x === 'gs:DownloadEstimator') > -1 && findIndex(ids, x => x === 'gs:Download') > -1;
return Rx.Observable.of(
setService(findIndex(ids, x => x === 'gs:DownloadEstimator') > -1 && findIndex(ids, x => x === 'gs:Download') > -1 ? 'wps' : 'wfs'),
setService(isWpsAvailable ? selectedService || 'wps' : 'wfs'),
setWPSAvailability(isWpsAvailable),
checkingWPSAvailability(false)
);
})
.catch(() => Rx.Observable.of(setService('wfs'), checkingWPSAvailability(false)))
.catch(() => Rx.Observable.of(setService('wfs'), setWPSAvailability(false), checkingWPSAvailability(false)))
.startWith(checkingWPSAvailability(true));
});
export const openDownloadTool = (action$) =>
Expand Down
10 changes: 8 additions & 2 deletions web/client/plugins/LayerDownload.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { createStructuredSelector } from 'reselect';
import {
downloadFeatures,
checkWPSAvailability,
setService,
onDownloadOptionChange,
onFormatOptionsFetch,
clearDownloadOptions,
Expand All @@ -26,6 +27,7 @@ import {
loadingSelector,
wfsFormatsSelector,
formatsLoadingSelector,
wpsAvailableSelector,
serviceSelector,
checkingWPSAvailabilitySelector,
wfsFilterSelector,
Expand Down Expand Up @@ -58,6 +60,7 @@ import { createPlugin } from '../utils/PluginsUtils';
* @prop {object[]} srsList An array of name-label objects for the allowed srs available. Use name:'native' to omit srsName param in wfs filter
* @prop {string} defaultSrs Default selected srs
* @prop {string} closeGlyph The icon to use for close the dialog
* @prop {string} defaultSelectedService The service that should be used by default for donwloading. Valid values: "wfs", "wps"
* @example
* {
* "name": "LayerDownload",
Expand All @@ -69,11 +72,12 @@ import { createPlugin } from '../utils/PluginsUtils';
* {"name": "excel2007", "label": "excel2007"},
* {"name": "dxf-zip", "label": "dxf-zip"}
* ],
* "srsList": [
* "srsList": [
* {"name": "native", "label": "Native"},
* {"name": "EPSG:4326", "label": "WGS84"}
* ],
* "defaultSrs": "native"
* "defaultSrs": "native",
* "defaultSelectedService": "wfs"
* }
* }
* // it is possible to support GeoPackage format when the targeted GeoServer uses wps download extensions
Expand Down Expand Up @@ -109,13 +113,15 @@ const LayerDownloadPlugin = createPlugin('LayerDownload', {
wfsFormats: wfsFormatsSelector,
formatsLoading: formatsLoadingSelector,
layer: getSelectedLayer,
wpsAvailable: wpsAvailableSelector,
service: serviceSelector,
checkingWPSAvailability: checkingWPSAvailabilitySelector,
virtualScroll: state => state && state.featuregrid && state.featuregrid.virtualScroll,
customAttributeSettings: customAttributesSettingsSelector,
attributes: attributesSelector
}), {
onExport: downloadFeatures,
setService,
onDownloadOptionChange,
onClearDownloadOptions: clearDownloadOptions,
onFormatOptionsFetch,
Expand Down
9 changes: 8 additions & 1 deletion web/client/reducers/layerdownload.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ import {
REMOVE_EXPORT_DATA_RESULTS,
SHOW_INFO_BUBBLE,
SET_INFO_BUBBLE_MESSAGE,
CHECKING_EXPORT_DATA_ENTRIES
CHECKING_EXPORT_DATA_ENTRIES,
SET_WPS_AVAILABILITY
} from '../actions/layerdownload';

/**
Expand Down Expand Up @@ -85,6 +86,12 @@ function layerdownload( state = {downloadOptions: {singlePage: true}}, action) {
service: action.service
};
}
case SET_WPS_AVAILABILITY: {
return {
...state,
wpsAvailable: action.value
};
}
case CHECKING_WPS_AVAILABILITY: {
return {
...state,
Expand Down
1 change: 1 addition & 0 deletions web/client/selectors/layerdownload.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export const loadingSelector = state => state?.layerdownload?.loading;
export const checkingWPSAvailabilitySelector = state => state?.layerdownload?.checkingWPSAvailability;
export const wfsFormatsSelector = state => state?.layerdownload?.wfsFormats;
export const formatsLoadingSelector = state => state?.layerdownload?.formatsLoading;
export const wpsAvailableSelector = state => state?.layerdownload?.wpsAvailable;
export const serviceSelector = state => state?.layerdownload?.service;
export const wfsFilterSelector = createSelector(
isFeatureGridOpen, wfsFilter, getSelectedLayer,
Expand Down
1 change: 1 addition & 0 deletions web/client/translations/data.de-DE.json
Original file line number Diff line number Diff line change
Expand Up @@ -1770,6 +1770,7 @@
},
"layerdownload": {
"title": "Daten exportieren",
"service": "Service",
"format": "Dateiformat",
"srs": "Räumliches Bezugssystem",
"export": "Export",
Expand Down
1 change: 1 addition & 0 deletions web/client/translations/data.en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -1732,6 +1732,7 @@
},
"layerdownload": {
"title": "Export Data",
"service": "Service",
"format": "File Format",
"srs": "Spatial Reference System",
"export": "Export",
Expand Down
1 change: 1 addition & 0 deletions web/client/translations/data.es-ES.json
Original file line number Diff line number Diff line change
Expand Up @@ -1732,6 +1732,7 @@
},
"layerdownload": {
"title": "Exportar los datos",
"service": "Servicio",
"format": "Formato de fichero",
"srs": "Sistema de referencia espacial",
"export": "Exportar",
Expand Down
1 change: 1 addition & 0 deletions web/client/translations/data.fi-FI.json
Original file line number Diff line number Diff line change
Expand Up @@ -1430,6 +1430,7 @@
},
"layerdownload": {
"title": "Vie tietoja",
"service": "Service",
"format": "Tiedostomuoto",
"srs": "SRS",
"export": "Vie",
Expand Down
1 change: 1 addition & 0 deletions web/client/translations/data.fr-FR.json
Original file line number Diff line number Diff line change
Expand Up @@ -1733,6 +1733,7 @@
},
"layerdownload": {
"title": "Exporter des données",
"service": "Service",
"format": "Format de fichier",
"srs": "Système de référence spatiale",
"export": "Exporter",
Expand Down
1 change: 1 addition & 0 deletions web/client/translations/data.hr-HR.json
Original file line number Diff line number Diff line change
Expand Up @@ -1387,6 +1387,7 @@
},
"layerdownload": {
"title": "Izvezi podatke",
"service": "Service",
"format": "Format datoteke",
"srs": "Koordinatni sustav",
"export": "Izvoz",
Expand Down
1 change: 1 addition & 0 deletions web/client/translations/data.it-IT.json
Original file line number Diff line number Diff line change
Expand Up @@ -1732,6 +1732,7 @@
},
"layerdownload": {
"title": "Esporta dati",
"service": "Servizio",
"format": "Formato file",
"srs": "Sistema di riferimento",
"export": "Esporta",
Expand Down
1 change: 1 addition & 0 deletions web/client/translations/data.nl-NL.json
Original file line number Diff line number Diff line change
Expand Up @@ -1655,6 +1655,7 @@
},
"layerdownload": {
"title": "Exporteer Data",
"service": "Service",
"format": "Bestandsformaat",
"srs": "Coördinaten ReferentieSysteem",
"export": "Exporteer",
Expand Down
1 change: 1 addition & 0 deletions web/client/translations/data.pt-PT.json
Original file line number Diff line number Diff line change
Expand Up @@ -1361,6 +1361,7 @@
},
"layerdownload": {
"title": "Export Data",
"service": "Service",
"format": "File Format",
"srs": "Spatial Reference System",
"export": "Export",
Expand Down
1 change: 1 addition & 0 deletions web/client/translations/data.sk-SK.json
Original file line number Diff line number Diff line change
Expand Up @@ -1670,6 +1670,7 @@
},
"layerdownload": {
"title": "Exportovať dáta",
"service": "Service",
"format": "Formát súboru",
"srs": "Spatial Reference System",
"export": "Exportovať",
Expand Down
1 change: 1 addition & 0 deletions web/client/translations/data.sv-SE.json
Original file line number Diff line number Diff line change
Expand Up @@ -1650,6 +1650,7 @@
},
"layerdownload": {
"title": "Exportera data",
"service": "Service",
"format": "Filformat",
"srs": "Geodetiskt referenssystem",
"export": "Exportera",
Expand Down
1 change: 1 addition & 0 deletions web/client/translations/data.vi-VN.json
Original file line number Diff line number Diff line change
Expand Up @@ -1773,6 +1773,7 @@
},
"warning": "Cảnh báo",
"layerdownload": {
"service": "Service",
"downloadonlycurrentpage": "Chỉ tải xuống trang hiện tại",
"error": {
"invalidOutputFormat": "Định dạng xuất đã chọn không khả dụng",
Expand Down
1 change: 1 addition & 0 deletions web/client/translations/data.zh-ZH.json
Original file line number Diff line number Diff line change
Expand Up @@ -1337,6 +1337,7 @@
},
"layerdownload": {
"title": "Export Data",
"service": "Service",
"format": "File Format",
"srs": "Spatial Reference System",
"export": "Export",
Expand Down