Interactive interface for browsing global, full-resolution satellite imagery
init embed mode feature
Ed Plato88a319f6e418
diff --git a/README.md b/README.mdindex 9bcf583af..8245664dc 100644--- a/README.md+++ b/README.md@@ -88,6 +88,7 @@ To update Worldview, pull down any branch or tag from GitHub. From the `main` br- [Uploading](doc/upload.md)- [Docker](doc/docker.md)- [Data Download (Smart Handoffs)](doc/smart_handoffs.md)+- [Embed Mode](doc/embed.md)- [Release Notes](doc/release_notes.md)- [Changelog](CHANGELOG.md)diff --git a/config/default/common/config/wv.json/stories/iceberg/larsen_c_ice_shelf_iceberg_a68a_july_2017.json b/config/default/common/config/wv.json/stories/iceberg/larsen_c_ice_shelf_iceberg_a68a_july_2017.jsonindex 6c8d17ebe..4dd3d2f79 100644--- a/config/default/common/config/wv.json/stories/iceberg/larsen_c_ice_shelf_iceberg_a68a_july_2017.json+++ b/config/default/common/config/wv.json/stories/iceberg/larsen_c_ice_shelf_iceberg_a68a_july_2017.json@@ -4,7 +4,7 @@"id": "larsen_c_ice_shelf_iceberg_a68a_july_2017","type": "iceberg","title": "Larsen C Ice Shelf / Iceberg A68A - July 2017",- "description": "Explore the Larsen C Ice Shelf using different map projections, zoom levels and layers. Use the event tab to quickly acess other events.",+ "description": "Explore the Larsen C Ice Shelf using different map projections, zoom levels and layers. Use the event tab to quickly access other events.","backgroundImage": "background.png","backgroundImageHover": "","readMoreLinks": [diff --git a/doc/branding.md b/doc/branding.mdindex 86fd1a1de..1a3270a08 100644--- a/doc/branding.md+++ b/doc/branding.md@@ -14,7 +14,7 @@ Update the following fields in `config/default/common/brand.json` with custom brNaming can be more specific by omitting the `name` field and usingthe following instead:-* `officalName`: Full name of the application (i.e. `EOSDIS Worldview`).+* `officialName`: Full name of the application (i.e. `EOSDIS Worldview`).* `shortName`: Short name of the application (i.e. `Worldview`).To add a logo, replace `config/default/common/brand/images/wv-logo.png` with an imagediff --git a/doc/config/configuration.md b/doc/config/configuration.mdindex ce1a91e98..b53580e02 100644--- a/doc/config/configuration.md+++ b/doc/config/configuration.md@@ -22,7 +22,7 @@ To quickly switch between different configurations, use a symlink for `config/acAfter making any changes to configuration files, rebuild the app for the changes to take effect.Use the `npm run build` command to make a request to [the GIBS GetCapabilities API](https://wiki.earthdata.nasa.gov/display/GIBS/GIBS+API+for+Developers) to update layer configurations and rebuild the-configuration file used by the application. After a successful buid, this file can be found at: `build/options/config/wv.json`+configuration file used by the application. After a successful build, this file can be found at: `build/options/config/wv.json`If you want to only rebuild `wv.json`, using GetCapabilities files that were previously requested,(e.g. if you are just modifying some configs locally and want to test your changes)diff --git a/doc/config/layers.md b/doc/config/layers.mdindex 419251fa9..1b0a55fd2 100644--- a/doc/config/layers.md+++ b/doc/config/layers.md@@ -112,7 +112,7 @@ Example:* **recommended**: Array of custom palette identifiers that are recommended for use with this layer (see [`config/default/common/config/palettes-custom.json`](../../config/default/common/config/palettes-custom.json)). Example, *["orange_1", "red_1"]** **immutable**(optional): When this flag is set to true, the options to adjust thresholds and colormaps are removed.* **availability**: Used to denote datetime availability info that cannot be gleaned from the capabilities document. Primarily for our geostationary layers which only have historical coverage going back ~30 days. Represented as an object with the following properties:- * **rollingWindow**: Number of days, counting backwards from app load time, that a layer has avilable coverage. Setting this will cause a layer's `startDate` property to be dynamically set at app load time.+ * **rollingWindow**: Number of days, counting backwards from app load time, that a layer has available coverage. Setting this will cause a layer's `startDate` property to be dynamically set at app load time.* **historicalRanges**: An array of date range objects denoting specific time periods in the past when imagery is available. Each range object should have the following properties:* startDate - `YYYY-MM-DDTHH:MM:SSZ`* endDate - `YYYY-MM-DDTHH:MM:SSZ`diff --git a/doc/config/vectors.md b/doc/config/vectors.mdindex 3eaf86c20..7039c11ca 100644--- a/doc/config/vectors.md+++ b/doc/config/vectors.md@@ -40,11 +40,11 @@ To display a custom vector layer style & legend, a *vectorStyle* property should## Creating Custom Vector Styles-Vector layers created from the Global Imagery Browse Services (GIBS) will have a default style.json file associated with the layer defined in the GIBS WMTS GetCapabilities document. The vector style JSON file follows the [mapbox-gl-js style spec](https://docs.mapbox.com/mapbox-gl-js/style-spec/). The layey's default style will be extracted from the GetCapabilities document and assigned to it's associated layer on build.+Vector layers created from the Global Imagery Browse Services (GIBS) will have a default style.json file associated with the layer defined in the GIBS WMTS GetCapabilities document. The vector style JSON file follows the [mapbox-gl-js style spec](https://docs.mapbox.com/mapbox-gl-js/style-spec/). The layer's default style will be extracted from the GetCapabilities document and assigned to it's associated layer on build.## Vector Style Example-The following is an example of a basic vector style. This vector layer is referenced in the "source-layer" and has line, point, and label features being styled. Each unique "source" defined within the vector style document will add a new style option to the layer settings panel and can be passed to the layer's style param in the URL. The legend in the layer settings panel will be rendered using the color identified in the style's paint settings (with circle taking presendence over line, polygon and label).+The following is an example of a basic vector style. This vector layer is referenced in the "source-layer" and has line, point, and label features being styled. Each unique "source" defined within the vector style document will add a new style option to the layer settings panel and can be passed to the layer's style param in the URL. The legend in the layer settings panel will be rendered using the color identified in the style's paint settings (with circle taking precedence over line, polygon and label).For more information on how to configure a mapbox-gl-js style spec, please refer to the [documentation]((https://docs.mapbox.com/mapbox-gl-js/style-spec/)).diff --git a/doc/developing.md b/doc/developing.mdindex ee56b7c36..3db47ebff 100644--- a/doc/developing.md+++ b/doc/developing.md@@ -34,7 +34,7 @@ To build the app with an incomplete configuration, prefix the command like this:**`npm run watch`**: Builds and serves local Development mode Webpack bundle in watch mode using Webpack Dev Server (*Note: It is necessary to wait for the initial build to finish before being able to develop*). JS and CSS bundles are updated automatically when source files change. You must run `npm run build` or `npm run build:config` first to make a request to the GIBS `GetCapabilities` API and build the configuration files.**`npm run watch:debug:logger`**: This will activate `redux-logger` which logs the before and after state of each action.-**`npm run watch:debug:devtools`**: This will activate `redux-devtools` which allows using a browser exetension to debug Redux state.+**`npm run watch:debug:devtools`**: This will activate `redux-devtools` which allows using a browser extension to debug Redux state.## Startingdiff --git a/doc/embed.md b/doc/embed.mdnew file mode 100644index 000000000..58257e4e0--- /dev/null+++ b/doc/embed.md@@ -0,0 +1,9 @@+# Embed mode++To embed NASA Worldview in your page, navigate to the share toolbar, select the `embed` tab and copy the embed link.++**Note:** Certain application features and interactions are not available in embed mode. Please try to think of a way to share your concept using the available features. We recommend to not share more layers than necessary and to provide detailed captions to help the user better understand the science concepts you are presenting.++TODO:+IFRAME+WIDTH/HEIGHTdiff --git a/doc/testing.md b/doc/testing.mdindex 0af699472..cd6acc366 100644--- a/doc/testing.md+++ b/doc/testing.md@@ -30,7 +30,7 @@ To run the end-to-end tests using Firefox in a docker container, create an image### Browserstack-Run `npm run browserstack` to test the app in `Chrome(OS X and Windows)`, `Firefox(Windows)`, `Internet Exporer(windows)`, and `Safari(OS X)` on BrowserStack. The tests run the `nightwatch.js` features found in `./e2e/features` using Selenium.+Run `npm run browserstack` to test the app in `Chrome(OS X and Windows)`, `Firefox(Windows)`, `Internet Explorer(windows)`, and `Safari(OS X)` on BrowserStack. The tests run the `nightwatch.js` features found in `./e2e/features` using Selenium.To run tests in BrowserStack from your local machine:@@ -73,7 +73,7 @@ To run tests for both browsers in sequence: `npm run e2e`.| `mockFutureLayer` | String | *`VIIRS_NOAA20_CorrectedReflectance_TrueColor,5D`*| Pass layer `id` and `futureTime` to be parsed and added to that layer on page load || `mockSources` | String | *`20170530`* | Use the static JSON file with sources feeds found at mock/sources\_data.json-X || `mockAlerts` | string | *`alert`*, *`message`*, *`outage`*, *`no_types`*, or *`all_types`* | Use a static JSON file by passing the notification type. Local sources can be found at mock/notify_{string}.json |-| `modalView` | string | *`categories`*, *`measurements`*, or *`layers`* | Forces the 'Add Layers' modal to display categories, measurements, or layers. By default Artic/Antarctic shows measurements and Geographic shows categories. |+| `modalView` | string | *`categories`*, *`measurements`*, or *`layers`* | Forces the 'Add Layers' modal to display categories, measurements, or layers. By default Arctic/Antarctic shows measurements and Geographic shows categories. || `now` | date | *`YYYY-MM-DDThh:mm:ssZ`* | Overrides the current date and time. This only works when using the `now()` function from `js/util/util.js`. || `showError` | boolean | *`true` or `false`* | If any value is specified, an error dialog will be shown on startup. || `showSubdaily` | boolean | *`true` or `false`* | If any value is specified, the hour input, minute input and "minutes" timeline zoom option will be shown. |diff --git a/doc/url_parameters.md b/doc/url_parameters.mdindex 138c84567..5971f36f3 100644--- a/doc/url_parameters.md+++ b/doc/url_parameters.md@@ -31,6 +31,8 @@| `cv` | Number | **`0`** to **`100`** | If `ca='true|false'`, The `cv` parameter is used to determine the location of the swiper or the value of opacity depending on the selected mode. Default is `50` which will place the swiper on the middle of any screen. This parameter is irrelevant when the `spy` mode is active (`cm=spy`) || `download` | string | _`product_id`_ | If any value is set, the data download tab will be activated. If a product identifier is set, the corresponding will be selected. || `r` | number | **`-180.0000`** to **`180.0000`** | The degree of map rotation. Only applies when `arctic` or `antarctic` projection is selected. |+| `df` | boolean | _`true`_ or _`false`_ | If `true` value is set, distraction free mode will be activated. Distraction free mode is disabled by default and can be toggled from the Information toolbar menu. |+| `em` | boolean | _`true`_ or _`false`_ | If `true` value is set, embed mode will be activated. Embed mode is disabled by default. || `tr` | string | _`tour_id`_ | The id of the tour story to load. Stories will load from step 1. |\* _1 = yearly, 2 = monthly, 3 = daily, 4 = hourly, and 5 = minutely. The subdaily zoom levels (4 & 5) will only be available when subdaily layers are active._diff --git a/web/css/compare.css b/web/css/compare.cssindex 6757ee381..c11d14423 100644--- a/web/css/compare.css+++ b/web/css/compare.css@@ -8,13 +8,25 @@cursor: move;cursor: grab;user-select: none;+ & .show-date-label {+ width: 98px;+ }+ & .left-label {+ left: -23px;+ &.show-date-label {+ left: -107px;+ }+ }+ & .right-label {+ left: 13px;+ }}.ab-swipe-line:active {cursor: grabbing;}.ab-swipe-dragger {position: absolute;- bottom: 30%;+ bottom: 210px;width: 65px;height: 65px;margin-top: -45px;@@ -38,19 +50,13 @@font-size: 26px;margin-top: 11px;}-.ab-swipe-line .left-label {- left: -23px;-}-.ab-swipe-line .right-label {- left: 13px;-}.ab-slider-case {position: absolute;margin-left: auto;margin-right: auto;left: 0;right: 0;- bottom: 25%;+ bottom: 195px;width: 232px;text-align: center;background: rgba(40, 40, 40, 0.85);@@ -83,7 +89,7 @@}.ab-swipe-line .ab-swipe-span {position: absolute;- bottom: 25%;+ bottom: 195px;padding: 2px;background: #fff;color: #000;diff --git a/web/css/embedded.css b/web/css/embedded.cssnew file mode 100644index 000000000..5115520ec--- /dev/null+++ b/web/css/embedded.css@@ -0,0 +1,109 @@+.embed-overlay-bg {+ position: absolute;+ top: 0;+ left: 0;+ height: 100%;+ width: 100%;+ background-color: rgba(0,0,0,0.5);+ z-index: 101;+}++.embed-overlay-btn {+ pointer-events: none;+ width: 220px;+ height: 100px;+ padding-top: 10px;+ line-height: 50px;+ position: fixed;+ top: 50%;+ left: 50%;+ margin-top: -50px;+ margin-left: -110px;+ background-color: rgba(40,40,40,.85);+ border-radius: 5px;+ border: 3px solid;+ border-color: #fff;+ text-align: center;+ color: #fff;+ z-index: 102;+ & p {+ font-size: 16px;+ }+}++#wv-embed-button {+ position: absolute;+ z-index: 102;+ top: 10px;+ right: 10px;+ font-size: 14px;+ padding: 2.5px 4px;+}++.embedded-mode {+ #wv-toolbar {+ display: none;+ }++ #productsHolder {+ width: 125px !important;+ height: calc(var(--vh, 1vh) * 100 - 220px);+ }++ #wv-sidebar {+ #download-sidebar-tab {+ display: none;+ }+ footer {+ display: none;+ }+ .group-overlays-checkbox {+ display: none;+ }+ .item.productsitem {+ & .layer-main {+ margin-left: 0;+ }+ &.layer-hidden {+ display: none;+ }+ .layer-enabled.layer-visible {+ display: none;+ }+ &.zotted div.zot {+ display: none;+ }+ & .layer-buttons {+ background: #ccc;+ width: 20px;+ & .wv-layers-options {+ display: none;+ }+ & .wv-layers-close {+ display: none;+ }+ }+ }+ .wv-palettes-colorbar {+ max-width: 100%;+ }+ }++ #wv-measure-button {+ display: none;+ }++ #ol-coords-case {+ bottom: 8px;+ }++ .wv-map-scale-imperial {+ bottom: 50px;+ right: 12px;+ }++ .wv-map-scale-metric {+ bottom: 68px;+ right: 12px;+ }+}diff --git a/web/css/link.css b/web/css/link.cssindex d15879246..36fb2d52d 100644--- a/web/css/link.css+++ b/web/css/link.css@@ -103,13 +103,11 @@}.social-share {- padding-top: 12px;display: -webkit-box;display: -ms-flexbox;display: flex;-ms-flex-pack: distribute;justify-content: space-around;- border-top: 1px solid #555;}.social-share .icon-link {@@ -124,6 +122,14 @@text-align: center;cursor: pointer;text-decoration: none;+ border: 2px solid transparent;+ transition: border 0.4s;+ &:hover {+ border: 2px solid #fff;+ }+ & svg.svg-inline--fa {+ margin-bottom: 2px;+ }}.social-share .social-icon-container-facebook {@@ -141,3 +147,46 @@.social-share .social-icon-container-email {background-color: #505050;}++.share-body {+ height: 108px;+}++.share-nav-container {+ .share-tab-link {+ p {+ padding: 10px 0 21px;+ }+ }+ .share-tab-embed {+ p {+ padding: 10px 0 5px;+ }+ }+ .share-tab-social {+ p {+ padding: 10px 0 5px;+ }+ }++ a:not(.share-embed-doc-link) {+ color: #fff;+ user-select: none;+ cursor: pointer;+ &:hover:not(.active) {+ color: #fff !important;+ text-decoration: none;+ }+ }+ a.share-embed-doc-link {+ color: #7bf;+ &:hover {+ color: #7df;+ }+ }+ .wv-checkbox {+ position: absolute;+ right: 12px;+ top: 55px;+ }+}\ No newline at end of filediff --git a/web/css/mobile.css b/web/css/mobile.cssindex e5cba1519..38a305e7b 100644--- a/web/css/mobile.css+++ b/web/css/mobile.css@@ -1,156 +1,158 @@@media only screen and (max-width: 768px) {- #wv-sidebar {- position: static;- }- #productsHolder {- display: block;- float: left;- left: 0;- min-width: 238px;- width: 100%;- height: 100%;- position: absolute !important;- overflow: hidden;- background: rgb(38, 43, 49);- top: 0;- z-index: 1000;- }+ #wv-content:not(.embedded-mode) {+ #wv-sidebar {+ position: static;+ }+ #productsHolder {+ display: block;+ float: left;+ left: 0;+ min-width: 238px;+ width: 100%;+ height: 100%;+ position: absolute !important;+ overflow: hidden;+ background: rgb(38, 43, 49);+ top: 0;+ z-index: 1000;+ }- .sidebar-panel {- height: 96%;- }+ .sidebar-panel {+ height: 96%;+ }- #selectorboxcontent {- max-height: 97%;- }+ #selectorboxcontent {+ max-height: 97%;+ }- img.sidebar-panel-item-img {- display: block;- height: 1.6em;- width: auto;- }+ img.sidebar-panel-item-img {+ display: block;+ height: 1.6em;+ width: auto;+ }- #productsHolder li.third {- display: none;- }+ #productsHolder li.third {+ display: none;+ }- #wv-logo {- background: url('../brand/images/wv-logo-mobile.svg?v=@BUILD_NONCE@')- no-repeat center rgba(40, 40, 40, 0.85);- display: block;- height: 42px;- width: 56px;- padding: 5px;- border-radius: 5px;- border: 1px solid #333;- }+ #wv-logo {+ background: url('../brand/images/wv-logo-mobile.svg?v=@BUILD_NONCE@')+ no-repeat center rgba(40, 40, 40, 0.85);+ display: block;+ height: 42px;+ width: 56px;+ padding: 5px;+ border-radius: 5px;+ border: 1px solid #333;+ }- a.staticLayers:not([href]):not([tabindex]) {- height: 45px;- width: 56px;- background-image: none;- border-radius: 5px;- top: 58px;- & svg.svg-inline--fa {- font-size: 33px;- position: absolute;- left: 10px;- top: 5px;- color: #fff;- }- & span.layer-count {- color: #fff;- position: relative;- top: 9px;- font-size: 18px;- font-weight: 600;- background: #333;- border-radius: 50%;- padding: 0 5px;- text-align: center;- margin-left: 0;+ a.staticLayers:not([href]):not([tabindex]) {+ height: 45px;+ width: 56px;+ background-image: none;+ border-radius: 5px;+ top: 58px;+ & svg.svg-inline--fa {+ font-size: 33px;+ position: absolute;+ left: 10px;+ top: 5px;+ color: #fff;+ }+ & span.layer-count {+ color: #fff;+ position: relative;+ top: 9px;+ font-size: 18px;+ font-weight: 600;+ background: #333;+ border-radius: 50%;+ padding: 0 5px;+ text-align: center;+ margin-left: 0;+ }}- }- a.staticLayers:not([href]):not([tabindex]):hover {- background-image: none;- }+ a.staticLayers:not([href]):not([tabindex]):hover {+ background-image: none;+ }- a.staticLayers::after {- display: none;- }+ a.staticLayers::after {+ display: none;+ }- #wv-toolbar li {- display: block;- float: left;- margin: 1px;- }+ #wv-toolbar li {+ display: block;+ float: left;+ margin: 1px;+ }- #wv-toolbar #wv-image-button {- display: none;- }+ #wv-toolbar #wv-image-button {+ display: none;+ }- .wv-toolbar-button {- font-size: 14.3px;- height: 44px;- margin: 0 0 0 4px;- padding: 5.72px 9.1px;- }+ .wv-toolbar-button {+ font-size: 14.3px;+ height: 44px;+ margin: 0 0 0 4px;+ padding: 5.72px 9.1px;+ }- div.olControlScaleLineCustom {- bottom: 10px;- }+ div.olControlScaleLineCustom {+ bottom: 10px;+ }- .olControlScaleLineCustomBottom {- display: none;- }+ .olControlScaleLineCustomBottom {+ display: none;+ }- div.olControlMousePosition {- display: none;- }+ div.olControlMousePosition {+ display: none;+ }- div.olControlMousePosition,- div.olControlScaleLineCustom {- display: none !important;- }+ div.olControlMousePosition,+ div.olControlScaleLineCustom {+ display: none !important;+ }- .wv-coords-map {- display: none !important;- }+ .wv-coords-map {+ display: none !important;+ }- button#layers-add,- button#compare-toggle-button {- width: 100%;- position: relative;- left: 0;- height: 50px;- span {- font-size: 18px;+ button#layers-add,+ button#compare-toggle-button {+ width: 100%;+ position: relative;+ left: 0;+ height: 50px;+ span {+ font-size: 18px;+ }}- }- #selected-category .ui-tabs-panel {- clear: both;- margin-left: 0;- border-top: 2px solid #d54e21;- padding: 10px 0 0;- }+ #selected-category .ui-tabs-panel {+ clear: both;+ margin-left: 0;+ border-top: 2px solid #d54e21;+ padding: 10px 0 0;+ }- #selected-category .ui-tabs .ui-tabs-nav {- margin-bottom: 15px;- }+ #selected-category .ui-tabs .ui-tabs-nav {+ margin-bottom: 15px;+ }- #categories-nav label {- font-size: 1em;- position: relative;- padding-top: 1px;- }+ #categories-nav label {+ font-size: 1em;+ position: relative;+ padding-top: 1px;+ }- .button-label-scientific {- top: -2px;- }+ .button-label-scientific {+ top: -2px;+ }- #selected-category .ui-tabs-panel li.measurement-settings-item {- margin-left: 0;+ #selected-category .ui-tabs-panel li.measurement-settings-item {+ margin-left: 0;+ }}-}+}\ No newline at end of filediff --git a/web/js/app.js b/web/js/app.jsindex c7914f51e..cbfb675b1 100644--- a/web/js/app.js+++ b/web/js/app.js@@ -20,6 +20,7 @@ import LocationSearch from './components/location-search/location-search';// Other/MISCimport Brand from './brand';+import Embed from './containers/embed';import MeasureButton from './components/measure-tool/measure-button';import FeatureAlert from './components/feature-alert/alert';import Alerts from './containers/alerts';@@ -84,6 +85,7 @@ import '../css/orbitTracks.css';import '../css/facets.css';import '../css/recent-layers.css';import '../css/location-search.css';+import '../css/embedded.css';require('@elastic/react-search-ui-views/lib/styles/styles.css');@@ -163,15 +165,17 @@ class App extends React.Component {render() {const {isAnimationWidgetActive,+ isEmbedModeActive,isMobile,isTourActive,locationKey,modalId,parameters,} = this.props;+ const appClass = `wv-content ${isEmbedModeActive ? 'embedded-mode' : ''}`;return (- <div className="wv-content" id="wv-content" data-role="content">- {!isMobile && <LocationSearch />}+ <div className={appClass} id="wv-content" data-role="content">+ {!isMobile && !isEmbedModeActive && <LocationSearch />}<Toolbar /><MapInteractions /><div id="wv-alert-container" className="wv-alert-container">@@ -189,6 +193,7 @@ class App extends React.Component {{isAnimationWidgetActive ? <AnimationWidget key={locationKey || '2'} /> : null}</div><MeasureButton />+ <Embed /><Modal key={modalId} /><ErrorBoundary><Debug parameters={parameters} />@@ -202,6 +207,7 @@ function mapStateToProps(state) {return {state,isAnimationWidgetActive: state.animation.isActive,+ isEmbedModeActive: state.embed.isEmbedModeActive,isMobile: state.browser.lessThan.medium,isTourActive: state.tour.active,tour: state.tour,@@ -227,6 +233,7 @@ export default connect(App.propTypes = {isAnimationWidgetActive: PropTypes.bool,+ isEmbedModeActive: PropTypes.bool,isMobile: PropTypes.bool,isTourActive: PropTypes.bool,keyPressAction: PropTypes.func,diff --git a/web/js/components/sidebar/nav/nav-case.js b/web/js/components/sidebar/nav/nav-case.jsindex 237883ff5..123c88e4c 100644--- a/web/js/components/sidebar/nav/nav-case.js+++ b/web/js/components/sidebar/nav/nav-case.js@@ -11,6 +11,7 @@ function NavCase (props) {tabTypes,isMobile,isCompareMode,+ isEventsTabDisabledEmbed,onTabClick,activeTab,isDataDisabled,@@ -84,7 +85,7 @@ function NavCase (props) {: `${tabClasses} first-tab`}/>- {renderEvents()}+ {!isEventsTabDisabledEmbed && renderEvents()}{renderDataDownload()}<div className="toggleIconHolder"><UncontrolledTooltip placement="right" target="accordion-toggler-button">@@ -103,6 +104,7 @@ function NavCase (props) {NavCase.propTypes = {activeTab: PropTypes.string,+ isEventsTabDisabledEmbed: PropTypes.bool,isCompareMode: PropTypes.bool,isDataDisabled: PropTypes.bool,isMobile: PropTypes.bool,diff --git a/web/js/components/timeline/timeline-coverage/coverage-item-container.js b/web/js/components/timeline/timeline-coverage/coverage-item-container.jsindex 2964f96d8..b36cba57b 100644--- a/web/js/components/timeline/timeline-coverage/coverage-item-container.js+++ b/web/js/components/timeline/timeline-coverage/coverage-item-container.js@@ -56,7 +56,7 @@ class CoverageItemContainer extends Component {*/getDateRangeToDisplay = (dateRanges) => {const { getMaxEndDate, getDatesInDateRange, layer } = this.props;- const multiDateToDisplay = dateRanges.reduce((mutliCoverageDates, range, innerIndex) => {+ const multiDateToDisplay = dateRanges.reduce((multiCoverageDates, range, innerIndex) => {const { dateInterval, startDate, endDate } = range;const isLastInRange = innerIndex === dateRanges.length - 1;const rangeInterval = Number(dateInterval);@@ -67,16 +67,16 @@ class CoverageItemContainer extends Component {const endDateTime = new Date(endDate).getTime();const dateIntervalStartDates = getDatesInDateRange(layer, range, endDateLimit, isLastInRange);- // add date intervals to mutliCoverageDates object to catch repeats+ // add date intervals to multiCoverageDates object to catch repeatsdateIntervalStartDates.forEach((dateIntStartDate) => {const dateIntTime = new Date(dateIntStartDate).getTime();// allow overwriting of subsequent date rangesif (dateIntTime >= startDateTime && startDateTime <= endDateTime) {const dateIntFormatted = dateIntStartDate.toISOString();- mutliCoverageDates[dateIntFormatted] = { date: dateIntFormatted, interval: rangeInterval };+ multiCoverageDates[dateIntFormatted] = { date: dateIntFormatted, interval: rangeInterval };}});- return mutliCoverageDates;+ return multiCoverageDates;}, {});return Object.values(multiDateToDisplay);diff --git a/web/js/containers/embed.js b/web/js/containers/embed.jsnew file mode 100644index 000000000..27812df70--- /dev/null+++ b/web/js/containers/embed.js@@ -0,0 +1,105 @@+import React from 'react';+import PropTypes from 'prop-types';+import { connect } from 'react-redux';+import { Button, UncontrolledTooltip } from 'reactstrap';+import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';+import { getPermalink } from '../modules/link/util';+import getSelectedDate from '../modules/date/selectors';+import history from '../main';++class Embed extends React.Component {+ constructor(props) {+ super(props);+ this.state = {+ showOverlay: true,+ };+ this.clickOverlay = this.clickOverlay.bind(this);+ this.renderEmbedLinkBtn = this.renderEmbedLinkBtn.bind(this);+ this.newTabLink = this.newTabLink.bind(this);+ }++ clickOverlay() {+ this.setState({ showOverlay: false });+ }++ renderTooltip = (buttonId, labelText) => {+ const { isMobile } = this.props;+ return !isMobile && (+ <UncontrolledTooltip+ trigger="hover"+ target={buttonId}+ boundariesElement="window"+ placement="bottom"+ >+ {labelText}+ </UncontrolledTooltip>+ );+ }++ newTabLink() {+ const { selectedDate } = this.props;+ const queryString = history.location.search || '';+ const permalink = getPermalink(queryString, selectedDate);+ window.open(permalink, '_blank');+ }++ renderEmbedLinkBtn() {+ const buttonId = 'wv-embed-button';+ const labelText = 'Open new tab with content in Worldview';+ return (+ <Button+ id={buttonId}+ className="wv-toolbar-button"+ aria-label={labelText}+ onClick={() => this.newTabLink()}+ >+ {this.renderTooltip(buttonId, labelText)}+ <FontAwesomeIcon icon="external-link-alt" size="2x" fixedWidth />+ </Button>+ );+ }++ render() {+ const { isEmbedModeActive } = this.props;+ const { showOverlay } = this.state;+ return (+ isEmbedModeActive && (+ <>+ {showOverlay && (+ <>+ <div onClick={() => this.clickOverlay()} className="embed-overlay-bg" />+ <div className="embed-overlay-btn">+ <FontAwesomeIcon icon="hand-pointer" size="2x" fixedWidth />+ <p>Click anywhere to interact</p>+ </div>+ </>+ )}+ {this.renderEmbedLinkBtn()}+ </>+ )+ );+ }+}++function mapStateToProps(state) {+ const { browser, embed } = state;+ const { isEmbedModeActive } = embed;+ const isMobile = browser.lessThan.medium;++ return {+ isEmbedModeActive,+ isMobile,+ selectedDate: getSelectedDate(state),+ };+}++export default connect(+ mapStateToProps,+ null,+)(Embed);++Embed.propTypes = {+ isEmbedModeActive: PropTypes.bool,+ isMobile: PropTypes.bool,+ selectedDate: PropTypes.object,+};diff --git a/web/js/containers/share.js b/web/js/containers/share.jsindex c905f042f..2235ad4a4 100644--- a/web/js/containers/share.js+++ b/web/js/containers/share.js@@ -8,11 +8,12 @@ import {Input,InputGroup,Button,+ Nav, NavItem, NavLink,+ TabContent, TabPane,} from 'reactstrap';import ShareLinks from '../components/toolbar/share/links';import ShareToolTips from '../components/toolbar/share/tooltips';-import { encode, getSharelink } from '../modules/link/util';-import { serializeDate } from '../modules/date/util';+import { getPermalink, getShareLink } from '../modules/link/util';import getSelectedDate from '../modules/date/selectors';import Checkbox from '../components/util/checkbox';import { requestShortLink } from '../modules/link/actions';@@ -35,6 +36,7 @@ class ShareLinkContainer extends Component {constructor(props) {super(props);this.state = {+ activeTab: 'link',shortLinkKey: '',isShort: false,tooltipToggleTime: 0,@@ -110,37 +112,15 @@ class ShareLinkContainer extends Component {copy(url, options);}- getPermalink = () => {+ getPermalink = (isEmbed) => {const { queryString } = this.state;const { selectedDate } = this.props;- const url = window.location.href;- const prefix = url.split('?')[0];-- // if no time query string parameter, add to permalink- const isTimeInQueryString = queryString.includes('t=');- let timeParam = '';- if (!isTimeInQueryString) {- const serialized = serializeDate(selectedDate);- const encoded = encode(serialized);- timeParam = `t=${encoded}`;- }-- // add to permalink based on existing querystring- let permalink = prefix;- if (!queryString) {- permalink += `?${timeParam}`;- } else if (!isTimeInQueryString) {- permalink += `${queryString}&${timeParam}`;- } else {- permalink = url;- }-- return permalink;+ return getPermalink(queryString, selectedDate, isEmbed);}onLinkClick = (type) => {const permalink = this.getPermalink();- let shareLink = getSharelink(type, permalink);+ let shareLink = getShareLink(type, permalink);googleTagManager.pushEvent({event: 'social_share_platform',@@ -151,13 +131,13 @@ class ShareLinkContainer extends Component {if (type === 'twitter') {const newTab = window.open('', '_blank');this.getShortLink().then(({ link }) => {- shareLink = getSharelink(type, link);+ shareLink = getShareLink(type, link);}).finally(() => {newTab.location = shareLink;});} else if (type === 'email') {this.getShortLink().then(({ link }) => {- shareLink = getSharelink(type, link);+ shareLink = getShareLink(type, link);}).finally(() => {window.location = shareLink;});@@ -166,13 +146,37 @@ class ShareLinkContainer extends Component {}}- render() {+ setActiveTab = (activeTab) => {+ this.setState({ activeTab });+ }++ renderNavTabs = () => {+ const {+ activeTab,+ } = this.state;++ return (+ <Nav tabs>+ <NavItem>+ <NavLink onClick={() => this.setActiveTab('link')} active={activeTab === 'link'}>Link</NavLink>+ </NavItem>+ <NavItem>+ <NavLink onClick={() => this.setActiveTab('embed')} active={activeTab === 'embed'}>Embed</NavLink>+ </NavItem>+ <NavItem>+ <NavLink onClick={() => this.setActiveTab('social')} active={activeTab === 'social'}>Social</NavLink>+ </NavItem>+ </Nav>+ );+ }++ renderLinkTab = () => {const { shortLink } = this.props;const {+ activeTab,isShort,- tooltipErrorTime,- tooltipToggleTime,} = this.state;+const value = shortLink.isLoading && isShort? 'Please wait...': isShort@@ -181,44 +185,134 @@ class ShareLinkContainer extends Component {? shortLink.response.link: this.getPermalink();+ return (+ <TabPane tabId="link" className="share-tab-link">+ {activeTab === 'link' && (+ <>+ <p>+ Copy URL to share link.++ </p>+ {' '}+ <Checkbox+ label="Shorten link"+ id="wv-link-shorten"+ onCheck={this.onToggleShorten}+ checked={isShort}+ disabled={!shortLink.isLoading}+ />+ <InputGroup>+ <Input+ type="text"+ value={value}+ name="permalink_content"+ id="permalink_content"+ onChange={(e) => {+ e.preventDefault();+ }}+ />+ <InputGroupAddon addonType="append">+ <Button+ id="copy-to-clipboard-button"+ onClick={() => this.copyToClipboard(value)}+ onTouchEnd={() => this.copyToClipboard(value)}+ >+ COPY+ </Button>+ </InputGroupAddon>+ </InputGroup>+ </>+ )}+ </TabPane>+ );+ }++ renderEmbedTab = () => {+ const {+ activeTab,+ } = this.state;++ const embedValue = this.getPermalink(true);++ return (+ <TabPane tabId="embed" className="share-tab-embed">+ {activeTab === 'embed' && (+ <>+ <p>+ Embed Worldview in your website. See our+ {' '}+ <a className="share-embed-doc-link" href="https://github.com/nasa-gibs/worldview/blob/main/doc/embed.md" target="_blank" rel="noopener noreferrer">documentation</a>+ {' '}+ for a guide.+ </p>+ <InputGroup>+ <Input+ type="text"+ value={embedValue}+ name="permalink_content"+ id="permalink_content"+ onChange={(e) => {+ e.preventDefault();+ }}+ />+ <InputGroupAddon addonType="append">+ <Button+ id="copy-to-clipboard-button"+ onClick={() => this.copyToClipboard(embedValue)}+ onTouchEnd={() => this.copyToClipboard(embedValue)}+ >+ COPY+ </Button>+ </InputGroupAddon>+ </InputGroup>+ </>+ )}+ </TabPane>+ );+ }++ renderSocialTab = () => {+ const {+ activeTab,+ } = this.state;++ return (+ <TabPane tabId="social" className="share-tab-social">+ {activeTab === 'social' && (+ <>+ <p>+ Share Worldview on social media.+ </p>+ <ShareLinks onClick={this.onLinkClick} />+ </>+ )}+ </TabPane>+ );+ }++ render() {+ const {+ activeTab,+ tooltipErrorTime,+ tooltipToggleTime,+ } = this.state;+return (<>- <div>+ <div className="share-body"><ShareToolTipstooltipErrorTime={tooltipErrorTime}tooltipToggleTime={tooltipToggleTime}/>- <InputGroup>- <Input- type="text"- value={value}- name="permalink_content"- id="permalink_content"- onChange={(e) => {- e.preventDefault();- }}- />- <InputGroupAddon addonType="append">- <Button- id="copy-to-clipboard-button"- onClick={() => this.copyToClipboard(value)}- onTouchEnd={() => this.copyToClipboard(value)}- >- COPY- </Button>- </InputGroupAddon>- </InputGroup>- <br />- <Checkbox- label="Shorten link"- id="wv-link-shorten"- onCheck={this.onToggleShorten}- checked={isShort}- disabled={!shortLink.isLoading}- />- <br />+ <div className="share-nav-container">+ {this.renderNavTabs()}+ <TabContent activeTab={activeTab}>+ {this.renderLinkTab()}+ {this.renderEmbedTab()}+ {this.renderSocialTab()}+ </TabContent>+ </div></div>- <ShareLinks onClick={this.onLinkClick} /></>);}diff --git a/web/js/containers/sidebar/layer-list.js b/web/js/containers/sidebar/layer-list.jsindex 59e54d7f5..a01f6dc36 100644--- a/web/js/containers/sidebar/layer-list.js+++ b/web/js/containers/sidebar/layer-list.js@@ -220,7 +220,7 @@ LayerList.propTypes = {zots: PropTypes.object,};-const mapStateToProps = (state, ownProps) => {+const mapStateToProps = (state) => {const { proj, config, map } = state;const zots = lodashGet(map, 'ui.selected')? getZotsForActiveLayers(state)diff --git a/web/js/containers/sidebar/layer-row.js b/web/js/containers/sidebar/layer-row.jsindex 5e33dee40..fd94a9025 100644--- a/web/js/containers/sidebar/layer-row.js+++ b/web/js/containers/sidebar/layer-row.js@@ -52,6 +52,7 @@ function LayerRow (props) {renderedPalette,requestPalette,isCustomPalette,+ isEmbedModeActive,isLoading,isMobile,zot,@@ -296,6 +297,7 @@ function LayerRow (props) {return (<Draggable+ isDragDisabled={isEmbedModeActive}draggableId={`${encodedLayerId}-${compareState}`}index={index}direction="vertical"@@ -332,7 +334,7 @@ const mapStateToProps = (state, ownProps) => {compareState,} = ownProps;const {- palettes, config, map, compare, proj,+ palettes, config, embed, map, compare, proj,} = state;const hasPalette = !lodashIsEmpty(layer.palette);const renderedPalettes = palettes.rendered;@@ -341,6 +343,7 @@ const mapStateToProps = (state, ownProps) => {? getPaletteLegends(layer.id, compareState, state): [];const isCustomPalette = hasPalette && palettes.custom[layer.id];+ const { isEmbedModeActive } = embed;const selectedMap = lodashGet(map, 'ui.selected');const isVector = layer.type === 'vector';const mapRes = selectedMap ? selectedMap.getView().getResolution() : null;@@ -355,6 +358,7 @@ const mapStateToProps = (state, ownProps) => {isVisible,paletteLegends,isCustomPalette,+ isEmbedModeActive,isLoading: palettes.isLoading[paletteName],renderedPalette: renderedPalettes[paletteName],isVectorLayer: isVector,@@ -441,6 +445,7 @@ LayerRow.propTypes = {index: PropTypes.number,isCustomPalette: PropTypes.bool,isDisabled: PropTypes.bool,+ isEmbedModeActive: PropTypes.bool,isInProjection: PropTypes.bool,isLoading: PropTypes.bool,isMobile: PropTypes.bool,diff --git a/web/js/containers/sidebar/layers-container.js b/web/js/containers/sidebar/layers-container.jsindex 25360c996..51c1467df 100644--- a/web/js/containers/sidebar/layers-container.js+++ b/web/js/containers/sidebar/layers-container.js@@ -24,6 +24,7 @@ function LayersContainer (props) {height,isActive,isCompareActive,+ isEmbedModeActive,isMobile,overlayGroups,overlays,@@ -106,22 +107,30 @@ function LayersContainer (props) {);const mobileHeightCoeff = isCompareActive ? -30 : 20;- const maxHeight = isMobile+ let maxHeight = isMobile? height + mobileHeightCoeff: height;++ if (isEmbedModeActive) {+ maxHeight = 'calc(var(--vh, 1vh) * 100 - 320px)';+ } else {+ maxHeight += 'px';+ }const scrollContainerStyles = {- maxHeight: `${maxHeight}px`,+ maxHeight,overflowY: 'auto',paddingBottom: '4px',minHeight: '100px',};+ const shouldHideForEmbedNoOverlays = isEmbedModeActive && overlays.length === 0;+ const shouldHideForEmbedNoBaseLayers = isEmbedModeActive && baselayers.length === 0;return isActive && (<><div id="layers-scroll-container" style={scrollContainerStyles}><div className="layer-container sidebar-panel">- {groupOverlays ? renderOverlayGroups() : (+ {groupOverlays ? renderOverlayGroups() : !shouldHideForEmbedNoOverlays && (<LayerListtitle="Overlays"groupId="overlays"@@ -133,6 +142,7 @@ function LayersContainer (props) {/>)}+ {!shouldHideForEmbedNoBaseLayers && (<div className="layer-group-baselayers"><LayerListtitle="Base Layers"@@ -144,6 +154,7 @@ function LayersContainer (props) {layerSplit={overlays.length}/></div>+ )}</div></div><div className="group-overlays-checkbox">@@ -160,15 +171,23 @@ function LayersContainer (props) {const mapStateToProps = (state, ownProps) => {const { compareState } = ownProps;- const { browser, compare, layers } = state;+ const {+ browser, compare, embed, layers,+ } = state;const isCompareActive = compare.active;+ const { isEmbedModeActive } = embed;const isMobile = browser.lessThan.medium;const { groupOverlays } = layers[compareState];- const { baselayers, overlays } = getAllActiveOverlaysBaselayers(state);+ // eslint-disable-next-line prefer-const+ let { baselayers, overlays } = getAllActiveOverlaysBaselayers(state);const overlayGroups = groupOverlays ? getActiveOverlayGroups(state) : [];+ if (isEmbedModeActive) {+ overlays = overlays.filter((layer) => layer.layergroup !== 'Reference');+ }return {isCompareActive,+ isEmbedModeActive,isMobile,baselayers,overlays,@@ -205,6 +224,7 @@ LayersContainer.propTypes = {height: PropTypes.number,isActive: PropTypes.bool,isCompareActive: PropTypes.bool,+ isEmbedModeActive: PropTypes.bool,isMobile: PropTypes.bool,overlayGroups: PropTypes.array,overlays: PropTypes.array,diff --git a/web/js/containers/sidebar/sidebar.js b/web/js/containers/sidebar/sidebar.jsindex 5b5ef1ea8..80d7b1116 100644--- a/web/js/containers/sidebar/sidebar.js+++ b/web/js/containers/sidebar/sidebar.js@@ -15,6 +15,8 @@ import {loadCustom as loadCustomPalette,} from '../../modules/palettes/util';import { loadedCustomPalettes } from '../../modules/palettes/actions';+import getSelectedDate from '../../modules/date/selectors';+import { getPermalink } from '../../modules/link/util';import {requestEvents as requestEventsActionCreator,requestSources as requestSourcesActionCreator,@@ -27,6 +29,7 @@ import {toggleSidebarCollapse as toggleSidebarCollapseAction,expandSidebar as expandSidebarAction,} from '../../modules/sidebar/actions';+import history from '../../main';import safeLocalStorage from '../../util/local-storage';const { SIDEBAR_COLLAPSED } = safeLocalStorage.keys;@@ -40,34 +43,35 @@ const getActiveTabs = function(config) {};};-const resetWorldview = function(e, isDistractionFreeModeActive) {- e.preventDefault();- if (!isDistractionFreeModeActive && window.location.search === '') return; // Nothing to reset- const msg = 'Do you want to reset Worldview to its defaults? You will lose your current state.';- // eslint-disable-next-line no-alert- if (window.confirm(msg)) {- googleTagManager.pushEvent({- event: 'logo_page_reset',- });- document.location.href = '/';- }-};-class Sidebar extends React.Component {constructor(props) {super(props);- this.state = { subComponentHeight: 700 };+ this.state = {+ subComponentHeight: 700,+ isEventsTabDisabledEmbed: false,+ };this.toggleSidebar = this.toggleSidebar.bind(this);+ this.renderSidebarLogo = this.renderSidebarLogo.bind(this);+ this.updateDimensions = this.updateDimensions.bind(this);+ this.getProductsToRender = this.getProductsToRender.bind(this);+ this.handleWorldviewLogoClick = this.handleWorldviewLogoClick.bind(this);}componentDidMount() {- const { config, loadedCustomPalettes } = this.props;+ const {+ activeTab, config, isEmbedModeActive, loadedCustomPalettes,+ } = this.props;const customPalettePromise = loadCustomPalette(config);customPalettePromise.then((customs) => {loadedCustomPalettes(customs);});this.updateDimensions();this.loadEvents();+ // prevent events tab if embed init layers tab+ if (isEmbedModeActive && activeTab === 'layers') {+ this.setState({ isEventsTabDisabledEmbed: true });+ }+// prevent browser zooming in safariif (util.browser.safari) {const onGestureCallback = (e) => {@@ -118,31 +122,27 @@ class Sidebar extends React.Component {updateDimensions() {const { subComponentHeight } = this.state;- const footerHeight = lodashGet(this, 'footerElement.clientHeight') || 20;const { isMobile, screenHeight } = this.props;- if (!isMobile && this.iconElement) {- const iconHeight = this.iconElement.clientHeight;- const topOffset = Math.abs(this.iconElement.getBoundingClientRect().top);- const tabHeight = 32;+ const footerHeight = lodashGet(this, 'footerElement.clientHeight') || 20;+ const tabHeight = 32;+ let newHeight;+ if (!isMobile) {+ const iconHeight = 53;+ const topOffset = 10;const basePadding = 130;- const newHeight = screenHeight+ newHeight = screenHeight- (iconHeight + topOffset + tabHeight + basePadding + footerHeight)- 10;- // Issue #1415: This was checking for subComponentHeight !== newHeight.- // Sometimes it would get stuck in a loop in which the newHeight- // would vary by a single pixel on each render. Hack fix is to- // only update when changed by more than a single pixel. This probably- // needs a refactoring.- if (Math.abs(subComponentHeight - newHeight) > 1) {- this.setState({ subComponentHeight: newHeight });- }} else {- const tabHeight = 32;- const newHeight = screenHeight - (tabHeight + footerHeight);- // See note above- if (Math.abs(subComponentHeight - newHeight) > 1) {- this.setState({ subComponentHeight: newHeight });- }+ newHeight = screenHeight - (tabHeight + footerHeight);+ }+ // Issue #1415: This was checking for subComponentHeight !== newHeight.+ // Sometimes it would get stuck in a loop in which the newHeight+ // would vary by a single pixel on each render. Hack fix is to+ // only update when changed by more than a single pixel. This probably+ // needs a refactoring.+ if (Math.abs(subComponentHeight - newHeight) > 1) {+ this.setState({ subComponentHeight: newHeight });}}@@ -185,27 +185,80 @@ class Sidebar extends React.Component {}}+ handleWorldviewLogoClick(e, permalink) {+ e.preventDefault();+ const { isEmbedModeActive } = this.props;+ if (window.location.search === '') return; // Nothing to reset+ let msg;+ if (isEmbedModeActive) {+ msg = 'Do you want to open full featured Worldview in a new tab with current content loaded?';+ // eslint-disable-next-line no-alert+ if (window.confirm(msg)) {+ window.open(permalink, '_blank');+ }+ } else {+ msg = 'Do you want to reset Worldview to its defaults? You will lose your current state.';+ // eslint-disable-next-line no-alert+ if (window.confirm(msg)) {+ googleTagManager.pushEvent({+ event: 'logo_page_reset',+ });+ document.location.href = '/';+ }+ }+ }++ renderSidebarLogo() {+ const {+ isDistractionFreeModeActive,+ isEmbedModeActive,+ selectedDate,+ } = this.props;+ const wheelCallBack = util.browser.chrome ? util.preventPinch : null;+ const permalink = getPermalink(history.location.search, selectedDate);+ const WVLogoTitle = isEmbedModeActive+ ? 'Click to Open New Tab of Worldview with Current Content'+ : 'Click to Reset Worldview to Defaults';+ const embedWVLogoLink = isEmbedModeActive ? permalink : '/';++ return (+ <a+ href={embedWVLogoLink}+ title={WVLogoTitle}+ id="wv-logo"+ className={isDistractionFreeModeActive ? 'wv-logo-distraction-free-mode' : ''}+ onClick={(e) => this.handleWorldviewLogoClick(e, permalink)}+ ref={(iconElement) => { this.iconElement = iconElement; }}+ onWheel={wheelCallBack}+ />+ );+ }+render() {- const { subComponentHeight } = this.state;const {+ isEventsTabDisabledEmbed,+ subComponentHeight,+ } = this.state;+ const {+ activeTab,+ changeTab,config,- onTabClick,- numberOfLayers,- screenHeight,+ eventsData,+ eventsSources,+ hasEventRequestError,isCollapsed,isCompareMode,- isDistractionFreeModeActive,- activeTab,- tabTypes,- isMobile,- changeTab,isDataDisabled,+ isDistractionFreeModeActive,+ isEmbedModeActive,isLoadingEvents,- hasEventRequestError,- eventsData,- eventsSources,+ isMobile,+ numberOfLayers,+ onTabClick,+ screenHeight,+ tabTypes,} = this.props;- if (isMobile && activeTab === 'download') changeTab('layers');+ if ((isMobile || isEmbedModeActive) && activeTab === 'download') changeTab('layers');const wheelCallBack = util.browser.chrome ? util.preventPinch : null;const { naturalEvents } = config.features;const { smartHandoffs } = config.features;@@ -213,15 +266,7 @@ class Sidebar extends React.Component {return (<ErrorBoundary><section id="wv-sidebar">- <a- href="/"- title="Click to Reset Worldview to Defaults"- id="wv-logo"- className={isDistractionFreeModeActive ? 'wv-logo-distraction-free-mode' : ''}- onClick={(e) => resetWorldview(e, isDistractionFreeModeActive)}- ref={(iconElement) => { this.iconElement = iconElement; }}- onWheel={wheelCallBack}- />+ {this.renderSidebarLogo()}<>{!isDistractionFreeModeActive && isCollapsed && (<CollapsedButton@@ -252,6 +297,7 @@ class Sidebar extends React.Component {toggleSidebar={this.toggleSidebar}isCompareMode={isCompareMode}isDataDisabled={isDataDisabled}+ isEventsTabDisabledEmbed={isEventsTabDisabledEmbed}/><TabContent activeTab={activeTab}><TabPane tabId="layers">@@ -293,16 +339,17 @@ class Sidebar extends React.Component {}function mapStateToProps(state) {const {+ animation,browser,- sidebar,compare,config,- modal,- measure,- animation,+ embed,events,+ measure,+ modal,requestedEvents,requestedEventSources,+ sidebar,ui,} = state;@@ -316,9 +363,16 @@ function mapStateToProps(state) {const { screenHeight } = browser;const { isDistractionFreeModeActive } = ui;+ const { isEmbedModeActive } = embed;const { activeTab, isCollapsed, mobileCollapsed } = sidebar;const { activeString } = compare;- const numberOfLayers = getAllActiveLayers(state).length;+ const activeLayers = getAllActiveLayers(state);+ let numberOfLayers;+ if (isEmbedModeActive) {+ numberOfLayers = activeLayers.filter((layer) => layer.layergroup !== 'Reference').length;+ } else {+ numberOfLayers = activeLayers.length;+ }const tabTypes = getActiveTabs(config);const snapshotModalOpen = modal.isOpen && modal.id === 'TOOLBAR_SNAPSHOT';const isMobile = browser.lessThan.medium;@@ -337,9 +391,11 @@ function mapStateToProps(state) {isCompareMode: compare.active,isDataDisabled: events.isAnimatingToEvent,isDistractionFreeModeActive,+ isEmbedModeActive,isLoadingEvents,isMobile,screenHeight,+ selectedDate: getSelectedDate(state),tabTypes,};}@@ -383,21 +439,23 @@ Sidebar.propTypes = {changeTab: PropTypes.func,collapseExpandToggle: PropTypes.func,config: PropTypes.object,+ eventRequestUrl: PropTypes.string,eventsData: PropTypes.array,eventsSources: PropTypes.array,- eventRequestUrl: PropTypes.string,hasEventRequestError: PropTypes.bool,isCollapsed: PropTypes.bool,isCompareMode: PropTypes.bool,isDataDisabled: PropTypes.bool,isDistractionFreeModeActive: PropTypes.bool,+ isEmbedModeActive: PropTypes.bool,isLoadingEvents: PropTypes.bool,isMobile: PropTypes.bool,loadedCustomPalettes: PropTypes.func,numberOfLayers: PropTypes.number,onTabClick: PropTypes.func,- screenHeight: PropTypes.number,- tabTypes: PropTypes.object,requestEvents: PropTypes.func,requestSources: PropTypes.func,+ screenHeight: PropTypes.number,+ selectedDate: PropTypes.object,+ tabTypes: PropTypes.object,};diff --git a/web/js/containers/sidebar/smart-handoff.js b/web/js/containers/sidebar/smart-handoff.jsindex 54a599ff8..1e24c744e 100644--- a/web/js/containers/sidebar/smart-handoff.js+++ b/web/js/containers/sidebar/smart-handoff.js@@ -584,7 +584,7 @@ const mapDispatchToProps = (dispatch) => ({dispatch(openCustomContent('granule-help', {desktopOnly: true,- headerText: 'Granule Availablilty',+ headerText: 'Granule Availability',bodyComponent: GranuleAlertModalBody,size: 'md',}),diff --git a/web/js/containers/timeline/timeline.js b/web/js/containers/timeline/timeline.jsindex 935e11454..7557b7fee 100644--- a/web/js/containers/timeline/timeline.js+++ b/web/js/containers/timeline/timeline.js@@ -1026,6 +1026,7 @@ class Timeline extends React.Component {isCompareModeActive,isDataDownload,isDistractionFreeModeActive,+ isEmbedModeActive,isSmallScreen,isTourActive,leftArrowDisabled,@@ -1096,7 +1097,7 @@ class Timeline extends React.Component {{initialLoadComplete && !isDistractionFreeModeActive&& (<ErrorBoundary>- {isSmallScreen+ {isSmallScreen || isEmbedModeActive/* Mobile Timeline Size */? (<div id="timeline-header" className="timeline-header-mobile">@@ -1363,35 +1364,37 @@ class Timeline extends React.Component {function mapStateToProps(state) {const {- config,- compare,- map,- layers,+ animation,browser,+ compare,+ config,date,- animation,+ embed,+ layers,+ map,+ modal,proj,sidebar,- modal,tour,ui,} = state;const {+ appNow,+ customDelta,+ customInterval,customSelected,+ delta,+ interval,selected,selectedB,- delta,- customDelta,- appNow,- timelineCustomModalOpen,selectedZoom,- interval,- customInterval,+ timelineCustomModalOpen,} = date;const { screenWidth, lessThan } = browser;const { isCompareA } = compare;const isCompareModeActive = compare.active;const { isDistractionFreeModeActive } = ui;+ const { isEmbedModeActive } = embed;const isSmallScreen = lessThan.medium;// handle active layer filtering and check for subdaily@@ -1496,6 +1499,7 @@ function mapStateToProps(state) {isGifActive: animation.gifActive,timelineCustomModalOpen,isDistractionFreeModeActive,+ isEmbedModeActive,};}@@ -1577,6 +1581,7 @@ Timeline.propTypes = {isCompareModeActive: PropTypes.bool,isDataDownload: PropTypes.bool,isDistractionFreeModeActive: PropTypes.bool,+ isEmbedModeActive: PropTypes.bool,isGifActive: PropTypes.bool,isSmallScreen: PropTypes.bool,isTourActive: PropTypes.bool,diff --git a/web/js/containers/toolbar.js b/web/js/containers/toolbar.jsindex 54f3581de..8bcae39eb 100644--- a/web/js/containers/toolbar.js+++ b/web/js/containers/toolbar.js@@ -51,7 +51,7 @@ const CUSTOM_MODAL_PROPS = {wrapClassName: 'toolbar_modal_outer toolbar_modal_outer',},TOOLBAR_SHARE_LINK: {- headerText: 'Copy Link to Share',+ headerText: 'Share',type: 'toolbar',backdrop: false,modalClassName: 'toolbar-share-modal toolbar-modal toolbar-medium-modal',diff --git a/web/js/location.js b/web/js/location.jsindex df25080a5..b52371fb4 100644--- a/web/js/location.js+++ b/web/js/location.js@@ -29,6 +29,7 @@ import {import { resetLayers, hasSubDaily, getActiveLayers } from './modules/layers/selectors';import { eventsReducerState } from './modules/natural-events/reducers';import { mapLocationToPaletteState } from './modules/palettes/util';+import { mapLocationToEmbedState } from './modules/embed/util';import { mapLocationToAnimationState } from './modules/animation/util';import { areCoordinatesWithinExtent, mapLocationToLocationSearchState } from './modules/location-search/util';import mapLocationToSidebarState from './modules/sidebar/util';@@ -100,6 +101,10 @@ export const mapLocationToState = (state, location) => {state,config,);+ stateFromLocation = mapLocationToEmbedState(+ parameters,+ stateFromLocation,+ );// one level deep merge of newState with defaultStateObject.keys(stateFromLocation).forEach((key) => {@@ -280,6 +285,14 @@ const getParameters = function(config, parameters) {},},},+ em: {+ stateKey: 'embed.isEmbedModeActive',+ initialState: false,+ type: 'bool',+ options: {+ parse: (str) => str === 'true',+ },+ },e: {stateKey: 'events',type: 'object',diff --git a/web/js/modules/combine-reducers.js b/web/js/modules/combine-reducers.jsindex 1e644c46e..c20461726 100644--- a/web/js/modules/combine-reducers.js+++ b/web/js/modules/combine-reducers.js@@ -43,6 +43,7 @@ import {} from './product-picker/reducers';import { LOCATION_POP_ACTION } from '../redux-location-state-customs';+import embedReducers from './embed/reducers';import uiReducers from './ui/reducers';import { alertReducer } from './alerts/reducer';import { smartHandoffReducer } from './smart-handoff/reducer';@@ -129,6 +130,7 @@ const reducers = {lastAction,location: locationReducer,measure: measureReducer,+ embed: embedReducers,ui: uiReducers,productPicker: productPickerReducer,};diff --git a/web/js/modules/embed/actions.js b/web/js/modules/embed/actions.jsnew file mode 100644index 000000000..77ce6d7a4--- /dev/null+++ b/web/js/modules/embed/actions.js@@ -0,0 +1,24 @@+// import googleTagManager from 'googleTagManager';++// import { TOGGLE_EMBED_MODE } from './constants';+// import { CLOSE as CLOSE_MODAL } from '../modal/constants';++// export default function toggleDistractionFreeMode() {+// return (dispatch, getState) => {+// const { modal, ui } = getState();+// const { isDistractionFreeModeActive } = ui;+// const modalIsOpen = modal.isOpen;+// if (!isDistractionFreeModeActive) {+// googleTagManager.pushEvent({+// event: 'init_distraction_free_mode',+// });+// }+// dispatch({+// type: TOGGLE_EMBED_MODE,+// isDistractionFreeModeActive: !isDistractionFreeModeActive,+// });+// if (!isDistractionFreeModeActive && modalIsOpen) {+// dispatch({ type: CLOSE_MODAL });+// }+// };+// }diff --git a/web/js/modules/embed/constants.js b/web/js/modules/embed/constants.jsnew file mode 100644index 000000000..bf449aa8f--- /dev/null+++ b/web/js/modules/embed/constants.js@@ -0,0 +1,2 @@+// eslint-disable-next-line import/prefer-default-export+// export const TOGGLE_EMBED_MODE = 'EMBED/TOGGLE_EMBED_MODE';diff --git a/web/js/modules/embed/reducers.js b/web/js/modules/embed/reducers.jsnew file mode 100644index 000000000..00c13902f--- /dev/null+++ b/web/js/modules/embed/reducers.js@@ -0,0 +1,17 @@+// import { assign as lodashAssign } from 'lodash';+// import { TOGGLE_EMBED_MODE } from './constants';++export const embedState = {+ isEmbedModeActive: false,+};++export default function embedReducers(state = embedState, action) {+ switch (action.type) {+ // case TOGGLE_EMBED_MODE:+ // return lodashAssign({}, state, {+ // isEmbedModeActive: !state.isEmbedModeActive,+ // });+ default:+ return state;+ }+}diff --git a/web/js/modules/embed/util.js b/web/js/modules/embed/util.jsnew file mode 100644index 000000000..9f9e55c23--- /dev/null+++ b/web/js/modules/embed/util.js@@ -0,0 +1,43 @@+import {+ assign as lodashAssign,+ cloneDeep as lodashCloneDeep,+} from 'lodash';+import { getOverlayGroups } from '../layers/util';++/**+ * Update embed state when location-pop action occurs+ *+ * @param {Object} parameters | parameters parsed from permalink+ * @param {Object} stateFromLocation | State derived from permalink parsers+ * @param {Object} state+ */+// eslint-disable-next-line import/prefer-default-export+export function mapLocationToEmbedState(+ parameters,+ stateFromLocation,+) {+ if (parameters.em === 'true') {+ const { layers } = stateFromLocation;+ const layersClone = lodashCloneDeep(layers);+ const { active, activeB } = layersClone;++ const activeFiltered = active.layers.filter((layer) => layer.visible);+ // remove reference layers overlay group+ const activeOverlayGroups = getOverlayGroups(activeFiltered).filter((group) => group.groupName !== 'Reference');+ layersClone.active.layers = activeFiltered;+ layersClone.active.overlayGroups = activeOverlayGroups;++ const activeBFiltered = activeB.layers.filter((layer) => layer.visible);+ // remove reference layers overlay group+ const activeBOverlayGroups = getOverlayGroups(activeBFiltered).filter((group) => group.groupName !== 'Reference');+ layersClone.activeB.layers = activeBFiltered;+ layersClone.activeB.overlayGroups = activeBOverlayGroups;++ stateFromLocation = lodashAssign({}, stateFromLocation, {+ embed: { isEmbedModeActive: true },+ layers: layersClone,+ });+ }++ return stateFromLocation;+}diff --git a/web/js/modules/link/util.js b/web/js/modules/link/util.jsindex 32001bb5a..080d17ef9 100644--- a/web/js/modules/link/util.js+++ b/web/js/modules/link/util.js@@ -1,4 +1,5 @@import { each as lodashEach } from 'lodash';+import { serializeDate } from '../date/util';import { ENCODING_EXCEPTIONS } from './constants';// Facebook: https://developers.facebook.com/docs/sharing/reference/share-dialog#redirectexport function facebookUrlParams(appId, href, redirectUri, display) {@@ -48,7 +49,7 @@ export function emailUrlParams(subject, body) {);}-export function getSharelink(type, url) {+export function getShareLink(type, url) {const shareMessage = 'Check out what I found in NASA Worldview!';const twMessage = 'Check out what I found in #NASAWorldview -';const emailBody = `${shareMessage} - ${url}`;@@ -74,3 +75,35 @@ export function encode(value) {});return encoded;}++export function getPermalink(queryString, selectedDate, isEmbed) {+ const url = window.location.href;+ const prefix = url.split('?')[0];++ // if no time query string parameter, add to permalink+ const isTimeInQueryString = queryString.includes('t=');+ let timeParam = '';+ if (!isTimeInQueryString) {+ const serialized = serializeDate(selectedDate);+ const encoded = encode(serialized);+ timeParam = `t=${encoded}`;+ }++ // add to permalink based on existing querystring+ let permalink = prefix;+ if (!queryString) {+ permalink += `?${timeParam}`;+ } else if (!isTimeInQueryString) {+ permalink += `${queryString}&${timeParam}`;+ } else {+ permalink = url;+ }++ if (isEmbed) {+ permalink += '&em=true';+ } else if (permalink.includes('em=')) {+ permalink = permalink.replace('em=true', 'em=false');+ }++ return permalink;+}