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 | %> |
---|
13 | <%@ taglib prefix="base" uri="/WEB-INF/base.tld" %> |
---|
14 | <%@ taglib prefix="p" uri="/WEB-INF/path.tld" %> |
---|
15 | <% |
---|
16 | final SessionControl sc = Base.getExistingSessionControl(request, true); |
---|
17 | final String ID = sc.getId(); |
---|
18 | final float scale = Base.getScale(sc); |
---|
19 | final String home = ExtensionsControl.getHomeUrl("net.sf.basedb.reggie"); |
---|
20 | DbControl dc = null; |
---|
21 | try |
---|
22 | { |
---|
23 | dc = sc.newDbControl(); |
---|
24 | final User user = User.getById(dc, sc.getLoggedInUserId()); |
---|
25 | %> |
---|
26 | <base:page type="default" > |
---|
27 | <base:head scripts="ajax.js" styles="path.css,table.css"> |
---|
28 | <link rel="stylesheet" type="text/css" href="../css/reggie.css"> |
---|
29 | <script language="JavaScript" src="../reggie.js" type="text/javascript" charset="UTF-8"></script> |
---|
30 | |
---|
31 | <script language="JavaScript"> |
---|
32 | |
---|
33 | function createMissingItems() |
---|
34 | { |
---|
35 | init('Install'); |
---|
36 | } |
---|
37 | |
---|
38 | function init(cmd) |
---|
39 | { |
---|
40 | var request = Ajax.getXmlHttpRequest(); |
---|
41 | var url = '../Install.servlet?ID=<%=ID%>&cmd='+cmd; |
---|
42 | request.open("GET", url, false); |
---|
43 | request.send(null); |
---|
44 | |
---|
45 | var response = JSON.parse(request.responseText); |
---|
46 | if (response.status != 'ok') |
---|
47 | { |
---|
48 | setFatalError(response.message); |
---|
49 | return false; |
---|
50 | } |
---|
51 | var COL_BREAKS = ['ANNOTATIONTYPE', 'PLUGINDEFINITION']; |
---|
52 | |
---|
53 | var numMissing = 0; |
---|
54 | var numWarnings = 0; |
---|
55 | var numErrors = 0; |
---|
56 | var numIncomplete = 0; |
---|
57 | var checks = response.checks; |
---|
58 | var html = '<table class="report">'; |
---|
59 | var lastItemType = null; |
---|
60 | var index = 0; |
---|
61 | var first10 = ''; |
---|
62 | var theRest = ''; |
---|
63 | var allOk = true; |
---|
64 | |
---|
65 | for (var i = 0; i < checks.length; i++) |
---|
66 | { |
---|
67 | var check = checks[i]; |
---|
68 | var icon = 'ok.png'; |
---|
69 | if (check.status == 'missing') |
---|
70 | { |
---|
71 | numMissing++; |
---|
72 | icon = 'error.png'; |
---|
73 | allOk = false; |
---|
74 | } |
---|
75 | if (check.status == 'incomplete') |
---|
76 | { |
---|
77 | numIncomplete++; |
---|
78 | icon = 'warning.png'; |
---|
79 | allOk = false; |
---|
80 | } |
---|
81 | if (check.status == 'error') |
---|
82 | { |
---|
83 | numErrors++; |
---|
84 | icon = 'error.png'; |
---|
85 | allOk = false; |
---|
86 | } |
---|
87 | if (check.status == 'warning') |
---|
88 | { |
---|
89 | numWarnings++; |
---|
90 | icon = 'warning.png'; |
---|
91 | allOk = false; |
---|
92 | } |
---|
93 | |
---|
94 | if (lastItemType != check.itemType) |
---|
95 | { |
---|
96 | html += first10; |
---|
97 | if (allOk && index > 13) |
---|
98 | { |
---|
99 | html += '<tr class="sameitemtype highlight" id="'+check.itemType+'" onclick="showMore(event)">'; |
---|
100 | html += '<td class="link">… '+(index-10)+' more</td>'; |
---|
101 | html += '<td><img src="../images/ok.png"></td><td>Ok</td></tr>'; |
---|
102 | html += '<tbody id="'+check.itemType+'.more" style="display: none;">'; |
---|
103 | html += theRest; |
---|
104 | html += '</tbody>'; |
---|
105 | } |
---|
106 | else |
---|
107 | { |
---|
108 | html += theRest; |
---|
109 | } |
---|
110 | |
---|
111 | first10 = ''; |
---|
112 | theRest = ''; |
---|
113 | allOk = true; |
---|
114 | index = 0; |
---|
115 | |
---|
116 | var col_break = COL_BREAKS.indexOf(check.itemType); |
---|
117 | if (col_break >= 0) |
---|
118 | { |
---|
119 | // End the left side and start on the right |
---|
120 | html += '</table>'; |
---|
121 | setInnerHTML('validationResult'+col_break, html); |
---|
122 | html = '<table class="report">'; |
---|
123 | } |
---|
124 | html += '<tr class="newitemtype"><td colspan="3">'+check.itemType+'</td></tr>'; |
---|
125 | } |
---|
126 | |
---|
127 | var line = '<tr class="sameitemtype highlight">'; |
---|
128 | lastItemType = check.itemType; |
---|
129 | var name = check.name; |
---|
130 | if (check.mainType) name += ' <span class="itemsubtype">[' + check.mainType + ']</span>'; |
---|
131 | if (check.id) |
---|
132 | { |
---|
133 | line += '<td class="itemTypeCol"><div class="link" onclick="itemOnClick(event, \''+check.itemType+'\','+check.id+')"'; |
---|
134 | line += ' title="View this item (use CTRL, ALT or SHIFT to edit)">'+name+'</div></td>'; |
---|
135 | } |
---|
136 | else |
---|
137 | { |
---|
138 | line += '<td class="itemTypeCol"><i>' + name + '</i></td>'; |
---|
139 | } |
---|
140 | line += '<td class="iconCol"><img src="../images/'+icon+'"></td>'; |
---|
141 | line += '<td class="statusCol">'; |
---|
142 | if (check.messages.length > 1) |
---|
143 | { |
---|
144 | for (var m = 0; m < check.messages.length; m++) |
---|
145 | { |
---|
146 | line += '• '+check.messages[m] + '<br>'; |
---|
147 | } |
---|
148 | } |
---|
149 | else |
---|
150 | { |
---|
151 | line += check.messages; |
---|
152 | } |
---|
153 | line += '</td></tr>'; |
---|
154 | |
---|
155 | if (index < 10) |
---|
156 | { |
---|
157 | first10 += line; |
---|
158 | } |
---|
159 | else |
---|
160 | { |
---|
161 | theRest += line; |
---|
162 | } |
---|
163 | index++; |
---|
164 | } |
---|
165 | |
---|
166 | html += first10; |
---|
167 | if (allOk && index > 13) |
---|
168 | { |
---|
169 | html += '<tr class="sameitemtype highlight" id="'+check.itemType+'" onclick="showMore(event)">'; |
---|
170 | html += '<td class="link">… '+(index-10)+' more</td>'; |
---|
171 | html += '<td><img src="../images/ok.png"></td><td>Ok</td></tr>'; |
---|
172 | html += '<tbody id="'+check.itemType+'.more" style="display: none;">'; |
---|
173 | html += theRest; |
---|
174 | html += '</tbody>'; |
---|
175 | } |
---|
176 | else |
---|
177 | { |
---|
178 | html += theRest; |
---|
179 | } |
---|
180 | |
---|
181 | html += '</table>'; |
---|
182 | setInnerHTML('validationResult'+COL_BREAKS.length, html); |
---|
183 | |
---|
184 | if (numErrors > 0) |
---|
185 | { |
---|
186 | setFatalError(numErrors+' errors was detected. You need to fix those manually.'); |
---|
187 | } |
---|
188 | else if (numWarnings > 0) |
---|
189 | { |
---|
190 | setWarningMessage(numWarnings+' warnings was detected. Reggie may still work. If not, you need to fix it manually.'); |
---|
191 | } |
---|
192 | Main.showHide('createMissingItems', numMissing > 0); |
---|
193 | Main.showHide('fixIncompleteItems', numMissing == 0 && numIncomplete > 0); |
---|
194 | } |
---|
195 | |
---|
196 | function setWarningMessage(message) |
---|
197 | { |
---|
198 | setInnerHTML('warningMessage.message', message); |
---|
199 | Main.show('warningMessage'); |
---|
200 | } |
---|
201 | |
---|
202 | function itemOnClick(event, itemType, itemId) |
---|
203 | { |
---|
204 | Main.itemOnClick(event, '<%=ID%>', itemType, itemId, true); |
---|
205 | } |
---|
206 | |
---|
207 | function showMore(event) |
---|
208 | { |
---|
209 | var target = event.currentTarget; |
---|
210 | Main.show(target.id + '.more'); |
---|
211 | Main.hide(target.id); |
---|
212 | } |
---|
213 | |
---|
214 | </script> |
---|
215 | <style> |
---|
216 | .report |
---|
217 | { |
---|
218 | width: 100%; |
---|
219 | border-collapse: collapse; |
---|
220 | } |
---|
221 | |
---|
222 | .report .itemTypeCol |
---|
223 | { |
---|
224 | width: 18em; |
---|
225 | overflow: hidden; |
---|
226 | text-overflow: ellipsis; |
---|
227 | } |
---|
228 | |
---|
229 | .report .iconCol |
---|
230 | { |
---|
231 | width: 20px; |
---|
232 | } |
---|
233 | .report .statusCol |
---|
234 | {} |
---|
235 | |
---|
236 | |
---|
237 | .report th |
---|
238 | { |
---|
239 | font-weight: bold; |
---|
240 | text-align: left; |
---|
241 | background: #E8E8E8; |
---|
242 | padding: 2px 4px 2px 4px; |
---|
243 | } |
---|
244 | |
---|
245 | .report td |
---|
246 | { |
---|
247 | padding: 2px; |
---|
248 | } |
---|
249 | |
---|
250 | .report .newitemtype |
---|
251 | { |
---|
252 | border-top: 1px solid #A0A0A0; |
---|
253 | border-bottom: 1px solid #A0A0A0; |
---|
254 | font-weight: bold; |
---|
255 | background-color: #E8E8E8; |
---|
256 | } |
---|
257 | .report .sameitemtype |
---|
258 | { |
---|
259 | border-top: 1px dotted #A0A0A0; |
---|
260 | border-bottom: 1px dotted #A0A0A0; |
---|
261 | } |
---|
262 | |
---|
263 | .report .sameitemtype > td:first-child |
---|
264 | { |
---|
265 | padding-left: 1em; |
---|
266 | } |
---|
267 | |
---|
268 | .report td |
---|
269 | { |
---|
270 | white-space: nowrap; |
---|
271 | overflow: hidden; |
---|
272 | text-overflow: ellipsis; |
---|
273 | } |
---|
274 | </style> |
---|
275 | </base:head> |
---|
276 | <base:body onload="init('Validate')"> |
---|
277 | |
---|
278 | <p:path><p:pathelement |
---|
279 | title="Reggie" href="<%="../index.jsp?ID="+ID%>" |
---|
280 | /><p:pathelement title="Installation wizard" |
---|
281 | /></p:path> |
---|
282 | |
---|
283 | <div class="content" style="padding-left: 2em;"> |
---|
284 | |
---|
285 | <div class="absolutefull" style="width: 33%; bottom: 10em;"> |
---|
286 | <div id="validationResult0" class="absolutefull fullborder" style="left: 1em; right: 0.5em; border-top-width: 0 !important;"> |
---|
287 | Checking; please wait... |
---|
288 | </div> |
---|
289 | </div> |
---|
290 | |
---|
291 | <div class="absolutefull" style="width: 33%; bottom: 10em; left: 33%;"> |
---|
292 | <div id="validationResult1" class="absolutefull fullborder" style="left: 0.5em; right: 1em; border-top-width: 0 !important;"> |
---|
293 | </div> |
---|
294 | </div> |
---|
295 | |
---|
296 | <div class="absolutefull" style="width: 34%; bottom: 10em; left: auto;"> |
---|
297 | <div id="validationResult2" class="absolutefull fullborder" style="left: 0.5em; right: 1em; border-top-width: 0 !important;"> |
---|
298 | </div> |
---|
299 | </div> |
---|
300 | |
---|
301 | <div class="absolutefull" style="top: auto; height: 10em; left: 1em; right: 1em;"> |
---|
302 | <div id="createMissingItems" style="display:none; margin-top: 1em;"> |
---|
303 | <base:buttongroup> |
---|
304 | <base:button title="Create missing items" image="add.png" onclick="createMissingItems()"/> |
---|
305 | </base:buttongroup> |
---|
306 | </div> |
---|
307 | |
---|
308 | <div id="fixIncompleteItems" style="display:none; margin-top: 1em;"> |
---|
309 | <base:buttongroup> |
---|
310 | <base:button title="Fix items" image="fixit.png" onclick="createMissingItems()"/> |
---|
311 | </base:buttongroup> |
---|
312 | </div> |
---|
313 | |
---|
314 | <div class="messagecontainer error" id="errorMessage" style="display: none;"></div> |
---|
315 | |
---|
316 | <div class="messagecontainer note" id="warningMessage" style="display: none;"> |
---|
317 | <div id="warningMessage.message"></div> |
---|
318 | </div> |
---|
319 | </div> |
---|
320 | |
---|
321 | </div> |
---|
322 | |
---|
323 | </base:body> |
---|
324 | </base:page> |
---|
325 | <% |
---|
326 | } |
---|
327 | finally |
---|
328 | { |
---|
329 | if (dc != null) dc.close(); |
---|
330 | } |
---|
331 | %> |
---|