Merge pull request #3400 from TDT-AG/pr/20191210-luci-mk
[oweals/luci.git] / modules / luci-mod-status / htdocs / luci-static / resources / view / status / include / 50_dsl.js
1 'use strict';
2 'require rpc';
3
4 var callLuciDSLStatus = rpc.declare({
5         object: 'luci-rpc',
6         method: 'getDSLStatus',
7         expect: { '': {} }
8 });
9
10 function renderbox(dsl) {
11         return E('div', { class: 'ifacebox' }, [
12                 E('div', { class: 'ifacebox-head center ' + ((dsl.line_state === 'UP') ? 'active' : '') },
13                         E('strong', _('DSL Status'))),
14                 E('div', { class: 'ifacebox-body left' }, [
15                         L.itemlist(E('span'), [
16                                 _('Line State'), '%s [0x%x]'.format(dsl.line_state, dsl.line_state_detail),
17                                 _('Line Mode'), dsl.line_mode_s || '-',
18                                 _('Line Uptime'), dsl.line_uptime_s || '-',
19                                 _('Annex'), dsl.annex_s || '-',
20                                 _('Profile'), dsl.profile_s || '-',
21                                 _('Data Rate'), '%s/s / %s/s'.format(dsl.data_rate_down_s, dsl.data_rate_up_s),
22                                 _('Max. Attainable Data Rate (ATTNDR)'), '%s/s / %s/s'.format(dsl.max_data_rate_down_s, dsl.max_data_rate_up_s),
23                                 _('Latency'), '%s / %s'.format(dsl.latency_num_down, dsl.latency_num_up),
24                                 _('Line Attenuation (LATN)'), '%.1f dB / %.1f dB'.format(dsl.line_attenuation_down, dsl.line_attenuation_up),
25                                 _('Signal Attenuation (SATN)'), '%.1f dB / %.1f dB'.format(dsl.signal_attenuation_down, dsl.signal_attenuation_up),
26                                 _('Noise Margin (SNR)'), '%.1f dB / %.1f dB'.format(dsl.noise_margin_down, dsl.noise_margin_up),
27                                 _('Aggregate Transmit Power (ACTATP)'), '%.1f dB / %.1f dB'.format(dsl.actatp_down, dsl.actatp_up),
28                                 _('Forward Error Correction Seconds (FECS)'), '%d / %d'.format(dsl.errors_fecs_near, dsl.errors_fecs_far),
29                                 _('Errored seconds (ES)'), '%d / %d'.format(dsl.errors_es_near, dsl.errors_es_far),
30                                 _('Severely Errored Seconds (SES)'), '%d / %d'.format(dsl.errors_ses_near, dsl.errors_ses_far),
31                                 _('Loss of Signal Seconds (LOSS)'), '%d / %d'.format(dsl.errors_loss_near, dsl.errors_loss_far),
32                                 _('Unavailable Seconds (UAS)'), '%d / %d'.format(dsl.errors_uas_near, dsl.errors_uas_far),
33                                 _('Header Error Code Errors (HEC)'), '%d / %d'.format(dsl.errors_hec_near, dsl.errors_hec_far),
34                                 _('Non Pre-emptive CRC errors (CRC_P)'), '%d / %d'.format(dsl.errors_crc_p_near, dsl.errors_crc_p_far),
35                                 _('Pre-emptive CRC errors (CRCP_P)'), '%d / %d'.format(dsl.errors_crcp_p_near, dsl.errors_crcp_p_far),
36                                 _('ATU-C System Vendor ID'), dsl.atuc_vendor_id,
37                                 _('Power Management Mode'), dsl.power_mode_s
38                         ])
39                 ])
40         ]);
41 }
42
43 return L.Class.extend({
44         title: _('DSL'),
45
46         load: function() {
47                 return L.resolveDefault(callLuciDSLStatus(), {});
48         },
49
50         render: function(dsl) {
51                 if (!dsl.line_state)
52                         return null;
53
54                 return E('div', { 'id': 'dsl_status_table', 'class': 'network-status-table' }, renderbox(dsl));
55         }
56 });