Skip to content

Interactive interface for browsing global, full-resolution satellite imagery

facet chips

Jason Kent75c61f85d6e7
diff --git a/web/css/facets.css b/web/css/facets.css
new file mode 100644
index 000000000..e3d0804c6
--- /dev/null
+++ b/web/css/facets.css
@@ -0,0 +1,114 @@
+.facet-container {
+ flex: 1;
+ max-width: 270px;
+ display: flex;
+ flex-direction: column;
+ & .bag-o-chips {
+ background: #333;
+ margin: 2px 4px 1px 2px;
+ padding: 3px;
+ }
+ & .filter-chip {
+ padding: 3px 20px 3px 5px;
+ margin: 4px;
+ background: #ccc;
+ color: #333;
+ border-radius: 20px;
+ position: relative;
+ display: inline-block;
+ font-weight: 500;
+ cursor: pointer;
+ &:hover {
+ background: #eee;
+ color: #111;
+ & .svg-inline--fa {
+ color: #222;
+ }
+ }
+ & .svg-inline--fa {
+ position: absolute;
+ right: 2px;
+ color: #666;
+ }
+ }
+ & .inner-container {
+ padding: 10px 12px 10px 10px;
+ margin: 0 4px 2px 2px;
+ background-color: #333;
+ height: 100%;
+ overflow-y: auto;
+ }
+ & .facet-wrapper {
+ display: block;
+ position: relative;
+ width: 100%;
+ min-height: 25px;
+ margin-bottom: 8px;
+
+ &.hidden {
+ display: none;
+ }
+ .no-matches {
+ color: #aaa;
+ margin: 6px;
+ text-align: center;
+ }
+
+ & .svg-inline--fa {
+ cursor: pointer;
+ color: #fff;
+ }
+ .facet-collapse-toggle {
+ position: absolute;
+ right: 0;
+ top: -4px;
+ width: 18px;
+ height: 20px;
+ }
+ .facet-tooltip {
+ position: absolute;
+ left: 0;
+ top: 2px;
+ }
+ }
+}
+
+@media (max-width: 768px) {
+ .facet-container {
+ max-width: 100%;
+ display: flex;
+ flex-direction: column;
+ & .filter-chip {
+ font-size: 16px;
+ padding: 6px 24px 6px 8px;
+ & .svg-inline--fa {
+ right: 3px;
+ top: 5px;
+ }
+ }
+ & .bag-o-chips,
+ & .inner-container {
+ margin-right: 2px;
+ }
+ }
+ .apply-facets {
+ height: 50px;
+ background: #d54f21;
+ font-size: 16px;
+ border: 1px solid #aa3c16;
+ margin: 4px auto;
+ width: 165px;
+ }
+ .facet-wrapper {
+ margin-bottom: 12px;
+ }
+ .facet-tooltip {
+ top: 1px;
+ height: 20px;
+ width: 16px;
+ }
+ .facet-collapse-toggle {
+ height: 28px;
+ width: 24px;
+ }
+}
diff --git a/web/css/layers.css b/web/css/layers.css
index 622649d42..28355fc1d 100644
--- a/web/css/layers.css
+++ b/web/css/layers.css
@@ -830,16 +830,6 @@
margin-right: 10px;
}
-.facet-container {
- flex: 1;
- max-width: 270px;
- & .inner-container {
- padding: 10px 8px 10px 10px;
- margin: 3px 10px 2px 2px;
- background-color: #333;
- }
-}
-
@media (min-width: 1024px) {
.search-layers-container {
& div.layer-list-detail-container {
@@ -937,19 +927,6 @@
width: 30px;
}
}
- .facet-container {
- max-width: 100%;
- display: flex;
- flex-direction: column;
- & .apply-facets {
- height: 50px;
- background: #d54f21;
- font-size: 16px;
- border: 1px solid #aa3c16;
- margin: 4px auto;
- width: 165px;
- }
- }
.layer-detail-container.search {
height: 65%;
border-top: 5px solid #d54e21;
@@ -1160,52 +1137,3 @@
margin-right: 10px;
}
-.facet-container .facet-wrapper {
- display: block;
- position: relative;
- width: 100%;
- min-height: 25px;
- margin-bottom: 8px;
-
- &.hidden {
- display: none;
- }
-
- .no-matches {
- color: #aaa;
- margin: 6px;
- text-align: center;
- }
-
- & .svg-inline--fa {
- cursor: pointer;
- color: #fff;
- }
- .facet-collapse-toggle {
- position: absolute;
- right: 0;
- top: -4px;
- width: 18px;
- height: 20px;
- }
- .facet-tooltip {
- position: absolute;
- left: 0;
- top: 2px;
- }
-}
-
-@media (max-width: 768px) {
- .facet-container .facet-wrapper {
- margin-bottom: 12px;
- & .facet-tooltip {
- top: 1px;
- height: 20px;
- width: 16px;
- }
- & .facet-collapse-toggle {
- height: 28px;
- width: 24px;
- }
- }
-}
diff --git a/web/js/app.js b/web/js/app.js
index 23173962c..771e2dd2b 100644
--- a/web/js/app.js
+++ b/web/js/app.js
@@ -80,6 +80,7 @@ import '../css/list.css';
import '../css/vectorMeta.css';
import '../css/geostationary-modal.css';
import '../css/orbitTracks.css';
+import '../css/facets.css';
import '../pages/css/document.css';
import keyPress from './modules/key-press/actions';
diff --git a/web/js/components/layer/product-picker/browse/browse-layers.js b/web/js/components/layer/product-picker/browse/browse-layers.js
index 0c7ce270f..f0d60125c 100644
--- a/web/js/components/layer/product-picker/browse/browse-layers.js
+++ b/web/js/components/layer/product-picker/browse/browse-layers.js
@@ -1,7 +1,6 @@
import React from 'react';
import { connect } from 'react-redux';
import PropTypes from 'prop-types';
-import lodashDebounce from 'lodash/debounce';
import {
Nav,
NavItem,
diff --git a/web/js/components/layer/product-picker/search/facets.js b/web/js/components/layer/product-picker/search/facets.js
new file mode 100644
index 000000000..1ae2674e9
--- /dev/null
+++ b/web/js/components/layer/product-picker/search/facets.js
@@ -0,0 +1,98 @@
+import React from 'react';
+import { connect } from 'react-redux';
+import PropTypes from 'prop-types';
+import { Button } from 'reactstrap';
+import { withSearch } from '@elastic/react-search-ui';
+import FilterChips from './filter-chips';
+import ProductFacet from './product-facet';
+import {
+ toggleMobileFacets as toggleMobileFacetsAction,
+} from '../../../../modules/product-picker/actions';
+import facetConfig from '../../../../modules/product-picker/facetConfig';
+
+function Facets(props) {
+ const {
+ isMobile,
+ browser,
+ facets,
+ filters,
+ removeFilter,
+ showMobileFacets,
+ toggleMobileFacets,
+ } = props;
+
+ const showFacets = browser.greaterThan.small || showMobileFacets;
+ const facetHeight = isMobile ? 'calc(100vh - 125px)' : '100%';
+
+ return !showFacets ? null : (
+ <div className="facet-container">
+
+ <FilterChips filters={filters} removeFilter={removeFilter} />
+
+ <div className="inner-container" style={{ height: facetHeight, overflowY: 'auto' }}>
+ {facetConfig.map((config) => {
+ const facet = facets[config.field];
+ const data = (facet && facet.length && facet[0].data) || [];
+ return (
+ <ProductFacet
+ key={config.field}
+ field={config.field}
+ label={config.label}
+ filterType={config.filterType}
+ tooltip={config.tooltip}
+ show={config.show}
+ view={config.view}
+ data={data}
+ />
+ );
+ })}
+ </div>
+
+ {isMobile && showMobileFacets && (
+ <Button
+ className="apply-facets"
+ onClick={toggleMobileFacets}
+ >
+ Apply
+ </Button>
+ )}
+ </div>
+ );
+}
+
+Facets.propTypes = {
+ browser: PropTypes.object,
+ facets: PropTypes.object,
+ filters: PropTypes.array,
+ isMobile: PropTypes.bool,
+ removeFilter: PropTypes.func,
+ showMobileFacets: PropTypes.bool,
+ toggleMobileFacets: PropTypes.func,
+};
+
+const mapDispatchToProps = (dispatch) => ({
+ toggleMobileFacets: () => {
+ dispatch(toggleMobileFacetsAction());
+ },
+});
+
+function mapStateToProps(state, ownProps) {
+ const { browser, productPicker } = state;
+ const { showMobileFacets } = productPicker;
+
+ return {
+ isMobile: browser.lessThan.medium,
+ showMobileFacets,
+ browser,
+ };
+}
+export default withSearch(
+ ({
+ facets, filters, removeFilter,
+ }) => ({
+ facets, filters, removeFilter,
+ }),
+)(connect(
+ mapStateToProps,
+ mapDispatchToProps,
+)(Facets));
diff --git a/web/js/components/layer/product-picker/search/filter-chips.js b/web/js/components/layer/product-picker/search/filter-chips.js
new file mode 100644
index 000000000..f62af9588
--- /dev/null
+++ b/web/js/components/layer/product-picker/search/filter-chips.js
@@ -0,0 +1,36 @@
+import React from 'react';
+import PropTypes from 'prop-types';
+import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
+import { faTimes } from '@fortawesome/free-solid-svg-icons';
+
+export default function FilterChips(props) {
+ const {
+ filters,
+ removeFilter,
+ } = props;
+
+ console.log(filters);
+
+ return !filters.length ? null : (
+ <div className="bag-o-chips">
+ {filters.flatMap(({ field, values }) => values.map((filterVal) => (
+ <div
+ key={field + filterVal}
+ className="filter-chip"
+ onClick={() => removeFilter(field, filterVal)}
+ >
+ {filterVal}
+ <FontAwesomeIcon
+ icon={faTimes}
+ fixedWidth
+ />
+ </div>
+ )))}
+ </div>
+ );
+}
+
+FilterChips.propTypes = {
+ filters: PropTypes.array,
+ removeFilter: PropTypes.func,
+};
diff --git a/web/js/components/layer/product-picker/search/search-layers.js b/web/js/components/layer/product-picker/search/search-layers.js
index 6795b3aaa..b435995db 100644
--- a/web/js/components/layer/product-picker/search/search-layers.js
+++ b/web/js/components/layer/product-picker/search/search-layers.js
@@ -1,17 +1,15 @@
import React from 'react';
import { connect } from 'react-redux';
import PropTypes from 'prop-types';
-import { Button } from 'reactstrap';
import { withSearch } from '@elastic/react-search-ui';
import SearchLayerList from './search-layers-list';
-import ProductFacet from './product-facet';
+import Facets from './facets';
import Scrollbars from '../../../util/scrollbar';
import LayerMetadataDetail from './layer-metadata-detail';
import {
updateListScrollTop,
toggleMobileFacets as toggleMobileFacetsAction,
} from '../../../../modules/product-picker/actions';
-import facetConfig from '../../../../modules/product-picker/facetConfig';
function SearchLayers(props) {
const {
@@ -19,9 +17,7 @@ function SearchLayers(props) {
browser,
selectedLayer,
bodyHeight,
- facets,
showMobileFacets,
- toggleMobileFacets,
} = props;
const listDetailContainerClass = selectedLayer
@@ -30,45 +26,11 @@ function SearchLayers(props) {
const showFacets = browser.greaterThan.small || showMobileFacets;
const showListAndDetails = isMobile ? !showFacets : true;
- const facetHeight = isMobile ? 'calc(100vh - 125px)' : '100%';
return (
<div className="search-layers-container" style={{ height: bodyHeight }}>
- {showFacets && (
- <div className="facet-container">
- <Scrollbars style={{ height: facetHeight }}>
- <div className="inner-container">
- {facetConfig.map((config) => {
- const facet = facets[config.field];
- const data = (facet && facet.length && facet[0].data) || [];
- return (
- <ProductFacet
- key={config.field}
- field={config.field}
- label={config.label}
- filterType={config.filterType}
- tooltip={config.tooltip}
- show={config.show}
- view={config.view}
- data={data}
- />
- );
- })}
- </div>
- </Scrollbars>
-
- {isMobile && showMobileFacets && (
- <Button
- className="apply-facets"
- onClick={toggleMobileFacets}
- >
- Apply
- </Button>
- )}
- </div>
- )}
-
+ <Facets />
{showListAndDetails && (
<div className={listDetailContainerClass}>
diff --git a/web/js/components/util/switch.js b/web/js/components/util/switch.js
index e2931f1f3..b9765cc18 100644
--- a/web/js/components/util/switch.js
+++ b/web/js/components/util/switch.js
@@ -54,11 +54,11 @@ const Switch = (props) => {
{tooltip
&& (
<>
- <FontAwesomeIcon icon={faInfoCircle} id="availability-filter" />
+ <FontAwesomeIcon icon={faInfoCircle} id="switch-tooltip" />
<Tooltip
placement="right"
isOpen={tooltipOpen}
- target="availability-filter"
+ target="switch-tooltip"
toggle={() => { toggleTooltip(!tooltipOpen); }}
>
{tooltip}
diff --git a/web/js/modules/product-picker/formatConfig.js b/web/js/modules/product-picker/formatConfig.js
index d26c1a7a0..e806213a5 100644
--- a/web/js/modules/product-picker/formatConfig.js
+++ b/web/js/modules/product-picker/formatConfig.js
@@ -121,8 +121,10 @@ export default function buildLayerFacetProps(config, selectedDate) {
return lodashMap(layers, (layer) => {
const { conceptId } = layer;
- const { processingLevelId } = collections[conceptId];
- layer.processingLevelId = processingLevelId;
+ const collectionData = (conceptId && collections[conceptId]) || {};
+ if (collectionData.processingLevelId) {
+ layer.processingLevelId = collectionData.processingLevelId;
+ }
layer.availableAtDate = availableAtDate(layer, selectedDate).toString();
getLayerPeriodFacetProps(layer);
getOrbitTrackRelatedFacetProps(layer, layers);