system_status.htm 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. <!-- ++ BEGIN ++ Dynamic DNS ++ system_status.htm ++ -->
  2. <script type="text/javascript">//<![CDATA[
  3. // helper to move status data to the relevant
  4. // screen objects
  5. // called by XHR.poll and XHR.get
  6. function _data2elements(x, data) {
  7. var tbl = document.getElementById('ddns_status_table');
  8. // security check
  9. if ( !(tbl) ) { return; }
  10. // clear all rows
  11. while (tbl.rows.length > 1)
  12. tbl.deleteRow(1);
  13. // variable for Modulo-Division use to set cbi-rowstyle-? (0 or 1)
  14. var i = -1;
  15. var j = 1;
  16. // DDNS Service disabled
  17. if (data[0].enabled == 0) {
  18. var txt = '<strong><font color="red"><%:DDNS Autostart disabled%></font>' ;
  19. var url = '<a href="' + data[0].url_up + '"><%:enable here%></a></strong>' ;
  20. var tr = tbl.insertRow(-1);
  21. tr.className = 'cbi-section-table-row cbi-rowstyle-' + (((j + i) % 2) + 1);
  22. var td = tr.insertCell(-1);
  23. td.colSpan = 2 ;
  24. td.innerHTML = txt + " - " + url
  25. tr.insertCell(-1).colSpan = 3 ;
  26. i++ ;
  27. }
  28. for( j = 1; j < data.length; j++ )
  29. {
  30. var tr = tbl.insertRow(-1);
  31. tr.className = 'cbi-section-table-row cbi-rowstyle-' + (((j + i) % 2) + 1) ;
  32. // configuration
  33. tr.insertCell(-1).innerHTML = '<strong>' + data[j].section + '</strong>' ;
  34. // pid
  35. // data[j].pid ignored here
  36. // last update
  37. // data[j].datelast ignored here
  38. // next update
  39. switch (data[j].datenext) {
  40. case "_empty_":
  41. tr.insertCell(-1).innerHTML = '<em><%:Unknown error%></em>' ;
  42. break;
  43. case "_stopped_":
  44. tr.insertCell(-1).innerHTML = '<em><%:Stopped%></em>' ;
  45. break;
  46. case "_disabled_":
  47. tr.insertCell(-1).innerHTML = '<em><%:Disabled%></em>' ;
  48. break;
  49. case "_noupdate_":
  50. tr.insertCell(-1).innerHTML = '<em><%:Update error%></em>' ;
  51. break;
  52. case "_runonce_":
  53. tr.insertCell(-1).innerHTML = '<em><%:Run once%></em>' ;
  54. break;
  55. case "_verify_":
  56. tr.insertCell(-1).innerHTML = '<em><%:Verify%></em>';
  57. break;
  58. default:
  59. tr.insertCell(-1).innerHTML = data[j].datenext ;
  60. break;
  61. }
  62. // domain
  63. if (data[j].domain == "_nodomain_")
  64. tr.insertCell(-1).innerHTML = '<em><%:config error%></em>';
  65. else
  66. tr.insertCell(-1).innerHTML = data[j].domain;
  67. // registered IP
  68. switch (data[j].reg_ip) {
  69. case "_nodomain_":
  70. tr.insertCell(-1).innerHTML = '<em><%:Config error%></em>';
  71. break;
  72. case "_nodata_":
  73. tr.insertCell(-1).innerHTML = '<em><%:No data%></em>';
  74. break;
  75. case "_noipv6_":
  76. tr.insertCell(-1).innerHTML = '<em><%:IPv6 not supported%></em>';
  77. break;
  78. default:
  79. tr.insertCell(-1).innerHTML = data[j].reg_ip;
  80. break;
  81. }
  82. // monitored interface
  83. if (data[j].iface == "_nonet_")
  84. tr.insertCell(-1).innerHTML = '<em><%:Config error%></em>';
  85. else
  86. tr.insertCell(-1).innerHTML = data[j].iface;
  87. }
  88. if (tbl.rows.length == 1 || (data[0].enabled == 0 && tbl.rows.length == 2) ) {
  89. var br = '<br />';
  90. if (tbl.rows.length > 1)
  91. br = '';
  92. var tr = tbl.insertRow(-1);
  93. tr.className = "cbi-section-table-row";
  94. var td = tr.insertCell(-1);
  95. td.colSpan = 5;
  96. td.innerHTML = '<em>' + br + '<%:There is no service configured.%></em>' ;
  97. }
  98. }
  99. // force to immediate show status (not waiting for XHR.poll)
  100. XHR.get('<%=luci.dispatcher.build_url("admin", "services", "ddns", "status")%>', null,
  101. function(x, data) {
  102. if (data) { _data2elements(x, data); }
  103. }
  104. );
  105. XHR.poll(5, '<%=luci.dispatcher.build_url("admin", "services", "ddns", "status")%>', null,
  106. function(x, data) {
  107. if (data) { _data2elements(x, data); }
  108. }
  109. );
  110. //]]></script>
  111. <fieldset class="cbi-section" id="ddns_status_section">
  112. <legend><a href="<%=luci.dispatcher.build_url([[admin]], [[services]], [[ddns]])%>"><%:Dynamic DNS%></a></legend>
  113. <table class="cbi-section-table" id="ddns_status_table">
  114. <tr class="cbi-section-table-titles">
  115. <th class="cbi-section-table-cell"><%:Configuration%></th>
  116. <th class="cbi-section-table-cell"><%:Next Update%></th>
  117. <th class="cbi-section-table-cell"><%:Hostname/Domain%></th>
  118. <th class="cbi-section-table-cell"><%:Registered IP%></th>
  119. <th class="cbi-section-table-cell"><%:Network%></th>
  120. </tr>
  121. <tr class="cbi-section-table-row">
  122. <td colspan="5"><em><br /><%:Collecting data...%></em></td>
  123. </tr>
  124. </table>
  125. </fieldset>
  126. <!-- ++ END ++ Dynamic DNS ++ system_status.htm ++ -->