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

Last change on this file since 2022 was 2022, checked in by Nicklas Nordborg, 10 years ago

Fixes #500: Plugin configurations should be grouped below their plug-ins

File size: 8.5 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.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<%
16final SessionControl sc = Base.getExistingSessionControl(request, true);
17final String ID = sc.getId();
18final float scale = Base.getScale(sc);
19final String home = ExtensionsControl.getHomeUrl("net.sf.basedb.reggie");
20DbControl dc = null;
21try
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
33function createMissingItems()
34{
35  init('Install');
36}
37
38function 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    var sameSection = lastItemType == check.itemType;
95    // Do not start new section when switching between plugin definition and configuration
96    if (!sameSection) sameSection = lastItemType == 'PLUGINDEFINITION' && check.itemType == 'PLUGINCONFIGURATION';
97    if (!sameSection) sameSection = lastItemType == 'PLUGINCONFIGURATION' && check.itemType == 'PLUGINDEFINITION';
98    if (!sameSection)
99    {
100      html += first10;
101      if (allOk && index > 13)
102      {
103        html += '<tr class="sameitemtype highlight" id="'+check.itemType+'" onclick="showMore(event)">';
104        html += '<td class="link">&hellip; '+(index-10)+' more</td>';
105        html += '<td><img src="../images/ok.png"></td><td>Ok</td></tr>';
106        html += '<tbody id="'+check.itemType+'.more" style="display: none;">';
107        html += theRest;
108        html += '</tbody>';
109      }
110      else
111      {
112        html += theRest;
113      }
114     
115      first10 = '';
116      theRest = '';
117      allOk = true;
118      index = 0;
119     
120      var col_break = COL_BREAKS.indexOf(check.itemType);
121      if (col_break >= 0)
122      {
123        // End the left side and start on the right
124        html += '</table>';
125        setInnerHTML('validationResult'+col_break, html);
126        html = '<table class="report">';
127      }
128      html += '<tr class="newitemtype"><td colspan="3">'+check.itemType+'</td></tr>';
129    }
130   
131    var line = '<tr class="sameitemtype highlight '+check.itemType+'">';
132    lastItemType = check.itemType;
133    var name = check.name;
134    if (check.mainType) name += ' <span class="itemsubtype">[' + check.mainType + ']</span>';
135    if (check.id)
136    {
137      line += '<td class="itemTypeCol"><div class="link" onclick="itemOnClick(event, \''+check.itemType+'\','+check.id+')"';
138      line += ' title="View this item (use CTRL, ALT or SHIFT to edit)">'+name+'</div></td>';
139    }
140    else
141    {
142      line += '<td class="itemTypeCol"><i>' + name + '</i></td>';
143    }
144    line += '<td class="iconCol"><img src="../images/'+icon+'"></td>';
145    line += '<td class="statusCol">';
146    if (check.messages.length > 1)
147    {
148      for (var m = 0; m < check.messages.length; m++)
149      {
150        line += '• '+check.messages[m] + '<br>';
151      }
152    }
153    else
154    {
155      line += check.messages;
156    }
157    line += '</td></tr>';
158   
159    if (index < 10)
160    {
161      first10 += line;
162    }
163    else
164    {
165      theRest += line;
166    }
167    index++;
168  }
169 
170  html += first10;
171  if (allOk && index > 13)
172  {
173    html += '<tr class="sameitemtype highlight" id="'+check.itemType+'" onclick="showMore(event)">';
174    html += '<td class="link">&hellip; '+(index-10)+' more</td>';
175    html += '<td><img src="../images/ok.png"></td><td>Ok</td></tr>';
176    html += '<tbody id="'+check.itemType+'.more" style="display: none;">';
177    html += theRest;
178    html += '</tbody>';
179  }
180  else
181  {
182    html += theRest;
183  }
184 
185  html += '</table>';
186  setInnerHTML('validationResult'+COL_BREAKS.length, html);
187 
188  if (numErrors > 0)
189  {
190    setFatalError(numErrors+' errors was detected. You need to fix those manually.');
191  }
192  else if (numWarnings > 0)
193  {
194    setWarningMessage(numWarnings+' warnings was detected. Reggie may still work. If not, you need to fix it manually.');
195  }
196  Main.showHide('createMissingItems', numMissing > 0);
197  Main.showHide('fixIncompleteItems', numMissing == 0 && numIncomplete > 0);
198}
199
200function setWarningMessage(message)
201{
202  setInnerHTML('warningMessage.message', message);
203  Main.show('warningMessage');
204}
205
206function itemOnClick(event, itemType, itemId)
207{
208  Main.itemOnClick(event, '<%=ID%>', itemType, itemId, true);
209}
210
211function showMore(event)
212{
213  var target = event.currentTarget;
214  Main.show(target.id + '.more');
215  Main.hide(target.id);
216}
217
218</script>
219<style>
220.report
221{
222  width: 100%;
223  border-collapse: collapse;
224}
225
226.report .itemTypeCol
227{
228  width: 18em;
229  overflow: hidden;
230  text-overflow: ellipsis;
231}
232
233.report .iconCol
234{
235  width: 20px;
236}
237.report .statusCol
238{}
239
240
241.report th
242{
243  font-weight: bold;
244  text-align: left;
245  background: #E8E8E8;
246  padding: 2px 4px 2px 4px;
247}
248
249.report td
250{
251  padding: 2px;
252}
253
254.report .newitemtype
255{
256  border-top: 1px solid #A0A0A0;
257  border-bottom: 1px solid #A0A0A0;
258  font-weight: bold;
259  background-color: #E8E8E8;
260}
261.report .sameitemtype
262{
263  border-top: 1px dotted #A0A0A0;
264  border-bottom: 1px dotted #A0A0A0;
265}
266
267.report .sameitemtype > td:first-child
268{
269  padding-left: 1em;
270}
271
272.report .sameitemtype.PLUGINCONFIGURATION > td:first-child
273{
274  padding-left: 2.5em;
275  font-style: italic;
276}
277
278.report td
279{
280  white-space: nowrap;
281  overflow: hidden;
282  text-overflow: ellipsis;
283}
284</style>
285</base:head>
286<base:body onload="init('Validate')">
287
288  <p:path><p:pathelement 
289    title="Reggie" href="<%="../index.jsp?ID="+ID%>" 
290    /><p:pathelement title="Installation wizard" 
291    /></p:path>
292
293  <div class="content" style="padding-left: 2em;">
294
295    <div class="absolutefull" style="width: 33%; bottom: 10em;">
296      <div id="validationResult0" class="absolutefull fullborder" style="left: 1em; right: 0.5em; border-top-width: 0 !important;">
297        Checking; please wait...
298      </div>
299    </div>
300   
301    <div class="absolutefull" style="width: 33%; bottom: 10em; left: 33%;">
302      <div id="validationResult1" class="absolutefull fullborder" style="left: 0.5em; right: 1em; border-top-width: 0 !important;">
303      </div>
304    </div>
305
306    <div class="absolutefull" style="width: 34%; bottom: 10em; left: auto;">
307      <div id="validationResult2" class="absolutefull fullborder" style="left: 0.5em; right: 1em; border-top-width: 0 !important;">
308      </div>
309    </div>
310
311    <div class="absolutefull" style="top: auto; height: 10em; left: 1em; right: 1em;">
312      <div id="createMissingItems" style="display:none; margin-top: 1em;">
313        <base:buttongroup>
314        <base:button title="Create missing items" image="add.png" onclick="createMissingItems()"/>
315        </base:buttongroup>
316      </div>
317   
318      <div id="fixIncompleteItems" style="display:none; margin-top: 1em;">
319        <base:buttongroup>
320        <base:button title="Fix items" image="fixit.png" onclick="createMissingItems()"/>
321        </base:buttongroup>
322      </div>
323   
324      <div class="messagecontainer error" id="errorMessage" style="display: none;"></div>
325   
326      <div class="messagecontainer note" id="warningMessage" style="display: none;">
327        <div id="warningMessage.message"></div>
328      </div>
329    </div>
330 
331  </div>
332 
333</base:body>
334</base:page>
335<%
336}
337finally
338{
339  if (dc != null) dc.close();
340}
341%>
Note: See TracBrowser for help on using the repository browser.