modules/admin-full: add uptime to iface status templates
authorJo-Philipp Wich <jow@openwrt.org>
Wed, 1 Dec 2010 21:17:39 +0000 (21:17 +0000)
committerJo-Philipp Wich <jow@openwrt.org>
Wed, 1 Dec 2010 21:17:39 +0000 (21:17 +0000)
modules/admin-full/luasrc/view/admin_network/iface_overview.htm
modules/admin-full/luasrc/view/admin_network/iface_status.htm

index 957d91749dca5732ff1586f7e218b40479860a5c..f914c404ecfbfe605847da333d594894326d92ca 100644 (file)
@@ -81,12 +81,20 @@ $Id$
                                                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)
@@ -98,6 +106,12 @@ $Id$
                                                        );
                                                }
 
+                                               var u = document.getElementById(ifc.id + '-ifc-uptime');
+                                               if (u)
+                                               {
+                                                       u.innerHTML = upt;
+                                               }
+
                                                var m = document.getElementById(ifc.id + '-ifc-mac');
                                                if (m)
                                                {
@@ -184,6 +198,7 @@ $Id$
                        <tr class="cbi-section-table-titles">
                                <th class="cbi-section-table-cell">&nbsp;</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>
@@ -198,6 +213,7 @@ $Id$
                                                <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">
index 7c0376965713b271c98648607f2398468028c2f8..ed5002bc6ce783b7aefa772720f0080472058d33 100644 (file)
                                        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('<%=self.option%>-ifc-signal');
                                        if (s)
                                        if (d && ifc.ifname)
                                        {
                                                d.innerHTML = String.format(
+                                                       '<strong><%:Uptime%>:</strong> %s<br />' +
                                                        '<strong><%:MAC Address%>:</strong> %s<br />' +
                                                        '<strong><%:RX%></strong>: %.2f <%:KB%> (%d <%:Pkts.%>)<br />' +
                                                        '<strong><%:TX%></strong>: %.2f <%:KB%> (%d <%:Pkts.%>)<br />',
-                                                               mac, rxb, rxp, txb, txp
+                                                               upt, mac, rxb, rxp, txb, txp
                                                );
 
                                                if (ifc.ipaddrs && ifc.ipaddrs.length)