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

Last change on this file since 1485 was 1463, checked in by Martin Svensson, 10 years ago

Merging trunk with branch 2.0

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