From 570e11a2e6da41b2bc3c3e5c8cef24cde44be1b8 Mon Sep 17 00:00:00 2001 From: allyoucanmap Date: Thu, 20 Jul 2017 10:07:12 +0200 Subject: [PATCH 1/4] Added url parser on query --- web/client/epics/wfsquery.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/web/client/epics/wfsquery.js b/web/client/epics/wfsquery.js index c88ed75421..8615928792 100644 --- a/web/client/epics/wfsquery.js +++ b/web/client/epics/wfsquery.js @@ -8,6 +8,7 @@ const Rx = require('rxjs'); const axios = require('../libs/ajax'); +const Url = require('url'); const {changeSpatialAttribute, SELECT_VIEWPORT_SPATIAL_METHOD, updateGeometrySpatialField} = require('../actions/queryform'); const {CHANGE_MAP_VIEW} = require('../actions/map'); const {FEATURE_TYPE_SELECTED, QUERY, featureTypeLoaded, featureTypeError, querySearchResponse, queryError, featureClose} = require('../actions/wfsquery'); @@ -122,8 +123,10 @@ const getWFSFilterData = (filterObj) => { const getWFSFeature = (searchUrl, filterObj) => { const data = getWFSFilterData(filterObj); + const urlParsedObj = Url.parse(searchUrl); + const parsedUrl = urlParsedObj.protocol + '//' + urlParsedObj.host + urlParsedObj.pathname; return Rx.Observable.defer( () => - axios.post(searchUrl + '?service=WFS&outputFormat=json', data, { + axios.post(parsedUrl + '?service=WFS&outputFormat=json', data, { timeout: 60000, headers: {'Accept': 'application/json', 'Content-Type': 'application/json'} })); @@ -197,7 +200,6 @@ const featureTypeSelectedEpic = action$ => const wfsQueryEpic = (action$, store) => action$.ofType(QUERY) .switchMap(action => { - return Rx.Observable.merge( Rx.Observable.of(setControlProperty('drawer', 'enabled', false)), getWFSFeature(action.searchUrl, action.filterObj) From 0176f77f248a5abc1e446a3803fd1c6e0b2ff24b Mon Sep 17 00:00:00 2001 From: allyoucanmap Date: Fri, 21 Jul 2017 10:48:30 +0200 Subject: [PATCH 2/4] Added additional params options on query url --- web/client/epics/wfsquery.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/web/client/epics/wfsquery.js b/web/client/epics/wfsquery.js index 8615928792..a91f5ba002 100644 --- a/web/client/epics/wfsquery.js +++ b/web/client/epics/wfsquery.js @@ -123,10 +123,16 @@ const getWFSFilterData = (filterObj) => { const getWFSFeature = (searchUrl, filterObj) => { const data = getWFSFilterData(filterObj); + const urlParsedObj = Url.parse(searchUrl); const parsedUrl = urlParsedObj.protocol + '//' + urlParsedObj.host + urlParsedObj.pathname; + + const additionalParams = isString(urlParsedObj.query) ? urlParsedObj.query.split('&').filter((q) => q.substring(0, 7) !== 'service' && q.substring(0, 12) !== 'outputFormat' && q !== '') : []; + const additionalParamsString = additionalParams.length > 0 ? additionalParams.reduce((a, b) => a + '&' + b, '') : ''; + const params = '?service=WFS&outputFormat=json' + additionalParamsString; + return Rx.Observable.defer( () => - axios.post(parsedUrl + '?service=WFS&outputFormat=json', data, { + axios.post(parsedUrl + params, data, { timeout: 60000, headers: {'Accept': 'application/json', 'Content-Type': 'application/json'} })); From 40d47f46d075ad9caca9aae080e2552014abb964 Mon Sep 17 00:00:00 2001 From: allyoucanmap Date: Fri, 21 Jul 2017 11:11:56 +0200 Subject: [PATCH 3/4] Updated additional params on url query --- web/client/epics/wfsquery.js | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/web/client/epics/wfsquery.js b/web/client/epics/wfsquery.js index a91f5ba002..daf4541699 100644 --- a/web/client/epics/wfsquery.js +++ b/web/client/epics/wfsquery.js @@ -14,8 +14,9 @@ const {CHANGE_MAP_VIEW} = require('../actions/map'); const {FEATURE_TYPE_SELECTED, QUERY, featureTypeLoaded, featureTypeError, querySearchResponse, queryError, featureClose} = require('../actions/wfsquery'); const FilterUtils = require('../utils/FilterUtils'); const assign = require('object-assign'); -const {isString} = require('lodash'); +const {isString, isObject} = require('lodash'); const {TOGGLE_CONTROL, setControlProperty} = require('../actions/controls'); +const querystring = require('querystring'); const types = { // string @@ -124,15 +125,15 @@ const getWFSFilterData = (filterObj) => { const getWFSFeature = (searchUrl, filterObj) => { const data = getWFSFilterData(filterObj); - const urlParsedObj = Url.parse(searchUrl); - const parsedUrl = urlParsedObj.protocol + '//' + urlParsedObj.host + urlParsedObj.pathname; - - const additionalParams = isString(urlParsedObj.query) ? urlParsedObj.query.split('&').filter((q) => q.substring(0, 7) !== 'service' && q.substring(0, 12) !== 'outputFormat' && q !== '') : []; - const additionalParamsString = additionalParams.length > 0 ? additionalParams.reduce((a, b) => a + '&' + b, '') : ''; - const params = '?service=WFS&outputFormat=json' + additionalParamsString; + const urlParsedObj = Url.parse(searchUrl, true); + const parsedUrl = urlParsedObj.protocol + '//' + urlParsedObj.host + urlParsedObj.pathname + '?'; + let params = isObject(urlParsedObj.query) ? urlParsedObj.query : {}; + params.service = 'WFS'; + params.outputFormat = 'json'; + const paramsString = querystring.stringify(params); return Rx.Observable.defer( () => - axios.post(parsedUrl + params, data, { + axios.post(parsedUrl + paramsString, data, { timeout: 60000, headers: {'Accept': 'application/json', 'Content-Type': 'application/json'} })); From 0749a78e0ed3bd0bdbf935cf68774698921d346c Mon Sep 17 00:00:00 2001 From: allyoucanmap Date: Mon, 31 Jul 2017 10:05:03 +0200 Subject: [PATCH 4/4] Removed querystring library --- web/client/epics/wfsquery.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/web/client/epics/wfsquery.js b/web/client/epics/wfsquery.js index daf4541699..ce8b5b376c 100644 --- a/web/client/epics/wfsquery.js +++ b/web/client/epics/wfsquery.js @@ -16,7 +16,6 @@ const FilterUtils = require('../utils/FilterUtils'); const assign = require('object-assign'); const {isString, isObject} = require('lodash'); const {TOGGLE_CONTROL, setControlProperty} = require('../actions/controls'); -const querystring = require('querystring'); const types = { // string @@ -126,14 +125,18 @@ const getWFSFeature = (searchUrl, filterObj) => { const data = getWFSFilterData(filterObj); const urlParsedObj = Url.parse(searchUrl, true); - const parsedUrl = urlParsedObj.protocol + '//' + urlParsedObj.host + urlParsedObj.pathname + '?'; let params = isObject(urlParsedObj.query) ? urlParsedObj.query : {}; params.service = 'WFS'; params.outputFormat = 'json'; - const paramsString = querystring.stringify(params); + const queryString = Url.format({ + protocol: urlParsedObj.protocol, + host: urlParsedObj.host, + pathname: urlParsedObj.pathname, + query: params + }); return Rx.Observable.defer( () => - axios.post(parsedUrl + paramsString, data, { + axios.post(queryString, data, { timeout: 60000, headers: {'Accept': 'application/json', 'Content-Type': 'application/json'} }));