Rev 1036 | Rev 1426 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1036 | Rev 1292 | ||
---|---|---|---|
1 | /* |
1 | /* |
2 | * OIDplus 2.0 |
2 | * OIDplus 2.0 |
3 | * Copyright 2019 - 2022 Daniel Marschall, ViaThinkSoft |
3 | * Copyright 2019 - 2022 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 | * |
9 | * http://www.apache.org/licenses/LICENSE-2.0 |
9 | * http://www.apache.org/licenses/LICENSE-2.0 |
10 | * |
10 | * |
11 | * Unless required by applicable law or agreed to in writing, software |
11 | * Unless required by applicable law or agreed to in writing, software |
12 | * distributed under the License is distributed on an "AS IS" BASIS, |
12 | * distributed under the License is distributed on an "AS IS" BASIS, |
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
14 | * See the License for the specific language governing permissions and |
14 | * See the License for the specific language governing permissions and |
15 | * limitations under the License. |
15 | * limitations under the License. |
16 | */ |
16 | */ |
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(rev, max) { |
23 | $("#update_versioninfo").hide(); |
23 | $("#update_versioninfo").hide(); |
24 | $("#update_infobox").html(_L("Started update from %1 to %2",rev,max)+"\n"); |
24 | $("#update_infobox").html(_L("Started update from %1 to %2",rev,max)+"\n"); |
25 | OIDplusPageAdminSoftwareUpdate._doUpdateOIDplus(rev, max); |
25 | OIDplusPageAdminSoftwareUpdate._doUpdateOIDplus(rev, max); |
26 | }, |
26 | }, |
27 | 27 | ||
28 | _doUpdateOIDplus: function(rev, max) { |
28 | _doUpdateOIDplus: function(rev, max) { |
29 | $("#update_header").text(_L("Updating to Revision %1 ...",rev)+"\n"); |
29 | $("#update_header").text(_L("Updating to Revision %1 ...",rev)+"\n"); |
30 | 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. |
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"); |
32 | $("#update_infobox").html($("#update_infobox").html() + '<span class="severity_2"><strong>' + _L('INFO') + ":</strong></span> "+msg+"\n"); |
33 | 33 | ||
34 | //show_waiting_anim(); |
34 | //show_waiting_anim(); |
35 | $.ajax({ |
35 | $.ajax({ |
36 | url: "ajax.php", |
36 | url: "ajax.php", |
37 | type: "POST", |
37 | type: "POST", |
38 | beforeSend: function(jqXHR, settings) { |
38 | beforeSend: function(jqXHR, settings) { |
39 | $.xhrPool.abortAll(); |
39 | $.xhrPool.abortAll(); |
40 | $.xhrPool.add(jqXHR); |
40 | $.xhrPool.add(jqXHR); |
41 | }, |
41 | }, |
42 | complete: function(jqXHR, text) { |
42 | complete: function(jqXHR, text) { |
43 | $.xhrPool.remove(jqXHR); |
43 | $.xhrPool.remove(jqXHR); |
44 | }, |
44 | }, |
45 | data: { |
45 | data: { |
46 | csrf_token:csrf_token, |
46 | csrf_token:csrf_token, |
47 | plugin: OIDplusPageAdminSoftwareUpdate.oid, |
47 | plugin: OIDplusPageAdminSoftwareUpdate.oid, |
48 | rev: rev, |
48 | rev: rev, |
49 | update_version: 2, |
49 | update_version: 2, |
50 | action: "update_now", |
50 | action: "update_now", |
51 | }, |
51 | }, |
52 | error:function(jqXHR, textStatus, errorThrown) { |
52 | error:function(jqXHR, textStatus, errorThrown) { |
53 | //hide_waiting_anim(); |
53 | //hide_waiting_anim(); |
54 | if (errorThrown == "abort") { |
54 | if (errorThrown == "abort") { |
55 | $("#update_header").text(_L("Update aborted")); |
55 | $("#update_header").text(_L("Update aborted")); |
56 | $("#update_infobox").html($("#update_infobox").html() + '\n\n<input type="button" onclick="location.reload()" value="'+_L('Reload page')+'">'); |
56 | $("#update_infobox").html($("#update_infobox").html() + '\n\n<input type="button" onclick="location.reload()" value="'+_L('Reload page')+'">'); |
57 | return; |
57 | return; |
58 | } else { |
58 | } else { |
59 | $("#update_header").text(_L("Update failed")); |
59 | $("#update_header").text(_L("Update failed")); |
60 | //alertError(_L("Error: %1",errorThrown)); |
60 | //alertError(_L("Error: %1",errorThrown)); |
61 | $("#update_infobox").html($("#update_infobox").html() + "\n\n" + '<span class="severity_4"><strong>' + _L('FATAL ERROR') + ':</strong></span> ' + errorThrown + "\n\n"); |
61 | $("#update_infobox").html($("#update_infobox").html() + "\n\n" + '<span class="severity_4"><strong>' + _L('FATAL ERROR') + ':</strong></span> ' + errorThrown + "\n\n"); |
62 | $("#update_infobox").html($("#update_infobox").html() + '\n\n<input type="button" onclick="location.reload()" value="'+_L('Reload page')+'">'); |
62 | $("#update_infobox").html($("#update_infobox").html() + '\n\n<input type="button" onclick="location.reload()" value="'+_L('Reload page')+'">'); |
63 | } |
63 | } |
64 | }, |
64 | }, |
65 | success: function(data) { |
65 | success: function(data) { |
- | 66 | // TODO: Use oidplus_ajax_success(), since this checks the existance of "error" in data, and checks if status>=0 |
|
66 | //hide_waiting_anim(); |
67 | //hide_waiting_anim(); |
67 | if (typeof data === "object" && "error" in data) { |
68 | if (typeof data === "object" && "error" in data) { |
68 | $("#update_header").text(_L("Update failed")); |
69 | $("#update_header").text(_L("Update failed")); |
69 | //alertError(_L("Error: %1",data.error)); |
70 | //alertError(_L("Error: %1",data.error)); |
70 | if (typeof data === "object" && "content" in data) { |
71 | if (typeof data === "object" && "content" in data) { |
71 | $("#update_infobox").html($("#update_infobox").html() + "\n\n" + data.content + "\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" + data.content + "\n\n" + '<span class="severity_4"><strong>' + _L('FATAL ERROR') + ':</strong></span> ' + data.error + "\n\n"); |
72 | } else { |
73 | } else { |
73 | $("#update_infobox").html($("#update_infobox").html() + "\n\n" + '<span class="severity_4"><strong>' + _L('FATAL ERROR') + ':</strong></span> ' + data.error + "\n\n"); |
74 | $("#update_infobox").html($("#update_infobox").html() + "\n\n" + '<span class="severity_4"><strong>' + _L('FATAL ERROR') + ':</strong></span> ' + data.error + "\n\n"); |
74 | } |
75 | } |
75 | $("#update_infobox").html($("#update_infobox").html() + '\n\n<input type="button" onclick="location.reload()" value="'+_L('Reload page')+'">'); |
76 | $("#update_infobox").html($("#update_infobox").html() + '\n\n<input type="button" onclick="location.reload()" value="'+_L('Reload page')+'">'); |
76 | } else if (typeof data === "object" && data.status >= 0) { |
77 | } else if (typeof data === "object" && data.status >= 0) { |
77 | 78 | ||
78 | if (!(typeof data === "object" && "update_file" in data)) { |
79 | if (!(typeof data === "object" && "update_file" in data)) { |
79 | 80 | ||
80 | output = data.content.trim(); |
81 | output = data.content.trim(); |
81 | output = output.replace(/INFO:/g, '<span class="severity_2"><strong>' + _L('INFO') + ':</strong></span>'); |
82 | output = output.replace(/INFO:/g, '<span class="severity_2"><strong>' + _L('INFO') + ':</strong></span>'); |
82 | output = output.replace(/WARNING:/g, '<span class="severity_3"><strong>' + _L('WARNING') + ':</strong></span>'); |
83 | output = output.replace(/WARNING:/g, '<span class="severity_3"><strong>' + _L('WARNING') + ':</strong></span>'); |
83 | output = output.replace(/FATAL ERROR:/g, '<span class="severity_4"><strong>' + _L('FATAL ERROR') + ':</strong></span>'); |
84 | output = output.replace(/FATAL ERROR:/g, '<span class="severity_4"><strong>' + _L('FATAL ERROR') + ':</strong></span>'); |
84 | $("#update_infobox").html($("#update_infobox").html() + output + "\n"); |
85 | $("#update_infobox").html($("#update_infobox").html() + output + "\n"); |
85 | rev = data.rev=="HEAD" ? max : data.rev; |
86 | rev = data.rev=="HEAD" ? max : data.rev; |
86 | if (rev >= max) { |
87 | if (rev >= max) { |
87 | $("#update_header").text(_L("Update finished")); |
88 | $("#update_header").text(_L("Update finished")); |
88 | $("#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)); |
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)); |
89 | $("#update_infobox").html($("#update_infobox").html() + '\n\n<input type="button" onclick="location.reload()" value="'+_L('Reload page')+'">'); |
90 | $("#update_infobox").html($("#update_infobox").html() + '\n\n<input type="button" onclick="location.reload()" value="'+_L('Reload page')+'">'); |
90 | } else { |
91 | } else { |
91 | if (output.includes("FATAL ERROR:")) { |
92 | if (output.includes("FATAL ERROR:")) { |
92 | $("#update_header").text(_L("Update failed")); |
93 | $("#update_header").text(_L("Update failed")); |
93 | $("#update_infobox").html($("#update_infobox").html() + '\n\n<input type="button" onclick="location.reload()" value="'+_L('Reload page')+'">'); |
94 | $("#update_infobox").html($("#update_infobox").html() + '\n\n<input type="button" onclick="location.reload()" value="'+_L('Reload page')+'">'); |
94 | } else { |
95 | } else { |
95 | OIDplusPageAdminSoftwareUpdate._doUpdateOIDplus(parseInt(rev)+1, max); |
96 | OIDplusPageAdminSoftwareUpdate._doUpdateOIDplus(parseInt(rev)+1, max); |
96 | } |
97 | } |
97 | } |
98 | } |
98 | return; |
99 | return; |
99 | 100 | ||
100 | } else { |
101 | } else { |
101 | 102 | ||
102 | console.log("Execute update file " + data.update_file); |
103 | console.log("Execute update file " + data.update_file); |
103 | 104 | ||
104 | $.ajax({ |
105 | $.ajax({ |
105 | url: data.update_file, |
106 | url: data.update_file, |
106 | type: "GET", |
107 | type: "GET", |
107 | beforeSend: function(jqXHR, settings) { |
108 | beforeSend: function(jqXHR, settings) { |
108 | $.xhrPool.abortAll(); |
109 | $.xhrPool.abortAll(); |
109 | $.xhrPool.add(jqXHR); |
110 | $.xhrPool.add(jqXHR); |
110 | }, |
111 | }, |
111 | complete: function(jqXHR, text) { |
112 | complete: function(jqXHR, text) { |
112 | $.xhrPool.remove(jqXHR); |
113 | $.xhrPool.remove(jqXHR); |
113 | }, |
114 | }, |
114 | data: { |
115 | data: { |
115 | }, |
116 | }, |
116 | error:function(jqXHR, textStatus, errorThrown) { |
117 | error:function(jqXHR, textStatus, errorThrown) { |
117 | //hide_waiting_anim(); |
118 | //hide_waiting_anim(); |
118 | if (errorThrown == "abort") { |
119 | if (errorThrown == "abort") { |
119 | $("#update_header").text(_L("Update aborted")); |
120 | $("#update_header").text(_L("Update aborted")); |
120 | $("#update_infobox").html($("#update_infobox").html() + '\n\n<input type="button" onclick="location.reload()" value="'+_L('Reload page')+'">'); |
121 | $("#update_infobox").html($("#update_infobox").html() + '\n\n<input type="button" onclick="location.reload()" value="'+_L('Reload page')+'">'); |
121 | return; |
122 | return; |
122 | } else { |
123 | } else { |
123 | $("#update_header").text(_L("Update failed")); |
124 | $("#update_header").text(_L("Update failed")); |
124 | //alertError(_L("Error: %1",errorThrown)); |
125 | //alertError(_L("Error: %1",errorThrown)); |
125 | $("#update_infobox").html($("#update_infobox").html() + "\n\n" + '<span class="severity_4"><strong>' + _L('FATAL ERROR') + ':</strong></span> ' + errorThrown + "\n\n"); |
126 | $("#update_infobox").html($("#update_infobox").html() + "\n\n" + '<span class="severity_4"><strong>' + _L('FATAL ERROR') + ':</strong></span> ' + errorThrown + "\n\n"); |
126 | $("#update_infobox").html($("#update_infobox").html() + '\n\n<input type="button" onclick="location.reload()" value="'+_L('Reload page')+'">'); |
127 | $("#update_infobox").html($("#update_infobox").html() + '\n\n<input type="button" onclick="location.reload()" value="'+_L('Reload page')+'">'); |
127 | } |
128 | } |
128 | }, |
129 | }, |
129 | success: function(data2) { |
130 | success: function(data2) { |
130 | //hide_waiting_anim(); |
131 | //hide_waiting_anim(); |
131 | output2 = data2.trim(); |
132 | output2 = data2.trim(); |
132 | output2 = output2.replace(/INFO:/g, '<span class="severity_2"><strong>' + _L('INFO') + ':</strong></span>'); |
133 | output2 = output2.replace(/INFO:/g, '<span class="severity_2"><strong>' + _L('INFO') + ':</strong></span>'); |
133 | output2 = output2.replace(/WARNING:/g, '<span class="severity_3"><strong>' + _L('WARNING') + ':</strong></span>'); |
134 | output2 = output2.replace(/WARNING:/g, '<span class="severity_3"><strong>' + _L('WARNING') + ':</strong></span>'); |
134 | output2 = output2.replace(/FATAL ERROR:/g, '<span class="severity_4"><strong>' + _L('FATAL ERROR') + ':</strong></span>'); |
135 | output2 = output2.replace(/FATAL ERROR:/g, '<span class="severity_4"><strong>' + _L('FATAL ERROR') + ':</strong></span>'); |
135 | $("#update_infobox").html($("#update_infobox").html() + output2 + "\n"); |
136 | $("#update_infobox").html($("#update_infobox").html() + output2 + "\n"); |
136 | rev = data.rev=="HEAD" ? max : data.rev; |
137 | rev = data.rev=="HEAD" ? max : data.rev; |
137 | if (rev >= max) { |
138 | if (rev >= max) { |
138 | $("#update_header").text(_L("Update finished")); |
139 | $("#update_header").text(_L("Update finished")); |
139 | $("#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)); |
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)); |
140 | $("#update_infobox").html($("#update_infobox").html() + '\n\n<input type="button" onclick="location.reload()" value="'+_L('Reload page')+'">'); |
141 | $("#update_infobox").html($("#update_infobox").html() + '\n\n<input type="button" onclick="location.reload()" value="'+_L('Reload page')+'">'); |
141 | } else { |
142 | } else { |
142 | if (output2.includes("FATAL ERROR:")) { |
143 | if (output2.includes("FATAL ERROR:")) { |
143 | $("#update_header").text(_L("Update failed")); |
144 | $("#update_header").text(_L("Update failed")); |
144 | $("#update_infobox").html($("#update_infobox").html() + '\n\n<input type="button" onclick="location.reload()" value="'+_L('Reload page')+'">'); |
145 | $("#update_infobox").html($("#update_infobox").html() + '\n\n<input type="button" onclick="location.reload()" value="'+_L('Reload page')+'">'); |
145 | } else { |
146 | } else { |
146 | OIDplusPageAdminSoftwareUpdate._doUpdateOIDplus(parseInt(rev)+1, max); |
147 | OIDplusPageAdminSoftwareUpdate._doUpdateOIDplus(parseInt(rev)+1, max); |
147 | } |
148 | } |
148 | } |
149 | } |
149 | return; |
150 | return; |
150 | }, |
151 | }, |
151 | timeout:0 // infinite |
152 | timeout:0 // infinite |
152 | }); |
153 | }); |
153 | 154 | ||
154 | } |
155 | } |
155 | 156 | ||
156 | return; |
157 | return; |
157 | } else { |
158 | } else { |
158 | $("#update_header").text(_L("Update failed")); |
159 | $("#update_header").text(_L("Update failed")); |
159 | //alertError(_L("Error: %1",data)); |
160 | //alertError(_L("Error: %1",data)); |
160 | if ("content" in data) { |
161 | if ("content" in data) { |
161 | $("#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"); |
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"); |
162 | } else { |
163 | } else { |
163 | $("#update_infobox").html($("#update_infobox").html() + "\n\n" + '<span class="severity_4"><strong>' + _L('FATAL ERROR') + ':</strong></span> ' + data + "\n\n"); |
164 | $("#update_infobox").html($("#update_infobox").html() + "\n\n" + '<span class="severity_4"><strong>' + _L('FATAL ERROR') + ':</strong></span> ' + data + "\n\n"); |
164 | } |
165 | } |
165 | $("#update_infobox").html($("#update_infobox").html() + '\n\n<input type="button" onclick="location.reload()" value="'+_L('Reload page')+'">'); |
166 | $("#update_infobox").html($("#update_infobox").html() + '\n\n<input type="button" onclick="location.reload()" value="'+_L('Reload page')+'">'); |
166 | } |
167 | } |
167 | }, |
168 | }, |
168 | timeout:0 // infinite |
169 | timeout:0 // infinite |
169 | }); |
170 | }); |
170 | return false; |
171 | return false; |
171 | } |
172 | } |
172 | 173 | ||
173 | }; |
174 | }; |
174 | 175 |