Skip to content

Interactive interface for browsing global, full-resolution satellite imagery

add a featured tab and category. show measurement view for tab contents

Jason Kent089bce54859b
diff --git a/config/default/common/config/wv.json/categories/featured/All.json b/config/default/common/config/wv.json/categories/featured/All.json
new file mode 100644
index 000000000..97ba00a6c
--- /dev/null
+++ b/config/default/common/config/wv.json/categories/featured/All.json
@@ -0,0 +1,15 @@
+{
+ "categories": {
+ "featured": {
+ "All": {
+ "title": "All",
+ "placement": "first",
+ "id": "featured-all",
+ "description": "",
+ "measurements": [
+ "Geostationary"
+ ]
+ }
+ }
+ }
+}
diff --git a/web/js/components/layer/product-picker/header.js b/web/js/components/layer/product-picker/header.js
index 6cc276815..c12ca29e2 100644
--- a/web/js/components/layer/product-picker/header.js
+++ b/web/js/components/layer/product-picker/header.js
@@ -47,7 +47,8 @@ class ProductPickerHeader extends React.Component {
render() {
const isAutoFocus = !util.browser.touchDevice;
const { selectedProjection, listType, category, width } = this.props;
- const isBreadCrumb =
+ const categoryId = category && category.id;
+ const isBreadCrumb = categoryId !== 'featured-all' &&
selectedProjection === 'geographic' &&
listType !== 'category' &&
width > 650;
diff --git a/web/js/components/layer/product-picker/product-picker.js b/web/js/components/layer/product-picker/product-picker.js
index 2c1ee86a3..72873e635 100644
--- a/web/js/components/layer/product-picker/product-picker.js
+++ b/web/js/components/layer/product-picker/product-picker.js
@@ -34,7 +34,7 @@ class ProductPicker extends React.Component {
super(props);
this.state = {
listType: props.listType,
- categoryType: Object.keys(props.categoryConfig)[0],
+ categoryType: Object.keys(props.categoryConfig)[1],
category: props.category,
selectedMeasurement: null,
filteredRows: props.filteredRows,
@@ -51,24 +51,34 @@ class ProductPicker extends React.Component {
*/
runSearch(value) {
const { filterProjections, filterSearch, allLayers } = this.props;
+ const { categoryType } = this.state;
const val = value.toLowerCase();
+ let newState;
+
+ // Search cleared
if (val.length === 0) {
- this.setState({
+ newState = {
filteredRows: [],
listType: 'category',
inputValue: ''
- });
+ };
+ if (categoryType === 'featured') {
+ this.toggleFeatureTab(newState);
+ return;
+ }
+ // Search with terms
} else {
const terms = val.split(/ +/);
- const filteredRows = allLayers.filter(function(layer) {
+ const filteredRows = allLayers.filter((layer) => {
return !(filterProjections(layer) || filterSearch(layer, val, terms));
});
- this.setState({
+ newState = {
filteredRows: filteredRows,
listType: 'search',
inputValue: value
- });
+ };
}
+ this.setState(newState);
}
/**
@@ -103,6 +113,22 @@ class ProductPicker extends React.Component {
}
}
+ toggleFeatureTab = (partialState) => {
+ const categoryType = 'featured';
+ const { categoryConfig, measurementConfig } = this.props;
+ const category = categoryConfig[categoryType].All;
+ const selectedMeasurement = category.measurements[0];
+ const selectedMeasurementId = measurementConfig[selectedMeasurement].id;
+
+ this.setState({
+ ...partialState,
+ categoryType,
+ category,
+ listType: 'measurements',
+ selectedMeasurement: selectedMeasurementId
+ });
+ }
+
/**
* Update category type in which to sort
* e.g. Hazards and disasters or science
@@ -110,9 +136,16 @@ class ProductPicker extends React.Component {
* @param {String} key | categoryType identifier
*/
sort(key) {
- this.setState({
- categoryType: key
- });
+ if (key === 'featured') {
+ this.toggleFeatureTab();
+ } else {
+ this.setState({
+ categoryType: key,
+ listType: 'category',
+ selectedMeasurement: null
+ });
+ }
+
googleTagManager.pushEvent({
event: 'layers_meta_category',
layers: {
@@ -146,8 +179,13 @@ class ProductPicker extends React.Component {
isMobile,
onToggle
} = this.props;
- const isCategoryDisplay =
- listType === 'category' && selectedProjection === 'geographic';
+ const isCategoryDisplay = listType === 'category' && selectedProjection === 'geographic';
+ const showCategoryTabs = isCategoryDisplay || categoryType === 'featured';
+ const categoryKeys = [
+ 'hazards and disasters',
+ 'scientific',
+ 'featured'
+ ];
return (
<React.Fragment>
@@ -169,24 +207,20 @@ class ProductPicker extends React.Component {
<ModalBody>
<div id="layer-modal-content" className="layer-modal-content">
- {isCategoryDisplay ? (
+ {showCategoryTabs && (
<Nav tabs id="categories-nav" className="categories-nav">
- {Object.keys(categoryConfig).map(sortKey => (
+ {categoryKeys.map(sortKey => (
<NavItem
key={sortKey}
className="layer-category-navigation"
active={sortKey === categoryType}
>
<NavLink onClick={this.sort.bind(this, sortKey)}>
- {sortKey === 'scientific'
- ? 'Science Disciplines'
- : sortKey}
+ {sortKey === 'scientific' ? 'Science Disciplines' : sortKey}
</NavLink>
</NavItem>
))}
</Nav>
- ) : (
- ''
)}
<Scrollbars style={{ maxHeight: height - 40 + 'px' }}>