From 00b015b4d3a09deaff1f4d72f882da356f1a9669 Mon Sep 17 00:00:00 2001 From: cramakri <cramakri> Date: Tue, 27 Nov 2012 13:24:48 +0000 Subject: [PATCH] BIS-263 SP-400 : Preparation for switch to SVG display SVN: 27773 --- .../1/as/webapps/bottom-up/html/webapp.js | 28 +++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/deep_sequencing_unit/source/core-plugins/ngs-sample-overview-graph/1/as/webapps/bottom-up/html/webapp.js b/deep_sequencing_unit/source/core-plugins/ngs-sample-overview-graph/1/as/webapps/bottom-up/html/webapp.js index 05eafeec5cf..eaf9483d691 100644 --- a/deep_sequencing_unit/source/core-plugins/ngs-sample-overview-graph/1/as/webapps/bottom-up/html/webapp.js +++ b/deep_sequencing_unit/source/core-plugins/ngs-sample-overview-graph/1/as/webapps/bottom-up/html/webapp.js @@ -1,13 +1,27 @@ +/** + * Sample-Relationship Bottom Up Webapp + * + * This webapp draws a graph emanating from a flowcell and terminating at the biological sample. + * + * Because the structure is rigid, it draws each sample type in its own column. + */ + // // BEGIN CONFIGURATION PARAMTERS // // The following parameters must be configured for the webapp -// The name of the dss +// TODO Remove -- this is not needed (The name of the dss) var DSS_NAME = "DSS1"; var FLOWCELL_SAMPLE_TYPE = "FLOWCELL"; +// The view is organized in columns that correspond to a sample type. The columns are defined here. +var COLUMNS = [ + { type : "FLOWLANE", label : "Flowlane", width : 120 }, + { type : "MULTIPLEX", label : "Multiplex", width : 120 } +]; + // END CONFIGURATION PARAMTERS /// The openbisServer we use for our data @@ -38,6 +52,7 @@ function SampleGraphNode(sample) { this.sampleType = sample.sampleTypeCode; this.children = []; this.serverSample = sample; + this.arrayIndex = -1 } @@ -54,6 +69,9 @@ SampleGraphModel.prototype.initializeModel = function() { this.sampleSpace = identifierTokens[1]; this.sampleCode = identifierTokens[2]; this.samplePermId = webappContext.getEntityPermId(); + var samplesByType = {}; + COLUMNS.forEach(function(column) { samplesByType[column.type] = [] }); + this.samplesByType = samplesByType; } /** @@ -113,10 +131,11 @@ SampleGraphModel.prototype.coalesceGraphData = function(data, callback) { var samples = data.result; var nodesById = {}; - function isPureId(sample) { return null == sample["@id"]; }; + function isPureId(sample) { return null == sample["@id"]; } function nodeForSample(sample) { return isPureId(sample) ? nodesById[sample] : nodesById[sample["@id"]]; } + var lexicalParent = this; function convertSampleToNode(sample) { // This is just a nodeId, it will be converted elsewhere if (isPureId(sample)) return; @@ -125,6 +144,11 @@ SampleGraphModel.prototype.coalesceGraphData = function(data, callback) { var node = new SampleGraphNode(sample); nodesById[node.nodeId] = node; + sampleTypeArray = lexicalParent.samplesByType[node.sampleType] + if (sampleTypeArray) { + node.arrayIndex = sampleTypeArray.length; + sampleTypeArray.push(node); + } } function resolveParents(sample) { -- GitLab