modules/admin-full: cope with undefined scan list in wifi_join
[project/luci.git] / modules / admin-full / luasrc / view / admin_network / wifi_join.htm
index a1959a4ee211227d3c6699544688a63dcb209376..f3b6dddefc9181b8b212862a312fb2add5ab086c 100644 (file)
@@ -50,18 +50,20 @@ $Id$
        end
 
        function format_wifi_encryption(info)
-               if info.wep == true and not info.wpa_version then
+               if info.wep == true then
                        return "WEP"
-               elseif info.wpa then
-                       return "<abbr title='Pairwise: %s / Group: %s'>%s - %s</abbr>" % {
+               elseif info.wpa > 0 then
+                       return translatef("<abbr title='Pairwise: %s / Group: %s'>%s - %s</abbr>",
                                table.concat(info.pair_ciphers, ", "),
                                table.concat(info.group_ciphers, ", "),
-                               (info.wpa == 3) and "mixed WPA/WPA2"
+                               (info.wpa == 3) and translate("mixed WPA/WPA2")
                                        or (info.wpa == 2 and "WPA2" or "WPA"),
                                table.concat(info.auth_suites, ", ")
-                       }
+                       )
+               elseif info.enabled then
+                       return "<em>%s</em>" % translate("unknown")
                else
-                       return "<em>None</em>"
+                       return "<em>%s</em>" % translate("open")
                end
        end
 
@@ -72,6 +74,24 @@ $Id$
                luci.http.redirect(luci.dispatcher.build_url("admin/network/wireless"))
                return
        end
+
+
+       function scanlist(times)
+               local i, k, v
+               local l = { }
+               local s = { }
+
+               for i = 1, times do
+                       for k, v in ipairs(iw.scanlist or { }) do
+                               if not s[v.bssid] then
+                                       l[#l+1] = v
+                                       s[v.bssid] = true
+                               end
+                       end
+               end
+
+               return l
+       end
 -%>
 
 <%+header%>
@@ -82,20 +102,20 @@ $Id$
        <fieldset class="cbi-section">
                <table class="cbi-section-table" style="empty-cells:hide">
                        <!-- scan list -->
-                       <% for i, net in ipairs(iw.scanlist) do net.encryption = net.encryption or { } %>
+                       <% for i, net in ipairs(scanlist(3)) do net.encryption = net.encryption or { } %>
                        <tr class="cbi-section-table-row cbi-rowstyle-<%=1 + ((i-1) % 2)%>">
                                <td class="cbi-value-field" style="width:16px; padding:3px">
-                                       <abbr title="Signal: <%=net.signal%> dB / Quality: <%=net.quality%>/<%=net.quality_max%>">
+                                       <abbr title="<%:Signal%>: <%=net.signal%> <%:dB%> / <%:Quality%>: <%=net.quality%>/<%=net.quality_max%>">
                                                <img src="<%=guess_wifi_signal(net)%>" /><br />
                                                <small><%=percent_wifi_signal(net)%>%</small>
                                        </abbr>
                                </td>
                                <td class="cbi-value-field" style="vertical-align:middle; text-align:left; padding:3px">
-                                       <big><strong><%=net.ssid and utl.pcdata(net.ssid) or "<em>hidden</em>"%></strong></big><br />
+                                       <big><strong><%=net.ssid and utl.pcdata(net.ssid) or "<em>%s</em>" % translate("hidden")%></strong></big><br />
                                        <strong>Channel:</strong> <%=net.channel%> |
                                        <strong>Mode:</strong> <%=net.mode%> |
                                        <strong>BSSID:</strong> <%=net.bssid%> |
-                                       <strong>Encryption:</strong> <%=net.encryption.description or translate("Open")%>
+                                       <strong>Encryption:</strong> <%=format_wifi_encryption(net.encryption)%>
                                </td>
                                <td class="cbi-value-field" style="width:40px">
                                        <form action="<%=REQUEST_URI%>" method="post">
@@ -114,7 +134,7 @@ $Id$
 
                                                <input type="hidden" name="clbridge" value="<%=iw.type == "wl" and 1 or 0%>" />
 
-                                               <input class="cbi-button-apply" type="submit" value="Join Network" />
+                                               <input class="cbi-button cbi-button-apply" type="submit" value="<%:Join Network%>" />
                                        </form>
                                </td>
                        </tr>
@@ -125,11 +145,11 @@ $Id$
 </div>
 <div class="cbi-page-actions right">
        <form class="inline" action="<%=luci.dispatcher.build_url("admin/network/wireless")%>" method="get">
-               <input class="cbi-button-reset" type="submit" value="<%:Back to overview%>" />
+               <input class="cbi-button cbi-button-reset" type="submit" value="<%:Back to overview%>" />
        </form>
        <form class="inline" action="<%=REQUEST_URI%>" method="get">
                <input type="hidden" name="device" value="<%=utl.pcdata(dev)%>" />
-               <input class="cbi-input-find" type="submit" value="<%:Repeat scan%>" />
+               <input class="cbi-button cbi-input-find" type="submit" value="<%:Repeat scan%>" />
        </form>
 </div>