Interactive interface for browsing global, full-resolution satellite imagery
move filters to standalone component, apply classes for category and measure view to set proper width
Jason Kent094f2d7b5a22
diff --git a/web/css/layers.css b/web/css/layers.cssindex e4c9b39e3..22910013e 100644--- a/web/css/layers.css+++ b/web/css/layers.css@@ -782,13 +782,27 @@}.custom-layer-dialog {- max-width: 1200px;- background-color: #e8e8e8;+ background-color: #dcdcdc;- & .product-outter-list-case {- width: 100%;- padding: 0 11px 5px 0;+ &.category-width {+ width: 978px;+ max-width: 978px;+ & .modal-body {+ padding: 0 0 0 11px;+ }+ .product-outer-list-case {+ padding: 0 13px 13px 0;+ }+ }+ &.browse-search-width {+ width: 95%;+ max-width: 1400px;+ & .product-outter-list-case {+ width: 100%;+ padding: 0 11px 5px 0;+ }}+& .category-masonry-case {overflow: hidden;margin: auto;@@ -807,11 +821,9 @@& .back-button {margin-right: 10px;}-}--.custom-layer-dialog.light .modal-content .modal-body {- padding: 0;- background-color: #dcdcdc;+ & .modal-body {+ padding: 0;+ }}.layer-bread-crumb .breadcrumb {@@ -822,7 +834,14 @@@media (max-width: 1024px) {.custom-layer-dialog {- width: 95%;+ &.category-width {+ width: 658px;+ }+ &.browse-search-width {+ width: 95%;+ max-width: 1000px;+ }+& .category-masonry-case {max-width: 640px;}@@ -833,11 +852,6 @@}@media (max-width: 700px) {- .measurement-row .source-settings {- border-top: 1px solid #d54e21;- margin-top: 10px;- padding-top: 5px;- }.custom-layer-dialog {width: auto;@@ -847,6 +861,12 @@}}+ .measurement-row .source-settings {+ border-top: 1px solid #d54e21;+ margin-top: 10px;+ padding-top: 5px;+ }+.layer-category {width: 100%;}@@ -861,6 +881,7 @@margin: 0 12px 0 0;}}+.no-results {margin-top: 50px;& h3 {diff --git a/web/js/components/layer/product-picker/category-grid.js b/web/js/components/layer/product-picker/category-grid.jsindex 6a640aead..a16fb5d6d 100644--- a/web/js/components/layer/product-picker/category-grid.js+++ b/web/js/components/layer/product-picker/category-grid.js@@ -21,7 +21,7 @@ class CategoryGrid extends React.Component {} = this.props;const masonryOptions = {transitionDuration: '0.6s',- columnWidth: 310,+ columnWidth: width >= 630 ? 310 : width - 26,gutter: 10};categories.map(item => {diff --git a/web/js/components/layer/product-picker/layer-filters.js b/web/js/components/layer/product-picker/layer-filters.jsnew file mode 100644index 000000000..34bc84abc--- /dev/null+++ b/web/js/components/layer/product-picker/layer-filters.js@@ -0,0 +1,78 @@+import React from 'react';+import PropTypes from 'prop-types';+import moment from 'moment';+import { Form, Tooltip } from 'reactstrap';++/*+ * A scrollable list of layers+ * @class LayerList+ * @extends React.Component+ */+class ProductPickerHeader extends React.Component {+ constructor(props) {+ super(props);+ this.state = {+ tooltipFilterAvailableOpen: false+ };+ }++ toggleTooltip() {+ this.setState({+ tooltipFilterAvailableOpen: !this.state.tooltipFilterAvailableOpen+ });+ }++ render() {+ const { tooltipFilterAvailableOpen } = this.state;+ const {+ selectedDate,+ numResults,+ filterByAvailable,+ toggleFilterByAvailable+ } = this.props;+ const diplayDate = moment(selectedDate).format('YYYY MMM DD');++ return (+ <div className="layer-filters-container">+ <div className="filter-controls">+ <h3>Filters</h3>+ <Form>+ <div className="custom-control custom-switch">+ <input+ id="unit-toggle"+ className="custom-control-input"+ type="checkbox"+ onChange={toggleFilterByAvailable}+ defaultChecked={filterByAvailable}/>+ <label className="custom-control-label" htmlFor="unit-toggle">+ Filter by availability+ </label>+ <i id="availability-filter" className="fa fa-info-circle" />+ <Tooltip+ placement="right"+ isOpen={tooltipFilterAvailableOpen}+ target="availability-filter"+ toggle={this.toggleTooltip.bind(this)}>+ If enabled, only show results which would be visible at the+ currently selected date: <br/>+ <span style={{ fontFamily: 'monospace' }}> {diplayDate} </span>+ </Tooltip>+ </div>+ </Form>+ </div>+ <div className="results-text">+ Showing {numResults} results+ </div>+ </div>+ );+ }+}++ProductPickerHeader.propTypes = {+ filterByAvailable: PropTypes.bool,+ numResults: PropTypes.number,+ selectedDate: PropTypes.object,+ toggleFilterByAvailable: PropTypes.func+};++export default ProductPickerHeader;diff --git a/web/js/components/layer/product-picker/product-picker.js b/web/js/components/layer/product-picker/product-picker.jsindex 25f6fc343..08f171dbe 100644--- a/web/js/components/layer/product-picker/product-picker.js+++ b/web/js/components/layer/product-picker/product-picker.js@@ -4,6 +4,7 @@ import PropTypes from 'prop-types';import LayerList from './layer-list';import CategoryGrid from './category-grid';import ProductPickerHeader from './header';+import LayerFilters from './layer-filters';import {toLower as lodashToLower,values as lodashValues,@@ -29,11 +30,8 @@ import {ModalHeader,Nav,NavItem,- NavLink,- Form,- Tooltip+ NavLink} from 'reactstrap';-import moment from 'moment';/** A scrollable list of layers@@ -54,11 +52,33 @@ class ProductPicker extends React.Component {filteredRows: props.filteredRows,inputValue: '',filterByAvailable: true,- tooltipFilterAvailableOpen: false+ tooltipFilterAvailableOpen: false,+ modalElement: null};this.runSearch = lodashDebounce(this.runSearch, 300);}+ componentDidMount() {+ const modalElement = document.getElementById('layer_picker_component');+ modalElement.classList.add('category-width');+ this.setState({ modalElement });+ }++ componentDidUpdate(prevProps, prevState, snapshot) {+ const { listType, modalElement } = this.state;+ if (prevState.listType === listType) {+ return;+ }+ if (listType === 'category') {+ modalElement.classList.remove('browse-search-width');+ modalElement.classList.add('category-width');+ }+ if (listType === 'search' || listType === 'measurements') {+ modalElement.classList.remove('category-width');+ modalElement.classList.add('browse-search-width');+ }+ }+/*** Either filter layers with search object or* revert to initial state@@ -192,6 +212,9 @@ class ProductPicker extends React.Component {this.runSearch(inputValue);}+ /**+ * When using "back" button or clearing search field, unset selections+ */revertSearchState() {this.setState({listType: 'category',@@ -201,62 +224,35 @@ class ProductPicker extends React.Component {});}+ /**+ * When in "search" mode+ * @param {*} selectedLayer - the layer for which to show metadata+ */showMetadataForLayer(selectedLayer) {this.setState({ selectedLayer });}+ /**+ * When in "browse" measurement mode+ * @param {*} measurementSourceIndex - the index of the source for which to show metadata+ */setSourceIndex(measurementSourceIndex) {this.setState({ measurementSourceIndex });}- toggleTooltip() {- this.setState({- tooltipFilterAvailableOpen: !this.state.tooltipFilterAvailableOpen- });- }-- renderLayerFilters() {- const {- filteredRows,- filterByAvailable,- tooltipFilterAvailableOpen- } = this.state;- const { selectedDate } = this.props;- const diplayDate = moment(selectedDate).format('YYYY MMM DD');+ getCurrentMeasureSource() {+ const { measurementConfig } = this.props;+ const { selectedMeasurement, measurementSourceIndex } = this.state;- return (- <div className="layer-filters-container">- <div className="filter-controls">- <h3>Filters</h3>- <Form>- <div className="custom-control custom-switch">- <input- id="unit-toggle"- className="custom-control-input"- type="checkbox"- onChange={this.toggleFilterByAvailable.bind(this)}- defaultChecked={filterByAvailable}/>- <label className="custom-control-label" htmlFor="unit-toggle">- Filter by availability- </label>- <i id="availability-filter" className="fa fa-info-circle" />- <Tooltip- placement="right"- isOpen={tooltipFilterAvailableOpen}- target="availability-filter"- toggle={this.toggleTooltip.bind(this)}>- If enabled, only show results which would be visible at the- currently selected date: <br/>- <span style={{ fontFamily: 'monospace' }}> {diplayDate} </span>- </Tooltip>- </div>- </Form>- </div>- <div className="results-text">- Showing {filteredRows.length} results- </div>- </div>- );+ let currentMeasurement;+ Object.keys(measurementConfig).forEach(measureName => {+ if (measurementConfig[measureName].id === selectedMeasurement) {+ currentMeasurement = measurementConfig[measureName];+ }+ });+ const sources = currentMeasurement && lodashValues(currentMeasurement.sources)+ .sort((a, b) => a.title.localeCompare(b.title));+ return sources && sources[measurementSourceIndex];}renderLayerList() {@@ -267,7 +263,7 @@ class ProductPicker extends React.Component {category,selectedMeasurement,selectedLayer,- measurementSourceIndex+ filterByAvailable} = this.state;const {categoryConfig,@@ -290,19 +286,18 @@ class ProductPicker extends React.Component {? 'layer-detail-container layers-all search': 'layer-detail-container layers-all browse';- let currentMeasurement;- Object.keys(measurementConfig).forEach(measureName => {- if (measurementConfig[measureName].id === selectedMeasurement) {- currentMeasurement = measurementConfig[measureName];- }- });- const sources = currentMeasurement && lodashValues(currentMeasurement.sources)- .sort((a, b) => a.title.localeCompare(b.title));- const currentMeasureSource = sources && sources[measurementSourceIndex];+ const currentMeasureSource = this.getCurrentMeasureSource();return (<>- {listType === 'search' && this.renderLayerFilters() }+ {listType === 'search' &&+ <LayerFilters+ selectedDate={selectedDate}+ numResults={filteredRows.length}+ filterByAvailable={filterByAvailable}+ toggleFilterByAvailable={this.toggleFilterByAvailable.bind(this)}+ />+ }<div className={listContainerClass}><Scrollbars style={{ maxHeight: height + 'px' }}>@@ -550,7 +545,7 @@ const filterSearch = function(layer, val, terms, config, projId) {!lodashIncludes(lodashToLower(names.title), term) &&!lodashIncludes(lodashToLower(names.subtitle), term) &&!lodashIncludes(lodashToLower(names.tags), term) &&- !lodashIncludes(lodashToLower(config.layers[layer.id].id), term);+ !lodashIncludes(lodashToLower(layer.id, term));if (filtered) return false;});return filtered;