luci-mod-network: wifi_join.js: Add WPA3 support
authorAntoine DeschĂȘnes <antdes45@gmail.com>
Sat, 24 Aug 2019 19:48:07 +0000 (15:48 -0400)
committerJo-Philipp Wich <jo@mein.io>
Tue, 10 Sep 2019 13:31:47 +0000 (15:31 +0200)
Signed-off-by: Antoine DeschĂȘnes <antoine@antoinedeschenes.com>
[squashed commits, cherry-picked into openwrt-19.07 branch]
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
modules/luci-mod-network/htdocs/luci-static/resources/view/network/wifi_join.js

index d5bd7b0a6d8fcea10c5f4beadfdc0fb350fdcdf4..e94fd467bcfbf8341f200830d984b92186b42a1c 100644 (file)
@@ -29,21 +29,39 @@ function format_signal(bss) {
 }
 
 function format_encryption(bss) {
-       var enc = bss.encryption || { }
+       var enc = bss.encryption || {};
+       var WPA = 1, WPA2 = 2, WPA3 = 4;
+       var wpa_label;
 
        if (enc.wep === true)
                return 'WEP';
-       else if (enc.wpa > 0)
+       else if (enc.wpa > 0) {
+               switch (enc.wpa) {
+                       case WPA2|WPA3:
+                               wpa_label = _('mixed WPA2/WPA3');
+                               break;
+                       case WPA3:
+                               wpa_label = _('WPA3');
+                               break;
+                       case WPA|WPA2:
+                               wpa_label = _('mixed WPA/WPA2');
+                               break;
+                       case WPA2:
+                               wpa_label = _('WPA2');
+                               break;
+                       default:
+                               wpa_label = _('WPA');
+               }
+
                return E('abbr', {
                        title: 'Pairwise: %h / Group: %h'.format(
                                enc.pair_ciphers.join(', '),
                                enc.group_ciphers.join(', '))
-                       },
-                       '%h - %h'.format(
-                               (enc.wpa === 3) ? _('mixed WPA/WPA2') : (enc.wpa === 2 ? 'WPA2' : 'WPA'),
-                               enc.auth_suites.join(', ')));
-       else
-               return E('em', enc.enabled ? _('unknown') : _('open'));
+               },
+               '%h - %h'.format(wpa_label, enc.auth_suites.join(', ')));
+       }
+
+       return E('em', enc.enabled ? _('unknown') : _('open'));
 }
 
 function format_actions(dev, type, bss) {