source: extensions/net.sf.basedb.reggie/trunk/resources/install.jsp @ 1333

Last change on this file since 1333 was 1333, checked in by Nicklas Nordborg, 11 years ago

Fixes #302: Update functionality in the Personal information registration

The create and update paths have been made more similar to reduce the number of special cases that the code needs to handle. Basically, as much info as we can is extracted from the case (if it exists) and specimen tubes in step 1. This information is used in step 3 and the user can accept it as it is, add missing information or change the current information.

There are some exotic cases that are still problematic. For example, it is not always possible to relate PAD to a case without specimen tubes if there is more than one case for a patient.

Also updated the index page to make it look better.

File size: 5.1 KB
Line 
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.util.Values"
11%>
12<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
13<%@ taglib prefix="p" uri="/WEB-INF/path.tld" %>
14<%
15final SessionControl sc = Base.getExistingSessionControl(request, true);
16final String ID = sc.getId();
17final float scale = Base.getScale(sc);
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,table.css">
26<script language="JavaScript">
27
28function createMissingItems()
29{
30  init('Install');
31}
32
33function init(cmd)
34{
35  var request = Ajax.getXmlHttpRequest();
36  var url = 'Install.servlet?ID=<%=ID%>&cmd='+cmd;
37  request.open("GET", url, false);
38  request.send(null);
39 
40  //setInnerHTML('debug', request.responseText);
41 
42  var response = JSON.parse(request.responseText);
43  if (response.status != 'ok')
44  {
45    setFatalError(response.message);
46    return false;
47  }
48 
49  var numMissing = 0;
50  var numWarnings = 0;
51  var numErrors = 0;
52  var checks = response.checks;
53  var html = '<table border="0" cellpadding="0" cellspacing="0" class="report">';
54  html += '<tr><th id="itemTypeCol">Item type</th><th id="nameCol">Name</th><th id="iconCol"></th><th id="statusCol">Status</th></tr>';
55  var lastItemType = null;
56  for (var i = 0; i < checks.length; i++)
57  {
58    var check = checks[i];
59    var icon = 'ok.gif';
60    if (check.status == 'missing') 
61    {
62      numMissing++;
63      icon = 'error.gif';
64    }
65    if (check.status == 'error') 
66    {
67      numErrors++;
68      icon = 'error.gif';
69    }
70    if (check.status == 'warning') 
71    {
72      numWarnings++;
73      icon = 'warning.gif';
74    }
75    if (lastItemType != check.itemType)
76    {
77      html += '<tr class="newitemtype" valign="top"><td>'+check.itemType+'</td>';
78    }
79    else
80    {
81      html += '<tr class="sameitemtype" valign="top"><td>&nbsp;</td>';
82    }
83    lastItemType = check.itemType;
84    if (check.id)
85    {
86      html += '<td><div class="link" onclick="itemOnClick(event, \''+check.itemType+'\','+check.id+')"';
87      html += ' title="View this item (use CTRL, ALT or SHIFT to edit)">'+check.name+'</div></td>';
88    }
89    else
90    {
91      html += '<td><i>' + check.name + '</i></td>';
92    }
93    html += '<td><img src="../../images/'+icon+'"></td><td>';
94    if (check.messages.length > 1)
95    {
96      for (var m = 0; m < check.messages.length; m++)
97      {
98        html += '• '+check.messages[m] + '<br>';
99      }
100    }
101    else
102    {
103      html += check.messages;
104    }
105    html += '</td></tr>';
106  }
107  html += '</table>';
108
109  setInnerHTML('validationResult', html);
110 
111  if (numErrors > 0)
112  {
113    setFatalError(numErrors+' errors was detected. You need to fix those manually.');
114  }
115  else if (numWarnings > 0)
116  {
117    setWarningMessage(numWarnings+' warnings was detected. Reggie may still work. If not, you need to fix it manually.');
118  }
119  Main.showHide('createMissingItems', numMissing > 0); 
120 
121}
122
123function setInnerHTML(id, html)
124{
125  var tag = document.getElementById(id);
126  if (!tag) alert('No tag with id='+id);
127  tag.innerHTML = html;
128}
129function setFatalError(message)
130{
131  setInnerHTML('errorMessage', message);
132  Main.show('errorMessage');
133}
134
135function setWarningMessage(message)
136{
137  setInnerHTML('warningMessage.message', message);
138  Main.show('warningMessage');
139}
140
141function itemOnClick(event, itemType, itemId)
142{
143  Main.itemOnClick(event, '<%=ID%>', itemType, itemId, true);
144}
145</script>
146<style>
147.report
148{
149  border: 1px solid #999999;
150  width: 800px;
151  table-layout: fixed;
152}
153
154.report #itemTypeCol
155{
156  width: 150px;
157}
158
159.report #nameCol
160{
161  width: 200px;
162}
163.report #iconCol
164{
165  width: 20px;
166}
167.report #statusCol
168{}
169
170
171.report th
172{
173  font-weight: bold;
174  text-align: left;
175  background: #E0E0E0;
176  padding: 2px 4px 2px 4px;
177}
178
179.report td
180{
181  padding: 2px;
182}
183
184.report .newitemtype td
185{
186  border-top: 1px solid #999999;
187}
188.report .sameitemtype td
189{
190  border-top: 1px dotted #cccccc;
191}
192
193</style>
194</base:head>
195<base:body onload="init('Validate')">
196
197  <p:path style="margin-top: 20px; margin-bottom: 10px;">
198    <p:pathelement title="Reggie" href="<%="index.jsp?ID="+ID%>" />
199    <p:pathelement title="Installation wizard" />
200  </p:path>
201
202  <div id="validationResult" style="margin-left: 20px;">Checking; please wait...</div>
203
204  <div id="createMissingItems" style="display:none; margin-left: 20px; margin-top: 10px;">
205    <table><tr><td>
206    <base:button title="Create missing items" image="add.png" onclick="createMissingItems()"/>
207    </td></tr></table>
208  </div>
209
210  <div class="error" id="errorMessage" style="display: none; width: 800px; margin-left: 20px; margin-bottom: 0px;"></div>
211
212  <base:note id="warningMessage" type="warning" style="display: none; width: 800px; margin-left: 20px; margin-top: 20px;"><div id="warningMessage.message"></div></base:note>
213
214  <pre>
215  <div id="debug"></div>
216  </pre>
217 
218</base:body>
219</base:page>
220<%
221}
222finally
223{
224  if (dc != null) dc.close();
225}
226%>
Note: See TracBrowser for help on using the repository browser.