6161 |
04 Mar 21 |
nicklas |
var Install = function() |
6161 |
04 Mar 21 |
nicklas |
2 |
{ |
6161 |
04 Mar 21 |
nicklas |
var install = {}; |
6161 |
04 Mar 21 |
nicklas |
4 |
|
6161 |
04 Mar 21 |
nicklas |
var checks; |
6161 |
04 Mar 21 |
nicklas |
var debug = 0; |
6161 |
04 Mar 21 |
nicklas |
7 |
|
6161 |
04 Mar 21 |
nicklas |
install.initPage = function() |
6161 |
04 Mar 21 |
nicklas |
9 |
{ |
6161 |
04 Mar 21 |
nicklas |
Events.addEventHandler('typeFilter', 'change', install.filterOnChange); |
6161 |
04 Mar 21 |
nicklas |
Events.addEventHandler('nameFilter', 'change', install.filterOnChange); |
6161 |
04 Mar 21 |
nicklas |
Events.addEventHandler('messageFilter', 'change', install.filterOnChange); |
6161 |
04 Mar 21 |
nicklas |
13 |
|
6161 |
04 Mar 21 |
nicklas |
Buttons.addClickHandler('btnFixItems', install.fixInstallation); |
6161 |
04 Mar 21 |
nicklas |
Buttons.addClickHandler('btnCreateMissingItems', install.fixInstallation); |
6161 |
04 Mar 21 |
nicklas |
16 |
|
6161 |
04 Mar 21 |
nicklas |
install.checkInstallation('Validate', 'Checking installation...'); |
6161 |
04 Mar 21 |
nicklas |
18 |
} |
6161 |
04 Mar 21 |
nicklas |
19 |
|
6161 |
04 Mar 21 |
nicklas |
install.fixInstallation = function() |
6161 |
04 Mar 21 |
nicklas |
21 |
{ |
6161 |
04 Mar 21 |
nicklas |
install.checkInstallation('Install', 'Fixing installation...'); |
6161 |
04 Mar 21 |
nicklas |
23 |
} |
6161 |
04 Mar 21 |
nicklas |
24 |
|
6161 |
04 Mar 21 |
nicklas |
25 |
|
6161 |
04 Mar 21 |
nicklas |
install.checkInstallation = function(cmd, workText, callback, progress) |
6161 |
04 Mar 21 |
nicklas |
27 |
{ |
6161 |
04 Mar 21 |
nicklas |
Doc.hide('item-list'); |
6161 |
04 Mar 21 |
nicklas |
Doc.hide('itemTable'); |
6161 |
04 Mar 21 |
nicklas |
Doc.hide('createMissingItems'); |
6161 |
04 Mar 21 |
nicklas |
Doc.hide('fixIncompleteItems'); |
6161 |
04 Mar 21 |
nicklas |
32 |
|
6161 |
04 Mar 21 |
nicklas |
var url = '../Install.servlet?ID=' + App.getSessionId(); |
6161 |
04 Mar 21 |
nicklas |
url += '&cmd='+cmd; |
6161 |
04 Mar 21 |
nicklas |
Doc.addClass('workInProgress', 'working'); |
6161 |
04 Mar 21 |
nicklas |
Wizard.showLoadingAnimation(workText, progress); |
6161 |
04 Mar 21 |
nicklas |
Wizard.asyncJsonRequest(url, callback || install.onChecked); |
6161 |
04 Mar 21 |
nicklas |
38 |
} |
6161 |
04 Mar 21 |
nicklas |
39 |
|
6161 |
04 Mar 21 |
nicklas |
install.onChecked = function(response) |
6161 |
04 Mar 21 |
nicklas |
41 |
{ |
6161 |
04 Mar 21 |
nicklas |
Doc.removeClass('workInProgress', 'working'); |
6161 |
04 Mar 21 |
nicklas |
43 |
|
6161 |
04 Mar 21 |
nicklas |
checks = response.checks; |
6161 |
04 Mar 21 |
nicklas |
45 |
|
6161 |
04 Mar 21 |
nicklas |
var numMissing = 0; |
6161 |
04 Mar 21 |
nicklas |
var numWarnings = 0; |
6161 |
04 Mar 21 |
nicklas |
var numErrors = 0; |
6161 |
04 Mar 21 |
nicklas |
var numIncomplete = 0; |
6161 |
04 Mar 21 |
nicklas |
50 |
|
6161 |
04 Mar 21 |
nicklas |
var index = 0; |
6161 |
04 Mar 21 |
nicklas |
var topLines = []; // Top lines are for items with error/warning/special message |
6161 |
04 Mar 21 |
nicklas |
var bottomLines = []; // Bottom lines are for all 'OK' items |
6161 |
04 Mar 21 |
nicklas |
var allOk = true; |
6161 |
04 Mar 21 |
nicklas |
var clickableItems = []; |
6161 |
04 Mar 21 |
nicklas |
var typeFilter = Doc.element('typeFilter'); |
6161 |
04 Mar 21 |
nicklas |
typeFilter.length = 0; |
6161 |
04 Mar 21 |
nicklas |
typeFilter[0] = new Option(); |
6161 |
04 Mar 21 |
nicklas |
var types = []; |
6161 |
04 Mar 21 |
nicklas |
60 |
|
6161 |
04 Mar 21 |
nicklas |
for (var checkNo = 0; checkNo < checks.length; checkNo++) |
6161 |
04 Mar 21 |
nicklas |
62 |
{ |
6161 |
04 Mar 21 |
nicklas |
var check = checks[checkNo]; |
6161 |
04 Mar 21 |
nicklas |
64 |
|
6161 |
04 Mar 21 |
nicklas |
var icon = 'ok.png'; |
6161 |
04 Mar 21 |
nicklas |
check.ok = true; |
6161 |
04 Mar 21 |
nicklas |
if (check.status == 'missing') |
6161 |
04 Mar 21 |
nicklas |
68 |
{ |
6161 |
04 Mar 21 |
nicklas |
numMissing++; |
6161 |
04 Mar 21 |
nicklas |
icon = 'warning.png'; |
6161 |
04 Mar 21 |
nicklas |
check.ok = false; |
6161 |
04 Mar 21 |
nicklas |
72 |
} |
6161 |
04 Mar 21 |
nicklas |
if (check.status == 'incomplete') |
6161 |
04 Mar 21 |
nicklas |
74 |
{ |
6161 |
04 Mar 21 |
nicklas |
numIncomplete++; |
6161 |
04 Mar 21 |
nicklas |
icon = 'warning.png'; |
6161 |
04 Mar 21 |
nicklas |
check.ok = false; |
6161 |
04 Mar 21 |
nicklas |
78 |
} |
6161 |
04 Mar 21 |
nicklas |
if (check.status == 'error') |
6161 |
04 Mar 21 |
nicklas |
80 |
{ |
6161 |
04 Mar 21 |
nicklas |
numErrors++; |
6161 |
04 Mar 21 |
nicklas |
icon = 'error.png'; |
6161 |
04 Mar 21 |
nicklas |
check.ok = false; |
6161 |
04 Mar 21 |
nicklas |
84 |
} |
6161 |
04 Mar 21 |
nicklas |
if (check.status == 'warning') |
6161 |
04 Mar 21 |
nicklas |
86 |
{ |
6161 |
04 Mar 21 |
nicklas |
numWarnings++; |
6161 |
04 Mar 21 |
nicklas |
icon = 'warning.png'; |
6161 |
04 Mar 21 |
nicklas |
check.ok = false; |
6161 |
04 Mar 21 |
nicklas |
90 |
} |
6161 |
04 Mar 21 |
nicklas |
allOk &= check.ok; |
6161 |
04 Mar 21 |
nicklas |
92 |
|
6161 |
04 Mar 21 |
nicklas |
if (!types[check.itemType]) |
6161 |
04 Mar 21 |
nicklas |
94 |
{ |
6161 |
04 Mar 21 |
nicklas |
typeFilter[typeFilter.length] = new Option(check.itemType); |
6161 |
04 Mar 21 |
nicklas |
types[check.itemType] = 1; |
6161 |
04 Mar 21 |
nicklas |
97 |
} |
6161 |
04 Mar 21 |
nicklas |
98 |
|
6161 |
04 Mar 21 |
nicklas |
var line = '<tr id="check'+checkNo+'" class="highlight '+check.itemType+' ' + (check.ok ? 'check-ok' : 'check-not-ok') + '">'; |
6161 |
04 Mar 21 |
nicklas |
line += '<td class="indexCol"><span id="index.'+checkNo+'">'+(checkNo+1)+'</span></td>'; |
6161 |
04 Mar 21 |
nicklas |
line += '<td class="dottedleft">'+Strings.encodeTags(check.itemType)+'</td>'; |
6161 |
04 Mar 21 |
nicklas |
var name = Strings.encodeTags(check.name); |
6161 |
04 Mar 21 |
nicklas |
if (check.mainType) name += ' <span class="itemsubtype">[' + Strings.encodeTags(check.mainType) + ']</span>'; |
6161 |
04 Mar 21 |
nicklas |
if (check.id) |
6161 |
04 Mar 21 |
nicklas |
105 |
{ |
6161 |
04 Mar 21 |
nicklas |
clickableItems[clickableItems.length] = check.itemType+check.id; |
6161 |
04 Mar 21 |
nicklas |
line += '<td><div class="link" id="'+check.itemType+check.id+'" data-item-type="'+check.itemType+'" data-item-id="'+check.id+'"'; |
6161 |
04 Mar 21 |
nicklas |
line += ' title="View this item (use CTRL, ALT or SHIFT to edit)">'+name+'</div></td>'; |
6161 |
04 Mar 21 |
nicklas |
109 |
} |
6161 |
04 Mar 21 |
nicklas |
else |
6161 |
04 Mar 21 |
nicklas |
111 |
{ |
6161 |
04 Mar 21 |
nicklas |
line += '<td><i>' + name + '</i></td>'; |
6161 |
04 Mar 21 |
nicklas |
113 |
} |
6161 |
04 Mar 21 |
nicklas |
line += '<td class="iconCol"><img src="../images/'+icon+'"></td>'; |
6161 |
04 Mar 21 |
nicklas |
line += '<td>'; |
6161 |
04 Mar 21 |
nicklas |
if (check.messages.length > 1) |
6161 |
04 Mar 21 |
nicklas |
117 |
{ |
6161 |
04 Mar 21 |
nicklas |
for (var m = 0; m < check.messages.length; m++) |
6161 |
04 Mar 21 |
nicklas |
119 |
{ |
6161 |
04 Mar 21 |
nicklas |
line += '• '+check.messages[m] + '<br>'; |
6161 |
04 Mar 21 |
nicklas |
121 |
} |
6161 |
04 Mar 21 |
nicklas |
122 |
} |
6161 |
04 Mar 21 |
nicklas |
else |
6161 |
04 Mar 21 |
nicklas |
124 |
{ |
6161 |
04 Mar 21 |
nicklas |
line += check.messages; |
6161 |
04 Mar 21 |
nicklas |
126 |
} |
6161 |
04 Mar 21 |
nicklas |
line += '</td></tr>'; |
6161 |
04 Mar 21 |
nicklas |
128 |
|
6161 |
04 Mar 21 |
nicklas |
if (!check.ok || check.messages != 'Ok') |
6161 |
04 Mar 21 |
nicklas |
130 |
{ |
6161 |
04 Mar 21 |
nicklas |
topLines[topLines.length] = line; |
6161 |
04 Mar 21 |
nicklas |
132 |
} |
6161 |
04 Mar 21 |
nicklas |
else |
6161 |
04 Mar 21 |
nicklas |
134 |
{ |
6161 |
04 Mar 21 |
nicklas |
bottomLines[bottomLines.length] = line; |
6161 |
04 Mar 21 |
nicklas |
136 |
} |
6161 |
04 Mar 21 |
nicklas |
index++; |
6161 |
04 Mar 21 |
nicklas |
138 |
} |
6161 |
04 Mar 21 |
nicklas |
139 |
|
6161 |
04 Mar 21 |
nicklas |
if (topLines.length + bottomLines.length > 0) |
6161 |
04 Mar 21 |
nicklas |
141 |
{ |
6161 |
04 Mar 21 |
nicklas |
Doc.element('item-list').innerHTML = topLines.join('') + bottomLines.join(''); |
6161 |
04 Mar 21 |
nicklas |
Doc.show('item-list'); |
6161 |
04 Mar 21 |
nicklas |
144 |
} |
6161 |
04 Mar 21 |
nicklas |
Doc.show('itemTable', 'table'); |
6161 |
04 Mar 21 |
nicklas |
146 |
|
6161 |
04 Mar 21 |
nicklas |
// Add click handler to items |
6161 |
04 Mar 21 |
nicklas |
for (var i = 0; i < clickableItems.length; i++) |
6161 |
04 Mar 21 |
nicklas |
149 |
{ |
6161 |
04 Mar 21 |
nicklas |
Events.addEventHandler(clickableItems[i], 'click', Items.itemOnClick); |
6161 |
04 Mar 21 |
nicklas |
151 |
} |
6161 |
04 Mar 21 |
nicklas |
152 |
|
6161 |
04 Mar 21 |
nicklas |
if (numErrors > 0) |
6161 |
04 Mar 21 |
nicklas |
154 |
{ |
6161 |
04 Mar 21 |
nicklas |
Wizard.setWizardStatus('messagecontainer error', numErrors+' errors was detected. You need to fix those manually.'); |
6161 |
04 Mar 21 |
nicklas |
156 |
} |
6161 |
04 Mar 21 |
nicklas |
else if (numWarnings > 0) |
6161 |
04 Mar 21 |
nicklas |
158 |
{ |
6161 |
04 Mar 21 |
nicklas |
Wizard.setWizardStatus('messagecontainer note', numWarnings+' warnings was detected. The Variant Search may still work. If not, you need to fix it manually.'); |
6161 |
04 Mar 21 |
nicklas |
160 |
} |
6161 |
04 Mar 21 |
nicklas |
if (numMissing > 0) |
6161 |
04 Mar 21 |
nicklas |
162 |
{ |
6161 |
04 Mar 21 |
nicklas |
Doc.show('createMissingItems'); |
6161 |
04 Mar 21 |
nicklas |
164 |
} |
6161 |
04 Mar 21 |
nicklas |
else if (numIncomplete > 0) |
6161 |
04 Mar 21 |
nicklas |
166 |
{ |
6161 |
04 Mar 21 |
nicklas |
Doc.show('fixIncompleteItems'); |
6161 |
04 Mar 21 |
nicklas |
168 |
} |
6161 |
04 Mar 21 |
nicklas |
if (allOk) |
6161 |
04 Mar 21 |
nicklas |
170 |
{ |
6161 |
04 Mar 21 |
nicklas |
Wizard.setWizardStatus('all-checks-passed', 'All checks passed'); |
6161 |
04 Mar 21 |
nicklas |
172 |
} |
6161 |
04 Mar 21 |
nicklas |
173 |
} |
6161 |
04 Mar 21 |
nicklas |
174 |
|
6161 |
04 Mar 21 |
nicklas |
install.showMessages = function(response) |
6161 |
04 Mar 21 |
nicklas |
176 |
{ |
6161 |
04 Mar 21 |
nicklas |
Doc.removeClass('workInProgress', 'working'); |
6161 |
04 Mar 21 |
nicklas |
Wizard.showFinalMessage(response.messages); |
6161 |
04 Mar 21 |
nicklas |
179 |
} |
6161 |
04 Mar 21 |
nicklas |
180 |
|
6161 |
04 Mar 21 |
nicklas |
install.filterOnChange = function() |
6161 |
04 Mar 21 |
nicklas |
182 |
{ |
6161 |
04 Mar 21 |
nicklas |
183 |
|
6161 |
04 Mar 21 |
nicklas |
var filter = new Filter(); |
6161 |
04 Mar 21 |
nicklas |
filter.addTextCriteria(ItemProperty.ItemType, Doc.element('typeFilter').value); |
6161 |
04 Mar 21 |
nicklas |
filter.addContainsCriteria(ItemProperty.Name, Doc.element('nameFilter').value); |
6161 |
04 Mar 21 |
nicklas |
filter.addContainsCriteria(ItemProperty.Messages, Doc.element('messageFilter').value); |
6161 |
04 Mar 21 |
nicklas |
188 |
|
6161 |
04 Mar 21 |
nicklas |
var numMatch = 0; |
6161 |
04 Mar 21 |
nicklas |
for (var checkNo = 0; checkNo < checks.length; checkNo++) |
6161 |
04 Mar 21 |
nicklas |
191 |
{ |
6161 |
04 Mar 21 |
nicklas |
var check = checks[checkNo]; |
6161 |
04 Mar 21 |
nicklas |
193 |
|
6161 |
04 Mar 21 |
nicklas |
check.include = filter.check(check); |
6161 |
04 Mar 21 |
nicklas |
if (check.include) |
6161 |
04 Mar 21 |
nicklas |
196 |
{ |
6161 |
04 Mar 21 |
nicklas |
numMatch++; |
6161 |
04 Mar 21 |
nicklas |
Doc.show('check'+checkNo); |
6161 |
04 Mar 21 |
nicklas |
199 |
} |
6161 |
04 Mar 21 |
nicklas |
else |
6161 |
04 Mar 21 |
nicklas |
201 |
{ |
6161 |
04 Mar 21 |
nicklas |
Doc.hide('check'+checkNo); |
6161 |
04 Mar 21 |
nicklas |
203 |
} |
6161 |
04 Mar 21 |
nicklas |
204 |
} |
6161 |
04 Mar 21 |
nicklas |
205 |
|
6161 |
04 Mar 21 |
nicklas |
Doc.showHide('item-list', numMatch > 0); |
6161 |
04 Mar 21 |
nicklas |
Doc.showHide('no-matching-items', numMatch==0); |
6161 |
04 Mar 21 |
nicklas |
208 |
} |
6161 |
04 Mar 21 |
nicklas |
209 |
|
6161 |
04 Mar 21 |
nicklas |
return install; |
6161 |
04 Mar 21 |
nicklas |
211 |
}(); |
6161 |
04 Mar 21 |
nicklas |
212 |
|
6161 |
04 Mar 21 |
nicklas |
Doc.onLoad(Install.initPage); |
6161 |
04 Mar 21 |
nicklas |
214 |
|
6161 |
04 Mar 21 |
nicklas |
var ItemProperty = function() |
6161 |
04 Mar 21 |
nicklas |
216 |
{ |
6161 |
04 Mar 21 |
nicklas |
var p = {}; |
6161 |
04 Mar 21 |
nicklas |
218 |
|
6161 |
04 Mar 21 |
nicklas |
p.Name = function(item) |
6161 |
04 Mar 21 |
nicklas |
220 |
{ |
6161 |
04 Mar 21 |
nicklas |
return item.name; |
6161 |
04 Mar 21 |
nicklas |
222 |
} |
6161 |
04 Mar 21 |
nicklas |
223 |
|
6161 |
04 Mar 21 |
nicklas |
p.ItemType = function(item) |
6161 |
04 Mar 21 |
nicklas |
225 |
{ |
6161 |
04 Mar 21 |
nicklas |
return item.itemType; |
6161 |
04 Mar 21 |
nicklas |
227 |
} |
6161 |
04 Mar 21 |
nicklas |
228 |
|
6161 |
04 Mar 21 |
nicklas |
p.Messages = function(item) |
6161 |
04 Mar 21 |
nicklas |
230 |
{ |
6161 |
04 Mar 21 |
nicklas |
return item.messages.join(''); |
6161 |
04 Mar 21 |
nicklas |
232 |
} |
6161 |
04 Mar 21 |
nicklas |
233 |
|
6161 |
04 Mar 21 |
nicklas |
return p; |
6161 |
04 Mar 21 |
nicklas |
235 |
}(); |
6161 |
04 Mar 21 |
nicklas |
236 |
|