Rev 642 | Rev 651 | 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(); |
||
24 | $("#update_infobox").text(_L("Started update from %1 to %2",rev,max)+"\n"); |
||
25 | OIDplusPageAdminSoftwareUpdate._doUpdateOIDplus(rev, max); |
||
26 | }, |
||
27 | |||
28 | _doUpdateOIDplus: function(rev, max) { |
||
29 | $("#update_header").text(_L("Updating to Revision %1 ...",rev)+"\n"); |
||
30 | //show_waiting_anim(); |
||
635 | daniel-mar | 31 | $.ajax({ |
32 | url: "ajax.php", |
||
33 | type: "POST", |
||
34 | beforeSend: function(jqXHR, settings) { |
||
35 | $.xhrPool.abortAll(); |
||
36 | $.xhrPool.add(jqXHR); |
||
37 | }, |
||
38 | complete: function(jqXHR, text) { |
||
39 | $.xhrPool.remove(jqXHR); |
||
40 | }, |
||
41 | data: { |
||
42 | csrf_token:csrf_token, |
||
43 | plugin: OIDplusPageAdminSoftwareUpdate.oid, |
||
647 | daniel-mar | 44 | rev: rev, |
635 | daniel-mar | 45 | action: "update_now", |
46 | }, |
||
47 | error:function(jqXHR, textStatus, errorThrown) { |
||
48 | hide_waiting_anim(); |
||
49 | if (errorThrown == "abort") return; |
||
50 | alert(_L("Error: %1",errorThrown)); |
||
51 | }, |
||
52 | success: function(data) { |
||
647 | daniel-mar | 53 | //hide_waiting_anim(); |
635 | daniel-mar | 54 | if ("error" in data) { |
55 | alert(_L("Error: %1",data.error)); |
||
56 | if ("content" in data) { |
||
647 | daniel-mar | 57 | $("#update_header").text(_L("Update failed")); |
58 | $("#update_infobox").text($("#update_infobox").text() + "\n\n" + data.content + "\n\n" + _L("Error: %1",data.error) + "\n\n"); |
||
635 | daniel-mar | 59 | } |
60 | } else if (data.status >= 0) { |
||
647 | daniel-mar | 61 | output = data.content.trim(); |
62 | output = output.replace(/INFO:/g, '<span class="severity_2"><strong>INFO:</strong></span>'); |
||
63 | output = output.replace(/WARNING:/g, '<span class="severity_3"><strong>WARNING:</strong></span>'); |
||
64 | output = output.replace(/FATAL ERROR:/g, '<span class="severity_4"><strong>FATAL ERROR:</strong></span>'); |
||
65 | $("#update_infobox").html($("#update_infobox").html() + output + "\n"); |
||
66 | if (rev >= max) { |
||
67 | //alert(_L("Update OK")); |
||
68 | $("#update_header").text(_L("Update finished")); |
||
69 | // reloadContent(); // don't reload... let the user read the messages? |
||
70 | } else { |
||
71 | OIDplusPageAdminSoftwareUpdate._doUpdateOIDplus(rev+1, max); |
||
72 | } |
||
635 | daniel-mar | 73 | return; |
74 | } else { |
||
75 | alert(_L("Error: %1",data)); |
||
76 | if ("content" in data) { |
||
647 | daniel-mar | 77 | $("#update_header").text(_L("Update failed")); |
78 | $("#update_infobox").text($("#update_infobox").text() + "\n\n" + data.content + "\n\n" + _L("Error: %1",data) + "\n\n"); |
||
635 | daniel-mar | 79 | } |
80 | } |
||
81 | }, |
||
82 | timeout:0 // infinite |
||
83 | }); |
||
84 | return false; |
||
85 | } |
||
86 | |||
87 | }; |