modules/admin-full: fix some small style quirks
[project/luci.git] / modules / admin-full / luasrc / view / admin_network / iface_overview.htm
index 132a5dd..b89d613 100644 (file)
@@ -8,7 +8,7 @@ You may obtain a copy of the License at
 
        http://www.apache.org/licenses/LICENSE-2.0
 
-$Id: wifi_overview.htm 6280 2010-10-12 05:06:34Z jow $
+$Id$
 
 -%>
 
@@ -24,10 +24,8 @@ $Id: wifi_overview.htm 6280 2010-10-12 05:06:34Z jow $
        end
 -%>
 
-<%+header%>
-
 <script type="text/javascript" src="<%=resource%>/cbi.js"></script>
-<script type="text/javascript"><![CDATA[
+<script type="text/javascript">//<![CDATA[
        function iface_shutdown(id, reconnect) {
                if (!reconnect && !confirm(String.format('<%_Really shutdown interface "%s" ?\nYou might loose access to this router if you are connected via this interface.%>', id)))
                        return;
@@ -68,7 +66,7 @@ $Id: wifi_overview.htm 6280 2010-10-12 05:06:34Z jow $
        var wifidevs = <%=luci.http.write_json(netdevs)%>;
        var arptable = <%=luci.http.write_json(arpcache)%>;
 
-       (function() {
+       var update_status = function() {
                iwxhr.get('<%=luci.dispatcher.build_url("admin", "network", "iface_status", table.concat(netlist, ","))%>', null,
                        function(x, ifcs)
                        {
@@ -78,17 +76,25 @@ $Id: wifi_overview.htm 6280 2010-10-12 05:06:34Z jow $
                                        {
                                                var ifc = ifcs[i];
                                                var is_up = (ifc.flags && ifc.flags.up);
-                                               var rxb = ifc.stats ? (ifc.stats["rx_bytes"] / 1024) : 0;
-                                               var txb = ifc.stats ? (ifc.stats["tx_bytes"] / 1024) : 0;
+                                               var rxb = ifc.stats ? ifc.stats["rx_bytes"] : 0;
+                                               var txb = ifc.stats ? ifc.stats["tx_bytes"] : 0;
                                                var rxp = ifc.stats ? ifc.stats["rx_packets"] : 0;
                                                var txp = ifc.stats ? ifc.stats["tx_packets"] : 0;
                                                var mac = ifc.macaddr ? ifc.macaddr : '00:00:00:00:00:00';
+                                               var upt = '-';
 
                                                var icon;
                                                if (is_up)
+                                               {
+                                                       if (ifc.uptime)
+                                                               upt = String.format('%t', ifc.uptime);
+
                                                        icon = "<%=resource%>/icons/ethernet.png";
+                                               }
                                                else
+                                               {
                                                        icon = "<%=resource%>/icons/ethernet_disabled.png";
+                                               }
 
                                                var s = document.getElementById(ifc.id + '-ifc-signal');
                                                if (s)
@@ -100,6 +106,12 @@ $Id: wifi_overview.htm 6280 2010-10-12 05:06:34Z jow $
                                                        );
                                                }
 
+                                               var u = document.getElementById(ifc.id + '-ifc-uptime');
+                                               if (u)
+                                               {
+                                                       u.innerHTML = upt;
+                                               }
+
                                                var m = document.getElementById(ifc.id + '-ifc-mac');
                                                if (m)
                                                {
@@ -156,21 +168,21 @@ $Id: wifi_overview.htm 6280 2010-10-12 05:06:34Z jow $
                                                if (t)
                                                {
                                                        t.innerHTML = String.format(
-                                                               '<strong><%:RX%></strong>: %.2f <%:KB%> (%d <%:Pkts.%>)<br />' +
-                                                               '<strong><%:TX%></strong>: %.2f <%:KB%> (%d <%:Pkts.%>)<br />',
-                                                                       txb, txp, rxb, rxp
+                                                               '<strong><%:RX%></strong>: %1024.2mB (%d <%:Pkts.%>)<br />' +
+                                                               '<strong><%:TX%></strong>: %1024.2mB (%d <%:Pkts.%>)<br />',
+                                                                       rxb, rxp, txb, txp
                                                        );
                                                }
                                        }
                                }
+
+                               window.setTimeout(update_status, 5000);
                        }
                )
+       };
 
-               window.setTimeout(arguments.callee, 5000);
-       })();
-]]></script>
-
-<h2><a id="content" name="content"><%:Interface Overview%></a></h2>
+       update_status();
+//]]></script>
 
 <fieldset class="cbi-section" style="display:none">
        <legend><%:Reconnecting interface%></legend>
@@ -180,10 +192,13 @@ $Id: wifi_overview.htm 6280 2010-10-12 05:06:34Z jow $
 
 <div class="cbi-map">
        <fieldset class="cbi-section">
+               <legend><%:Interface Overview%></legend>
+
                <table class="cbi-section-table" style="margin:10px; empty-cells:hide">
                        <tr class="cbi-section-table-titles">
-                               <th class="cbi-section-table-cell">&nbsp;</th>
+                               <th class="cbi-section-table-cell">&#160;</th>
                                <th class="cbi-section-table-cell"><%:Interface%></th>
+                               <th class="cbi-section-table-cell"><%:Uptime%></th>
                                <th class="cbi-section-table-cell"><%:MAC%></th>
                                <th class="cbi-section-table-cell" style="text-align:left"><%:Addresses%></th>
                                <th class="cbi-section-table-cell" style="text-align:left"><%:Transfer%></th>
@@ -194,10 +209,11 @@ $Id: wifi_overview.htm 6280 2010-10-12 05:06:34Z jow $
                                        <td>
                                                <span style="background-color:#FFFFFF; border:1px solid #CCCCCC; padding:2px"><%=net%></span>
                                        </td>
-                                       <td class="cbi-value-field" style="width:16px; padding:3px; text-align:center" id="<%=net%>-ifc-signal">
+                                       <td class="cbi-value-field" style="min-width:16px; padding:3px; text-align:center" id="<%=net%>-ifc-signal">
                                                <img src="<%=resource%>/icons/ethernet_disabled.png" style="width:16px; height:16px" /><br />
                                                <small>?</small>
                                        </td>
+                                       <td class="cbi-value-field" id="<%=net%>-ifc-uptime">?</td>
                                        <td class="cbi-value-field" id="<%=net%>-ifc-mac">?</td>
                                        <td class="cbi-value-field" style="text-align:left; padding:3px" id="<%=net%>-ifc-addrs"><em><%:Collecting data...%></em></td>
                                        <td class="cbi-value-field" style="text-align:left; padding:3px" id="<%=net%>-ifc-transfer">
@@ -215,12 +231,7 @@ $Id: wifi_overview.htm 6280 2010-10-12 05:06:34Z jow $
                                </tr>
                        <% end %>
                </table>
-       </fieldset>
 
-       <form action="<%=luci.dispatcher.build_url("admin/network/iface_add")%>" method="post">
-               <br />
-               <input type="submit" class="cbi-button cbi-button-apply" value="<%:Add new interface...%>" />
-       </form>
+               <input type="button" class="cbi-button cbi-button-add" value="<%:Add new interface...%>" onclick="location.href='<%=luci.dispatcher.build_url("admin/network/iface_add")%>'" />
+       </fieldset>
 </div>
-
-<%+footer%>