Skip to content

Interactive interface for browsing global, full-resolution satellite imagery

WV-629: Remove granules from download list

Mike McGanne05968a50718
diff --git a/src/css/dataDownload.css b/src/css/dataDownload.css
index 829d3edf5..5212f58c4 100644
--- a/src/css/dataDownload.css
+++ b/src/css/dataDownload.css
@@ -90,6 +90,27 @@
vertical-align: top;
}
+#DataDownload_DownloadListPanel .remove {
+ display: block;
+ padding: 3px;
+ border: 1px solid #707070;
+ background: #191C20;
+ color: #c0c0c0;
+ border-radius: 5px;
+}
+
+#DataDownload_DownloadListPanel .remove:hover {
+ background: #ffaaaa;
+ border-color: #ffaaaa;
+ color: #000000;
+}
+
+#DataDownload_DownloadListPanel .remove:active {
+ background: #df8a8a;
+ border-color: #df8a8a;
+ color: #000000;
+}
+
#DataDownload_Notice {
width: 80%;
margin: 0 auto;
diff --git a/src/js/Worldview/DataDownload/DownloadListPanel.js b/src/js/Worldview/DataDownload/DownloadListPanel.js
index ef367ce57..02b05077c 100644
--- a/src/js/Worldview/DataDownload/DownloadListPanel.js
+++ b/src/js/Worldview/DataDownload/DownloadListPanel.js
@@ -36,6 +36,8 @@ Worldview.DataDownload.DownloadListPanel = function(config, model) {
self.events = Worldview.Events();
self.show = function() {
+ $("#DataDownload_DownloadListPanel .remove").off("click", removeGranule);
+
selection = reformatSelection();
log.debug("selection", selection);
var newPanel = false;
@@ -64,6 +66,18 @@ Worldview.DataDownload.DownloadListPanel = function(config, model) {
$("#DataDownload_DownloadListPanel a.wget").click(showWgetPage);
$("#DataDownload_DownloadListPanel a.curl").click(showCurlPage);
}
+
+ $("#DataDownload_DownloadListPanel .remove").click(removeGranule);
+
+ var bulkVisible = isBulkDownloadable() &&
+ Worldview.size(model.selectedGranules) !== 0;
+ if ( bulkVisible ) {
+ $("#DataDownload_DownloadListPanel .ft .bulk")
+ .css("visibility", "visible");
+ } else {
+ $("#DataDownload_DownloadListPanel .ft .bulk")
+ .css("visibility", "hidden");
+ }
};
self.hide = function() {
@@ -137,6 +151,7 @@ Worldview.DataDownload.DownloadListPanel = function(config, model) {
$.each(product.granules, function(index, granule) {
var item = {
+ id: granule.id,
label: granule.downloadLabel || granule.label,
links: [],
urs: granule.urs
@@ -206,6 +221,9 @@ Worldview.DataDownload.DownloadListPanel = function(config, model) {
if ( product.name !== granule.label ) {
var elements = [
"<tr>",
+ "<td><input type='button' class='remove' " +
+ "data-granule='" + granule.id + "' " +
+ "value='X'></input></td>",
"<td><nobr><ul><li>" + granule.label + "</li></ul></nobr></td>",
"<td>" + linksText(granule.links) + "</td>",
"</tr>"
@@ -213,6 +231,9 @@ Worldview.DataDownload.DownloadListPanel = function(config, model) {
} else {
var elements = [
"<tr>",
+ "<td><input type='button' class='remove' " +
+ "data-granule='" + granule.id + "' " +
+ "value='X'></input></td>",
"<td colspan='2'>" + linksText(granule.links) + "</td>",
"</tr>"
];
@@ -244,7 +265,10 @@ Worldview.DataDownload.DownloadListPanel = function(config, model) {
};
var bodyText = function() {
- var elements =[];
+ if ( Worldview.size(model.selectedGranules) === 0 ) {
+ return "<br/><h3>Selection Empty</h3>";
+ }
+ var elements = [];
if ( urs ) {
elements.push(NOTICE);
}
@@ -258,6 +282,7 @@ Worldview.DataDownload.DownloadListPanel = function(config, model) {
var bulkDownloadText = function() {
var bulk =
+ "<div class='bulk'>" +
"<h4>Bulk Download</h4>" +
"<ul class='BulkDownload'>" +
"<li><a class='wget' href='#'>List of Links:</a> " +
@@ -266,7 +291,8 @@ Worldview.DataDownload.DownloadListPanel = function(config, model) {
"<li><a class='curl' href='#'>List of cURL Commands:</a> " +
"can be copied and pasted to " +
"a terminal window to download using cURL.</li>" +
- "</ul>";
+ "</ul>" +
+ "</div>";
return bulk;
};
@@ -278,6 +304,11 @@ Worldview.DataDownload.DownloadListPanel = function(config, model) {
Worldview.DataDownload.BulkDownloadPage.show(selection, "curl");
};
+ var removeGranule = function() {
+ var id = $(this).attr("data-granule");
+ model.unselectGranule(model.selectedGranules[id]);
+ };
+
return self;
};
diff --git a/src/js/Worldview/DataDownload/Layers/Button.js b/src/js/Worldview/DataDownload/Layers/Button.js
index 5c98ab5ae..3fb81b170 100644
--- a/src/js/Worldview/DataDownload/Layers/Button.js
+++ b/src/js/Worldview/DataDownload/Layers/Button.js
@@ -55,11 +55,13 @@ Worldview.DataDownload.Layers.Button = function(model, maps, config) {
$.each(maps.projections, function(index, map) {
map.events.register("zoomend", self, resize);
});
+ model.events.on("granuleUnselect", onUnselect);
};
self.update = function(results) {
var layer = getLayer();
layer.removeAllFeatures();
+ features = {};
var featureList = [];
var selectedFeatures = [];
$.each(results.granules, function(index, granule) {
@@ -199,6 +201,13 @@ Worldview.DataDownload.Layers.Button = function(model, maps, config) {
layer.redraw();
};
+ var onUnselect = function(granule) {
+ var feature = features[granule.id];
+ if ( feature ) {
+ getLayer().selectionControl.unselect(feature);
+ }
+ };
+
var onHoverOver = function(event) {
var feature = event.feature;
var granule = feature.attributes.granule;
diff --git a/src/js/Worldview/DataDownload/Model.js b/src/js/Worldview/DataDownload/Model.js
index 130d00d93..c6369ff3f 100644
--- a/src/js/Worldview/DataDownload/Model.js
+++ b/src/js/Worldview/DataDownload/Model.js
@@ -237,8 +237,10 @@ Worldview.DataDownload.Model = function(config, spec) {
};
self.unselectGranule = function(granule) {
- delete self.selectedGranules[granule.id];
- self.events.trigger(self.EVENT_GRANULE_UNSELECT, granule);
+ if ( self.selectedGranules[granule.id] ) {
+ delete self.selectedGranules[granule.id];
+ self.events.trigger(self.EVENT_GRANULE_UNSELECT, granule);
+ }
};
self.isSelected = function(granule) {
diff --git a/src/js/Worldview/DataDownload/SelectionListPanel.js b/src/js/Worldview/DataDownload/SelectionListPanel.js
index d2804e112..948c61e75 100644
--- a/src/js/Worldview/DataDownload/SelectionListPanel.js
+++ b/src/js/Worldview/DataDownload/SelectionListPanel.js
@@ -1,23 +1,27 @@
/*
* NASA Worldview
- *
+ *
* This code was originally developed at NASA/Goddard Space Flight Center for
- * the Earth Science Data and Information System (ESDIS) project.
+ * the Earth Science Data and Information System (ESDIS) project.
*
- * Copyright (C) 2013 United States Government as represented by the
+ * Copyright (C) 2013 United States Government as represented by the
* Administrator of the National Aeronautics and Space Administration.
* All Rights Reserved.
*/
Worldview.namespace("DataDownload");
Worldview.DataDownload.SelectionListPanel = function(model, results) {
-
+
var log = Logging.getLogger("Worldview.DataDownload");
-
+
var panel = null;
var self = {};
var granules = {};
-
+
+ var init = function() {
+ model.events.on("granuleUnselect", onGranuleUnselect);
+ };
+
self.show = function() {
panel = new YAHOO.widget.Panel("DataDownload_SelectionListPanel", {
width: "400px",
@@ -28,7 +32,7 @@ Worldview.DataDownload.SelectionListPanel = function(model, results) {
constraintoviewport: true
});
panel.setHeader("Select data");
-
+
panel.setBody(bodyText());
panel.render(document.body);
panel.show();
@@ -36,24 +40,24 @@ Worldview.DataDownload.SelectionListPanel = function(model, results) {
panel.hideEvent.subscribe(function() {
setTimeout(dispose, 25);
});
-
+
$.each(results.granules, function(index, granule) {
- granules[granule.id] = granule;
+ granules[granule.id] = granule;
});
-
+
$("#DataDownload_GranuleList input").on("click", toggleSelection);
};
-
+
self.hide = function() {
if ( panel ) {
panel.hide();
}
};
-
+
self.visible = function() {
return panel !== null;
};
-
+
self.setVisible = function(value) {
if ( !value ) {
$("#DataDownload_SelectionListPanel").hide();
@@ -63,29 +67,29 @@ Worldview.DataDownload.SelectionListPanel = function(model, results) {
};
var dispose = function() {
- panel.destroy();
+ panel.destroy();
panel = null;
- $("#DataDownload_GranuleList input").off("click", toggleSelection);
+ $("#DataDownload_GranuleList input").off("click", toggleSelection);
};
-
+
var resultsText = function() {
var elements = [];
$.each(results.granules, function(index, granule) {
var selected = model.isSelected(granule) ? "checked='true'" : "";
elements.push(
- "<tr>" +
- "<td>" +
- "<input type='checkbox' value='" + granule.id + "' " +
- selected + ">" +
- "</td>" +
- "<td class='label'>" + granule.label + "</td>" +
+ "<tr>" +
+ "<td>" +
+ "<input type='checkbox' value='" + granule.id + "' " +
+ selected + ">" +
+ "</td>" +
+ "<td class='label'>" + granule.label + "</td>" +
"</tr>"
- );
+ );
});
var text = elements.join("\n");
- return text;
+ return text;
};
-
+
var bodyText = function() {
var elements = [
"<div id='DataDownload_GranuleList'>",
@@ -97,7 +101,7 @@ Worldview.DataDownload.SelectionListPanel = function(model, results) {
var text = elements.join("\n") + "<br/>";
return text;
};
-
+
var toggleSelection = function(event, ui) {
var granule = granules[$(this).attr("value")];
var selected = $(this).prop("checked");
@@ -107,7 +111,14 @@ Worldview.DataDownload.SelectionListPanel = function(model, results) {
model.unselectGranule(granule);
}
};
-
+
+ var onGranuleUnselect = function(granule) {
+ $("#DataDownload_GranuleList input[value='" + granule.id + "']")
+ .removeAttr("checked");
+ };
+
+
+ init();
return self;
};