Skip to content

Commit

Permalink
Make preview info match the old UI.
Browse files Browse the repository at this point in the history
  • Loading branch information
kring committed Jun 2, 2016
1 parent 58e6ea2 commit 92a05bf
Showing 1 changed file with 85 additions and 24 deletions.
109 changes: 85 additions & 24 deletions lib/ReactViews/Preview/MappablePreview.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import React from 'react';

import DataPreviewSections from './DataPreviewSections';
import DataPreviewMap from './DataPreviewMap.jsx';
import DataPreviewUrl from './DataPreviewUrl.jsx';
import ObserveModelMixin from '../ObserveModelMixin';
import Styles from './mappable-preview.scss';
import renderMarkdownInReact from '../../Core/renderMarkdownInReact';
Expand Down Expand Up @@ -35,12 +34,12 @@ const MappablePreview = React.createClass({
},

render() {
const metadataItem = this.props.previewed.nowViewingCatalogItem || this.props.previewed;
const catalogItem = this.props.previewed.nowViewingCatalogItem || this.props.previewed;

return (
<div>
<h3>{this.props.previewed.name}</h3>
<If condition={this.props.previewed.isMappable}>
<h3>{catalogItem.name}</h3>
<If condition={catalogItem.isMappable}>
<DataPreviewMap terria={this.props.terria} previewedCatalogItem={this.props.previewed}/>
</If>
<div className={Styles.previewedInfo}>
Expand All @@ -52,33 +51,95 @@ const MappablePreview = React.createClass({
Back to the map
</button>
<div className="data-info url">
<Choose>
<When
condition={this.props.previewed.description && this.props.previewed.description.length > 0}>
<div>
<h4>Description</h4>
{renderMarkdownInReact(this.props.previewed.description, this.props.previewed)}
</div>
</When>
<When condition={!this.props.previewed.hasDescription}>
<p>
Please contact the provider of this data for more information, including information
about usage rights and constraints.
</p>
</When>
</Choose>
<If condition={catalogItem.description && catalogItem.description.length > 0}>
<div>
<h4>Description</h4>
{renderMarkdownInReact(catalogItem.description, catalogItem)}
</div>
</If>

<If condition={catalogItem.dataUrlType === 'local'}>
<p>This file only exists in your browser. To share it, you must load it onto a public web server.</p>
</If>

<If condition={catalogItem.dataUrlType !== 'local' && !catalogItem.hasDescription}>
<p>Please contact the provider of this data for more information, including information about usage rights and constraints.</p>
</If>

<DataPreviewSections metadataItem={metadataItem}/>
<DataPreviewSections metadataItem={catalogItem}/>

<If condition={metadataItem.dataCustodian}>
<If condition={catalogItem.dataCustodian && catalogItem.dataCustodian.length > 0}>
<div>
<h4>Data Custodian</h4>
{renderMarkdownInReact(metadataItem.dataCustodian, metadataItem)}
{renderMarkdownInReact(catalogItem.dataCustodian, catalogItem)}
</div>
</If>

<If condition={metadataItem.url && metadataItem.url.length}>
<DataPreviewUrl metadataItem={metadataItem}/>
<If condition={!catalogItem.hideSource}>
<If condition={catalogItem.url}>
<h4>{catalogItem.typeName} URL</h4>
<Choose>
<When condition={catalogItem.type === 'wms'}>
<p>
This is a <a href="https://en.wikipedia.org/wiki/Web_Map_Service" target="_blank">WMS
service</a>, which generates map images on request. It can be used in GIS software with this
URL:
</p>
</When>
<When condition={catalogItem.type === 'wfs'}>
<p>
This is a <a href="https://en.wikipedia.org/wiki/Web_Feature_Service" target="_blank">WFS
service</a>, which transfers raw spatial data on request. It can be used in GIS software with this
URL:
</p>
</When>
</Choose>

<input readOnly
className='field'
type="text"
value={catalogItem.url}
onClick={this.selectUrl} />

<Choose>
<When condition={catalogItem.type === 'wms' || (catalogItem.type === 'esri-mapServer' && typeof catalogItem.layers !== 'undefined')}>
<p>
Layer name{catalogItem.layers.split(',').length > 1 ? 's' : ''}: {catalogItem.layers}
</p>
</When>
<When condition={catalogItem.type === 'wfs'}>
<p>
Type name{catalogItem.typeNames.split(',').length > 1 ? 's' : ''}: {catalogItem.typeNames}
</p>
</When>
</Choose>
</If>

<If condition={catalogItem.metadataUrl}>
<h4>Metadata URL</h4>
<p>
<a href={catalogItem.metadataUrl} target="_blank">{catalogItem.metadataUrl}</a>
</p>
</If>

<If condition={catalogItem.dataUrlType && catalogItem.dataUrlType !== 'none' && catalogItem.dataUrl}>
<h4>Data URL</h4>
<p>
<Choose>
<When condition={catalogItem.dataUrlType.indexOf('wfs') === 0 || catalogItem.dataUrlType.indexOf('wcs') === 0}>
Use the link below to download the data. See the
{catalogItem.dataUrlType.indexOf('wfs') === 0 && <a href="http://docs.geoserver.org/latest/en/user/services/wfs/reference.html" target="_blank">Web Feature Service (WFS) documentation</a>}
{catalogItem.dataUrlType.indexOf('wcs') === 0 && <a href="http://docs.geoserver.org/latest/en/user/services/wcs/reference.html" target="_blank">Web Coverage Service (WCS) documentation</a>}
for more information on customising URL query parameters.
</When>
<Otherwise>
Use the link below to download data directly.
</Otherwise>
</Choose>
<br/>
<a href={catalogItem.dataUrl} target="_blank">{catalogItem.dataUrl}</a>
</p>
</If>
</If>
</div>
</div>
Expand Down

0 comments on commit 92a05bf

Please sign in to comment.