diff options
author | Christian Schoenebeck <christian.schoenebeck@gmail.com> | 2014-11-09 18:37:15 +0100 |
---|---|---|
committer | Christian Schoenebeck <christian.schoenebeck@gmail.com> | 2014-11-09 18:37:15 +0100 |
commit | ee9fdba61744111d8f5d7f7d616992ac7135ac09 (patch) | |
tree | 8d20f47184b2a2f75a7b47ad26fe354b47b02b82 /applications/luci-ddns/luasrc/view | |
parent | 92bfcbbc3463cbb7f384d688cb5f1c7e4bed326c (diff) |
luci-app-ddns: Update to support ddns-scripts 2.1.0-1
fix verify of entry for DNS server Issue #244
https://github.com/openwrt/luci/issues/244
add support for option 'update_script'
add display of version information when click on "Dynamic DNS" on
overview page
add verify of installed ddns-scripts version and show as hint if not
correct version
modified epoch to date conversation
cbi object Flag did not set section.changed state, fixed in
tools.flag_parse function
ucitrack entry no longer needed and removed
minor fixes
Signed-off-by: Christian Schoenebeck <christian.schoenebeck@gmail.com>
Diffstat (limited to 'applications/luci-ddns/luasrc/view')
-rw-r--r-- | applications/luci-ddns/luasrc/view/ddns/overview_status.htm | 56 | ||||
-rw-r--r-- | applications/luci-ddns/luasrc/view/ddns/system_status.htm | 241 |
2 files changed, 170 insertions, 127 deletions
diff --git a/applications/luci-ddns/luasrc/view/ddns/overview_status.htm b/applications/luci-ddns/luasrc/view/ddns/overview_status.htm index b0cc2fac35..e23cc796e9 100644 --- a/applications/luci-ddns/luasrc/view/ddns/overview_status.htm +++ b/applications/luci-ddns/luasrc/view/ddns/overview_status.htm @@ -2,6 +2,12 @@ <!-- ++ BEGIN ++ Dynamic DNS ++ overview_status.htm ++ --> <script type="text/javascript">//<![CDATA[ + // variables to store version information + var luci_version + var luci_build + var ddns_version + var ddns_required + // helper to extract section from objects id // cbi.ddns.SECTION._xyz function _id2section(id) { @@ -14,7 +20,11 @@ // called by XHR.poll and onclick_startstop function _data2elements(data) { // DDNS Service - // data[0] ignored here + // fill Version informations + luci_version = data[0].luci_ver + luci_build = data[0].luci_build + ddns_version = data[0].script_ver + ddns_required = data[0].script_min // Service sections for( i = 1; i < data.length; i++ ) @@ -38,7 +48,7 @@ btn.className = "cbi-button cbi-input-apply"; } btn.disabled = false; // button enabled - + // last update switch (data[i].datelast) { case "_empty_": @@ -71,7 +81,7 @@ nup.innerHTML = '<em><%:Disabled%></em>'; btn.value = '----------'; btn.className = "cbi-button cbi-input-button"; // no image - btn.disabled = true; // disabled + btn.disabled = true; // disabled } break; default: @@ -84,13 +94,13 @@ // registered IP // rip.innerHTML = "Registered IP"; - if (data[i].domain == "_nodomain_") + if (data[i].domain == "_nodomain_") rip.innerHTML = ''; else if (data[i].reg_ip == "_nodata_") rip.innerHTML = '<em><%:No data%></em>'; else rip.innerHTML = data[i].reg_ip; - + // monitored interfacce // data[i].iface ignored here } @@ -121,13 +131,27 @@ } else { btn.value = '----------'; btn.className = "cbi-button cbi-input-button"; // no image - btn.disabled = true; // disabled - } + btn.disabled = true; // disabled + } + } + + // event handler for map.title link + function onclick_maptitle() { + var str = "<%:Version Information%>"; + str += "\n\nluci-app-ddns:"; + str += "\n\t<%:Version%>:\t" + luci_version; + str += "\n\t<%:Build%>:\t" + luci_build; + str += "\n\nddns-scripts <%:installed%>:"; + str += "\n\t<%:Version%>:\t" + ddns_version; + str += "\n\nddns-scripts <%:required%>:"; + str += "\n\t<%:Version%>:\t" + ddns_required + " <%:or greater%>"; + str += "\n\n" + alert(str); } // event handler for start/stop button function onclick_startstop(id) { - // extract section + // extract section var section = _id2section(id); // get elements var cbx = document.getElementById("cbid.ddns." + section + ".enabled"); // Enabled @@ -158,14 +182,20 @@ ); } + // force to immediate show status on page load (not waiting for XHR.poll) + XHR.get('<%=luci.dispatcher.build_url("admin", "services", "ddns", "status")%>', null, + function(x, data) { + _data2elements(data); + } + ); + // define only ONE XHR.poll in a page because if one is running it blocks the other one // optimum is to define on Map or Section Level from here you can reach all elements - // we need update every 30 seconds only - XHR.poll(30, '<%=luci.dispatcher.build_url("admin", "services", "ddns", "status")%>', null, - function(x, data) - { + // we need update every 15 seconds only + XHR.poll(15, '<%=luci.dispatcher.build_url("admin", "services", "ddns", "status")%>', null, + function(x, data) { _data2elements(data); - } + } ); //]]></script> diff --git a/applications/luci-ddns/luasrc/view/ddns/system_status.htm b/applications/luci-ddns/luasrc/view/ddns/system_status.htm index d2c2b7e62c..dcf06cc0bb 100644 --- a/applications/luci-ddns/luasrc/view/ddns/system_status.htm +++ b/applications/luci-ddns/luasrc/view/ddns/system_status.htm @@ -1,127 +1,140 @@ <!-- ++ BEGIN ++ Dynamic DNS ++ system_status.htm ++ --> <script type="text/javascript">//<![CDATA[ - XHR.poll(10, '<%=luci.dispatcher.build_url("admin", "services", "ddns", "status")%>', null, - function(x, data) + // helper to move status data to the relevant + // screen objects + // called by XHR.poll and XHR.get + function _data2elements(x, data) { + var tbl = document.getElementById('ddns_status_table'); + // security check + if ( !(tbl) ) { return; } + + // clear all rows + while (tbl.rows.length > 1) + tbl.deleteRow(1); + + // variable for Modulo-Division use to set cbi-rowstyle-? (0 or 1) + var x = -1; + var i = 1; + + // no data => no ddns-scripts Version 2 installed + if ( !data ) { + var txt = '<br /><strong><font color="red"><%:Old version of ddns-scripts installed%></font>' ; + var url = '<a href="' ; + url += '<%=luci.dispatcher.build_url("admin", "system", "packages")%>' ; + url += '"><%:install update here%></a></strong>' ; + var tr = tbl.insertRow(-1); + tr.className = 'cbi-section-table-row cbi-rowstyle-' + (((i + x) % 2) + 1); + var td = tr.insertCell(-1); + td.colSpan = 2 ; + td.innerHTML = txt + " - " + url + tr.insertCell(-1).colSpan = 3 ; + return; + } + + // DDNS Service disabled + if (data[0].enabled == 0) { + var txt = '<strong><font color="red"><%:DDNS Autostart disabled%></font>' ; + var url = '<a href="' + data[0].url_up + '"><%:enable here%></a></strong>' ; + var tr = tbl.insertRow(-1); + tr.className = 'cbi-section-table-row cbi-rowstyle-' + (((i + x) % 2) + 1); + var td = tr.insertCell(-1); + td.colSpan = 2 ; + td.innerHTML = txt + " - " + url + tr.insertCell(-1).colSpan = 3 ; + x++ ; + } + + for( i = 1; i < data.length; i++ ) { - var tbl = document.getElementById('ddns_status_table'); - // security check - if ( !(tbl) ) { return; } - - // clear all rows - while (tbl.rows.length > 1) - tbl.deleteRow(1); - - // variable for Modulo-Division use to set cbi-rowstyle-? (0 or 1) - var x = -1; - var i = 1; - - // no data => no ddns-scripts Version 2 installed - if ( !data ) { - var txt = '<br /><strong><font color="red"><%:Old version of ddns-scripts installed%></font>' ; - var url = '<a href="' ; - url += '<%=luci.dispatcher.build_url("admin", "system", "packages")%>' ; - url += '"><%:install update here%></a></strong>' ; - var tr = tbl.insertRow(-1); - tr.className = 'cbi-section-table-row cbi-rowstyle-' + (((i + x) % 2) + 1); - var td = tr.insertCell(-1); - td.colSpan = 2 ; - td.innerHTML = txt + " - " + url - tr.insertCell(-1).colSpan = 3 ; - return; + var tr = tbl.insertRow(-1); + tr.className = 'cbi-section-table-row cbi-rowstyle-' + (((i + x) % 2) + 1) ; + + // configuration + tr.insertCell(-1).innerHTML = '<strong>' + data[i].section + '</strong>' ; + + // pid + // data[i].pid ignored here + + // last update + // data[i].datelast ignored here + + // next update + switch (data[i].datenext) { + case "_empty_": + tr.insertCell(-1).innerHTML = '<em><%:Unknown error%></em>' ; + break; + case "_stopped_": + tr.insertCell(-1).innerHTML = '<em><%:Stopped%></em>' ; + break; + case "_disabled_": + tr.insertCell(-1).innerHTML = '<em><%:Disabled%></em>' ; + break; + case "_noupdate_": + tr.insertCell(-1).innerHTML = '<em><%:Update error%></em>' ; + break; + case "_runonce_": + tr.insertCell(-1).innerHTML = '<em><%:Run once%></em>' ; + break; + case "_verify_": + tr.insertCell(-1).innerHTML = '<em><%:Verify%></em>'; + break; + default: + tr.insertCell(-1).innerHTML = data[i].datenext ; + break; } - // DDNS Service disabled - if (data[0].enabled == 0) { - var txt = '<strong><font color="red"><%:DDNS Autostart disabled%></font>' ; - var url = '<a href="' + data[0].url_up + '"><%:enable here%></a></strong>' ; - var tr = tbl.insertRow(-1); - tr.className = 'cbi-section-table-row cbi-rowstyle-' + (((i + x) % 2) + 1); - var td = tr.insertCell(-1); - td.colSpan = 2 ; - td.innerHTML = txt + " - " + url - tr.insertCell(-1).colSpan = 3 ; - x++ ; - } + // domain + if (data[i].domain == "_nodomain_") + tr.insertCell(-1).innerHTML = '<em><%:config error%></em>'; + else + tr.insertCell(-1).innerHTML = data[i].domain; - for( i = 1; i < data.length; i++ ) - { - var tr = tbl.insertRow(-1); - tr.className = 'cbi-section-table-row cbi-rowstyle-' + (((i + x) % 2) + 1) ; - - // configuration - tr.insertCell(-1).innerHTML = '<strong>' + data[i].section + '</strong>' ; - - // pid - // data[i].pid ignored here - - // last update - // data[i].datelast ignored here - - // next update - switch (data[i].datenext) { - case "_empty_": - tr.insertCell(-1).innerHTML = '<em><%:Unknown error%></em>' ; - break; - case "_stopped_": - tr.insertCell(-1).innerHTML = '<em><%:Stopped%></em>' ; - break; - case "_disabled_": - tr.insertCell(-1).innerHTML = '<em><%:Disabled%></em>' ; - break; - case "_noupdate_": - tr.insertCell(-1).innerHTML = '<em><%:Update error%></em>' ; - break; - case "_runonce_": - tr.insertCell(-1).innerHTML = '<em><%:Run once%></em>' ; - break; - case "_verify_": - tr.insertCell(-1).innerHTML = '<em><%:Verify%></em>'; - break; - default: - tr.insertCell(-1).innerHTML = data[i].datenext ; - break; - } - - // domain - if (data[i].domain == "_nodomain_") - tr.insertCell(-1).innerHTML = '<em><%:config error%></em>'; - else - tr.insertCell(-1).innerHTML = data[i].domain; - - // registered IP - switch (data[i].reg_ip) { - case "_nodomain_": - tr.insertCell(-1).innerHTML = '<em><%:Config error%></em>'; - break; - case "_nodata_": - tr.insertCell(-1).innerHTML = '<em><%:No data%></em>'; - break; - case "_noipv6_": - tr.insertCell(-1).innerHTML = '<em><%:IPv6 not supported%></em>'; - break; - default: - tr.insertCell(-1).innerHTML = data[i].reg_ip; - break; - } - - // monitored interfacce - if (data[i].iface == "_nonet_") + // registered IP + switch (data[i].reg_ip) { + case "_nodomain_": tr.insertCell(-1).innerHTML = '<em><%:Config error%></em>'; - else - tr.insertCell(-1).innerHTML = data[i].iface; + break; + case "_nodata_": + tr.insertCell(-1).innerHTML = '<em><%:No data%></em>'; + break; + case "_noipv6_": + tr.insertCell(-1).innerHTML = '<em><%:IPv6 not supported%></em>'; + break; + default: + tr.insertCell(-1).innerHTML = data[i].reg_ip; + break; } - if (tbl.rows.length == 1 || (data[0].enabled == 0 && tbl.rows.length == 2) ) { - var br = '<br />'; - if (tbl.rows.length > 1) - br = ''; - var tr = tbl.insertRow(-1); - tr.className = "cbi-section-table-row"; - var td = tr.insertCell(-1); - td.colSpan = 5; - td.innerHTML = '<em>' + br + '<%:There is no service configured.%></em>' ; - } + // monitored interfacce + if (data[i].iface == "_nonet_") + tr.insertCell(-1).innerHTML = '<em><%:Config error%></em>'; + else + tr.insertCell(-1).innerHTML = data[i].iface; + } + + if (tbl.rows.length == 1 || (data[0].enabled == 0 && tbl.rows.length == 2) ) { + var br = '<br />'; + if (tbl.rows.length > 1) + br = ''; + var tr = tbl.insertRow(-1); + tr.className = "cbi-section-table-row"; + var td = tr.insertCell(-1); + td.colSpan = 5; + td.innerHTML = '<em>' + br + '<%:There is no service configured.%></em>' ; + } + } + + // force to immediate show status (not waiting for XHR.poll) + XHR.get('<%=luci.dispatcher.build_url("admin", "services", "ddns", "status")%>', null, + function(x, data) { + _data2elements(x, data); + } + ); + + XHR.poll(10, '<%=luci.dispatcher.build_url("admin", "services", "ddns", "status")%>', null, + function(x, data) { + _data2elements(x, data); } ); //]]></script> |