1 | <%@ page |
---|
2 | pageEncoding="UTF-8" |
---|
3 | session="false" |
---|
4 | import="net.sf.basedb.core.Application" |
---|
5 | import="net.sf.basedb.core.User" |
---|
6 | import="net.sf.basedb.core.DbControl" |
---|
7 | import="net.sf.basedb.core.SessionControl" |
---|
8 | import="net.sf.basedb.clients.web.Base" |
---|
9 | import="net.sf.basedb.clients.web.util.HTML" |
---|
10 | import="net.sf.basedb.clients.web.extensions.ExtensionsControl" |
---|
11 | import="net.sf.basedb.util.Values" |
---|
12 | import="net.sf.basedb.util.formatter.DateFormatter" |
---|
13 | import="java.util.Calendar" |
---|
14 | import="java.util.Locale" |
---|
15 | import="java.text.SimpleDateFormat" |
---|
16 | %> |
---|
17 | <%@ taglib prefix="base" uri="/WEB-INF/base.tld" %> |
---|
18 | <%@ taglib prefix="p" uri="/WEB-INF/path.tld" %> |
---|
19 | <% |
---|
20 | final SessionControl sc = Base.getExistingSessionControl(request, true); |
---|
21 | final String ID = sc.getId(); |
---|
22 | final float scale = Base.getScale(sc); |
---|
23 | final String home = ExtensionsControl.getHomeUrl("net.sf.basedb.labenv"); |
---|
24 | DbControl dc = null; |
---|
25 | try |
---|
26 | { |
---|
27 | dc = sc.newDbControl(); |
---|
28 | final User user = User.getById(dc, sc.getLoggedInUserId()); |
---|
29 | %> |
---|
30 | <base:page type="default" > |
---|
31 | <base:head scripts="ajax.js" styles="path.css"> |
---|
32 | <link rel="stylesheet" type="text/css" href="../css/reggie.css"> |
---|
33 | <script language="JavaScript" src="../reggie.js" type="text/javascript" charset="UTF-8"></script> |
---|
34 | |
---|
35 | <script language="JavaScript"> |
---|
36 | |
---|
37 | window.onload = function() |
---|
38 | { |
---|
39 | // Create lab sensor menu from configuration data |
---|
40 | createSensorMenu(); |
---|
41 | }; |
---|
42 | |
---|
43 | function createSensorMenu() |
---|
44 | { |
---|
45 | // Get lab sensor configurations dynamically from server data |
---|
46 | var frm = document.forms['labenv']; |
---|
47 | var labSensorConfigList = getLabSensorConfigList(); |
---|
48 | if (labSensorConfigList != null) |
---|
49 | { |
---|
50 | // Construct lab sensor menu from JSON data |
---|
51 | var sensorSelect = document.getElementById('sensorSelectId'); |
---|
52 | for (var i=0; i < labSensorConfigList.length; i++) |
---|
53 | { |
---|
54 | // Get URL and name for lab sensor number 'i' |
---|
55 | var labSensorConfig = labSensorConfigList[i]; |
---|
56 | var sensorUrl = labSensorConfig['url']; |
---|
57 | var sensorName = labSensorConfig['name']; |
---|
58 | // Create and add new option element to select menu |
---|
59 | var optionEl = document.createElement('option'); |
---|
60 | optionEl.setAttribute('value',sensorUrl); |
---|
61 | optionEl.innerHTML = sensorName; |
---|
62 | sensorSelect.appendChild(optionEl); |
---|
63 | } |
---|
64 | } |
---|
65 | } |
---|
66 | |
---|
67 | function getLabSensorConfigList() |
---|
68 | { |
---|
69 | // Get lab sensor configurations JSON object with AJAX |
---|
70 | var frm = document.forms['labenv']; |
---|
71 | var request = Ajax.getXmlHttpRequest(); |
---|
72 | var url = '../../labenv.jar/LabEnvironment.servlet?ID=<%=ID%>&cmd=GetLabSensorConfigList'; |
---|
73 | request.open("GET", url, false); |
---|
74 | request.send(null); |
---|
75 | |
---|
76 | //if (debug) Main.debug(request.responseText); |
---|
77 | //Main.debug(request.responseText); |
---|
78 | |
---|
79 | var response = JSON.parse(request.responseText); |
---|
80 | if (response.status != 'ok') |
---|
81 | { |
---|
82 | setFatalError(response.message); |
---|
83 | return false; |
---|
84 | } |
---|
85 | |
---|
86 | // Get sensor configurations information from the AJAX response |
---|
87 | var labSensorConfigList = response.labSensorConfigList; |
---|
88 | |
---|
89 | return labSensorConfigList; |
---|
90 | } |
---|
91 | |
---|
92 | function goExport(preview) |
---|
93 | { |
---|
94 | var frm = document.forms['labenv']; |
---|
95 | var url = '../../labenv.jar/LabEnvironment.servlet?ID=<%=ID%>&cmd=LabEnvironmentSensorQuery'; |
---|
96 | if (frm.sensorSelect.value != null) url += '&sensorurl='+frm.sensorSelect.value; |
---|
97 | var sensorUrlText = frm.sensorSelect[frm.sensorSelect.selectedIndex].text; |
---|
98 | url += '&sensorname='+sensorUrlText; |
---|
99 | if (preview) |
---|
100 | { |
---|
101 | var previewTitle = document.getElementById('previewTitle'); |
---|
102 | var previewList = document.getElementById('previewList'); |
---|
103 | |
---|
104 | Main.hide('previewWrapper'); |
---|
105 | previewTitle.innerHTML = 'Working...'; |
---|
106 | previewList.innerHTML = ''; |
---|
107 | |
---|
108 | url += '&preview=1'; |
---|
109 | var request = Ajax.getXmlHttpRequest(); |
---|
110 | |
---|
111 | try |
---|
112 | { |
---|
113 | showLoadingAnimation('Working...'); |
---|
114 | request.open("GET", url, false); |
---|
115 | request.send(null); |
---|
116 | } |
---|
117 | finally |
---|
118 | { |
---|
119 | hideLoadingAnimation(); |
---|
120 | } |
---|
121 | |
---|
122 | if (request.status != 200) |
---|
123 | { |
---|
124 | Main.openPopup('', 'ErrorWindow', 800, 600); |
---|
125 | Main.getWindow('ErrorWindow').document.write(request.responseText); |
---|
126 | } |
---|
127 | else |
---|
128 | { |
---|
129 | var allLines = request.responseText.split('\n'); |
---|
130 | var numCases = allLines.length - 2; // First line is a header line |
---|
131 | var numSpecimen = 0; |
---|
132 | var numNoSpecimen = 0; |
---|
133 | |
---|
134 | var html = '<tr><th>'+allLines[0].replace(/\t/g, '</th><th>')+'</th></tr>'; |
---|
135 | // Check second column for the 'Subtype' value |
---|
136 | var numNoConsent = 0; |
---|
137 | var numMissingConsent = 0; |
---|
138 | for (var i = 1 ; i <= numCases; i++) |
---|
139 | { |
---|
140 | var line = allLines[i]; |
---|
141 | var cols = line.split(/\t/); |
---|
142 | var sampleSubtype = cols[1]; |
---|
143 | if (sampleSubtype == 'Specimen') |
---|
144 | { |
---|
145 | numSpecimen++; |
---|
146 | } |
---|
147 | else if (sampleSubtype == 'NoSpecimen') |
---|
148 | { |
---|
149 | numNoSpecimen++; |
---|
150 | } |
---|
151 | var rowClass = ''; |
---|
152 | html += '<tr class="'+rowClass+'"><td>'+cols.join('</td><td>')+'</td></tr>'; |
---|
153 | } |
---|
154 | |
---|
155 | //var sensorUrlText = frm.sensorSelect[frm.sensorSelect.selectedIndex].text; |
---|
156 | previewTitle.innerHTML = 'Sensor - ' + sensorUrlText; |
---|
157 | previewList.innerHTML = '<table>'+html+'</table>'; |
---|
158 | Main.show('previewWrapper'); |
---|
159 | } |
---|
160 | } |
---|
161 | else |
---|
162 | { |
---|
163 | window.location = url; |
---|
164 | } |
---|
165 | |
---|
166 | } |
---|
167 | |
---|
168 | </script> |
---|
169 | <style> |
---|
170 | |
---|
171 | .fullyear |
---|
172 | { |
---|
173 | font-weight: bold; |
---|
174 | } |
---|
175 | |
---|
176 | #previewWrapper |
---|
177 | { |
---|
178 | position: absolute; |
---|
179 | top: 11em; |
---|
180 | bottom: 1em; |
---|
181 | left: 20px; |
---|
182 | width: 950px; |
---|
183 | overflow: visible; |
---|
184 | } |
---|
185 | |
---|
186 | #previewList |
---|
187 | { |
---|
188 | position: absolute; |
---|
189 | top: 1.5em; |
---|
190 | bottom: 0px; |
---|
191 | width: 950px; |
---|
192 | overflow: auto; |
---|
193 | white-space: pre; |
---|
194 | font-family: monospace; |
---|
195 | border: 1px dotted #A0A0A0; |
---|
196 | border-radius: 4px; |
---|
197 | background: #E8E8E8; |
---|
198 | padding: 0.25em; |
---|
199 | } |
---|
200 | |
---|
201 | #previewTitle |
---|
202 | { |
---|
203 | font-weight: bold; |
---|
204 | } |
---|
205 | |
---|
206 | #previewList th |
---|
207 | { |
---|
208 | border-bottom: 1px dotted #A0A0A0; |
---|
209 | } |
---|
210 | |
---|
211 | #previewList td, #previewList th |
---|
212 | { |
---|
213 | text-align: left; |
---|
214 | padding-right: 2em; |
---|
215 | vertical-align: bottom; |
---|
216 | } |
---|
217 | |
---|
218 | .consent-warning |
---|
219 | { |
---|
220 | color: #A00000; |
---|
221 | background-color: #F8F8E8; |
---|
222 | } |
---|
223 | |
---|
224 | .consent-warning td:last-child |
---|
225 | { |
---|
226 | background-image: url('../images/warning_small.png'); |
---|
227 | background-position: 95% 50%; |
---|
228 | background-repeat: no-repeat; |
---|
229 | } |
---|
230 | |
---|
231 | </style> |
---|
232 | </base:head> |
---|
233 | <base:body > |
---|
234 | |
---|
235 | <p:path><p:pathelement |
---|
236 | title="LabEnv" href="<%="./labsensorinfo.jsp?ID="+ID%>" |
---|
237 | /><p:pathelement title="Lab sensor info" |
---|
238 | /></p:path> |
---|
239 | |
---|
240 | <div class="content"> |
---|
241 | <% |
---|
242 | if (sc.getActiveProjectId() == 0) |
---|
243 | { |
---|
244 | %> |
---|
245 | <div class="messagecontainer note" style="width: 950px; margin-left: 20px; margin-bottom: 20px; margin-right: 0px; font-weight: bold; color: #cc0000;"> |
---|
246 | No project has been selected. You may proceed with the export but |
---|
247 | it may no include all items. |
---|
248 | </div> |
---|
249 | <% |
---|
250 | } |
---|
251 | %> |
---|
252 | <form name="labenv" onsubmit="return false;"> |
---|
253 | |
---|
254 | <!-- 1. Select lab sensor --> |
---|
255 | <table border="0" cellspacing="0" cellpadding="0" class="stepform"> |
---|
256 | <tr> |
---|
257 | <td rowspan="3" class="stepno">1</td> |
---|
258 | <td class="steptitle">Select lab sensor(s)</td> |
---|
259 | </tr> |
---|
260 | <tr> |
---|
261 | <td class="stepfields"> |
---|
262 | <table border="0" cellspacing="0" cellpadding="0" width="100%"> |
---|
263 | <tr> |
---|
264 | <td class="prompt">Sensor</td> |
---|
265 | <td class="input"> |
---|
266 | <select id="sensorSelectId" name="sensorSelect"> |
---|
267 | <option value="all">All</option> |
---|
268 | </select> |
---|
269 | </td> |
---|
270 | <td class="status" id="sensorSelect.status"></td> |
---|
271 | <td class="help"><span id="sensor.message" class="message" style="display: none;"></span>Only sensors with start date set will be queried</td> |
---|
272 | </tr> |
---|
273 | </table> |
---|
274 | </td> |
---|
275 | </tr> |
---|
276 | </table> |
---|
277 | |
---|
278 | <div class="messagecontainer error" id="errorMessage" style="display: none; width: 950px; margin-left: 20px; margin-bottom: 0px;"></div> |
---|
279 | |
---|
280 | <div id="done" class="success" style="display: none; width: 950px; margin-left: 20px; margin-top: 20px;"></div> |
---|
281 | |
---|
282 | <table style="margin-left: 20px; margin-top: 10px;" class="navigation"> |
---|
283 | <tr> |
---|
284 | <!-- |
---|
285 | <td><base:button id="gopreview" title="Preview" image="<%=home+"/images/export.png"%>" onclick="goExport(true)"/></td> |
---|
286 | <td><base:button id="goexport" title="Download" image="<%=home+"/images/download.png"%>" onclick="goExport(false)"/></td> |
---|
287 | --> |
---|
288 | <td><base:button id="gopreview" title="Preview" image="<%="export.png"%>" onclick="goExport(true)"/></td> |
---|
289 | <td><base:button id="goexport" title="Download" image="<%="download.png"%>" onclick="goExport(false)"/></td> |
---|
290 | </tr> |
---|
291 | </table> |
---|
292 | </form> |
---|
293 | |
---|
294 | <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> |
---|
295 | |
---|
296 | <div id="previewWrapper" style="display: none;"> |
---|
297 | <div> |
---|
298 | <span id="previewTitle">Preview</span> |
---|
299 | <span id="previewWarning"></span> |
---|
300 | </div> |
---|
301 | <div id="previewList"></div> |
---|
302 | </div> |
---|
303 | |
---|
304 | </div> |
---|
305 | |
---|
306 | </base:body> |
---|
307 | </base:page> |
---|
308 | <% |
---|
309 | } |
---|
310 | finally |
---|
311 | { |
---|
312 | if (dc != null) dc.close(); |
---|
313 | } |
---|
314 | %> |
---|