Rev 799 | Rev 807 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
635 | daniel-mar | 1 | /* |
2 | * OIDplus 2.0 |
||
3 | * Copyright 2019 - 2021 Daniel Marschall, ViaThinkSoft |
||
4 | * |
||
5 | * Licensed under the Apache License, Version 2.0 (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 |
||
8 | * |
||
9 | * http://www.apache.org/licenses/LICENSE-2.0 |
||
10 | * |
||
11 | * Unless required by applicable law or agreed to in writing, software |
||
12 | * distributed under the License is distributed on an "AS IS" BASIS, |
||
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||
14 | * See the License for the specific language governing permissions and |
||
15 | * limitations under the License. |
||
16 | */ |
||
17 | |||
18 | var OIDplusPageAdminSoftwareUpdate = { |
||
19 | |||
20 | oid: "1.3.6.1.4.1.37476.2.5.2.4.3.900", |
||
21 | |||
647 | daniel-mar | 22 | doUpdateOIDplus: function(rev, max) { |
23 | $("#update_versioninfo").hide(); |
||
651 | daniel-mar | 24 | $("#update_infobox").html(_L("Started update from %1 to %2",rev,max)+"\n"); |
647 | daniel-mar | 25 | OIDplusPageAdminSoftwareUpdate._doUpdateOIDplus(rev, max); |
26 | }, |
||
27 | |||
28 | _doUpdateOIDplus: function(rev, max) { |
||
29 | $("#update_header").text(_L("Updating to Revision %1 ...",rev)+"\n"); |
||
797 | daniel-mar | 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. |
||
803 | daniel-mar | 32 | $("#update_infobox").html($("#update_infobox").html() + '<span class="severity_2"><strong>' + _L('INFO') + ":</strong></span> "+msg+"\n"); |
797 | daniel-mar | 33 | |
647 | daniel-mar | 34 | //show_waiting_anim(); |
635 | daniel-mar | 35 | $.ajax({ |
36 | url: "ajax.php", |
||
37 | type: "POST", |
||
38 | beforeSend: function(jqXHR, settings) { |
||
39 | $.xhrPool.abortAll(); |
||
40 | $.xhrPool.add(jqXHR); |
||
41 | }, |
||
42 | complete: function(jqXHR, text) { |
||
43 | $.xhrPool.remove(jqXHR); |
||
44 | }, |
||
45 | data: { |
||
46 | csrf_token:csrf_token, |
||
47 | plugin: OIDplusPageAdminSoftwareUpdate.oid, |
||
647 | daniel-mar | 48 | rev: rev, |
635 | daniel-mar | 49 | action: "update_now", |
50 | }, |
||
51 | error:function(jqXHR, textStatus, errorThrown) { |
||
651 | daniel-mar | 52 | //hide_waiting_anim(); |
53 | if (errorThrown == "abort") { |
||
54 | $("#update_header").text(_L("Update aborted")); |
||
687 | daniel-mar | 55 | $("#update_infobox").html($("#update_infobox").html() + '\n\n<input type="button" onclick="location.reload()" value="'+_L('Reload page')+'">'); |
651 | daniel-mar | 56 | return; |
57 | } else { |
||
58 | $("#update_header").text(_L("Update failed")); |
||
59 | //alert(_L("Error: %1",errorThrown)); |
||
659 | daniel-mar | 60 | $("#update_infobox").html($("#update_infobox").html() + "\n\n" + '<span class="severity_4"><strong>' + _L('FATAL ERROR') + ':</strong></span> ' + errorThrown + "\n\n"); |
687 | daniel-mar | 61 | $("#update_infobox").html($("#update_infobox").html() + '\n\n<input type="button" onclick="location.reload()" value="'+_L('Reload page')+'">'); |
651 | daniel-mar | 62 | } |
635 | daniel-mar | 63 | }, |
64 | success: function(data) { |
||
647 | daniel-mar | 65 | //hide_waiting_anim(); |
635 | daniel-mar | 66 | if ("error" in data) { |
651 | daniel-mar | 67 | $("#update_header").text(_L("Update failed")); |
68 | //alert(_L("Error: %1",data.error)); |
||
635 | daniel-mar | 69 | if ("content" in data) { |
659 | daniel-mar | 70 | $("#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"); |
651 | daniel-mar | 71 | } else { |
659 | daniel-mar | 72 | $("#update_infobox").html($("#update_infobox").html() + "\n\n" + '<span class="severity_4"><strong>' + _L('FATAL ERROR') + ':</strong></span> ' + data.error + "\n\n"); |
635 | daniel-mar | 73 | } |
687 | daniel-mar | 74 | $("#update_infobox").html($("#update_infobox").html() + '\n\n<input type="button" onclick="location.reload()" value="'+_L('Reload page')+'">'); |
635 | daniel-mar | 75 | } else if (data.status >= 0) { |
647 | daniel-mar | 76 | output = data.content.trim(); |
659 | daniel-mar | 77 | output = output.replace(/INFO:/g, '<span class="severity_2"><strong>' + _L('INFO') + ':</strong></span>'); |
78 | output = output.replace(/WARNING:/g, '<span class="severity_3"><strong>' + _L('WARNING') + ':</strong></span>'); |
||
79 | output = output.replace(/FATAL ERROR:/g, '<span class="severity_4"><strong>' + _L('FATAL ERROR') + ':</strong></span>'); |
||
647 | daniel-mar | 80 | $("#update_infobox").html($("#update_infobox").html() + output + "\n"); |
662 | daniel-mar | 81 | rev = data.rev=="HEAD" ? max : data.rev; |
647 | daniel-mar | 82 | if (rev >= max) { |
83 | $("#update_header").text(_L("Update finished")); |
||
687 | daniel-mar | 84 | $("#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)); |
696 | daniel-mar | 85 | $("#update_infobox").html($("#update_infobox").html() + '\n\n<input type="button" onclick="location.reload()" value="'+_L('Reload page')+'">'); |
647 | daniel-mar | 86 | } else { |
651 | daniel-mar | 87 | if (output.includes("FATAL ERROR:")) { |
88 | $("#update_header").text(_L("Update failed")); |
||
696 | daniel-mar | 89 | $("#update_infobox").html($("#update_infobox").html() + '\n\n<input type="button" onclick="location.reload()" value="'+_L('Reload page')+'">'); |
651 | daniel-mar | 90 | } else { |
668 | daniel-mar | 91 | OIDplusPageAdminSoftwareUpdate._doUpdateOIDplus(parseInt(rev)+1, max); |
651 | daniel-mar | 92 | } |
647 | daniel-mar | 93 | } |
635 | daniel-mar | 94 | return; |
95 | } else { |
||
651 | daniel-mar | 96 | $("#update_header").text(_L("Update failed")); |
97 | //alert(_L("Error: %1",data)); |
||
635 | daniel-mar | 98 | if ("content" in data) { |
659 | daniel-mar | 99 | $("#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"); |
651 | daniel-mar | 100 | } else { |
659 | daniel-mar | 101 | $("#update_infobox").html($("#update_infobox").html() + "\n\n" + '<span class="severity_4"><strong>' + _L('FATAL ERROR') + ':</strong></span> ' + data + "\n\n"); |
635 | daniel-mar | 102 | } |
687 | daniel-mar | 103 | $("#update_infobox").html($("#update_infobox").html() + '\n\n<input type="button" onclick="location.reload()" value="'+_L('Reload page')+'">'); |
635 | daniel-mar | 104 | } |
105 | }, |
||
106 | timeout:0 // infinite |
||
107 | }); |
||
108 | return false; |
||
109 | } |
||
110 | |||
111 | }; |