Interactive interface for browsing global, full-resolution satellite imagery
Merge branch 'develop' of https://github.com/nasa-gibs/worldview into redux-1553
Benjamin Kinga82eb673ee3e
diff --cc package-lock.jsonindex 37cd35319,fb4373503..e00612e87--- a/package-lock.json+++ b/package-lock.json@@@ -14179,9 -14094,9 +14176,9 @@@"dev": true},"popper.js": {- "version": "1.14.6",- "resolved": "https://registry.npmjs.org/popper.js/-/popper.js-1.14.6.tgz",- "integrity": "sha512-AGwHGQBKumlk/MDfrSOf0JHhJCImdDMcGNoqKmKkU+68GFazv3CQ6q9r7Ja1sKDZmYWTckY/uLyEznheTDycnA=="- "version": "1.14.4",- "resolved": "https://registry.npmjs.org/popper.js/-/popper.js-1.14.4.tgz",- "integrity": "sha1-juwdj/AqWjoVLdQ0FKFce3n9abY="++ "version": "1.14.7",++ "resolved": "https://registry.npmjs.org/popper.js/-/popper.js-1.14.7.tgz",++ "integrity": "sha512-4q1hNvoUre/8srWsH7hnoSJ5xVmIL4qgz+s4qf2TnJIMyZFUFMGH+9vE7mXynAlHSZ/NdTmmow86muD0myUkVQ=="},"portfinder": {"version": "1.0.16",@@@ -18128,16 -18034,8 +18125,16 @@@"resolved": "https://registry.npmjs.org/react-popper/-/react-popper-0.10.4.tgz","integrity": "sha1-rypBXqIike3VBGeNev2opu4ylao=","requires": {- "popper.js": "1.14.6",- "popper.js": "^1.14.1",- "prop-types": "^15.6.1"++ "popper.js": "1.14.7",+ "prop-types": "15.6.2"+ }+ },+ "react-portal": {+ "version": "4.2.0",+ "resolved": "https://registry.npmjs.org/react-portal/-/react-portal-4.2.0.tgz",+ "integrity": "sha512-Zf+vGQ/VEAb5XAy+muKEn48yhdCNYPZaB1BWg1xc8sAZWD8pXTgPtQT4ihBdmWzsfCq8p8/kqf0GWydSBqc+Eg==",+ "requires": {+ "prop-types": "15.6.2"}},"react-redux": {diff --cc web/index.htmlindex 80defae16,71b601a8c..ccff082f1--- a/web/index.html+++ b/web/index.html@@@ -50,6 -50,12 +50,8 @@@ Licensed under the NASA Open Source Agr<body><div data-role="page" id="app"></div>- <div id="wv-image-top" class="wv-image-coords wv-image-top"></div>- <div id="wv-image-right" class="wv-image-coords wv-image-right"></div>- <div id="wv-image-bottom" class="wv-image-coords wv-image-bottom"></div>- <div id="wv-image-left" class="wv-image-coords wv-image-left"></div>+ <div id="wv-tour" class="wv-tour"></div>+ <div id="wv-alerts" class="wv-alerts"></div><div class="backdrop"></div></body>diff --cc web/js/app.jsindex bf5f1df24,a62cfbd6d..4ab4974aa--- a/web/js/app.js+++ b/web/js/app.js@@@ -77,20 -74,16 +77,23 @@@ import naturalEventsRequest from './nat// UIimport loadingIndicator from './ui/indicator';+// Toolbar+import Toolbar from './containers/toolbar';+++// Modal++import Modal from './containers/modal';+++// Notifications+import {+ STATUS_REQUEST_URL,+ REQUEST_NOTIFICATIONS+} from './modules/notifications/constants';+import {+ requestNotifications,+ setNotifications+} from './modules/notifications/actions';// Linkimport { linkModel } from './link/model';-import { linkUi } from './link/ui';// Projectionsimport { parse as projectionParser } from './projection/projection';@@@ -100,16 -94,18 +103,17 @@@ import { projectionModel } from './projimport { compareModel } from './compare/model';import { compareUi } from './compare/ui';- // Modal- import Modal from './containers/modal';+ // Tour+ import { tourModel } from './tour/model';+ import { tourUi } from './tour/ui';+-// Alert-import { alertUi } from './alert/ui';-// Otherimport { debugConfig, debugLayers } from './debug';import Brand from './brand';- import tour from './tour';-import { uiInfo } from './ui/info';+// Crutch between state systems+import { sendConfigToStore } from './modules/migration/actions';+import { updatePermalink } from './modules/link/actions';// Dependency CSSimport '../../node_modules/bootstrap/dist/css/bootstrap.css';import '../../node_modules/jquery-ui-bundle/jquery-ui.structure.css';@@@ -437,11 -435,13 +444,11 @@@ class App extends React.Component// HACK: Map needs permalink state loaded before starting. But// data download now needs it too.models.link.load(state); // needs to be loaded twice-+ self.props.updateConfig(models, config); // crutch between old state system and reduxelapsed('ui');// Create widgets- ui.tour = tour(models, ui, config);- ui.alert = alertUi(ui);- ui.proj = projectionUi(models, config);ui.sidebar = sidebarUi(models, config, ui);+ ui.tour = tourUi(models, ui, config);ui.activeLayers = layersActive(models, ui, config);ui.addModal = layersModal(models, ui, config);ui.layerSettingsModal = layersOptions(models, ui, config);diff --cc web/js/containers/share.jsindex 100ff7370,000000000..452f60830mode 100644,000000..100644--- a/web/js/containers/share.js+++ b/web/js/containers/share.js@@@ -1,215 -1,0 +1,215 @@@+import React, { Component } from 'react';+import PropTypes from 'prop-types';+import { connect } from 'react-redux';- import ShareLinks from '../components/share/links';++import ShareLinks from '../components/toolbar/share/links';+import { getSharelink, openPromisedSocial } from '../modules/link/util';+import { CopyToClipboard } from 'react-copy-to-clipboard';+import { Checkbox } from '../components/util/checkbox';+import { requestShortLink } from '../modules/link/actions';+import {+ InputGroupAddon,+ Input,+ InputGroup,+ Button,+ Tooltip+} from 'reactstrap';++const getShortenRequestString = function(mock, permalink) {+ const mockStr = mock || '';+ if (/localhost/.test(location)) {+ return 'mock/short_link.json';+ }+ return (+ 'service/link/shorten.cgi' ++ mockStr ++ '?url=' ++ encodeURIComponent(permalink)+ );+};+class ShareLinkContainer extends Component {+ constructor(props) {+ super(props);+ this.state = {+ shortLinkKey: '',+ isShort: false,+ tooltipOpen: false+ };+ }+ getShortLink() {+ const { requestShortLink, mock } = this.props;+ const link = this.getPermalink();+ const location = getShortenRequestString(mock, link);+ return requestShortLink(location);+ }+ onToggleShorten() {+ const { queryString } = this.props;+ const { shortLinkKey, isShort } = this.state;++ if (!isShort && shortLinkKey !== queryString) {+ this.getShortLink();+ this.setState({+ shortLinkKey: queryString,+ isShort: !isShort+ });+ } else {+ this.setState({ isShort: !isShort });+ }+ }+ getPermalink() {+ const { queryString } = this.props;+ let url = window.location.href;+ let prefix = url.split('?')[0];+ prefix = prefix !== null && prefix !== undefined ? prefix : url;+ return !queryString ? prefix : prefix + '?' + queryString;+ }+ onLinkClick(type) {+ const permalink = this.getPermalink();+ // If a short link can be generated, replace the full link.+ if (type === 'twitter' || type === 'email') {+ let promise = this.getShortLink();+ let win = window;+ if (type === 'twitter') {+ win = window.open('', '_blank');+ }+ promise+ .then(function(result) {+ if (result.status_code === 200) {+ const href = getSharelink(type, result.data.url);+ openPromisedSocial(href, win);+ }+ })+ .catch(function() {+ const href = getSharelink(type, permalink);+ openPromisedSocial(href, win);+ console.warn('Unable to shorten URL, full link generated.');+ });+ } else {+ let href = getSharelink(type, permalink);+ window.open(href, '_blank');+ }+ }+ static getDerivedStateFromProps(nextProps, prevState) {+ if (prevState.shortLinkKey !== nextProps.queryString) {+ return {+ isShort: false,+ shortLinkKey: ''+ };+ } else if (nextProps.shortLink.error && prevState.isShort) {+ return { isShort: false, showErrorTooltip: true };+ } else return null;+ }+ renderToolTips() {+ const { showErrorTooltip, tooltipOpen } = this.state;+ if (showErrorTooltip) {+ setTimeout(() => {+ this.setState({ showErrorTooltip: false });+ }, 2000);+ }+ return (+ <React.Fragment>+ <Tooltip+ placement="left"+ isOpen={showErrorTooltip}+ target="permalink_content"+ >+ Link cannot be shortened at this time.+ </Tooltip>+ <Tooltip+ placement="right"+ isOpen={tooltipOpen}+ target="copy-to-clipboard-button"+ >+ Copied!+ </Tooltip>+ </React.Fragment>+ );+ }+ render() {+ const { shortLink } = this.props;+ const { isShort } = this.state;++ const value =+ shortLink.isLoading && isShort+ ? 'Please wait...'+ : isShort &&+ shortLink.response &&+ shortLink.response.data &&+ shortLink.response.data.url+ ? shortLink.response.data.url+ : this.getPermalink();++ return (+ <React.Fragment>+ <div>+ {this.renderToolTips()}+ <InputGroup>+ <Input+ type="text"+ value={value}+ name="permalink_content"+ id="permalink_content"+ onChange={e => {+ e.preventDefault();+ }}+ />++ <CopyToClipboard+ text={value}+ onCopy={() => {+ this.setState({ tooltipOpen: true });+ setTimeout(() => {+ this.setState({ tooltipOpen: false });+ }, 2000);+ }}+ >+ <InputGroupAddon addonType="append">+ <Button id="copy-to-clipboard-button">COPY</Button>+ </InputGroupAddon>+ </CopyToClipboard>+ </InputGroup>+ <br />+ <Checkbox+ label="Shorten link"+ id="wv-link-shorten"+ onCheck={this.onToggleShorten.bind(this)}+ checked={isShort}+ disabled={!shortLink.isLoading}+ />+ <br />+ </div>+ <ShareLinks onClick={this.onLinkClick.bind(this)} />+ </React.Fragment>+ );+ }+}++function mapStateToProps(state) {+ const { queryString } = state.link;+ const { config } = state.legacy;++ return {+ queryString: queryString,+ shortLink: state.shortLink,+ mock:+ config.parameters && config.parameters.shorten+ ? config.parameters.shorten+ : ''+ };+}+const mapDispatchToProps = dispatch => ({+ requestShortLink: (location, signal) => {+ return dispatch(requestShortLink(location, 'json', signal));+ }+});++export default connect(+ mapStateToProps,+ mapDispatchToProps+)(ShareLinkContainer);++ShareLinkContainer.propTypes = {+ projection: PropTypes.string,+ queryString: PropTypes.string,+ requestShortLink: PropTypes.function,+ mock: PropTypes.function+};diff --cc web/js/link/ui.jsindex e7c685f28,26d0ac8eb..185001c38--- a/web/js/link/ui.js+++ b/web/js/link/ui.js@@@ -1,6 -1,14 +1,5 @@@-import 'jquery-ui-bundle/jquery-ui';-import 'icheck';import lodashThrottle from 'lodash/throttle';-import React from 'react';-import ReactDOM from 'react-dom';-import Clipboard from 'clipboard';-import Share from '../components/toolbar/share/share';-import googleTagManager from 'googleTagManager';--import util from '../util/util';-import wvui from '../ui/ui';export function linkUi(models, config) {var self = {};