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

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

References #292: Check/create annotation types, etc. required by reggie

This should now work with the items that we need so far for the personal information registration wizard.

File size: 4.0 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 numErrors = 0;
51  var checks = response.checks;
52  var html = '<table border="0" cellpadding="0" cellspacing="0" class="report">';
53  html += '<tr><th id="itemTypeCol">Item type</th><th id="nameCol">Name</th><th id="iconCol"></th><th id="statusCol">Status</th></tr>';
54  var lastItemType = null;
55  for (var i = 0; i < checks.length; i++)
56  {
57    var check = checks[i];
58    var icon = check.status == 'ok' ? 'ok.gif' : 'error.gif';
59    if (check.status == 'missing') numMissing++;
60    if (check.status == 'error') numErrors++;
61    if (lastItemType != check.itemType)
62    {
63      html += '<tr class="newitemtype"><td>'+check.itemType+'</td>';
64    }
65    else
66    {
67      html += '<tr><td>&nbsp;</td>';
68    }
69    lastItemType = check.itemType;
70    html += '<td><div class="link" onclick="itemOnClick(event, \''+check.itemType+'\','+check.id+')"';
71    html += ' title="View this item (use CTRL, ALT or SHIFT to edit)">'+check.name+'</div></td>';
72    html += '<td><img src="../../images/'+icon+'"></td>';
73    html += '<td>'+check.message+'</td>';
74    html += '</tr>';
75  }
76  html += '</table>';
77
78  setInnerHTML('validationResult', html);
79 
80  if (numErrors > 0)
81  {
82    setFatalError(numErrors+' errors was detected. You need to fix those manually.');
83  }
84  Main.showHide('createMissingItems', numMissing > 0); 
85 
86}
87
88function setInnerHTML(id, html)
89{
90  var tag = document.getElementById(id);
91  if (!tag) alert('No tag with id='+id);
92  tag.innerHTML = html;
93}
94function setFatalError(message)
95{
96  setInnerHTML('errorMessage', message);
97  Main.show('errorMessage');
98}
99
100function itemOnClick(event, itemType, itemId)
101{
102  Main.itemOnClick(event, '<%=ID%>', itemType, itemId, true);
103}
104</script>
105<style>
106.report
107{
108  border: 1px solid #999999;
109  width: 800px;
110  table-layout: fixed;
111}
112
113.report #itemTypeCol
114{
115  width: 150px;
116}
117
118.report #nameCol
119{
120  width: 200px;
121}
122.report #iconCol
123{
124  width: 20px;
125}
126.report #statusCol
127{}
128
129
130.report th
131{
132  font-weight: bold;
133  text-align: left;
134  background: #E0E0E0;
135  padding: 2px 4px 2px 4px;
136}
137
138.report td
139{
140  padding: 2px;
141}
142
143.report .newitemtype td
144{
145  border-top: 1px  solid #999999;
146}
147
148</style>
149</base:head>
150<base:body onload="init('Validate')">
151
152  <p:path>
153    <p:pathelement title="Reggie" href="<%="index.jsp?ID="+ID%>" />
154    <p:pathelement title="Verify/install required items" />
155  </p:path>
156
157  <div id="validationResult">Checking; please wait...</div>
158
159  <div class="error" id="errorMessage" style="display: none; width: 800px; margin-left: 0px;"></div>
160
161  <div id="createMissingItems" style="display:none;">
162    <table><tr><td>
163    <base:button title="Create missing items" image="add.png" onclick="createMissingItems()"/>
164    </td></tr></table>
165  </div>
166
167  <pre>
168  <div id="debug"></div>
169  </pre>
170 
171</base:body>
172</base:page>
173<%
174}
175finally
176{
177  if (dc != null) dc.close();
178}
179%>
Note: See TracBrowser for help on using the repository browser.