Skip to content

Commit

Permalink
Fix geosolutions-it#1194. First commits
Browse files Browse the repository at this point in the history
  • Loading branch information
offtherailz committed Nov 3, 2016
1 parent 8e628c8 commit f9bea27
Show file tree
Hide file tree
Showing 8 changed files with 100 additions and 16 deletions.
1 change: 0 additions & 1 deletion web/client/actions/catalog.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
13 changes: 8 additions & 5 deletions web/client/actions/layers.js
Original file line number Diff line number Diff line change
Expand Up @@ -185,15 +185,14 @@ 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) {
let layerParts = layer.name.split(":");
if (layerParts.length === 2) {
reqUrl = urlParts[0] + "/geoserver/" + layerParts [0] + "/" + layerParts[1] + "/" + urlParts[1];
}

}
return (dispatch) => {
// TODO, look ad current cached capabilities;
Expand All @@ -202,17 +201,21 @@ 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;
}
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"}}));

Expand Down
1 change: 0 additions & 1 deletion web/client/api/WMS.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ const Api = {
resolve(axios.get(parseUrl(getCapabilitiesUrl)).then((response) => {
let json = unmarshaller.unmarshalString(response.data);
return json && json.value;

}));
});
});
Expand Down
3 changes: 3 additions & 0 deletions web/client/components/TOC/DefaultLayer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -56,6 +57,7 @@ var DefaultLayer = React.createClass({
onToggle: () => {},
onZoom: () => {},
onSettings: () => {},
retrieveLayerData: () => {},
activateRemoveLayer: false,
activateLegendTool: false,
activateSettingsTool: false,
Expand Down Expand Up @@ -106,6 +108,7 @@ var DefaultLayer = React.createClass({
tools.push(
<SettingsModal key="toolsettingsmodal" options={this.props.modalOptions}
{...this.props.settingsOptions}
retrieveLayerData={this.props.retrieveLayerData}
hideSettings={this.props.hideSettings}
settings={this.props.settings}
element={this.props.node}
Expand Down
36 changes: 28 additions & 8 deletions web/client/components/TOC/fragments/SettingsModal.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const Dialog = require('../../misc/Dialog');
const ConfirmButton = require('../../buttons/ConfirmButton');
const General = require('./settings/General');
const Display = require('./settings/Display');
const WMSStyle = require('./settings/WMSStyle');
const {Portal} = require('react-overlays');
const assign = require('object-assign');
const Message = require('../../I18N/Message');
Expand All @@ -28,6 +29,7 @@ const SettingsModal = React.createClass({
hideSettings: React.PropTypes.func,
updateNode: React.PropTypes.func,
removeNode: React.PropTypes.func,
retrieveLayerData: React.PropTypes.func,
titleText: React.PropTypes.oneOfType([React.PropTypes.string, React.PropTypes.element]),
opacityText: React.PropTypes.oneOfType([React.PropTypes.string, React.PropTypes.element]),
saveText: React.PropTypes.oneOfType([React.PropTypes.string, React.PropTypes.element]),
Expand All @@ -54,6 +56,7 @@ const SettingsModal = React.createClass({
hideSettings: () => {},
updateNode: () => {},
removeNode: () => {},
retrieveLayerData: () => {},
asModal: true,
buttonSize: "large",
closeGlyph: "",
Expand Down Expand Up @@ -98,22 +101,39 @@ const SettingsModal = React.createClass({
);
this.props.hideSettings();
},
render() {
const general = (<General
renderGeneral() {
return (<General
updateSettings={this.updateParams}
element={this.props.element}
groups={this.props.groups}
key="general"
on/>);
const display = (<Display
opacityText={this.props.opacityText}
element={this.props.element}
settings={this.props.settings}
onChange={(key, value) => this.updateParams({[key]: value}, this.props.realtimeUpdate)} />);
},
renderDisplay() {
return (<Display
opacityText={this.props.opacityText}
element={this.props.element}
settings={this.props.settings}
onChange={(key, value) => this.updateParams({[key]: value}, this.props.realtimeUpdate)} />);
},
renderStyleTab() {
if (this.props.element.type === "wms") {
return (<WMSStyle
retrieveLayerData={this.props.retrieveLayerData}
updateSettings={this.updateParams}
element={this.props.element}
key="style"
o/>);
}
},
render() {
const general = this.renderGeneral();
const display = this.renderDisplay();
const style = this.renderStyleTab();
const tabs = (<Tabs defaultActiveKey={1} id="layerProperties-tabs">
<Tab eventKey={1} title={<Message msgId="layerProperties.general" />}>{general}</Tab>
<Tab eventKey={2} title={<Message msgId="layerProperties.display" />}>{display}</Tab>
<Tab eventKey={3} title={<Message msgId="layerProperties.style" />} disabled>Tab 3 content</Tab>
<Tab eventKey={3} title={<Message msgId="layerProperties.style" />} disabled={!style} >{style}</Tab>
</Tabs>);
const footer = (<span role="footer">
{this.props.includeCloseButton ? <Button bsSize={this.props.buttonSize} onClick={this.onClose}>{this.props.closeText}</Button> : <span/>}
Expand Down
54 changes: 54 additions & 0 deletions web/client/components/TOC/fragments/settings/WMSStyle.jsx
Original file line number Diff line number Diff line change
@@ -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 (<form ref="style">
<Select
key="styles-dropdown"
options={[{label: "Default Style", value: ""}].concat((this.props.element.availableStyles && this.props.element.availableStyles || []).map((item) => {
return {label: item.title || item.name, value: item.name};
}))}
value={this.props.element.style || ""}
onChange={(selected) => {
this.updateEntry("style", {target: {value: selected.value || ""}});
}}
/>
<br />
<Button bsStyle="primary" style={{"float": "right"}} onClick={() => this.props.retrieveLayerData(this.props.element)}><Glyphicon glyph="refresh" />Refresh Styles List</Button>
<br />
</form>);
},
updateEntry(key, event) {
let value = event.target.value;
this.props.updateSettings({[key]: value});
}
});

module.exports = WMSStyle;
2 changes: 2 additions & 0 deletions web/client/components/catalog/RecordItem.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,14 @@ const RecordItem = React.createClass({
let links = [];
if (wmsGetCap) {
links.push({
type: "WMS_GET_CAPABILITIES",
url: wmsGetCap.url,
labelId: 'catalog.wmsGetCapLink'
});
}
if (wfsGetCap) {
links.push({
type: "WFS_GET_CAPABILITIES",
url: wfsGetCap.url,
labelId: 'catalog.wfsGetCapLink'
});
Expand Down
6 changes: 5 additions & 1 deletion web/client/plugins/TOC.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const React = require('react');
const {connect} = require('react-redux');
const {createSelector} = require('reselect');
const {changeLayerProperties, changeGroupProperties, toggleNode,
sortNode, showSettings, hideSettings, updateSettings, updateNode, removeNode} = require('../actions/layers');
sortNode, showSettings, hideSettings, updateSettings, updateNode, removeNode, getLayerCapabilities} = require('../actions/layers');
const {zoomToExtent} = require('../actions/map');

const {groupsSelector} = require('../selectors/layers');
Expand Down Expand Up @@ -49,6 +49,7 @@ const LayerTree = React.createClass({
onToggleGroup: React.PropTypes.func,
onToggleLayer: React.PropTypes.func,
onZoomToExtent: React.PropTypes.func,
retrieveLayerData: React.PropTypes.func,
onSort: React.PropTypes.func,
onSettings: React.PropTypes.func,
hideSettings: React.PropTypes.func,
Expand All @@ -66,6 +67,7 @@ const LayerTree = React.createClass({
return {
groupPropertiesChangeHandler: () => {},
layerPropertiesChangeHandler: () => {},
retrieveLayerData: () => {},
onToggleGroup: () => {},
onToggleLayer: () => {},
onZoomToExtent: () => {},
Expand Down Expand Up @@ -115,6 +117,7 @@ const LayerTree = React.createClass({
activateLegendTool={this.props.activateLegendTool}
activateZoomTool={this.props.activateZoomTool}
activateSettingsTool={this.props.activateSettingsTool}
retrieveLayerData={this.props.retrieveLayerData}
settingsText={<Message msgId="layerProperties.windowTitle"/>}
opacityText={<Message msgId="opacity"/>}
saveText={<Message msgId="save"/>}
Expand All @@ -130,6 +133,7 @@ const LayerTree = React.createClass({
const TOCPlugin = connect(tocSelector, {
groupPropertiesChangeHandler: changeGroupProperties,
layerPropertiesChangeHandler: changeLayerProperties,
retrieveLayerData: getLayerCapabilities,
onToggleGroup: LayersUtils.toggleByType('groups', toggleNode),
onToggleLayer: LayersUtils.toggleByType('layers', toggleNode),
onSort: LayersUtils.sortUsing(LayersUtils.sortLayers, sortNode),
Expand Down

0 comments on commit f9bea27

Please sign in to comment.