Rev 1292 | Rev 1434 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1292 | Rev 1426 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | /* |
1 | /* |
2 | * OIDplus 2.0 |
2 | * OIDplus 2.0 |
3 | * Copyright 2019 - 2022 Daniel Marschall, ViaThinkSoft |
3 | * Copyright 2019 - 2023 Daniel Marschall, ViaThinkSoft |
4 | * |
4 | * |
5 | * Licensed under the Apache License, Version 2.0 (the "License"); |
5 | * Licensed under the Apache License, Version 2.0 (the "License"); |
6 | * you may not use this file except in compliance with the License. |
6 | * you may not use this file except in compliance with the License. |
7 | * You may obtain a copy of the License at |
7 | * You may obtain a copy of the License at |
8 | * |
8 | * |
Line 17... | Line 17... | ||
17 | 17 | ||
18 | var OIDplusPageAdminSoftwareUpdate = { |
18 | var OIDplusPageAdminSoftwareUpdate = { |
19 | 19 | ||
20 | oid: "1.3.6.1.4.1.37476.2.5.2.4.3.900", |
20 | oid: "1.3.6.1.4.1.37476.2.5.2.4.3.900", |
21 | 21 | ||
22 | doUpdateOIDplus: function(rev, max) { |
22 | doUpdateOIDplus: function(next_rev, max_rev) { |
23 | $("#update_versioninfo").hide(); |
23 | $("#update_versioninfo").hide(); |
24 | $("#update_infobox").html(_L("Started update from %1 to %2",rev,max)+"\n"); |
- | |
25 | OIDplusPageAdminSoftwareUpdate._doUpdateOIDplus(rev, max); |
24 | OIDplusPageAdminSoftwareUpdate._downloadUpdate(next_rev, max_rev); |
26 | }, |
25 | }, |
27 | 26 | ||
28 | _doUpdateOIDplus: function(rev, max) { |
27 | _downloadUpdate: function(next_rev, max_rev) { |
29 | $("#update_header").text(_L("Updating to Revision %1 ...",rev)+"\n"); |
28 | var msg = _L("Downloading update beginning from version %1 up to %2...",next_rev,max_rev); |
30 | - | ||
31 | var msg = "Update to OIDplus version svn-"+rev+" is running..."; // TODO: If we would translate this to German, then we would also need to generate the serverside scripts to German. So we keep this in English. |
- | |
32 | $("#update_infobox").html($("#update_infobox").html() + '<span class="severity_2"><strong>' + _L('INFO') + ":</strong></span> "+msg+"\n"); |
29 | $("#update_infobox").html(/*$("#update_infobox").html() +*/ '<span class="severity_2"><strong>' + _L('INFO') + ":</strong></span> "+msg+"\n"); |
33 | 30 | ||
34 | //show_waiting_anim(); |
31 | //show_waiting_anim(); |
35 | $.ajax({ |
32 | $.ajax({ |
36 | url: "ajax.php", |
33 | url: "ajax.php", |
37 | type: "POST", |
34 | type: "POST", |
Line 43... | Line 40... | ||
43 | $.xhrPool.remove(jqXHR); |
40 | $.xhrPool.remove(jqXHR); |
44 | }, |
41 | }, |
45 | data: { |
42 | data: { |
46 | csrf_token:csrf_token, |
43 | csrf_token:csrf_token, |
47 | plugin: OIDplusPageAdminSoftwareUpdate.oid, |
44 | plugin: OIDplusPageAdminSoftwareUpdate.oid, |
- | 45 | next_version: next_rev, |
|
48 | rev: rev, |
46 | max_version: max_rev, |
49 | update_version: 2, |
47 | update_version: 3, |
50 | action: "update_now", |
48 | action: "update_now", |
51 | }, |
49 | }, |
52 | error:function(jqXHR, textStatus, errorThrown) { |
50 | error:function(jqXHR, textStatus, errorThrown) { |
53 | //hide_waiting_anim(); |
51 | //hide_waiting_anim(); |
54 | if (errorThrown == "abort") { |
52 | if (errorThrown == "abort") { |
Line 74... | Line 72... | ||
74 | $("#update_infobox").html($("#update_infobox").html() + "\n\n" + '<span class="severity_4"><strong>' + _L('FATAL ERROR') + ':</strong></span> ' + data.error + "\n\n"); |
72 | $("#update_infobox").html($("#update_infobox").html() + "\n\n" + '<span class="severity_4"><strong>' + _L('FATAL ERROR') + ':</strong></span> ' + data.error + "\n\n"); |
75 | } |
73 | } |
76 | $("#update_infobox").html($("#update_infobox").html() + '\n\n<input type="button" onclick="location.reload()" value="'+_L('Reload page')+'">'); |
74 | $("#update_infobox").html($("#update_infobox").html() + '\n\n<input type="button" onclick="location.reload()" value="'+_L('Reload page')+'">'); |
77 | } else if (typeof data === "object" && data.status >= 0) { |
75 | } else if (typeof data === "object" && data.status >= 0) { |
78 | 76 | ||
79 | if (!(typeof data === "object" && "update_file" in data)) { |
77 | if (!(typeof data === "object" && "update_files" in data)) { |
80 | - | ||
- | 78 | // This code is usual for svn-wc and git-wc update |
|
81 | output = data.content.trim(); |
79 | var output = data.content.trim(); |
82 | output = output.replace(/INFO:/g, '<span class="severity_2"><strong>' + _L('INFO') + ':</strong></span>'); |
80 | output = output.replace(/INFO:/g, '<span class="severity_2"><strong>' + _L('INFO') + ':</strong></span>'); |
83 | output = output.replace(/WARNING:/g, '<span class="severity_3"><strong>' + _L('WARNING') + ':</strong></span>'); |
81 | output = output.replace(/WARNING:/g, '<span class="severity_3"><strong>' + _L('WARNING') + ':</strong></span>'); |
84 | output = output.replace(/FATAL ERROR:/g, '<span class="severity_4"><strong>' + _L('FATAL ERROR') + ':</strong></span>'); |
82 | output = output.replace(/FATAL ERROR:/g, '<span class="severity_4"><strong>' + _L('FATAL ERROR') + ':</strong></span>'); |
85 | $("#update_infobox").html($("#update_infobox").html() + output + "\n"); |
83 | $("#update_infobox").html($("#update_infobox").html() + output + "\n"); |
86 | rev = data.rev=="HEAD" ? max : data.rev; |
84 | var cur_rev = data.rev=="HEAD" ? max_rev : data.rev; |
87 | if (rev >= max) { |
85 | if (cur_rev >= max_rev) { |
88 | $("#update_header").text(_L("Update finished")); |
86 | $("#update_header").text(_L("Update finished")); |
89 | $("#update_infobox").html($("#update_infobox").html() + "\n\n" + '<span class="severity_1"><strong> ' + _L('UPDATE FINISHED') + ':</strong></span> ' + _L('You are now at SVN revision %1', rev)); |
87 | $("#update_infobox").html($("#update_infobox").html() + "\n\n" + '<span class="severity_1"><strong> ' + _L('UPDATE FINISHED') + ':</strong></span> ' + _L('You are now at version %1', cur_rev)); |
90 | $("#update_infobox").html($("#update_infobox").html() + '\n\n<input type="button" onclick="location.reload()" value="'+_L('Reload page')+'">'); |
88 | $("#update_infobox").html($("#update_infobox").html() + '\n\n<input type="button" onclick="location.reload()" value="'+_L('Reload page')+'">'); |
91 | } else { |
89 | } else { |
92 | if (output.includes("FATAL ERROR:")) { |
90 | if (output.includes("FATAL ERROR:")) { |
93 | $("#update_header").text(_L("Update failed")); |
91 | $("#update_header").text(_L("Update failed")); |
94 | $("#update_infobox").html($("#update_infobox").html() + '\n\n<input type="button" onclick="location.reload()" value="'+_L('Reload page')+'">'); |
92 | $("#update_infobox").html($("#update_infobox").html() + '\n\n<input type="button" onclick="location.reload()" value="'+_L('Reload page')+'">'); |
95 | } else { |
93 | } else { |
96 | OIDplusPageAdminSoftwareUpdate._doUpdateOIDplus(parseInt(rev)+1, max); |
94 | // This is an undefined state! (TODO) |
97 | } |
95 | } |
98 | } |
96 | } |
99 | return; |
97 | return; |
100 | - | ||
101 | } else { |
98 | } else { |
- | 99 | // This code is usual for version 3 "manual" update |
|
- | 100 | OIDplusPageAdminSoftwareUpdate._applyChangescripts(data.update_files); |
|
- | 101 | } |
|
- | 102 | return; |
|
- | 103 | } else { |
|
- | 104 | $("#update_header").text(_L("Update failed")); |
|
- | 105 | //alertError(_L("Error: %1",data)); |
|
- | 106 | if ("content" in data) { |
|
- | 107 | $("#update_infobox").html($("#update_infobox").html() + "\n\n" + data.content + "\n\n" + '<span class="severity_4"><strong>' + _L('FATAL ERROR') + ':</strong></span> ' + data + "\n\n"); |
|
- | 108 | } else { |
|
- | 109 | $("#update_infobox").html($("#update_infobox").html() + "\n\n" + '<span class="severity_4"><strong>' + _L('FATAL ERROR') + ':</strong></span> ' + data + "\n\n"); |
|
- | 110 | } |
|
- | 111 | $("#update_infobox").html($("#update_infobox").html() + '\n\n<input type="button" onclick="location.reload()" value="'+_L('Reload page')+'">'); |
|
- | 112 | } |
|
- | 113 | }, |
|
- | 114 | timeout:0 // infinite |
|
- | 115 | }); |
|
- | 116 | return false; |
|
- | 117 | }, |
|
102 | 118 | ||
- | 119 | _applyChangescripts: function(leftscripts) { |
|
- | 120 | ||
- | 121 | if (leftscripts.length == 0) { |
|
- | 122 | $("#update_header").text(_L("Update successful")); |
|
- | 123 | $("#update_infobox").html($("#update_infobox").html() + "\n\n" + '<span class="severity_1"><strong> ' + _L('UPDATE FINISHED') + '</strong></span>'); |
|
- | 124 | $("#update_infobox").html($("#update_infobox").html() + '\n\n<input type="button" onclick="location.reload()" value="'+_L('Reload page')+'">'); |
|
- | 125 | return; |
|
- | 126 | } |
|
- | 127 | ||
- | 128 | var tmp = leftscripts.shift(); |
|
- | 129 | var version = tmp[0]; |
|
- | 130 | var scripturl = tmp[1]; |
|
- | 131 | ||
103 | console.log("Execute update file " + data.update_file); |
132 | console.log("Execute update file " + scripturl); |
- | 133 | $("#update_header").text(_L("Updating to version %1 ...",version)+"\n"); |
|
- | 134 | var msg = _L("Update to OIDplus version %1 is running...",version); |
|
- | 135 | $("#update_infobox").html($("#update_infobox").html() + '<span class="severity_2"><strong>' + _L('INFO') + ":</strong></span> "+msg+"\n"); |
|
104 | 136 | ||
105 | $.ajax({ |
137 | $.ajax({ |
106 | url: data.update_file, |
138 | url: scripturl, |
107 | type: "GET", |
139 | type: "GET", |
108 | beforeSend: function(jqXHR, settings) { |
140 | beforeSend: function(jqXHR, settings) { |
109 | $.xhrPool.abortAll(); |
141 | $.xhrPool.abortAll(); |
110 | $.xhrPool.add(jqXHR); |
142 | $.xhrPool.add(jqXHR); |
111 | }, |
143 | }, |
Line 127... | Line 159... | ||
127 | $("#update_infobox").html($("#update_infobox").html() + '\n\n<input type="button" onclick="location.reload()" value="'+_L('Reload page')+'">'); |
159 | $("#update_infobox").html($("#update_infobox").html() + '\n\n<input type="button" onclick="location.reload()" value="'+_L('Reload page')+'">'); |
128 | } |
160 | } |
129 | }, |
161 | }, |
130 | success: function(data2) { |
162 | success: function(data2) { |
131 | //hide_waiting_anim(); |
163 | //hide_waiting_anim(); |
132 | output2 = data2.trim(); |
164 | var output2 = data2.trim(); |
133 | output2 = output2.replace(/INFO:/g, '<span class="severity_2"><strong>' + _L('INFO') + ':</strong></span>'); |
165 | output2 = output2.replace(/INFO:/g, '<span class="severity_2"><strong>' + _L('INFO') + ':</strong></span>'); |
134 | output2 = output2.replace(/WARNING:/g, '<span class="severity_3"><strong>' + _L('WARNING') + ':</strong></span>'); |
166 | output2 = output2.replace(/WARNING:/g, '<span class="severity_3"><strong>' + _L('WARNING') + ':</strong></span>'); |
135 | output2 = output2.replace(/FATAL ERROR:/g, '<span class="severity_4"><strong>' + _L('FATAL ERROR') + ':</strong></span>'); |
167 | output2 = output2.replace(/FATAL ERROR:/g, '<span class="severity_4"><strong>' + _L('FATAL ERROR') + ':</strong></span>'); |
136 | $("#update_infobox").html($("#update_infobox").html() + output2 + "\n"); |
- | |
- | 168 | ||
137 | rev = data.rev=="HEAD" ? max : data.rev; |
169 | if (output2 == "DONE") { // DO NOT TRANSLATE |
138 | if (rev >= max) { |
- | |
139 | $("#update_header").text(_L("Update finished")); |
170 | var msg = _L("Update to OIDplus version %1 was successful!",version); |
140 | $("#update_infobox").html($("#update_infobox").html() + "\n\n" + '<span class="severity_1"><strong> ' + _L('UPDATE FINISHED') + ':</strong></span> ' + _L('You are now at SVN revision %1', rev)); |
171 | $("#update_infobox").html($("#update_infobox").html() + '<span class="severity_2"><strong>' + _L('INFO') + ":</strong></span> "+msg+"\n"); |
141 | $("#update_infobox").html($("#update_infobox").html() + '\n\n<input type="button" onclick="location.reload()" value="'+_L('Reload page')+'">'); |
- | |
142 | } else { |
172 | } else { |
- | 173 | $("#update_infobox").html($("#update_infobox").html() + output2 + "\n"); |
|
- | 174 | } |
|
- | 175 | ||
143 | if (output2.includes("FATAL ERROR:")) { |
176 | if (output2.includes("FATAL ERROR:")) { |
144 | $("#update_header").text(_L("Update failed")); |
177 | $("#update_header").text(_L("Update failed")); |
145 | $("#update_infobox").html($("#update_infobox").html() + '\n\n<input type="button" onclick="location.reload()" value="'+_L('Reload page')+'">'); |
178 | $("#update_infobox").html($("#update_infobox").html() + '\n\n<input type="button" onclick="location.reload()" value="'+_L('Reload page')+'">'); |
146 | } else { |
179 | } else { |
147 | OIDplusPageAdminSoftwareUpdate._doUpdateOIDplus(parseInt(rev)+1, max); |
180 | OIDplusPageAdminSoftwareUpdate._applyChangescripts(leftscripts); |
148 | } |
- | |
149 | } |
181 | } |
150 | return; |
182 | return; |
151 | }, |
183 | }, |
152 | timeout:0 // infinite |
184 | timeout:0 // infinite |
153 | }); |
185 | }); |
154 | 186 | ||
155 | } |
187 | } |
156 | 188 | ||
157 | return; |
- | |
158 | } else { |
- | |
159 | $("#update_header").text(_L("Update failed")); |
- | |
160 | //alertError(_L("Error: %1",data)); |
- | |
161 | if ("content" in data) { |
- | |
162 | $("#update_infobox").html($("#update_infobox").html() + "\n\n" + data.content + "\n\n" + '<span class="severity_4"><strong>' + _L('FATAL ERROR') + ':</strong></span> ' + data + "\n\n"); |
- | |
163 | } else { |
- | |
164 | $("#update_infobox").html($("#update_infobox").html() + "\n\n" + '<span class="severity_4"><strong>' + _L('FATAL ERROR') + ':</strong></span> ' + data + "\n\n"); |
- | |
165 | } |
- | |
166 | $("#update_infobox").html($("#update_infobox").html() + '\n\n<input type="button" onclick="location.reload()" value="'+_L('Reload page')+'">'); |
- | |
167 | } |
- | |
168 | }, |
- | |
169 | timeout:0 // infinite |
- | |
170 | }); |
- | |
171 | return false; |
- | |
172 | } |
- | |
173 | - | ||
174 | }; |
189 | }; |