Interactive interface for browsing global, full-resolution satellite imagery
Add ability to load a tour from URL
ZachTRicea263bb3801aa
diff --git a/config/default/common/features.json b/config/default/common/features.jsonindex 8a392eec9..02d51e450 100644--- a/config/default/common/features.json+++ b/config/default/common/features.json@@ -10,7 +10,7 @@"googleTagManager": {"id": "GTM-WNP7MLF"},- "alert": {+ "notification": {"url": "https://status.earthdata.nasa.gov/api/v1/notifications?domain=https%3A%2F%2Fworldview.earthdata.nasa.gov","releases": "https://github.com/nasa-gibs/worldview/releases"},@@ -25,4 +25,4 @@"https://earthdata.nasa.gov/lib/ntpagetag.js","https://fbm.earthdata.nasa.gov/for/worldview/feedback.js"]-}\ No newline at end of file+}diff --git a/web/js/app.js b/web/js/app.jsindex 79b3bb34f..a695a2ceb 100644--- a/web/js/app.js+++ b/web/js/app.js@@ -395,7 +395,7 @@ class App extends React.Component {models.compare = compareModel(models, config);models.link.register(models.compare);}- models.tour = tourModel(models, config);+ models.tour = tourModel(config);models.link.register(models.proj).register(models.layers)@@ -499,8 +499,8 @@ class App extends React.Component {}ui.link = linkUi(models, config);ui.info = uiInfo(ui, config);- if (config.features.alert) {- ui.alert = notificationsUi(ui, config);+ if (config.features.notification) {+ ui.notification = notificationsUi(ui, config);}if (config.features.compare) {ui.compare = compareUi(models, ui, config);diff --git a/web/js/sidebar/ui.js b/web/js/sidebar/ui.jsindex 6c222561b..f07e1e379 100644--- a/web/js/sidebar/ui.js+++ b/web/js/sidebar/ui.js@@ -35,7 +35,7 @@ export function sidebarUi(models, config, ui) {trailing: true});var layerAdd = function(layer) {- if (!ui.tour.resetting && !ui.naturalEvents.selecting) {+ if (!ui.naturalEvents.selecting) {updateLayers();}};@@ -200,23 +200,21 @@ export function sidebarUi(models, config, ui) {* Update layer when something happens (Event listeners)*/var updateLayers = function() {- if (!ui.tour.resetting) {- if (models.compare && models.compare.active) {- let compareObj = getCompareObjects(models);- return self.reactComponent.setState({- firstDateObject: compareObj.a,- secondDateObject: compareObj.b,- zotsObject: getZotsForActiveLayers(config, models, ui)- });- } else {- self.reactComponent.setState({- layers: models.layers.get(- { group: 'all', proj: models.proj.selected.id },- models.layers[models.layers.activeLayers]- ),- zotsObject: getZotsForActiveLayers(config, models, ui)- });- }+ if (models.compare && models.compare.active) {+ let compareObj = getCompareObjects(models);+ return self.reactComponent.setState({+ firstDateObject: compareObj.a,+ secondDateObject: compareObj.b,+ zotsObject: getZotsForActiveLayers(config, models, ui)+ });+ } else {+ self.reactComponent.setState({+ layers: models.layers.get(+ { group: 'all', proj: models.proj.selected.id },+ models.layers[models.layers.activeLayers]+ ),+ zotsObject: getZotsForActiveLayers(config, models, ui)+ });}};var onProductSelect = function(product) {diff --git a/web/js/tour/model.js b/web/js/tour/model.jsindex 2161e8093..082ea75bd 100644--- a/web/js/tour/model.js+++ b/web/js/tour/model.js@@ -5,28 +5,29 @@ export function tourModel(config) {self.selected = null;self.events = util.events();- self.select = function (tourId) {- var tour = 1;- if (!tour) {- throw new Error('Invalid tour: ' + tourId);+ self.select = function (storyId) {+ var story = config.stories[storyId];+ if (!story) {+ throw new Error('Invalid tour: ' + storyId);}var updated = false;- if (!self.selected || self.selected.id !== tourId) {- self.selected = tour;- self.events.trigger('select', tour);+ if (!self.selected || self.selected.id !== storyId) {+ self.selected = story;+ self.events.trigger('select', story);}return updated;};self.save = function (state) {- // console.log(self.selected);- // state.tr = self.selected.id;+ if (state.tr) {+ state.tr = self.selected.id;+ }};self.load = function (state) {- var tourId = state.tr;- if (tourId) {- self.select(tourId);+ var storyId = state.tr;+ if (storyId) {+ self.select(storyId);}};diff --git a/web/js/tour/tour.js b/web/js/tour/tour.jsindex dbe1a01af..1c9ace287 100644--- a/web/js/tour/tour.js+++ b/web/js/tour/tour.js@@ -1,11 +1,11 @@export function parse(state, errors, config) {- var tourId = state.tr;- if (tourId) {- // if (!config.tour[tourId]) {- // delete state.tr;- // errors.push({- // message: 'Unsupported tour: ' + tourId- // });- // }+ var storyId = state.tr;+ if (storyId) {+ if (!config.stories[storyId]) {+ delete state.tr;+ errors.push({+ message: 'Unsupported tour: ' + storyId+ });+ }}};diff --git a/web/js/tour/ui.js b/web/js/tour/ui.jsindex e65969429..316030dfa 100644--- a/web/js/tour/ui.js+++ b/web/js/tour/ui.js@@ -7,6 +7,7 @@ export function tourUi(models, ui, config) {var self = {};var init = function() {+if (!config.features.tour || !config.stories || !config.storyOrder) {return;}@@ -15,6 +16,15 @@ export function tourUi(models, ui, config) {React.createElement(Tour, getInitialProps()),document.getElementById('wv-tour'));++ models.wv.events.on('startup', function() {+ let story = models.tour.selected;+ let storyLoaded = false;+ if (story && storyLoaded === false) {+ self.selectTour(null, story, 1, story.id);+ storyLoaded = true;+ }+ });};var getInitialProps = function() {@@ -82,6 +92,9 @@ export function tourUi(models, ui, config) {let totalSteps = currentStory.steps;if (e) e.preventDefault();self.reactComponent.setState({+ models: models,+ config: config,+ ui: ui,currentStep: 1,totalSteps: totalSteps.length,currentStoryIndex: currentStoryIndex,diff --git a/web/js/ui/info.js b/web/js/ui/info.jsindex 97d491a41..5d000133f 100644--- a/web/js/ui/info.js+++ b/web/js/ui/info.js@@ -48,8 +48,8 @@ export function uiInfo (ui, config) {var $source = $('<li><a><i class=\'ui-icon fa fa-code fa-fw\'></i>Source Code</a></li>');var $new = $('<li><a target=\'_blank\' href=\'' + whatsNewUrl + '\'><i class=\'ui-icon fa fa-flag fa-fw\'></i>What\'s New</a></li>');- if (config.features.alert) {- $alerts = ui.alert.getAlert();+ if (config.features.notification) {+ $alerts = ui.notification.getAlert();}if (config.features.feedback) {$menuItems.append($feedback);