diff --git a/package.json b/package.json index 224ddd0f79..84b44f4b9d 100644 --- a/package.json +++ b/package.json @@ -50,7 +50,7 @@ "react-motion": "0.4.4", "react-router": "2.4.0", "react-router-redux": "2.1.0", - "react-select": "1.0.0-beta14", + "react-select": "1.0.0-rc.1", "react-transform-catch-errors": "1.0.2", "redbox-react": "1.2.4", "redux-devtools": "3.1.1", diff --git a/web/client/actions/__tests__/layers-test.js b/web/client/actions/__tests__/layers-test.js index 937d5f4d8f..3fc4c94c24 100644 --- a/web/client/actions/__tests__/layers-test.js +++ b/web/client/actions/__tests__/layers-test.js @@ -33,7 +33,8 @@ var { removeLayer, showSettings, hideSettings, - updateSettings + updateSettings, + getLayerCapabilities } = require('../layers'); describe('Test correctness of the layers actions', () => { @@ -167,4 +168,25 @@ describe('Test correctness of the layers actions', () => { expect(action.type).toBe(UPDATE_SETTINGS); expect(action.options).toEqual({opacity: 0.5, size: 500}); }); + it('get layer capabilities', (done) => { + const layer = { + id: "TEST_ID", + name: 'testworkspace:testlayer', + title: 'Layer', + visibility: true, + storeIndex: 9, + type: 'shapefile', + url: 'base/web/client/test-resources/geoserver/wms' + }; + const actionCall = getLayerCapabilities(layer); + expect(actionCall).toExist(); + actionCall((action)=> { + expect(action).toExist(); + expect(action.options).toExist(); + expect(action.type === UPDATE_NODE); + if (action.options.capabilities) { + done(); + } + }); + }); }); diff --git a/web/client/actions/layers.js b/web/client/actions/layers.js index 36e6d1f98f..7f6358e381 100644 --- a/web/client/actions/layers.js +++ b/web/client/actions/layers.js @@ -196,6 +196,9 @@ function getLayerCapabilities(layer, options) { } return (dispatch) => { // TODO, look ad current cached capabilities; + dispatch(updateNode(layer.id, "id", { + capabilitiesLoading: true + })); return WMS.getCapabilities(reqUrl, options).then((capabilities) => { let layers = _.get(capabilities, "capability.layer.layer"); let layerCapability; @@ -213,6 +216,7 @@ function getLayerCapabilities(layer, options) { if (layerCapability) { dispatch(updateNode(layer.id, "id", { capabilities: layerCapability, + capabilitiesLoading: null, boundingBox: layerCapability.latLonBoundingBox, availableStyles: layerCapability.style && (Array.isArray(layerCapability.style) ? layerCapability.style : [layerCapability.style]) })); @@ -220,7 +224,7 @@ function getLayerCapabilities(layer, options) { // return dispatch(updateNode(layer.id, "id", {capabilities: capabilities || {"error": "no describe Layer found"}})); }).catch((error) => { - dispatch(updateNode(layer.id, "id", {capabilities: {error: "error getting capabilities", details: error}} )); + dispatch(updateNode(layer.id, "id", {capabilitiesLoading: null, capabilities: {error: "error getting capabilities", details: error}} )); // return dispatch(updateNode(layer.id, "id", {capabilities: capabilities || {"error": "no describe Layer found"}})); diff --git a/web/client/components/TOC/fragments/settings/WMSStyle.jsx b/web/client/components/TOC/fragments/settings/WMSStyle.jsx index 146a1ae574..e2543d60e4 100644 --- a/web/client/components/TOC/fragments/settings/WMSStyle.jsx +++ b/web/client/components/TOC/fragments/settings/WMSStyle.jsx @@ -7,7 +7,7 @@ */ var React = require('react'); -// const Message = require('../../../I18N/Message'); +const Message = require('../../../I18N/Message'); const Select = require('react-select'); const {Button, Glyphicon, Alert} = require('react-bootstrap'); @@ -29,28 +29,39 @@ const WMSStyle = React.createClass({ }; }, renderLegend() { - if (this.props.element && this.props.element.availableStyles) { - let i = this.props.element.availableStyles.findIndex((item) => item.name === this.props.element.style); - if (i >= 0) { - let style = this.props.element.availableStyles[i]; - let legendUrl = style.legendURL && style.legendURL[0]; - } - } + // legend can not added because of this issue + // https://github.com/highsource/ogc-schemas/issues/183 + return null; }, renderError() { if (this.props.element && this.props.element.capabilities && this.props.element && this.props.element.capabilities.error) { - return There was an error getting layer's style list; + return ; } }, render() { + let options = [{label: "Default Style", value: ""}].concat((this.props.element.availableStyles || []).map((item) => { + return {label: item.title || item.name, value: item.name}; + })); + let currentStyleIndex = this.props.element.style && this.props.element.availableStyles && this.props.element.availableStyles.findIndex( el => el.name === this.props.element.style); + if (!(currentStyleIndex >= 0) && this.props.element.style) { + options.push({label: this.props.element.style, value: this.props.element.style }); + } return (
-