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