From 2e1305178ba2382188c7b48414152004ff036e09 Mon Sep 17 00:00:00 2001 From: Aaron LI Date: Thu, 24 Nov 2016 12:45:26 +0800 Subject: webui: products.js: Support download healpix/hpx products --- fg21sim/webui/static/js/products.js | 31 +++++++++++++++++++++++++------ 1 file changed, 25 insertions(+), 6 deletions(-) (limited to 'fg21sim/webui/static/js/products.js') diff --git a/fg21sim/webui/static/js/products.js b/fg21sim/webui/static/js/products.js index 452d05e..1de8ffd 100644 --- a/fg21sim/webui/static/js/products.js +++ b/fg21sim/webui/static/js/products.js @@ -38,12 +38,13 @@ var makeManifestTableCell = function (data, localhost) { var cell = $("").addClass("product"); cell.data("localhost", localhost) .data("frequency", data.frequency) - .data("path", data.healpix.path) - .data("size", data.healpix.size) - .data("md5", data.healpix.md5); + .data("healpix-path", data.healpix.path) + .data("healpix-size", data.healpix.size) + .data("healpix-md5", data.healpix.md5); cell.append($("").attr("title", "Show product information") .addClass("info btn btn-small fa fa-info-circle")); cell.append($("").attr("title", "Download HEALPix map") + .data("ptype", "healpix") .addClass("healpix healpix-download btn btn-small fa fa-file")); if (data.hpx) { cell.data("hpx-image", true) @@ -53,6 +54,7 @@ var makeManifestTableCell = function (data, localhost) { cell.append($("").attr("title", localhost ? "Open HPX FITS image" : "Download HPX FITS image") + .data("ptype", "hpx") .addClass("hpx") .addClass(localhost ? "hpx-open" : "hpx-download") .addClass("btn btn-small fa fa-image")); @@ -274,6 +276,8 @@ var openProductHPX = function (url, compID, freqID, viewer) { $(document).ready(function () { // URL to handle the "products" AJAX requests var ajax_url = "/ajax/products"; + // URL to download the products (NOTE the trailing slash "/") + var download_url = "/products/download/"; // Update the products manifest file path $("#conf-form input[name='workdir'], " + @@ -336,9 +340,9 @@ $(document).ready(function () { title: ("Product: " + product.data("compID") + " @ " + product.data("frequency") + " (#" + product.data("freqID") + ")"), contents: [ - ("HEALPix map: " + product.data("path") + - ", size: " + (product.data("size")/1024/1024).toFixed(1) + - " MB, MD5: " + product.data("md5")) + ("HEALPix map: " + product.data("healpix-path") + + ", size: " + (product.data("healpix-size")/1024/1024).toFixed(1) + + " MB, MD5: " + product.data("healpix-md5")) ] }; if (product.data("hpx-image")) { @@ -392,4 +396,19 @@ $(document).ready(function () { }); } }); + + // Download the HEALPix maps and HPX images + $(document).on( + "click", + ("td.product > .healpix.healpix-download, " + + "td.product > .hpx.hpx-download"), + function () { + var cell = $(this).closest("td"); + var ptype = $(this).data("ptype"); + var filepath = cell.data(ptype + "-path"); + var url = download_url + filepath; + console.log("Download", ptype, "product at URL:", url); + // Open the download URL in a new window + window.open(url, "_blank"); + }); }); -- cgit v1.2.2