From b7f0b7a928ff439562c529dab49865e7d5948733 Mon Sep 17 00:00:00 2001
From: cramakri <cramakri>
Date: Wed, 16 Nov 2011 15:06:21 +0000
Subject: [PATCH] LMS-2638 Retrieve files

SVN: 23692
---
 .../html/downloader/openbis-dendrogram.html   | 30 ++++++++++++++-----
 .../source/html/downloader/openbis.js         |  2 +-
 .../source/html/downloader/tree.css           |  8 +++--
 3 files changed, 28 insertions(+), 12 deletions(-)

diff --git a/deep_sequencing_unit/source/html/downloader/openbis-dendrogram.html b/deep_sequencing_unit/source/html/downloader/openbis-dendrogram.html
index c2846681ece..53337387617 100644
--- a/deep_sequencing_unit/source/html/downloader/openbis-dendrogram.html
+++ b/deep_sequencing_unit/source/html/downloader/openbis-dendrogram.html
@@ -11,7 +11,7 @@
   <script type="text/javascript" src="openbis.js"></script>
   <script type="text/javascript" src="openbis-dsu.js"></script>
   <!-- To speed development, cache the requests -->
-  <script type="text/javascript" src="openbis-request-cache.js"></script>
+  <!-- <script type="text/javascript" src="openbis-request-cache.js"></script> -->
   <script>
 
 dsu = new openbis_dsu('https://openbis-dsu.ethz.ch/openbis/openbis', 'https://openbis-dsu.ethz.ch/datastore_server');
@@ -325,11 +325,14 @@ function updateInspectors(duration)
 			.transition()
 				.style("opacity", "1");
 				
-	var downloadTable = box.append("table");
+	var downloadTable = inspector.selectAll("table.downloads").data(function(d) { return [d] });
+	
 	downloadTable
-		.attr("width", "100%")
-		.attr("class", "downloads")
-		.style("color", "steelblue");
+		.enter()
+			.append("table")
+				.attr("width", "100%")
+				.attr("class", "downloads")
+				.style("color", "steelblue");
 			
 	// Add a caption, but make sure there is just one (this does not work with select())
 	downloadTable.selectAll("caption")
@@ -345,7 +348,8 @@ function updateInspectors(duration)
 			.append("tr")
 				.append("td")
 				.style("text-align", "left")
-				.text(function (d) { return d.pathInListing });
+				.on("click", downloadTableFile)
+				.text(function(d) { return d.pathInListing });
 		
 	inspector.exit().transition()
 		.duration(duration)
@@ -379,11 +383,12 @@ function retrieveFilesForSequencingSample(sequencing)
 
 			sequencing.datasets = data.result.map(function(bisds) { return {bis : bisds} });
 			sequencing.files = [];
+			sequencing.loadingFiles = true;
 						
 			// Get all the files and update the inspectors once all the data is avilable
 			var deferrer = 
 				new actionDeferrer(
-					function() { updateInspectors(500) }, 
+					function() { sequencing.loadingFiles = false; updateInspectors(500) }, 
 					sequencing.datasets.map(function(ds) { return ds.bis.code; }));
 				
 			sequencing.datasets.forEach(function(ds) { 
@@ -392,7 +397,7 @@ function retrieveFilesForSequencingSample(sequencing)
 						deferrer.dependencyCompleted(ds.bis.code);
 						return;
 					}
-					
+					data.result.forEach(function (file) { file.dataset = ds });
 					sequencing.files = sequencing.files.concat(data.result);
 					deferrer.dependencyCompleted(ds.bis.code);
 				})
@@ -429,6 +434,15 @@ function downloadTableCaption(d)
 	return hasSampleBeenSequenced(d) ? ["Files"] : ["Not Yet Sequenced"];
 }
 
+function downloadTableFile(d)
+{
+	// If there is no dataset, this is just a marker for loading
+	if (!d.dataset) return;
+	
+	var action = function(data) { document.location.href = data.result };
+	dsu.server.getDownloadUrlForFileForDataSet(d.dataset.bis.code, d.pathInDataSet, action);
+}
+
 function enterApp()
 {
 	$("#login-form-div").hide();
diff --git a/deep_sequencing_unit/source/html/downloader/openbis.js b/deep_sequencing_unit/source/html/downloader/openbis.js
index 4815067191d..7050a58ac8e 100644
--- a/deep_sequencing_unit/source/html/downloader/openbis.js
+++ b/deep_sequencing_unit/source/html/downloader/openbis.js
@@ -182,7 +182,7 @@ openbis.prototype.listFilesForDataSet = function(dataSetCode, path, recursive, a
 
 openbis.prototype.getDownloadUrlForFileForDataSet = function(dataSetCode, filePath, action) {
 	ajaxRequest({
-			url: openbis.dssUrl,
+			url: this.dssUrl,
 			data: { "method" : "getDownloadUrlForFileForDataSet",
 							"params" : [ this.sessionToken, dataSetCode, filePath ]
 						 },
diff --git a/deep_sequencing_unit/source/html/downloader/tree.css b/deep_sequencing_unit/source/html/downloader/tree.css
index 66ee9ed7c86..898bbb9bdb1 100644
--- a/deep_sequencing_unit/source/html/downloader/tree.css
+++ b/deep_sequencing_unit/source/html/downloader/tree.css
@@ -71,6 +71,8 @@ table.downloads {
   font-family: "Trebuchet MS", sans-serif;
 	font-size: 14px;
 	table-layout: fixed;
+	border-collapse: collapse;
+	margin: 0px;
 	padding: 0px;
 }
 
@@ -81,12 +83,12 @@ table.downloads {
 */
 
 .downloads tr {
-	border-bottom: 2px solid #FFFFFF;
+	padding: 0px;
 }
 
 .downloads td {
-	width: 50%;
-	border-bottom: 2px solid #FFFFFF;
+	border: 2px solid #FFFFFF;	
+	padding: 2px;
 }
 
 .downloads td:hover {
-- 
GitLab