Interactive interface for browsing global, full-resolution satellite imagery
Remove burned in notification, make code readable, css fixes, remove whatsnew config
ZachTRice72d20eda1323
diff --git a/config/default/common/features.json b/config/default/common/features.jsonindex 52fb6a00c..169884b62 100644--- a/config/default/common/features.json+++ b/config/default/common/features.json@@ -6,7 +6,6 @@"customPalettes": true,"compare": true,"tour": true,- "whatsNew": true,"feedback": true,"googleAnalytics": {"id": "UA-88182106-1"diff --git a/web/css/alert.css b/web/css/alert.cssindex ead5d996b..eb18a69ff 100644--- a/web/css/alert.css+++ b/web/css/alert.css@@ -112,3 +112,7 @@border-bottom: 1px solid #404040;margin: 0;}++.wv-dialog .wv-notify-modal ul li div {+ padding: 0;+}diff --git a/web/css/toolbar.css b/web/css/toolbar.cssindex 894971cba..a097400fc 100644--- a/web/css/toolbar.css+++ b/web/css/toolbar.css@@ -9,7 +9,7 @@#wv-toolbar li {font-size: 14.3px;display: inline-block;- margin: 0 2px;+ margin: 0 0 0 4px;background: rgba(40, 40, 40, 0.85);border: 1px solid #333;border-radius: 5px;diff --git a/web/js/notifications/ui.js b/web/js/notifications/ui.jsindex ddccc6260..62c4f53f8 100644--- a/web/js/notifications/ui.js+++ b/web/js/notifications/ui.js@@ -2,42 +2,32 @@ import $ from 'jquery';import util from '../util/util';import lodashIsEmpty from 'lodash/isEmpty';import wvui from '../ui/ui';-/*- * @Class- */+export function notificationsUi(models, config) {+ var alertBlockExists, mainNotification, mainIcon, mainIconLabel, url;var self = {};- var mainNotification;- var mainIcon;- var mainIconLabel;+ var classes = {};var sortedNotifications = {};-var activeNotifications = {};- var activeMessageId;- var url;- var alertBlockExists;- var messageBlockExists;- url = config.features.alert.url;- messageBlockExists = false;- alertBlockExists = false;+self.events = util.events();self.infoIconActive = false;self.notifyIconActive = false;self.messageIconActive = false;- var classes = {+ url = config.features.alert.url;+ alertBlockExists = false;+ classes = {alert: 'bolt',message: 'gift',outage: 'exclamation-circle'};- /*- * Sets global vars, initiates API request- * and triggers dom adjustments based on request- * results- *++ /**+ * Sets global vars, initiates API request and triggers dom adjustments based+ * on request results* @function init* @private- ** @returns {void}*/var init = function () {@@ -51,7 +41,6 @@ export function notificationsUi(models, config) {if (config.parameters.notificationURL) {url = 'https://status.earthdata.nasa.gov/api/v1/notifications?domain=' + config.parameters.notificationURL;}-mainIcon = $('#wv-info-button')[0];mainIconLabel = $('#wv-info-button label')[0];p = util.get(url);@@ -66,95 +55,105 @@ export function notificationsUi(models, config) {console.warn(error);});};- /*++ /*** Sets active state global values- *- * @function setGlobals+ * @function getPriority* @private- *- * @param {object} sortedNotifications - object that- * contains categorized notifications- *+ * @param {object} sortedNotifications - object that contains categorized+ * notifications* @returns {void}*/var getPriority = function (sortedNotifications) {var priority, message, outage, alert;+priority = null;message = sortedNotifications.messages[0];outage = sortedNotifications.outages[0];alert = sortedNotifications.alerts[0];- if (outage || alert) {++ if (outage || alert || message) {alertBlockExists = true;}- if (message) {- messageBlockExists = true;- }+if (message && !objectAlreadySeen(message)) {priority = 'message';mainNotification = 'message';- activeMessageId = message.created_at;+ activeNotifications.messages = message.created_at;}+if (alert && !objectAlreadySeen(alert)) {priority = 'alert';mainNotification = 'alert';activeNotifications.alert = alert.created_at;}+if (outage && !objectAlreadySeen(outage)) {priority = 'outage';mainNotification = 'outage';activeNotifications.outage = outage.created_at;}+return priority;};- var getCounts = function () {- var outageCount, messageCount, alertsAndOutages;- messageCount = getNumberOfTypeNotseen('message', sortedNotifications.messages);-- alertsAndOutages = getNumberOfTypeNotseen('alert', sortedNotifications.alerts); // Number of alerts not yet seen- outageCount = getNumberOfTypeNotseen('outage', sortedNotifications.outages); // Number of outages not yet seen+ /**+ * Gets a count of the unseen notifications+ * @function getCounts+ * @private+ * @returns {array}+ */+ var getCounts = function () {+ var outageCount, messageCount, alertCount;- alertsAndOutages = alertsAndOutages + outageCount;+ messageCount = getNumberOfTypeNotSeen('message', sortedNotifications.messages); // Number of messages not yet seen+ alertCount = getNumberOfTypeNotSeen('alert', sortedNotifications.alerts); // Number of alerts not yet seen+ outageCount = getNumberOfTypeNotSeen('outage', sortedNotifications.outages); // Number of outages not yet seenreturn {messageCount: messageCount,- alertCount: alertsAndOutages+ outageCount: outageCount,+ alertCount: alertCount};};+/**+ * Updates the main icon with the number of unseen notifications+ * @function update+ * @private* @return {void}*/var update = function () {- var alertCount, messageCount, counts, priority;+ var alertCount, outageCount, messageCount, counts, priority;+counts = getCounts();alertCount = counts.alertCount;+ outageCount = counts.outageCount;messageCount = counts.messageCount;priority = getPriority(sortedNotifications);- updateMainIcon(priority, alertCount + messageCount);++ updateMainIcon(priority, alertCount + outageCount + messageCount);};- /*- * Determines the number of status of this type- * that the user is yet to see- *- * @function getNumberOfTypeNotseen+ /**+ * Determines the number of status of this type that the user is yet to see+ * @function getNumberOfTypeNotSeen* @private- ** @param {string} type - Status type* @param {object} arra - array of status of one type- *- * @returns {Number} count - number of unseen messages- * in LocalStorage+ * @returns {Number} count - number of unseen messages in LocalStorage*/- var getNumberOfTypeNotseen = function (type, arra) {+ var getNumberOfTypeNotSeen = function (type, arra) {var storageItem = localStorage.getItem(type);var count, len;len = arra.length;count = 0;+if (!storageItem) {return len;}+for (var i = 0; i < len; i++) {if (new Date(storageItem) < new Date(arra[i].created_at)) {count++;@@ -162,18 +161,15 @@ export function notificationsUi(models, config) {return count;}}+return count;};- /*- * Determines if most recent notification has already- * been seen- *+ /**+ * Determines if most recent notification has already been seen* @function objectAlreadySeen* @private- ** @param {object} obj - object from API array- ** @returns {void}*/var objectAlreadySeen = function (obj) {@@ -183,20 +179,19 @@ export function notificationsUi(models, config) {idString = obj.created_at.toString();fieldValueMatches = false;fieldExists = !!localStorage.getItem(type);+if (fieldExists) {fieldValueMatches = localStorageValueMatches(type, idString);}+return fieldValueMatches;};- /*+ /*** Categorizes the returned array- ** @function separateByType* @private- ** @param {object} obj - array from API- ** @returns {void}*/var separateByType = function (obj) {@@ -218,6 +213,7 @@ export function notificationsUi(models, config) {outages.push(subObj);}}+return {messages: orderByDate(messages),alerts: orderByDate(alerts),@@ -225,88 +221,51 @@ export function notificationsUi(models, config) {};};- /*+ /*** Organizes array by date created- ** @function orderByDate* @private- ** @param {object} obj - array- ** @returns {void}*/var orderByDate = function (obj) {obj.sort(function (a, b) {return new Date(b.created_at) - new Date(a.created_at);});+return obj;};- /*+ /*** Manipulates the Info Icon's class name- ** @function updateMainIcon* @private- ** @returns {void}*/var updateMainIcon = function (type, numberOfAlerts) {mainIconLabel.setAttribute('data-content', numberOfAlerts);+if (type) {mainIcon.className = 'wv-toolbar-button wv-status-' + type;} else {mainIcon.className = 'wv-toolbar-button wv-status-hide';}};- /*- * Creates a message menu item and attaches- * event listeners to the element- *- * @function getMessages- * @static- *- * @returns {object} a jquery element- */- self.getMessages = function () {- var $message, messageNumber, messages, hide;- hide = '';- messages = sortedNotifications.messages;- if (!messageBlockExists) {- return null;- }- if (activeMessageId) {- messageNumber = getNumberOfTypeNotseen('message', messages);- if (messageNumber === 0) {- hide = 'wv-status-hide'; // hides number value when === zero- }- $message = $('<li class=\'gift\'><a class=\'' + hide + '\' data-content=\'' + messageNumber + '\'><i class=\'ui-icon fa fa-fw fa-gift active\'></i>What\'s New</a></li>');- $message.on('click', deactivateMessage);- self.messageIconActive = true;- return $message;- } else {- $message = $('<li><a class=\'wv-status-hide\'><i class=\'ui-icon fa fa-fw fa-gift\'></i>What\'s New</a></li>');- $message.on('click', deactivateMessage);- return $message;- }- };-- /*- * Creates a notification menu item and attaches- * event listeners to the element- *+ /**+ * Creates a notification menu item and attaches event listeners to the element* @function getAlert* @static- ** @returns {object} a jquery element*/self.getAlert = function () {- var $notifyMenuItem, alertsNumber, outageNumber, count, hide;+ var $notifyMenuItem, alertsNumber, outagesNumber, messagesNumber, count, hide;if (!lodashIsEmpty(activeNotifications)) {- alertsNumber = getNumberOfTypeNotseen('alert', sortedNotifications.alerts);- outageNumber = getNumberOfTypeNotseen('outage', sortedNotifications.outages);- count = outageNumber + alertsNumber;+ messagesNumber = getNumberOfTypeNotSeen('message', sortedNotifications.messages);+ alertsNumber = getNumberOfTypeNotSeen('alert', sortedNotifications.alerts);+ outagesNumber = getNumberOfTypeNotSeen('outage', sortedNotifications.outages);+ count = outagesNumber + alertsNumber + messagesNumber;hide = '';if (count === 0) {hide = 'wv-status-hide'; // hides number value when === zero@@ -314,7 +273,6 @@ export function notificationsUi(models, config) {$notifyMenuItem = $('<li class=\'' + classes[mainNotification] + '\'><a class=\'' + hide + '\' data-content=\'' + count + '\'><i class=\'ui-icon fa fa-fw active fa-' + classes[mainNotification] + '\'></i>Notifications</a></li>');self.infoIconActive = true;self.notifyIconActive = true;-$notifyMenuItem.on('click', notify);return $notifyMenuItem;} else if (alertBlockExists) {@@ -326,42 +284,11 @@ export function notificationsUi(models, config) {}};- /*- * Adds API element to localstorage,- * deactives message active state,- * and updates the info icon- *- * @function deactivateMessage- * @private- *- * @returns {void}- */- var deactivateMessage = function (e) {- var messages;- this.className = 'ui-icon fa fa-fw fa-gift';- self.messageIconActive = false;- if (activeMessageId) {- localStorage.setItem('message', activeMessageId);- }- activeMessageId = null;- messages = sortedNotifications.messages[0];- if (messages) {- create$whatsNew(messages, 'Latest Release');- }- if (mainNotification === 'message') {- mainNotification = null;- }- update();- };-- /*- * Adds API element to localstorage,- * deactives notification active states,- * and updates the info icon- *+ /**+ * Adds API element to localstorage, deactives notification active states,+ * and updates the info icon* @function notify* @private- ** @returns {void}*/var notify = function (e) {@@ -371,41 +298,50 @@ export function notificationsUi(models, config) {mainNotification = null;createNotifyDialog();+if (activeNotifications.outage) {localStorage.setItem('outage', activeNotifications.outage);}+if (activeNotifications.alert) {localStorage.setItem('alert', activeNotifications.alert);}++ if (activeNotifications.messages) {+ localStorage.setItem('message', activeNotifications.messages);+ }+activeNotifications = {};+if (self.messageIconActive) {mainNotification = 'message';}+update();};- /*- * Adds API element to localstorage,- * deactives notification active states,- * and updates the info icon- *+ /**+ * Adds API element to localstorage, deactives notification active states,+ * and updates the info icon* @function createNotifyDialog* @private- ** @returns {void}*/var createNotifyDialog = function () {- var $dialog, dimensions;- var $notifyContent = $('<div class="wv-notify-modal"></div>');- if (!sortedNotifications.alerts && !sortedNotifications.outages) {+ var $dialog, dimensions, $notifyContent;++ $notifyContent = $('<div class="wv-notify-modal"></div>');++ if (!sortedNotifications.alerts && !sortedNotifications.outages && !sortedNotifications.messages) {return null;}+dimensions = getModalDimensions();$notifyContent.append(create$block(sortedNotifications.outages, 'outage'));$notifyContent.append(create$block(sortedNotifications.alerts, 'alert'));- $dialog = wvui.getDialog()- .append($notifyContent);+ $notifyContent.append(create$block(sortedNotifications.messages, 'message'));+ $dialog = wvui.getDialog().append($notifyContent);$dialog.dialog({title: 'Notifications',@@ -422,12 +358,10 @@ export function notificationsUi(models, config) {});};- /*+ /*** Gets proper size for modal- ** @function createNotifyDialog* @private- ** @returns {Object} Dimension array*/var getModalDimensions = function () {@@ -435,24 +369,23 @@ export function notificationsUi(models, config) {width = 625;height = 'auto';+if (util.browser.small || util.browser.touchDevice) {width = $(window).width();height = $(window).height();}+return [width, height];};- /*+ /*** Creates a Feed of Jquery list items- ** @function create$block* @private- ** @param {Object} arra - array of objects* @param {string} title - title- ** @returns {Object} Jquery ul element*/var create$block = function (arra, title) {@@ -462,7 +395,7 @@ export function notificationsUi(models, config) {var activeClass;var $ul = $('<ul></ul>');- numNotSeen = getNumberOfTypeNotseen(title, sortedNotifications[title + 's']);+ numNotSeen = getNumberOfTypeNotSeen(title, sortedNotifications[title + 's']);for (var i = 0, len = arra.length; i < len; i++) {activeClass = '';@@ -474,18 +407,16 @@ export function notificationsUi(models, config) {$li = $('<li><div class=\'' + activeClass + '\'><h2> <i class=\'fa fa-' + classes[title] + '\'/> ' + title + '<span> Posted ' + date + '</span></h2><p>' + arra[i].message + '</p></div></li>');$ul.append($li);}+return $ul;};- /*- * Checks to see if id or smaller #id- * is in localstorage- *++ /**+ * Checks to see if id or smaller #id is in localstorage* @function localStorageValueMatches* @private- ** @param {String} property - name of category type* @param {string} value - id of notification- ** @returns {Boolean}*/var localStorageValueMatches = function (property, value) {@@ -493,44 +424,6 @@ export function notificationsUi(models, config) {return new Date(value) <= new Date(oldValue);};- /*- * Creates a Feed containing most recent message- *- * @function create$whatsNew- * @private- *- * @param {Object} most recent message API object- * @param {string} title - title- *- * @returns {void}- */- var create$whatsNew = function (obj, title) {- var $dialog, $notifyContent, releasePageUrl, date, dimensions, $footer;-- date = new Date(obj.created_at);- date = date.getDate() + ' ' + util.giveMonth(date) + ' ' + date.getFullYear();- releasePageUrl = config.features.alert.releases || 'https://github.com/nasa-gibs/worldview/releases';- dimensions = getModalDimensions();- $notifyContent = $('<div class=\'wv-notify-modal\'><div><h2>' + title + '<span> Posted ' + date + '</span></h2><p>' + obj.message + '</p></div></div>');- $footer = $('<div class="wv-notify-footer"><p> Check out our <a target="_blank" href="' + releasePageUrl + '">release notes</a> for a complete list of new additions.</p></div>');- $notifyContent.append($footer);- $dialog = wvui.getDialog()- .append($notifyContent);- $dialog.dialog({- title: 'What\'s New',- width: dimensions[0],- height: dimensions[1],- maxHeight: 525,- show: {- effect: 'fade'- },- hide: {- effect: 'fade'- },- closeText: ''- });- };-init();return self;};diff --git a/web/js/ui/info.js b/web/js/ui/info.jsindex c855246dc..e3342961b 100644--- a/web/js/ui/info.js+++ b/web/js/ui/info.js@@ -39,23 +39,17 @@ export function uiInfo (ui, config) {var show = function () {var $menu = wvui.getMenu().attr('id', 'wv-info-menu');- var $alerts, $new;+ var $alerts;var whatsNewUrl = 'https://github.com/nasa-gibs/worldview/releases';var $menuItems = $('<ul></ul>');var $feedback = $('<li><a class=\'feedback\'><i class=\'ui-icon fa fa-envelope fa-fw\'></i>Send Feedback</a></li>');var $tour = $('<li><a><i class=\'ui-icon fa fa-truck fa-fw\'></i>Start Tour</a></li>');var $about = $('<li><a><i class=\'ui-icon fa fa-file fa-fw\'></i>About</a></li>');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();- $new = ui.alert.getMessages();- if (config.features.alert.releases) {- whatsNewUrl = config.features.alert.releases;- }- }- if (!$new) {- $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.feedback) {$menuItems.append($feedback);@@ -65,9 +59,7 @@ export function uiInfo (ui, config) {}$menuItems.append($source);$menuItems.append($about);- if (config.features.whatsNew) {- $menuItems.append($new);- }+ $menuItems.append($new);if ($alerts) {$menuItems.append($alerts);}