applications/luci-upnp: enable/disable service, live status, allow removing single...
[project/luci.git] / applications / luci-upnp / luasrc / view / upnp_status.htm
1 <script type="text/javascript"><![CDATA[
2
3
4         function upnp_delete_fwd(idx) {
5                 var dlxhr = new XHR();
6
7                 dlxhr.get('<%=luci.dispatcher.build_url("admin", "services", "upnp", "delete")%>/' + idx, null,
8                         function(x)
9                         {
10                                 var tb = document.getElementById('upnp_status_table');
11                                 if (tb && (idx < tb.rows.length))
12                                         tb.rows[0].parentNode.removeChild(tb.rows[idx]);
13                         }
14                 );
15         }
16
17         var stxhr = new XHR();
18         (function() {
19                 stxhr.get('<%=luci.dispatcher.build_url("admin", "services", "upnp", "status")%>', null,
20                         function(x)
21                         {
22                                 var st = x.responseText ? eval('(' + x.responseText + ')') : null;
23                                 var tb = document.getElementById('upnp_status_table');
24
25                                 if (st && tb)
26                                 {
27                                         /* clear all rows */
28                                         while( tb.rows.length > 1 )
29                                                 tb.rows[1].parentNode.removeChild(tb.rows[1]);
30
31                                         for( var i = 0; i < st.length; i++ )
32                                         {
33                                                 var tr = document.createElement('tr');
34                                                         tr.className = 'cbi-section-table-row cbi-rowstyle-' + ((i % 2) + 1);
35
36                                                 tr.innerHTML = String.format(
37                                                         '<td class="cbi-section-table-cell">%s</td>' +
38                                                         '<td class="cbi-section-table-cell">%d</td>' +
39                                                         '<td class="cbi-section-table-cell">%s</td>' +
40                                                         '<td class="cbi-section-table-cell">%d</td>' +
41                                                         '<td class="cbi-section-table-cell">' +
42                                                                 '<input class="cbi-input-remove" type="button" value="<%:Delete Redirect%>" onclick="upnp_delete_fwd(%d)" />' +
43                                                         '</td>',
44                                                                 st[i].proto,
45                                                                 st[i].extport,
46                                                                 st[i].intaddr,
47                                                                 st[i].intport,
48                                                                 st[i].num
49                                                 );
50
51                                                 tb.rows[0].parentNode.appendChild(tr);
52                                         }
53
54                                         if( tb.rows.length == 1 )
55                                         {
56                                                 var tr = document.createElement('tr');
57                                                         tr.className = 'cbi-section-table-row';
58                                                         tr.innerHTML = '<td colspan="5"><em><br /><%:There are no active redirects.%></em></td>';
59
60                                                 tb.rows[0].parentNode.appendChild(tr);
61                                         }
62                                 }
63                         }
64                 )
65
66                 window.setTimeout(arguments.callee, 5000);
67         })();
68 ]]></script>
69
70 <fieldset class="cbi-section">
71         <legend><%:Active UPnP Redirects%></legend>
72         <table class="cbi-section-table" id="upnp_status_table">
73                 <tr class="cbi-section-table-titles">
74                         <th class="cbi-section-table-cell"><%:Protocol%></th>
75                         <th class="cbi-section-table-cell"><%:External Port%></th>
76                         <th class="cbi-section-table-cell"><%:Client Address%></th>
77                         <th class="cbi-section-table-cell"><%:Client Port%></th>
78                         <th class="cbi-section-table-cell">&nbsp;</th>
79                 </tr>
80                 <tr class="cbi-section-table-row">
81                         <td colspan="5"><em><br /><%:Collecting data...%></em></td>
82                 </tr>
83         </table>
84 </fieldset>