Skip to content

Interactive interface for browsing global, full-resolution satellite imagery

Move notificationRequest to toolbar component #1576

Benjamin Kingedae0dc7a642
diff --git a/web/js/app.js b/web/js/app.js
index 6bde05c27..f1dc8dbd6 100644
--- a/web/js/app.js
+++ b/web/js/app.js
@@ -81,9 +81,6 @@ import '../pages/css/document.css';
class App extends React.Component {
constructor(props) {
super(props);
- this.state = {
- maps: null
- };
this.onload();
}
render() {
@@ -212,36 +209,11 @@ class App extends React.Component {
});
}
const main = function() {
- // If at the beginning of the day, wait on the previous day until GIBS
- // catches up (about three hours)
- var initialDate;
- if (config.defaults.startDate) {
- initialDate = util.parseDateUTC(config.defaults.startDate);
- } else {
- initialDate = util.now();
- if (initialDate.getUTCHours() < 3) {
- initialDate.setUTCDate(initialDate.getUTCDate() - 1);
- }
- }
const models = self.props.models;
if (config.features.googleTagManager) {
googleTagManager.init(config.features.googleTagManager.id); // Insert google tag manager
}
- if (config.features.notification) {
- let notificationURL = config.features.alert
- ? config.features.notification.url
- : STATUS_REQUEST_URL;
- if (config.parameters.mockAlerts) {
- notificationURL =
- 'mock/notify_' + config.parameters.mockAlerts + '.json';
- } else if (config.parameters.notificationURL) {
- notificationURL =
- 'https://status.earthdata.nasa.gov/api/v1/notifications?domain=' +
- config.parameters.notificationURL;
- }
- self.props.requestNotifications(notificationURL);
- }
document.activeElement.blur();
$('input').blur();
$('#eventsHolder').hide();
diff --git a/web/js/combine-ui.js b/web/js/combine-ui.js
index 9ce8ed1bd..70719bc9e 100644
--- a/web/js/combine-ui.js
+++ b/web/js/combine-ui.js
@@ -66,7 +66,9 @@ export function combineUi(models, config, MapMouseEvents) {
});
window.addEventListener('testPassive', null, opts);
window.removeEventListener('testPassive', null, opts);
- } catch (e) {}
+ } catch (e) {
+ util.warn(e);
+ }
function timelineInit() {
ui.timeline = timeline(models, config, ui);
ui.timeline.data = timelineData(models, config, ui);
diff --git a/web/js/containers/toolbar.js b/web/js/containers/toolbar.js
index 13abec861..ac1f5b2b3 100644
--- a/web/js/containers/toolbar.js
+++ b/web/js/containers/toolbar.js
@@ -7,6 +7,15 @@ import ImageDownload from './image-download';
import Projection from './projection';
import InfoList from './info';
import ShareLinks from './share';
+import {
+ requestNotifications,
+ setNotifications
+} from '../modules/notifications/actions';
+import {
+ STATUS_REQUEST_URL,
+ REQUEST_NOTIFICATIONS
+} from '../modules/notifications/constants';
+
const CUSTOM_MODAL_PROPS = {
TOOLBAR_PROJECTION: {
headerText: null,
@@ -45,6 +54,28 @@ const CUSTOM_MODAL_PROPS = {
}
};
class toolbarContainer extends Component {
+ constructor(props) {
+ super(props);
+ this.requestNotifications();
+ }
+ requestNotifications() {
+ const { config, requestNotifications } = this.props;
+ if (config.features.notification) {
+ let notificationURL = config.features.notification.url
+ ? config.features.notification.url
+ : STATUS_REQUEST_URL;
+ if (config.parameters.mockAlerts) {
+ notificationURL =
+ 'mock/notify_' + config.parameters.mockAlerts + '.json';
+ } else if (config.parameters.notificationURL) {
+ console.log('mock notificationURL');
+ notificationURL =
+ 'https://status.earthdata.nasa.gov/api/v1/notifications?domain=' +
+ config.parameters.notificationURL;
+ }
+ requestNotifications(notificationURL);
+ }
+ }
render() {
const {
openModal,
@@ -127,6 +158,17 @@ function mapStateToProps(state) {
const mapDispatchToProps = dispatch => ({
openModal: (key, customParams) => {
dispatch(openCustomContent(key, customParams));
+ },
+ requestNotifications: location => {
+ const promise = dispatch(
+ requestNotifications(location, REQUEST_NOTIFICATIONS, 'json')
+ );
+ promise.then(data => {
+ const obj = JSON.parse(data);
+ if (obj.notifications) {
+ dispatch(setNotifications(obj.notifications));
+ }
+ });
}
});