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