treewide: always include cbi.js
[project/luci.git] / modules / luci-mod-freifunk / luasrc / view / freifunk / public_status.htm
index 72bd136c5eab52172130e91bd45a70f32a93b753..572f8585d17d878dc8353a4655ac3b2e82d42f30 100644 (file)
@@ -23,12 +23,12 @@ local load = string.format("%.2f, %.2f, %.2f", loads[1] / 65535.0, loads[2] / 65
 
 local mem = string.format(
        "%.2f MB (%.2f %s, %.2f %s, %.2f %s)",
-       memory.total / 1024 / 1024,
-       (memory.total - memory.free) / 1024 / 1024,
+       meminfo.total / 1024 / 1024,
+       (meminfo.total - meminfo.free) / 1024 / 1024,
        tostring(i18n.translate("used")),
-       memory.free / 1024 / 1024,
+       meminfo.free / 1024 / 1024,
        tostring(i18n.translate("free")),
-       memory.buffered / 1024 / 1024,
+       meminfo.buffered / 1024 / 1024,
        tostring(i18n.translate("buffered"))
 )
 
@@ -49,6 +49,32 @@ for _, dev in ipairs(devices) do
 end
 local has_iwinfo = pcall(require, "iwinfo")
 
+
+-- Find default routes
+
+local _, r, def4, def6
+
+for _, r in ipairs(ip.routes({ type = 1, dest_exact = "0.0.0.0/0" })) do
+       def4 = {
+               gateway = r.gw:string(),
+               dest = r.dest:string(),
+               dev = r.dev,
+               metr = r.metric or 0
+       }
+       break
+end
+
+for _, r in ipairs(ip.routes({ type = 1, dest_exact = "::/0" })) do
+       def6 = {
+               gateway = r.gw:string(),
+               dest = r.dest:string(),
+               dev = r.dev,
+               metr = r.metric or 0
+       }
+       break
+end
+
+
 if luci.http.formvalue("status") == "1" then
        local rv = { }
        for dev in pairs(netdevs) do
@@ -67,30 +93,6 @@ if luci.http.formvalue("status") == "1" then
        end
 
 
-       -- Find default routes
-
-       local _, r, def4, def6
-
-       for _, r in ipairs(ip.routes({ type = 1, dest_exact = "0.0.0.0/0" })) do
-               def4 = {
-                       gateway = r.gw:string(),
-                       dest = r.dest:string(),
-                       dev = r.dev,
-                       metr = r.metric or 0
-               }
-               break
-       end
-
-       for _, r in ipairs(ip.routes({ type = 1, dest_exact = "::/0" })) do
-               def6 = {
-                       gateway = r.gw:string(),
-                       dest = r.dest:string(),
-                       dev = r.dev,
-                       metr = r.metric or 0
-               }
-               break
-       end
-
        rv[#rv+1] = {
                time = time,
                uptime = uptime,
@@ -108,7 +110,6 @@ end
 
 <%+header%>
 
-<script type="text/javascript" src="<%=resource%>/cbi.js"></script>
 
 <script type="text/javascript">//<![CDATA[
         XHR.poll(<%=interval%> , '<%=REQUEST_URI%>', { status: 1 },
@@ -236,25 +237,25 @@ end
        <h2><%:Wireless Overview%></h2>
 
                <% if not has_iwinfo then %>
-                       <div class="errorbox">
-                               <strong><%:Package libiwinfo required!%></strong><br />
-                               <%_The <em>libiwinfo</em> package is not installed. You must install this component for working wireless configuration!%>
+                       <div class="alert-message warning">
+                               <h4><%:Package libiwinfo required!%></h4>
+                               <p><%_The <em>libiwinfo</em> package is not installed. You must install this component for working wireless configuration!%></p>
                        </div>
                <% end %>
 
                <div class="cbi-section">
                        <div class="cbi-section-node">
-                               <table class="cbi-section-table">
-                                       <tr class="cbi-section-table-titles">
-                                               <th class="cbi-section-table-cell"><%:Signal%></th>
-                                               <th class="cbi-section-table-cell"><%:Bitrate%></th>
-                                               <th class="cbi-section-table-cell"><%:SSID%></th>
-                                               <th class="cbi-section-table-cell"><%:BSSID%></th>
-                                               <th class="cbi-section-table-cell"><%:Channel%></th>
-                                               <th class="cbi-section-table-cell"><%:Mode%></th>
-                                               <th class="cbi-section-table-cell"><%:TX%>-<%:Power%></th>
-                                               <th class="cbi-section-table-cell"><%:Interface%></th>
-                                       </tr>
+                               <div class="table cbi-section-table">
+                                       <div class="tr cbi-section-table-titles">
+                                               <div class="th cbi-section-table-cell"><%:Signal%></div>
+                                               <div class="th cbi-section-table-cell"><%:Bitrate%></div>
+                                               <div class="th cbi-section-table-cell"><%:SSID%></div>
+                                               <div class="th cbi-section-table-cell"><%:BSSID%></div>
+                                               <div class="th cbi-section-table-cell"><%:Channel%></div>
+                                               <div class="th cbi-section-table-cell"><%:Mode%></div>
+                                               <div class="th cbi-section-table-cell"><%:TX%>-<%:Power%></div>
+                                               <div class="th cbi-section-table-cell"><%:Interface%></div>
+                                       </div>
        <%
        for _, dev in ipairs(devices) do
        local net
@@ -262,7 +263,7 @@ end
                        netlist[#netlist+1] = net:ifname()
                        netdevs[net:ifname()] = dev:name()
 
-                       if net.iwdata.device then
+                       if net.iwinfo.signal and net.iwinfo.bssid then
                                local signal = net.iwinfo.signal or "N/A"
                                local noise = net.iwinfo.noise or "N/A"
                                local q = net.iwinfo.quality or "0"
@@ -297,22 +298,22 @@ end
                                if bitrate ~= "N/A" then
                                        bitrate = ( bitrate / 1000 ).."Mb/s"
                                end
-                               local interface = net.iwdata.ifname or "N/A"
+                               local interface = net.iwinfo.ifname or "N/A"
        %>
-                                               <tr class="cbi-section-table-row cbi-rowstyle-1">
-                                               <td class="cbi-value-field" id="<%=net:ifname()%>-signal"><%=signal_string%></td>
-                                               <td class="cbi-value-field" id="<%=net:ifname()%>-bitrate"><%=bitrate%></td>
-                                               <td class="cbi-value-field" id="<%=net:ifname()%>-ssid"><%=ssid%></td>
-                                               <td class="cbi-value-field" id="<%=net:ifname()%>-bssid"><%=bssid%></td>
-                                               <td class="cbi-value-field" id="<%=net:ifname()%>-channel"><%=chan%></td>
-                                               <td class="cbi-value-field" id="<%=net:ifname()%>-mode"><%=mode%></td>
-                                               <td class="cbi-value-field" id="<%=net:ifname()%>-txpower"><%=txpwr%></td>
-                                               <td class="cbi-value-field"><%=interface%></td>
-                                       </tr>
+                                               <div class="tr cbi-section-table-row cbi-rowstyle-1">
+                                               <div class="td cbi-value-field" id="<%=net:ifname()%>-signal"><%=signal_string%></div>
+                                               <div class="td cbi-value-field" id="<%=net:ifname()%>-bitrate"><%=bitrate%></div>
+                                               <div class="td cbi-value-field" id="<%=net:ifname()%>-ssid"><%=ssid%></div>
+                                               <div class="td cbi-value-field" id="<%=net:ifname()%>-bssid"><%=bssid%></div>
+                                               <div class="td cbi-value-field" id="<%=net:ifname()%>-channel"><%=chan%></div>
+                                               <div class="td cbi-value-field" id="<%=net:ifname()%>-mode"><%=mode%></div>
+                                               <div class="td cbi-value-field" id="<%=net:ifname()%>-txpower"><%=txpwr%></div>
+                                               <div class="td cbi-value-field"><%=interface%></div>
+                                       </div>
                        <% end
                end
        end %>
-                       </table>
+                       </div>
                </div>
        </div>
 </div>
@@ -323,39 +324,38 @@ end
                <div class="cbi-section">
                        <div class="cbi-section-node">
 
-<% if not defroutev4 and not defroutev6 then %>
+<% if not def4 and not def6 then %>
        <%:No default routes known.%>
 <%else%>
-                               <table class="cbi-section-table">
-                                               <tr class="cbi-section-table-titles">
-                                                       <th class="cbi-section-table-cell"><%:Network%></th>
-                                                       <th class="cbi-section-table-cell"><%:Interface%></th>
-                                                       <th class="cbi-section-table-cell"><%:Gateway%></th>
-                                                       <th class="cbi-section-table-cell"><%:Metric%></th>
-                                               </tr>
-
-       <% if defroutev4 then %>
-
-                                               <tr class="cbi-section-table-row cbi-rowstyle-1">
-                                                       <td class="cbi-value-field" id="v4dst"><%=defroutev4.dest%></td>
-                                                       <td class="cbi-value-field" id="v4dev"><%=defroutev4.device%></td>
-                                                       <td class="cbi-value-field" id="v4gw"><%=defroutev4.gateway%></td>
-                                                       <td class="cbi-value-field" id="v4metr"><%=defroutev4.metric%></td>
-                                               </tr>
+                               <div class="table cbi-section-table">
+                                               <div class="tr cbi-section-table-titles">
+                                                       <div class="th cbi-section-table-cell"><%:Network%></div>
+                                                       <div class="th cbi-section-table-cell"><%:Interface%></div>
+                                                       <div class="th cbi-section-table-cell"><%:Gateway%></div>
+                                                       <div class="th cbi-section-table-cell"><%:Metric%></div>
+                                               </div>
+
+       <% if def4 then %>
+                                               <div class="tr cbi-section-table-row cbi-rowstyle-1">
+                                                       <div class="td cbi-value-field" id="v4dst"><%=def4.dest%></div>
+                                                       <div class="td cbi-value-field" id="v4dev"><%=def4.dev%></div>
+                                                       <div class="td cbi-value-field" id="v4gw"><%=def4.gateway%></div>
+                                                       <div class="td cbi-value-field" id="v4metr"><%=def4.metr%></div>
+                                               </div>
 
        <% end
-       if defroutev6 then %>
+       if def6 then %>
 
-                                               <tr class="cbi-section-table-row cbi-rowstyle-2">
-                                                       <td class="cbi-value-field" id="v6dst"><%=defroutev6.dest%></td>
-                                                       <td class="cbi-value-field" id="v6dev"><%=defroutev6.device%></td>
-                                                       <td class="cbi-value-field" id="v6gw"><%=defroutev6.nexthop%></td>
-                                                       <td class="cbi-value-field" id="v6metr"><%=defroutev6.metric%></td>
-                                               </tr>
+                                               <div class="tr cbi-section-table-row cbi-rowstyle-2">
+                                                       <div class="td cbi-value-field" id="v6dst"><%=def6.dest%></div>
+                                                       <div class="td cbi-value-field" id="v6dev"><%=def6.dev%></div>
+                                                       <div class="td cbi-value-field" id="v6gw"><%=def6.gateway%></div>
+                                                       <div class="td cbi-value-field" id="v6metr"><%=def6.metr%></div>
+                                               </div>
 
        <% end %>
 
-                               </table>
+                               </div>
 <% end %>
                </div>
        </div>