Interactive interface for browsing global, full-resolution satellite imagery
Prepare for merge
Mike McGann358ab3355653
diff --git a/src/js/Worldview/DataDownload/Model.js b/src/js/Worldview/DataDownload/Model.jsindex 11ae97d03..3c4fd939c 100644--- a/src/js/Worldview/DataDownload/Model.js+++ b/src/js/Worldview/DataDownload/Model.js@@ -30,6 +30,10 @@ Worldview.DataDownload.Model = function(config) {time: null};+ var noProduct = {+ name: "Not available"+ };+var ns = Worldview.DataDownload;var self = {};@@ -137,6 +141,27 @@ Worldview.DataDownload.Model = function(config) {}};+ self.groupByProducts = function() {+ var products = {};+ $.each(self.layers, function(index, layer) {+ var productId = layer.product || "__NO_PRODUCT";+ var product = config.products[productId] || noProduct;+ if ( !products[productId] ) {+ products[productId] = {+ title: product.name,+ items: []+ };+ }+ products[productId].items.push({+ label: layer.name,+ sublabel: layer.description,+ value: layer.id,+ categories: { All: 1 }+ });+ });+ return products;+ };+self.selectLayer = function(layerName) {if ( self.selectedLayer === layerName ) {return;@@ -229,7 +254,7 @@ Worldview.DataDownload.Model = function(config) {var description = config.layers[layer].description;var productName = null;if ( config.layers[layer].echo ) {- productName = config.layers[layer].echo.name;+ productName = config.layers[layer].echo.product;}self.layers.push({id: id,diff --git a/src/js/Worldview/Widget/DataDownload.js b/src/js/Worldview/Widget/DataDownload.jsindex cb16eabb8..e869e8961 100644--- a/src/js/Worldview/Widget/DataDownload.js+++ b/src/js/Worldview/Widget/DataDownload.js@@ -33,18 +33,20 @@ Worldview.Widget.DataDownload = function(config, spec) {var HTML_WIDGET_INACTIVE = "<img src='images/camera.png'></img>";var HTML_WIDGET_ACTIVE = "<img src='images/cameraon.png'></img>";+ var list = null;var model = spec.model;var mapController = null;var downloadListPanel = null;var self = {};- self.containerId = "dataDownload";+ self.containerId = "DataDownload";var init = function() {model.events.on("activate", onActivate).on("deactivate", onDeactivate).on("layerSelect", onLayerSelect)+ .on("layerUpdate", onLayerUpdate).on("query", onQuery).on("queryResults", onQueryResults).on("queryCancel", onQueryCancel)@@ -86,30 +88,21 @@ Worldview.Widget.DataDownload = function(config, spec) {};self.render = function() {- var tabsHeight = $(".ui-tabs-nav").outerHeight(true);- $(spec.selector)- .height($(spec.selector).parent().outerHeight() - tabsHeight)- .html(- "<div id='DataDownload_Button'>" +- "<input id='DataDownload_Button' type='button'" +- "class='ui-disabled' value=''>" +- "</div>" +- "<div id='productSelector'></div>" +- "<div data-role='fieldcontain'>" +- "<fieldset id='DataDownload_Prefer' data-role='controlgroup'>" +- "<input type='radio' id='DataDownload_BestAvailable' name='prefer' value='science' checked='checked'/>" +- "<label for='DataDownload_BestAvailable'>Best Available</label>" +- "<input type='radio' id='DataDownload_PreferNRT' name='prefer' value='nrt'/>" +- "<label for='DataDownload_PreferNRT'>Prefer Near Real Time</label>" +- "</fieldset></div>")- .trigger("create");- Worldview.DataDownload.ProductSelector(model,"#productSelector");- $(spec.selector + " input[type='button']").click(function() {- model.activate();- });+ var tabs_height = $(".ui-tabs-nav").outerHeight(true);+ $(spec.selector).addClass('bank');+ $(spec.selector).height($(spec.selector).parent().outerHeight() - tabs_height);- $("#DataDownload_Button .ui-btn").click(showDownloadList);- $("#DataDownload_Prefer").on("change", updatePreference);+ list = new SOTE.widget.List(self.containerId, {+ data: [],+ selected: "~",+ close: true,+ filter: true,+ search: false,+ action: {text: "Download (~0GB)", callback: SOTE.widget.Download.handleAction},+ selectableCategories: {callback: SOTE.widget.Download.handleCategoryChange, defaultText: "0 selected"},+ onchange: function() { console.log("onchange", arguments); },+ args: self+ });};var toggleMode = function() {@@ -124,6 +117,7 @@ Worldview.Widget.DataDownload = function(config, spec) {Worldview.DataDownload.MapController(model, spec.maps, config);}updateSelection();+ onLayerUpdate();};var onDeactivate = function() {@@ -135,6 +129,15 @@ Worldview.Widget.DataDownload = function(config, spec) {log.debug("selectLayer", layerName);};+ var onLayerUpdate = function() {+ if ( !model.active ) {+ return;+ }+ console.log(model.groupByProducts());+ list.data = model.groupByProducts();+ list.update();+ };+var onQuery = function() {log.debug("query");Worldview.Indicator.searching();diff --git a/src/js/download.js b/src/js/download.jsindex f4d745f19..ca0a832f6 100644--- a/src/js/download.js+++ b/src/js/download.js@@ -21,8 +21,6 @@ SOTE.widget.Download.prototype = new SOTE.widget.Component;*/SOTE.widget.Download = function(containerId, config){this.log = Logging.getLogger("Worldview.Widget.Download");- this.VALID_PROJECTIONS = ["geographic", "arctic", "antarctic"];- this.hidden = {};//Get the ID of the container elementthis.container=document.getElementById(containerId);@@ -93,7 +91,7 @@ SOTE.widget.Download.handleMetaSuccess = function(data,status,xhr,args){var self = args.self;var dupes = new Object;var count = 0;-+for(var i in data){if(i != "palettes") {@@ -113,6 +111,8 @@ SOTE.widget.Download.handleMetaSuccess = function(data,status,xhr,args){}}}++ self.data = [];if(args.callback){args.callback({self:self,val:args.val});@@ -122,6 +122,7 @@ SOTE.widget.Download.handleMetaSuccess = function(data,status,xhr,args){self.fire();}self.buildMetaDone = true;+ console.log(self.data);};/**diff --git a/src/js/list.js b/src/js/list.jsindex 76bebe18d..da603e55f 100644--- a/src/js/list.js+++ b/src/js/list.js@@ -402,7 +402,7 @@ SOTE.widget.List.adjustCategoryHeights = function(args){$("#" + heights[1].name).css("height",heights[1].height+"px");}- else {+ else if ( heights.length === 1 ) {heights[0].height = container_height;$("#" + heights[0].name).css("height",heights[0].height+"px");}diff --git a/src/js/main.js b/src/js/main.jsindex 3a9670853..5441536f6 100644--- a/src/js/main.js+++ b/src/js/main.js@@ -123,7 +123,7 @@ $(function() {// Initialize "static" varswvEPSG: crs});var dataDownload = Worldview.Widget.DataDownload(config, {- selector: "#dataDownload",+ selector: "#DataDownload",model: dataDownloadModel,maps: map.maps});diff --git a/src/js/products.js b/src/js/products.jsindex 6aa9b41e0..4633371b1 100644--- a/src/js/products.js+++ b/src/js/products.js@@ -136,7 +136,7 @@ SOTE.widget.Products.prototype.render = function(){"<a class='addlayerstab tab' href='#selectorbox'></a>" +"</li>" +"<li class='layerPicker third'>" +- "<a class='tab' href='#ddownload'></a>" ++ "<a class='tab' href='#DataDownload'></a>" +"</li>";this.container.appendChild(tabs);SOTE.widget.Products.change({data: {self: this}}, {index: 0});@@ -161,7 +161,7 @@ SOTE.widget.Products.prototype.render = function(){this.container.appendChild(selectorbox);var downloadBox = document.createElement("div");- downloadBox.setAttribute("id", "ddownload");+ downloadBox.setAttribute("id", "DataDownload");this.container.appendChild(downloadBox);//this.container.appendChild(productContainer);@@ -192,6 +192,7 @@ SOTE.widget.Products.prototype.render = function(){},config: this.config});+ /* FIXME: Removethis.d = new SOTE.widget.Download("ddownload", {dataSourceUrl: "ap_products.php",categories: ["Base Layers","Overlays"],@@ -202,6 +203,7 @@ SOTE.widget.Products.prototype.render = function(){},config: this.config});+ *///$('#'+this.id+"prods").on("tabsshow",SOTE.widget.Products.change);$('.accordionToggler').bind('click',{self:this},SOTE.widget.Products.toggle);