From f9bea27384f8004f4cd89633d94e7c5a8b636448 Mon Sep 17 00:00:00 2001 From: Lorenzo Natali Date: Thu, 3 Nov 2016 11:30:33 +0100 Subject: [PATCH] Fix #1194. First commits --- web/client/actions/catalog.js | 1 - web/client/actions/layers.js | 13 +++-- web/client/api/WMS.js | 1 - web/client/components/TOC/DefaultLayer.jsx | 3 ++ .../TOC/fragments/SettingsModal.jsx | 36 ++++++++++--- .../TOC/fragments/settings/WMSStyle.jsx | 54 +++++++++++++++++++ web/client/components/catalog/RecordItem.jsx | 2 + web/client/plugins/TOC.jsx | 6 ++- 8 files changed, 100 insertions(+), 16 deletions(-) create mode 100644 web/client/components/TOC/fragments/settings/WMSStyle.jsx diff --git a/web/client/actions/catalog.js b/web/client/actions/catalog.js index 0f9c96f602..ce7a49045d 100644 --- a/web/client/actions/catalog.js +++ b/web/client/actions/catalog.js @@ -16,7 +16,6 @@ const RECORD_LIST_LOAD_ERROR = 'RECORD_LIST_LOAD_ERROR'; const CHANGE_CATALOG_FORMAT = 'CHANGE_CATALOG_FORMAT'; const ADD_LAYER_ERROR = 'ADD_LAYER_ERROR'; const CATALOG_RESET = 'CATALOG_RESET'; - function recordsLoaded(options, result) { return { type: RECORD_LIST_LOADED, diff --git a/web/client/actions/layers.js b/web/client/actions/layers.js index 4e1dedeea1..d8d497866e 100644 --- a/web/client/actions/layers.js +++ b/web/client/actions/layers.js @@ -185,7 +185,7 @@ function getDescribeLayer(url, layer, options) { } function getLayerCapabilities(layer, options) { - // geoserver's specific. + // geoserver's specific. TODO parse layer.capabilitiesURL. let reqUrl = layer.url; let urlParts = reqUrl.split("/geoserver/"); if (urlParts.length === 2) { @@ -193,7 +193,6 @@ function getLayerCapabilities(layer, options) { if (layerParts.length === 2) { reqUrl = urlParts[0] + "/geoserver/" + layerParts [0] + "/" + layerParts[1] + "/" + urlParts[1]; } - } return (dispatch) => { // TODO, look ad current cached capabilities; @@ -202,9 +201,9 @@ function getLayerCapabilities(layer, options) { let layerCapability; layerCapability = _.head(layers.filter( ( capability ) => { - if (layer.name.split(":").length === 2 && capability.name.split(":").length === 2 ) { + if (layer.name.split(":").length === 2 && capability.name && capability.name.split(":").length === 2 ) { return layer.name === capability.name; - } else if (capability.name.split(":").length === 2) { + } else if (capability.name && capability.name.split(":").length === 2) { return (layer.name === capability.name.split(":")[1]); } else if (layer.name.split(":").length === 2) { return layer.name.split(":")[1] === capability.name; @@ -212,7 +211,11 @@ function getLayerCapabilities(layer, options) { return layer.name === capability.name; })); if (layerCapability) { - dispatch(updateNode(layer.id, "id", {capabilities: layerCapability, boundingBox: layerCapability.latLonBoundingBox})); + dispatch(updateNode(layer.id, "id", { + capabilities: layerCapability, + boundingBox: layerCapability.latLonBoundingBox, + availableStyles: Array.isArray(layerCapability.style) ? layerCapability.style : [layerCapability.style] + })); } // return dispatch(updateNode(layer.id, "id", {capabilities: capabilities || {"error": "no describe Layer found"}})); diff --git a/web/client/api/WMS.js b/web/client/api/WMS.js index 49cf4b032f..095fb91c93 100644 --- a/web/client/api/WMS.js +++ b/web/client/api/WMS.js @@ -67,7 +67,6 @@ const Api = { resolve(axios.get(parseUrl(getCapabilitiesUrl)).then((response) => { let json = unmarshaller.unmarshalString(response.data); return json && json.value; - })); }); }); diff --git a/web/client/components/TOC/DefaultLayer.jsx b/web/client/components/TOC/DefaultLayer.jsx index c9b3d8559e..25767f74af 100644 --- a/web/client/components/TOC/DefaultLayer.jsx +++ b/web/client/components/TOC/DefaultLayer.jsx @@ -23,6 +23,7 @@ var DefaultLayer = React.createClass({ node: React.PropTypes.object, settings: React.PropTypes.object, propertiesChangeHandler: React.PropTypes.func, + retrieveLayerData: React.PropTypes.func, onToggle: React.PropTypes.func, onZoom: React.PropTypes.func, onSettings: React.PropTypes.func, @@ -56,6 +57,7 @@ var DefaultLayer = React.createClass({ onToggle: () => {}, onZoom: () => {}, onSettings: () => {}, + retrieveLayerData: () => {}, activateRemoveLayer: false, activateLegendTool: false, activateSettingsTool: false, @@ -106,6 +108,7 @@ var DefaultLayer = React.createClass({ tools.push( {}, updateNode: () => {}, removeNode: () => {}, + retrieveLayerData: () => {}, asModal: true, buttonSize: "large", closeGlyph: "", @@ -98,22 +101,39 @@ const SettingsModal = React.createClass({ ); this.props.hideSettings(); }, - render() { - const general = (); - const display = ( this.updateParams({[key]: value}, this.props.realtimeUpdate)} />); + }, + renderDisplay() { + return ( this.updateParams({[key]: value}, this.props.realtimeUpdate)} />); + }, + renderStyleTab() { + if (this.props.element.type === "wms") { + return (); + } + }, + render() { + const general = this.renderGeneral(); + const display = this.renderDisplay(); + const style = this.renderStyleTab(); const tabs = ( }>{general} }>{display} - } disabled>Tab 3 content + } disabled={!style} >{style} ); const footer = ( {this.props.includeCloseButton ? : } diff --git a/web/client/components/TOC/fragments/settings/WMSStyle.jsx b/web/client/components/TOC/fragments/settings/WMSStyle.jsx new file mode 100644 index 0000000000..e404d5f60b --- /dev/null +++ b/web/client/components/TOC/fragments/settings/WMSStyle.jsx @@ -0,0 +1,54 @@ +/** + * Copyright 2016, GeoSolutions Sas. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. + */ + +var React = require('react'); +// const Message = require('../../../I18N/Message'); +const Select = require('react-select'); +const {Button, Glyphicon} = require('react-bootstrap'); + +/** + * General Settings form for layer + */ +const WMSStyle = React.createClass({ + propTypes: { + retrieveLayerData: React.PropTypes.func, + updateSettings: React.PropTypes.func, + element: React.PropTypes.object, + groups: React.PropTypes.array + }, + getDefaultProps() { + return { + element: {}, + retrieveLayerData: () => {}, + updateSettings: () => {} + }; + }, + render() { + return (
+