+ handleGetWPSStatus: function(wifinet) {
+ return rpc.declare({
+ object: 'hostapd.%s'.format(wifinet),
+ method: 'wps_status',
+ })()
+ },
+
+ handleCallWPS: function(wifinet, ev) {
+ ev.currentTarget.classList.add('spinning');
+ ev.currentTarget.disabled = true;
+ ev.currentTarget.blur();
+
+ return rpc.declare({
+ object: 'hostapd.%s'.format(wifinet),
+ method: 'wps_start',
+ })();
+ },
+
+ handleCancelWPS: function(wifinet, ev) {
+ ev.currentTarget.classList.add('spinning');
+ ev.currentTarget.disabled = true;
+ ev.currentTarget.blur();
+
+ return rpc.declare({
+ object: 'hostapd.%s'.format(wifinet),
+ method: 'wps_cancel',
+ })();
+ },
+
+ renderbox: function(radio, networks) {
+ var chan = null,
+ freq = null,
+ rate = null,
+ badges = [];
+
+ for (var i = 0; i < networks.length; i++) {
+ var net = networks[i],
+ is_assoc = (net.getBSSID() != '00:00:00:00:00:00' && net.getChannel() && !net.isDisabled()),
+ quality = net.getSignalPercent();
+
+ var icon;
+ if (net.isDisabled())
+ icon = L.resource('icons/signal-none.png');
+ else if (quality <= 0)
+ icon = L.resource('icons/signal-0.png');
+ else if (quality < 25)
+ icon = L.resource('icons/signal-0-25.png');
+ else if (quality < 50)
+ icon = L.resource('icons/signal-25-50.png');
+ else if (quality < 75)
+ icon = L.resource('icons/signal-50-75.png');
+ else
+ icon = L.resource('icons/signal-75-100.png');
+
+ var WPS_button;
+
+ if (this.isWPSEnabled[net.sid]) {
+ if (net.wps_status == 'Active') {
+ WPS_button = E('button', {
+ 'class' : 'cbi-button cbi-button-remove',
+ 'click': L.bind(this.handleCancelWPS, this, net.getIfname()),
+ }, [ _('Stop WPS') ])
+ } else {
+ WPS_button = E('button', {
+ 'class' : 'cbi-button cbi-button-apply',
+ 'click': L.bind(this.handleCallWPS, this, net.getIfname()),
+ }, [ _('Start WPS') ])
+ }
+ }
+
+ var badge = renderBadge(
+ icon,
+ '%s: %d dBm / %s: %d%%'.format(_('Signal'), net.getSignal(), _('Quality'), quality),
+ _('SSID'), net.getActiveSSID() || '?',
+ _('Mode'), net.getActiveMode(),
+ _('BSSID'), is_assoc ? (net.getActiveBSSID() || '-') : null,
+ _('Encryption'), is_assoc ? net.getActiveEncryption() : null,
+ _('Associations'), is_assoc ? (net.assoclist.length || '-') : null,
+ null, is_assoc ? null : E('em', net.isDisabled() ? _('Wireless is disabled') : _('Wireless is not associated')),
+ _('WPS status'), this.WPSTranslateTbl[net.wps_status],
+ '', WPS_button
+ );
+
+ badges.push(badge);
+
+ chan = (chan != null) ? chan : net.getChannel();
+ freq = (freq != null) ? freq : net.getFrequency();
+ rate = (rate != null) ? rate : net.getBitRate();
+ }
+
+ return E('div', { class: 'ifacebox' }, [
+ E('div', { class: 'ifacebox-head center ' + (radio.isUp() ? 'active' : '') },
+ E('strong', radio.getName())),
+ E('div', { class: 'ifacebox-body left' }, [
+ L.itemlist(E('span'), [
+ _('Type'), radio.getI18n().replace(/^Generic | Wireless Controller .+$/g, ''),
+ _('Channel'), chan ? '%d (%.3f %s)'.format(chan, freq, _('GHz')) : '-',
+ _('Bitrate'), rate ? '%d %s'.format(rate, _('Mbit/s')) : '-',
+ ]),
+ E('div', {}, badges)
+ ])
+ ]);
+ },
+
+ isWPSEnabled: {},
+