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