2933 |
14 Nov 14 |
olle |
var Install = function() |
2933 |
14 Nov 14 |
olle |
2 |
{ |
2933 |
14 Nov 14 |
olle |
var install = {}; |
2933 |
14 Nov 14 |
olle |
var debug = 0; |
2933 |
14 Nov 14 |
olle |
5 |
|
2933 |
14 Nov 14 |
olle |
install.initPage = function() |
2933 |
14 Nov 14 |
olle |
7 |
{ |
2933 |
14 Nov 14 |
olle |
if (!App.getActiveProjectId()) return; |
2933 |
14 Nov 14 |
olle |
Buttons.addClickHandler('btnFixItems', install.fixInstallation); |
2933 |
14 Nov 14 |
olle |
Buttons.addClickHandler('btnCreateMissingItems', install.fixInstallation); |
2933 |
14 Nov 14 |
olle |
11 |
|
2933 |
14 Nov 14 |
olle |
install.checkInstallation('Validate', 'Checking installation...'); |
2933 |
14 Nov 14 |
olle |
13 |
} |
2933 |
14 Nov 14 |
olle |
14 |
|
2933 |
14 Nov 14 |
olle |
install.fixInstallation = function() |
2933 |
14 Nov 14 |
olle |
16 |
{ |
2933 |
14 Nov 14 |
olle |
install.checkInstallation('Install', 'Fixing installation...'); |
2933 |
14 Nov 14 |
olle |
18 |
} |
2933 |
14 Nov 14 |
olle |
19 |
|
2933 |
14 Nov 14 |
olle |
20 |
|
2933 |
14 Nov 14 |
olle |
install.checkInstallation = function(cmd, workText) |
2933 |
14 Nov 14 |
olle |
22 |
{ |
2933 |
14 Nov 14 |
olle |
Doc.hide('validationResult0'); |
2933 |
14 Nov 14 |
olle |
Doc.hide('validationResult1'); |
2933 |
14 Nov 14 |
olle |
Doc.hide('validationResult2'); |
2933 |
14 Nov 14 |
olle |
Doc.hide('createMissingItems'); |
2933 |
14 Nov 14 |
olle |
Doc.hide('fixIncompleteItems'); |
2933 |
14 Nov 14 |
olle |
28 |
|
2933 |
14 Nov 14 |
olle |
var request = Ajax.getXmlHttpRequest(); |
2933 |
14 Nov 14 |
olle |
var url = '../Install.servlet?ID=' + App.getSessionId(); |
2933 |
14 Nov 14 |
olle |
url += '&cmd='+cmd; |
2933 |
14 Nov 14 |
olle |
Doc.addClass('workInProgress', 'working'); |
2933 |
14 Nov 14 |
olle |
Wizard.showLoadingAnimation(workText); |
2933 |
14 Nov 14 |
olle |
Wizard.asyncJsonRequest(url, install.onChecked); |
2933 |
14 Nov 14 |
olle |
35 |
} |
2933 |
14 Nov 14 |
olle |
36 |
|
2933 |
14 Nov 14 |
olle |
install.onChecked = function(response) |
2933 |
14 Nov 14 |
olle |
38 |
{ |
2933 |
14 Nov 14 |
olle |
Doc.removeClass('workInProgress', 'working'); |
2933 |
14 Nov 14 |
olle |
40 |
|
2933 |
14 Nov 14 |
olle |
var COL_BREAKS = ['ANNOTATIONTYPE', 'PLUGINDEFINITION']; |
2933 |
14 Nov 14 |
olle |
var checks = response.checks; |
2933 |
14 Nov 14 |
olle |
43 |
|
2933 |
14 Nov 14 |
olle |
var numMissing = 0; |
2933 |
14 Nov 14 |
olle |
var numWarnings = 0; |
2933 |
14 Nov 14 |
olle |
var numErrors = 0; |
2933 |
14 Nov 14 |
olle |
var numIncomplete = 0; |
2933 |
14 Nov 14 |
olle |
var html = '<table class="report">'; |
2933 |
14 Nov 14 |
olle |
var lastItemType = null; |
2933 |
14 Nov 14 |
olle |
var index = 0; |
2933 |
14 Nov 14 |
olle |
var topLines = []; // Top lines are for items with error/warning/special message |
2933 |
14 Nov 14 |
olle |
var bottomLines = []; // Bottom lines are for all 'OK' items |
2933 |
14 Nov 14 |
olle |
var allOk = true; |
2933 |
14 Nov 14 |
olle |
var clickableItems = []; |
2933 |
14 Nov 14 |
olle |
var showMore = []; |
2933 |
14 Nov 14 |
olle |
56 |
|
2933 |
14 Nov 14 |
olle |
for (var i = 0; i < checks.length; i++) |
2933 |
14 Nov 14 |
olle |
58 |
{ |
2933 |
14 Nov 14 |
olle |
var check = checks[i]; |
2933 |
14 Nov 14 |
olle |
var icon = 'ok.png'; |
2933 |
14 Nov 14 |
olle |
check.ok = true; |
2933 |
14 Nov 14 |
olle |
if (check.status == 'missing') |
2933 |
14 Nov 14 |
olle |
63 |
{ |
2933 |
14 Nov 14 |
olle |
numMissing++; |
2933 |
14 Nov 14 |
olle |
icon = 'error.png'; |
2933 |
14 Nov 14 |
olle |
check.ok = false; |
2933 |
14 Nov 14 |
olle |
67 |
} |
2933 |
14 Nov 14 |
olle |
if (check.status == 'incomplete') |
2933 |
14 Nov 14 |
olle |
69 |
{ |
2933 |
14 Nov 14 |
olle |
numIncomplete++; |
2933 |
14 Nov 14 |
olle |
icon = 'warning.png'; |
2933 |
14 Nov 14 |
olle |
check.ok = false; |
2933 |
14 Nov 14 |
olle |
73 |
} |
2933 |
14 Nov 14 |
olle |
if (check.status == 'error') |
2933 |
14 Nov 14 |
olle |
75 |
{ |
2933 |
14 Nov 14 |
olle |
numErrors++; |
2933 |
14 Nov 14 |
olle |
icon = 'error.png'; |
2933 |
14 Nov 14 |
olle |
check.ok = false; |
2933 |
14 Nov 14 |
olle |
79 |
} |
2933 |
14 Nov 14 |
olle |
if (check.status == 'warning') |
2933 |
14 Nov 14 |
olle |
81 |
{ |
2933 |
14 Nov 14 |
olle |
numWarnings++; |
2933 |
14 Nov 14 |
olle |
icon = 'warning.png'; |
2933 |
14 Nov 14 |
olle |
check.ok = false; |
2933 |
14 Nov 14 |
olle |
85 |
} |
2933 |
14 Nov 14 |
olle |
allOk &= check.ok; |
2933 |
14 Nov 14 |
olle |
87 |
|
2933 |
14 Nov 14 |
olle |
var sameSection = lastItemType == check.itemType; |
2933 |
14 Nov 14 |
olle |
// Do not start new section when switching between plugin definition and configuration |
2933 |
14 Nov 14 |
olle |
if (!sameSection) sameSection = lastItemType == 'PLUGINDEFINITION' && check.itemType == 'PLUGINCONFIGURATION'; |
2933 |
14 Nov 14 |
olle |
if (!sameSection) sameSection = lastItemType == 'PLUGINCONFIGURATION' && check.itemType == 'PLUGINDEFINITION'; |
2933 |
14 Nov 14 |
olle |
if (!sameSection) |
2933 |
14 Nov 14 |
olle |
93 |
{ |
2933 |
14 Nov 14 |
olle |
html += topLines.join(''); // Always show the top-lines |
2933 |
14 Nov 14 |
olle |
if ((topLines.length + bottomLines.length > 13) && bottomLines.length > 0) |
2933 |
14 Nov 14 |
olle |
96 |
{ |
2933 |
14 Nov 14 |
olle |
// Show 10 lines and hide the rest |
2933 |
14 Nov 14 |
olle |
var showMoreFrom = Math.max(0, 10 - topLines.length); |
2933 |
14 Nov 14 |
olle |
if (showMoreFrom > 0) |
2933 |
14 Nov 14 |
olle |
100 |
{ |
2933 |
14 Nov 14 |
olle |
html += bottomLines.slice(0, showMoreFrom).join(''); |
2933 |
14 Nov 14 |
olle |
102 |
} |
2933 |
14 Nov 14 |
olle |
showMore[showMore.length] = check.itemType; |
2933 |
14 Nov 14 |
olle |
html += '<tr class="sameitemtype highlight" id="'+check.itemType+'">'; |
2933 |
14 Nov 14 |
olle |
html += '<td class="link">… '+(bottomLines.length-showMoreFrom)+' more</td>'; |
2933 |
14 Nov 14 |
olle |
html += '<td><img src="../images/ok.png"></td><td>Ok</td></tr></tbody>'; |
2933 |
14 Nov 14 |
olle |
html += '<tbody id="'+check.itemType+'.more" style="display: none;">'; |
2933 |
14 Nov 14 |
olle |
html += bottomLines.slice(showMoreFrom).join(''); |
2933 |
14 Nov 14 |
olle |
html += '</tbody>'; |
2933 |
14 Nov 14 |
olle |
110 |
} |
2933 |
14 Nov 14 |
olle |
else |
2933 |
14 Nov 14 |
olle |
112 |
{ |
2933 |
14 Nov 14 |
olle |
html += bottomLines.join('')+'</tbody>'; |
2933 |
14 Nov 14 |
olle |
114 |
} |
2933 |
14 Nov 14 |
olle |
115 |
|
2933 |
14 Nov 14 |
olle |
topLines = []; |
2933 |
14 Nov 14 |
olle |
bottomLines = []; |
2933 |
14 Nov 14 |
olle |
allOk = true; |
2933 |
14 Nov 14 |
olle |
index = 0; |
2933 |
14 Nov 14 |
olle |
120 |
|
2933 |
14 Nov 14 |
olle |
var col_break = COL_BREAKS.indexOf(check.itemType); |
2933 |
14 Nov 14 |
olle |
if (col_break >= 0) |
2933 |
14 Nov 14 |
olle |
123 |
{ |
2933 |
14 Nov 14 |
olle |
// End the left side and start on the right |
2933 |
14 Nov 14 |
olle |
html += '</table>'; |
2933 |
14 Nov 14 |
olle |
Doc.element('validationResult'+col_break).innerHTML = html; |
2933 |
14 Nov 14 |
olle |
Doc.show('validationResult'+col_break); |
2933 |
14 Nov 14 |
olle |
html = '<table class="report">'; |
2933 |
14 Nov 14 |
olle |
129 |
} |
2933 |
14 Nov 14 |
olle |
html += '<tbody><tr class="newitemtype"><td colspan="3">'+check.itemType+'</td></tr>'; |
2933 |
14 Nov 14 |
olle |
131 |
} |
2933 |
14 Nov 14 |
olle |
132 |
|
2933 |
14 Nov 14 |
olle |
var line = '<tr class="sameitemtype highlight '+check.itemType+' ' + (check.ok ? 'check-ok' : 'check-not-ok') + '">'; |
2933 |
14 Nov 14 |
olle |
lastItemType = check.itemType; |
2933 |
14 Nov 14 |
olle |
var name = check.name; |
2933 |
14 Nov 14 |
olle |
if (check.mainType) name += ' <span class="itemsubtype">[' + check.mainType + ']</span>'; |
2933 |
14 Nov 14 |
olle |
if (check.id) |
2933 |
14 Nov 14 |
olle |
138 |
{ |
2933 |
14 Nov 14 |
olle |
clickableItems[clickableItems.length] = check.itemType+check.id; |
2933 |
14 Nov 14 |
olle |
line += '<td class="itemTypeCol"><div class="link" id="'+check.itemType+check.id+'" data-item-type="'+check.itemType+'" data-item-id="'+check.id+'"'; |
2933 |
14 Nov 14 |
olle |
line += ' title="View this item (use CTRL, ALT or SHIFT to edit)">'+name+'</div></td>'; |
2933 |
14 Nov 14 |
olle |
142 |
} |
2933 |
14 Nov 14 |
olle |
else |
2933 |
14 Nov 14 |
olle |
144 |
{ |
2933 |
14 Nov 14 |
olle |
line += '<td class="itemTypeCol"><i>' + name + '</i></td>'; |
2933 |
14 Nov 14 |
olle |
146 |
} |
2933 |
14 Nov 14 |
olle |
line += '<td class="iconCol"><img src="../images/'+icon+'"></td>'; |
2933 |
14 Nov 14 |
olle |
line += '<td class="statusCol">'; |
2933 |
14 Nov 14 |
olle |
if (check.messages.length > 1) |
2933 |
14 Nov 14 |
olle |
150 |
{ |
2933 |
14 Nov 14 |
olle |
for (var m = 0; m < check.messages.length; m++) |
2933 |
14 Nov 14 |
olle |
152 |
{ |
2933 |
14 Nov 14 |
olle |
line += '• '+check.messages[m] + '<br>'; |
2933 |
14 Nov 14 |
olle |
154 |
} |
2933 |
14 Nov 14 |
olle |
155 |
} |
2933 |
14 Nov 14 |
olle |
else |
2933 |
14 Nov 14 |
olle |
157 |
{ |
2933 |
14 Nov 14 |
olle |
line += check.messages; |
2933 |
14 Nov 14 |
olle |
159 |
} |
2933 |
14 Nov 14 |
olle |
line += '</td></tr>'; |
2933 |
14 Nov 14 |
olle |
161 |
|
2933 |
14 Nov 14 |
olle |
if (!check.ok || check.messages != 'Ok') |
2933 |
14 Nov 14 |
olle |
163 |
{ |
2933 |
14 Nov 14 |
olle |
topLines[topLines.length] = line; |
2933 |
14 Nov 14 |
olle |
165 |
} |
2933 |
14 Nov 14 |
olle |
else |
2933 |
14 Nov 14 |
olle |
167 |
{ |
2933 |
14 Nov 14 |
olle |
bottomLines[bottomLines.length] = line; |
2933 |
14 Nov 14 |
olle |
169 |
} |
2933 |
14 Nov 14 |
olle |
index++; |
2933 |
14 Nov 14 |
olle |
171 |
} |
2933 |
14 Nov 14 |
olle |
172 |
|
2933 |
14 Nov 14 |
olle |
html += topLines.join(''); |
2933 |
14 Nov 14 |
olle |
if ((topLines.length + bottomLines.length > 13) && bottomLines.length > 0) |
2933 |
14 Nov 14 |
olle |
175 |
{ |
2933 |
14 Nov 14 |
olle |
// Show 10 lines and hide the rest |
2933 |
14 Nov 14 |
olle |
var showMoreFrom = Math.max(0, 10 - topLines.length); |
2933 |
14 Nov 14 |
olle |
if (showMoreFrom > 0) |
2933 |
14 Nov 14 |
olle |
179 |
{ |
2933 |
14 Nov 14 |
olle |
html += bottomLines.slice(0, showMoreFrom).join(''); |
2933 |
14 Nov 14 |
olle |
181 |
} |
2933 |
14 Nov 14 |
olle |
showMore[showMore.length] = check.itemType; |
2933 |
14 Nov 14 |
olle |
html += '<tr class="sameitemtype highlight" id="'+check.itemType+'">'; |
2933 |
14 Nov 14 |
olle |
html += '<td class="link">… '+(bottomLines.length-showMoreFrom)+' more</td>'; |
2933 |
14 Nov 14 |
olle |
html += '<td><img src="../images/ok.png"></td><td>Ok</td></tr></tbody>'; |
2933 |
14 Nov 14 |
olle |
html += '<tbody id="'+check.itemType+'.more" style="display: none;">'; |
2933 |
14 Nov 14 |
olle |
html += bottomLines.slice(showMoreFrom).join(''); |
2933 |
14 Nov 14 |
olle |
html += '</tbody>'; |
2933 |
14 Nov 14 |
olle |
189 |
} |
2933 |
14 Nov 14 |
olle |
else |
2933 |
14 Nov 14 |
olle |
191 |
{ |
2933 |
14 Nov 14 |
olle |
html += bottomLines.join('')+'</tbody>'; |
2933 |
14 Nov 14 |
olle |
193 |
} |
2933 |
14 Nov 14 |
olle |
194 |
|
2933 |
14 Nov 14 |
olle |
html += '</table>'; |
2933 |
14 Nov 14 |
olle |
Doc.element('validationResult'+COL_BREAKS.length).innerHTML = html; |
2933 |
14 Nov 14 |
olle |
Doc.show('validationResult'+COL_BREAKS.length); |
2933 |
14 Nov 14 |
olle |
198 |
|
2933 |
14 Nov 14 |
olle |
// Add click handler to items |
2933 |
14 Nov 14 |
olle |
for (var i = 0; i < clickableItems.length; i++) |
2933 |
14 Nov 14 |
olle |
201 |
{ |
2933 |
14 Nov 14 |
olle |
Events.addEventHandler(clickableItems[i], 'click', Items.itemOnClick); |
2933 |
14 Nov 14 |
olle |
203 |
} |
2933 |
14 Nov 14 |
olle |
// Add click handler to 'show more...' |
2933 |
14 Nov 14 |
olle |
for (var i = 0; i < showMore.length; i++) |
2933 |
14 Nov 14 |
olle |
206 |
{ |
2933 |
14 Nov 14 |
olle |
Events.addEventHandler(showMore[i], 'click', install.showMore); |
2933 |
14 Nov 14 |
olle |
208 |
} |
2933 |
14 Nov 14 |
olle |
209 |
|
2933 |
14 Nov 14 |
olle |
if (numErrors > 0) |
2933 |
14 Nov 14 |
olle |
211 |
{ |
2933 |
14 Nov 14 |
olle |
Wizard.setFatalError(numErrors+' errors was detected. You need to fix those manually.'); |
2933 |
14 Nov 14 |
olle |
213 |
} |
2933 |
14 Nov 14 |
olle |
else if (numMissing > 0) |
2933 |
14 Nov 14 |
olle |
215 |
{ |
2933 |
14 Nov 14 |
olle |
Doc.show('createMissingItems'); |
2933 |
14 Nov 14 |
olle |
217 |
} |
2933 |
14 Nov 14 |
olle |
else if (numIncomplete > 0) |
2933 |
14 Nov 14 |
olle |
219 |
{ |
2933 |
14 Nov 14 |
olle |
Doc.show('fixIncompleteItems'); |
2933 |
14 Nov 14 |
olle |
221 |
} |
2933 |
14 Nov 14 |
olle |
else if (numWarnings > 0) |
2933 |
14 Nov 14 |
olle |
223 |
{ |
2933 |
14 Nov 14 |
olle |
Wizard.showStatusMessage(numWarnings+' warnings was detected. MeLuDi may still work. If not, you need to fix it manually.'); |
2933 |
14 Nov 14 |
olle |
225 |
} |
2933 |
14 Nov 14 |
olle |
226 |
} |
2933 |
14 Nov 14 |
olle |
227 |
|
2933 |
14 Nov 14 |
olle |
install.showMore = function(event) |
2933 |
14 Nov 14 |
olle |
229 |
{ |
2933 |
14 Nov 14 |
olle |
var target = event.currentTarget; |
2933 |
14 Nov 14 |
olle |
Doc.show(target.id + '.more'); |
2933 |
14 Nov 14 |
olle |
Doc.hide(target.id); |
2933 |
14 Nov 14 |
olle |
233 |
} |
2933 |
14 Nov 14 |
olle |
234 |
|
2933 |
14 Nov 14 |
olle |
235 |
|
2933 |
14 Nov 14 |
olle |
return install; |
2933 |
14 Nov 14 |
olle |
237 |
}(); |
2933 |
14 Nov 14 |
olle |
238 |
|
2933 |
14 Nov 14 |
olle |
Doc.onLoad(Install.initPage); |