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 | <% |
---|
14 | final SessionControl sc = Base.getExistingSessionControl(request, true); |
---|
15 | final String ID = sc.getId(); |
---|
16 | final float scale = Base.getScale(sc); |
---|
17 | final String home = ExtensionsControl.getHomeUrl("net.sf.basedb.reggie"); |
---|
18 | DbControl dc = null; |
---|
19 | try |
---|
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"> |
---|
30 | var debug = false; |
---|
31 | var currentStep = 1; |
---|
32 | |
---|
33 | var pools; |
---|
34 | |
---|
35 | function 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('step.1.section'); |
---|
90 | Main.show('gocreate'); |
---|
91 | } |
---|
92 | else |
---|
93 | { |
---|
94 | var msg = 'No pools available for processing.'; |
---|
95 | setFatalError(msg); |
---|
96 | return; |
---|
97 | } |
---|
98 | |
---|
99 | } |
---|
100 | |
---|
101 | |
---|
102 | function getUnpooledPools() |
---|
103 | { |
---|
104 | var frm = document.forms['reggie']; |
---|
105 | |
---|
106 | var request = Ajax.getXmlHttpRequest(); |
---|
107 | try |
---|
108 | { |
---|
109 | showLoadingAnimation('Loading unprocessed pools...'); |
---|
110 | var url = '../Pool.servlet?ID=<%=ID%>&cmd=GetUnprocessedPools'; |
---|
111 | request.open("GET", url, false); |
---|
112 | request.send(null); |
---|
113 | } |
---|
114 | finally |
---|
115 | { |
---|
116 | hideLoadingAnimation(); |
---|
117 | } |
---|
118 | |
---|
119 | if (debug) Main.debug(request.responseText); |
---|
120 | var response = JSON.parse(request.responseText); |
---|
121 | if (response.status != 'ok') |
---|
122 | { |
---|
123 | setFatalError(response.message); |
---|
124 | return false; |
---|
125 | } |
---|
126 | return response.pools; |
---|
127 | } |
---|
128 | |
---|
129 | // Add pools to the pools list based on the bioplate selection |
---|
130 | function bioplateOnChange() |
---|
131 | { |
---|
132 | var frm = document.forms['reggie']; |
---|
133 | |
---|
134 | var libPlateId = parseInt(frm.bioplate.value); |
---|
135 | |
---|
136 | // Clear current list |
---|
137 | frm.pools.length = 0; |
---|
138 | |
---|
139 | for (var poolNo = 0; poolNo < pools.length; poolNo++) |
---|
140 | { |
---|
141 | var pool = pools[poolNo]; |
---|
142 | // If a libplate is selected, only show pools that have all libraries from that plate |
---|
143 | // If no libplate is selected, only show pools that have libraries from multiple plates |
---|
144 | var addPool = (libPlateId && pool.libPlate.id == libPlateId) || (!libPlateId && pool.libPlate == null); |
---|
145 | if (addPool) |
---|
146 | { |
---|
147 | frm.pools[frm.pools.length] = new Option(pool.name, pool.id, libPlateId); |
---|
148 | } |
---|
149 | } |
---|
150 | |
---|
151 | setInputStatus('pools', '', ''); |
---|
152 | if (libPlateId) |
---|
153 | { |
---|
154 | frm.pools.disabled = true; |
---|
155 | Main.removeClass(document.getElementById('plateview'), 'disabled'); |
---|
156 | } |
---|
157 | else |
---|
158 | { |
---|
159 | frm.pools.disabled = false; |
---|
160 | Main.addClass(document.getElementById('plateview'), 'disabled'); |
---|
161 | } |
---|
162 | } |
---|
163 | |
---|
164 | |
---|
165 | function viewProtocol(type) |
---|
166 | { |
---|
167 | var frm = document.forms['reggie']; |
---|
168 | var libPlateId = parseInt(frm.bioplate.value); |
---|
169 | |
---|
170 | if (libPlateId == 0) |
---|
171 | { |
---|
172 | // 'multiple' option selected, check that at least one pool is selected |
---|
173 | var numSelectedPools = 0; |
---|
174 | for (var poolNo = 0; poolNo < frm.pools.length; poolNo++) |
---|
175 | { |
---|
176 | if (frm.pools[poolNo].selected) numSelectedPools++; |
---|
177 | } |
---|
178 | |
---|
179 | if (numSelectedPools == 0) |
---|
180 | { |
---|
181 | setInputStatus('pools', 'Select at least one pool', 'invalid'); |
---|
182 | return; |
---|
183 | } |
---|
184 | setInputStatus('pools', '', 'valid'); |
---|
185 | } |
---|
186 | |
---|
187 | frm.pools.disabled = false; |
---|
188 | frm.view.value = type; |
---|
189 | frm.submit(); |
---|
190 | frm.pools.disabled = (libPlateId != 0); |
---|
191 | } |
---|
192 | |
---|
193 | </script> |
---|
194 | </base:head> |
---|
195 | <base:body onload="init()"> |
---|
196 | |
---|
197 | <p:path><p:pathelement |
---|
198 | title="Reggie" href="<%="../index.jsp?ID="+ID%>" |
---|
199 | /><p:pathelement title="Lab protocols for library pooling" |
---|
200 | /></p:path> |
---|
201 | |
---|
202 | <div class="content"> |
---|
203 | <% |
---|
204 | if (sc.getActiveProjectId() == 0) |
---|
205 | { |
---|
206 | %> |
---|
207 | <div class="messagecontainer note" style="width: 950px; margin-left: 20px; margin-bottom: 20px; margin-right: 0px; font-weight: bold; color: #cc0000;"> |
---|
208 | No project has been selected. You may proceed with the registration but |
---|
209 | created items will not be shared. |
---|
210 | </div> |
---|
211 | <% |
---|
212 | } |
---|
213 | %> |
---|
214 | |
---|
215 | <form name="reggie" onsubmit="return false;" action="pool_protocol2.jsp" method="post" target="_blank"> |
---|
216 | <input type="hidden" name="ID" value="<%=ID%>"> |
---|
217 | <input type="hidden" name="view" value="list"> |
---|
218 | |
---|
219 | <div id="step.1.section" style="display: none;"> |
---|
220 | <table class="stepform"> |
---|
221 | <tr> |
---|
222 | <td rowspan="3" class="stepno">1</td> |
---|
223 | <td class="steptitle">Select pools</td> |
---|
224 | </tr> |
---|
225 | <tr> |
---|
226 | <td class="stepfields"> |
---|
227 | <table> |
---|
228 | <tr valign="top"> |
---|
229 | <td class="prompt">Library plate</td> |
---|
230 | <td class="input"> |
---|
231 | <select style="width:90%;" name="bioplate" id="bioplate" onchange="bioplateOnChange()"> |
---|
232 | <option value="0">- multiple - |
---|
233 | </select> |
---|
234 | <br> |
---|
235 | <i>- or -</i> |
---|
236 | </td> |
---|
237 | <td class="status" id="bioplate.status"></td> |
---|
238 | <td class="help"><span id="bioplate.message" class="message" style="display: none;"></span> |
---|
239 | Select the library bioplate that should be pooled in this step. The list contains |
---|
240 | all plates with pools that has not yet been created (determined by abscense of creation date). |
---|
241 | Use the <b>multiple</b> option to select pools with libraries from multiple plates. |
---|
242 | </td> |
---|
243 | </tr> |
---|
244 | <tr valign="top"> |
---|
245 | <td class="prompt">Pools</td> |
---|
246 | <td class="input"><select style="width:90%;" size="6" |
---|
247 | name="pools" id="pools" multiple></select> |
---|
248 | </td> |
---|
249 | <td class="status" id="pools.status"></td> |
---|
250 | <td class="help"><span id="pools.message" class="message" style="display: none;"></span> |
---|
251 | Select the pools to work with. If a plate has been selected no changes can be made. |
---|
252 | </td> |
---|
253 | </tr> |
---|
254 | <tr valign="top"> |
---|
255 | <td class="prompt">Lab protocols</td> |
---|
256 | <td class="input" id="protocol" style="white-space: nowrap; line-height: 1.5em;"> |
---|
257 | <span id="listview" class="link" onclick="viewProtocol('list')"><img src="../images/listview.png"> List layout</span><br> |
---|
258 | <span id="plateview" class="link" onclick="viewProtocol('plate')"><img src="../images/plateview.png"> Plate layout</span><br> |
---|
259 | </td> |
---|
260 | <td class="status" id="protocol.status"></td> |
---|
261 | <td class="help"><span id="protocol.message" class="message" style="display: none;"></span> |
---|
262 | The 'list layout' generates a table with one row for each well on the work plate. |
---|
263 | The 'plate layout' generates a grid with wells arranged according to row and column coordinates. |
---|
264 | </td> |
---|
265 | </tr> |
---|
266 | </table> |
---|
267 | </td> |
---|
268 | </tr> |
---|
269 | </table> |
---|
270 | </div> |
---|
271 | |
---|
272 | <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> |
---|
273 | |
---|
274 | <div class="messagecontainer error" id="errorMessage" style="display: none; width: 950px; margin-left: 20px; margin-bottom: 0px;"></div> |
---|
275 | |
---|
276 | <div id="done" class="success" style="display: none; width: 950px; margin-left: 20px; margin-top: 20px;"></div> |
---|
277 | |
---|
278 | </form> |
---|
279 | </div> |
---|
280 | |
---|
281 | </base:body> |
---|
282 | </base:page> |
---|
283 | <% |
---|
284 | } |
---|
285 | finally |
---|
286 | { |
---|
287 | if (dc != null) dc.close(); |
---|
288 | } |
---|
289 | %> |
---|