source: extensions/net.sf.basedb.reggie/trunk/resources/libprep/pool_protocol.jsp @ 1965

Last change on this file since 1965 was 1965, checked in by Nicklas Nordborg, 9 years ago

References #479: Generate lab protocol for pooling and flow cell preparation

Fixed bug in calculations for list view. Some style changes to the list view protocol. Better document title for saving to pdf.

File size: 8.5 KB
Line 
1<%@ page
2  pageEncoding="UTF-8"
3  session="false"
4  import="net.sf.basedb.core.User"
5  import="net.sf.basedb.core.DbControl"
6  import="net.sf.basedb.core.SessionControl"
7  import="net.sf.basedb.core.Application"
8  import="net.sf.basedb.clients.web.Base" 
9  import="net.sf.basedb.clients.web.extensions.ExtensionsControl"
10%>
11<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
12<%@ taglib prefix="p" uri="/WEB-INF/path.tld" %>
13<%
14final SessionControl sc = Base.getExistingSessionControl(request, true);
15final String ID = sc.getId();
16final float scale = Base.getScale(sc);
17final String home = ExtensionsControl.getHomeUrl("net.sf.basedb.reggie");
18DbControl dc = null;
19try
20{
21  dc = sc.newDbControl();
22  final User user = User.getById(dc, sc.getLoggedInUserId());
23%>
24<base:page type="default" >
25<base:head scripts="ajax.js" styles="path.css">
26  <link rel="stylesheet" type="text/css" href="../css/reggie.css">
27  <script language="JavaScript" src="../reggie.js" type="text/javascript" charset="UTF-8"></script>
28
29<script language="JavaScript">
30var debug = false;
31var currentStep = 1;
32
33var pools;
34
35function init()
36{
37  var frm = document.forms['reggie'];
38  pools = getUnpooledPools();
39 
40  var poolsList = frm.pools;
41  var plateList = frm.bioplate;
42 
43  // We get a list of pools from the servlet
44  // Each pool has a list of libraries
45  // We want to find the Library bioplates that are unique
46  // within a pool (eg. all libraries are from the same bioplate)
47  if (pools != null && pools.length > 0)
48  {
49    var libPlates = [];
50    for (var poolNo=0; poolNo < pools.length; poolNo++)
51    {
52      var pool = pools[poolNo];
53     
54      var libPlateForPool = null;
55      for (var libNo = 0; libNo < pool.libraries.length; libNo++)
56      {
57        var lib = pool.libraries[libNo];
58        var libPlate = lib.bioWell.bioPlate;
59       
60        if (libNo == 0)
61        {
62          libPlateForPool = libPlate;
63        }
64        else if (libPlateForPool.id != libPlate.id)
65        {
66          libPlateForPool = null;
67          break;
68        }
69      }
70     
71      // Store the library bioplate
72      pool.libPlate = libPlateForPool;
73     
74      // If the pool has a single library bioplate add it to the selection list
75      // If the pool doesn't have a single library bioplate, nothing is added to
76      // the list and the pool can only be selected when the 'multiple' option is
77      // active for the bioplates list
78      if (libPlateForPool != null && !libPlates[libPlateForPool.name])
79      {
80        libPlates[libPlateForPool.name] = libPlateForPool;
81        var plateOption = new Option(libPlateForPool.name, libPlateForPool.id);
82        plateOption.plate = libPlateForPool;
83        plateList[plateList.length] = plateOption;
84      }
85
86    }
87    if (plateList.length > 1) plateList.selectedIndex = 1;
88    bioplateOnChange();
89    Main.show('gocreate');
90  }
91  else
92  {
93    var msg = 'No pools available for processing.';
94    setFatalError(msg);
95    return;
96  }
97
98}
99
100
101function getUnpooledPools()
102{
103  var frm = document.forms['reggie'];
104 
105  var request = Ajax.getXmlHttpRequest();
106  try
107  {
108    showLoadingAnimation('Loading unprocessed pools...');
109    var url = '../Pool.servlet?ID=<%=ID%>&cmd=GetUnprocessedPools';   
110    request.open("GET", url, false); 
111    request.send(null);
112  }
113  finally
114  {
115    hideLoadingAnimation();
116  }
117 
118  if (debug) Main.debug(request.responseText);
119  var response = JSON.parse(request.responseText); 
120  if (response.status != 'ok')
121  {
122    setFatalError(response.message);
123    return false;
124  }
125  return response.pools;
126}
127
128// Add pools to the pools list based on the bioplate selection
129function bioplateOnChange()
130{
131  var frm = document.forms['reggie'];
132 
133  var libPlateId = parseInt(frm.bioplate.value);
134
135  // Clear current list
136  frm.pools.length = 0;
137 
138  for (var poolNo = 0; poolNo < pools.length; poolNo++)
139  {
140    var pool = pools[poolNo];
141    // If a libplate is selected, only show pools that have all libraries from that plate
142    // If no libplate is selected, only show pools that have libraries from multiple plates
143    var addPool = (libPlateId && pool.libPlate.id == libPlateId) || (!libPlateId && pool.libPlate == null);
144    if (addPool)
145    {
146      frm.pools[frm.pools.length] = new Option(pool.name, pool.id, libPlateId);
147    }
148  }
149 
150  setInputStatus('pools', '', '');
151  if (libPlateId)
152  {
153    frm.pools.disabled = true;
154    Main.removeClass(document.getElementById('plateview'), 'disabled');
155  }
156  else
157  {
158    frm.pools.disabled = false;
159    Main.addClass(document.getElementById('plateview'), 'disabled');
160  }
161}
162
163
164function viewProtocol(type)
165{
166  var frm = document.forms['reggie'];
167  var libPlateId = parseInt(frm.bioplate.value);
168 
169  if (libPlateId == 0)
170  {
171    // 'multiple' option selected, check that at least one pool is selected
172    var numSelectedPools = 0;
173    for (var poolNo = 0; poolNo < frm.pools.length; poolNo++)
174    {
175      if (frm.pools[poolNo].selected) numSelectedPools++;
176    }
177   
178    if (numSelectedPools == 0)
179    {
180      setInputStatus('pools', 'Select at least one pool', 'invalid');
181      return;
182    }
183    setInputStatus('pools', '', 'valid');
184  }
185
186  frm.pools.disabled = false;
187  frm.view.value = type;
188  frm.submit();
189  frm.pools.disabled = (libPlateId != 0);
190}
191
192</script>
193</base:head>
194<base:body onload="init()">
195
196  <p:path><p:pathelement 
197    title="Reggie" href="<%="../index.jsp?ID="+ID%>" 
198    /><p:pathelement title="Lab protocols for library pooling" 
199    /></p:path>
200
201  <div class="content">
202  <%
203  if (sc.getActiveProjectId() == 0)
204  {
205    %>
206    <div class="messagecontainer note" style="width: 950px; margin-left: 20px; margin-bottom: 20px; margin-right: 0px; font-weight: bold; color: #cc0000;">
207      No project has been selected. You may proceed with the registration but
208      created items will not be shared.
209    </div>
210    <%
211  }
212  %>
213
214  <form name="reggie" onsubmit="return false;" action="pool_protocol2.jsp" method="post" target="_blank">
215  <input type="hidden" name="ID" value="<%=ID%>">
216  <input type="hidden" name="view" value="list">
217 
218  <table class="stepform">
219  <tr>
220    <td rowspan="3" class="stepno">1</td>
221    <td class="steptitle">Select pools</td>
222  </tr>
223  <tr>
224    <td class="stepfields">
225      <table>
226      <tr valign="top">
227        <td class="prompt">Library plate</td>
228        <td class="input">
229          <select style="width:90%;" name="bioplate" id="bioplate" onchange="bioplateOnChange()">
230            <option value="0">- multiple -
231          </select>
232          <br>
233          <i>- or -</i>
234        </td>
235        <td class="status" id="bioplate.status"></td>
236        <td class="help"><span id="bioplate.message" class="message" style="display: none;"></span>
237          Select the library bioplate that should be pooled in this step. The list contains
238          all plates with pools that has not yet been created (determined by abscense of creation date).
239          Use the <b>multiple</b> option to select pools with libraries from multiple plates.
240        </td>
241      </tr>
242      <tr valign="top">
243        <td class="prompt">Pools</td>
244        <td class="input"><select style="width:90%;" size="6" 
245            name="pools" id="pools" multiple></select>
246        </td>
247        <td class="status" id="pools.status"></td>
248        <td class="help"><span id="pools.message" class="message" style="display: none;"></span>
249          Select the pools to work with. If a plate has been selected no changes can be made.
250        </td>
251      </tr>
252      <tr valign="top">
253        <td class="prompt">Lab protocols</td>
254        <td class="input" id="protocol" style="white-space: nowrap; line-height: 1.5em;">
255          <span id="listview" class="link" onclick="viewProtocol('list')"><img src="../images/listview.png">&nbsp;List layout</span><br>
256          <span id="plateview" class="link" onclick="viewProtocol('plate')"><img src="../images/plateview.png">&nbsp;Plate layout</span><br>
257        </td>
258        <td class="status" id="protocol.status"></td>
259        <td class="help"><span id="protocol.message" class="message" style="display: none;"></span>
260          The 'list layout' generates a table with one row for each well on the work plate.
261          The 'plate layout' generates a grid with wells arranged according to row and column coordinates.
262        </td>
263      </tr>
264      </table>
265    </td>
266  </tr>
267  </table>
268 
269  <div class="loading" id="loading" style="display: none;"><table><tr><td><img src="../images/loading.gif"></td><td id="loading.msg">Please wait...</td></tr></table></div>
270 
271  <div class="messagecontainer error" id="errorMessage" style="display: none; width: 950px; margin-left: 20px; margin-bottom: 0px;"></div>
272 
273  <div id="done" class="success" style="display: none; width: 950px; margin-left: 20px; margin-top: 20px;"></div>
274 
275  </form>
276  </div>
277 
278</base:body>
279</base:page>
280<%
281}
282finally
283{
284  if (dc != null) dc.close();
285}
286%>
Note: See TracBrowser for help on using the repository browser.