bc39ed50182a9ea918ec4c945baa573a9a93dd97
2 * Copyright (c) 2018-2020, Tano Systems LLC. All Rights Reserved.
3 * Anton Kikin <a.kikin@tano-systems.com>
14 * Filter neighbors (-H)
16 * The filter column means that filtering is enabled
17 * The 1proto column tells that only one protocol will be kept.
18 * The 1neigh column tells that only one neighbor will be kept.
21 * filter 1proto 1neigh filter 1proto 1neigh
43 var cbiFilterSelect
= form
.Value
.extend({
44 __name__
: 'CBI.LLDPD.FilterSelect',
46 __init__: function() {
47 this.super('__init__', arguments
);
76 handleRowClick: function(section_id
, ev
) {
77 var row
= ev
.currentTarget
;
78 var tbody
= row
.parentNode
;
79 var selected
= row
.getAttribute('data-filter');
80 var input
= tbody
.querySelector('[id="' + this.cbid(section_id
) + '-' + selected
+ '"]');
82 this.selected
= selected
;
84 tbody
.querySelectorAll('tr').forEach(function(e
) {
85 e
.classList
.remove('lldpd-filter-selected');
89 row
.classList
.add('lldpd-filter-selected');
92 formvalue: function(section_id
) {
93 return this.selected
|| this.cfgvalue(section_id
);
96 renderFrame: function(section_id
, in_table
, option_index
, nodes
) {
97 var tmp
= this.description
;
99 // Prepend description with table legend
101 '<ul><li>' + _('E — enable filter') + '</li>' +
102 '<li>' + _('P — keep only one protocol') + '</li>' +
103 '<li>' + _('N — keep only one neighbor') + '</li>' +
104 '</ul>' + this.description
;
106 var rendered
= this.super('renderFrame', arguments
);
108 // Restore original description
109 this.description
= tmp
;
114 renderWidget: function(section_id
, option_index
, cfgvalue
) {
115 var selected
= parseInt(cfgvalue
) - 1;
119 var renderFilterVal
= L
.bind(function(row
, col
) {
120 return this.filterVal
[row
][col
] ? '✔' : '';
123 for (var i
= 0; i
< this.filterVal
.length
; i
++) {
125 'class': ((selected
== i
) ? 'lldpd-filter-selected' : ''),
126 'click': L
.bind(this.handleRowClick
, this, section_id
),
131 'class': 'cbi-input-radio',
132 'data-update': 'click change',
134 'id': this.cbid(section_id
) + '-' + i
,
135 'name': this.cbid(section_id
),
136 'checked': (selected
== i
) ? '' : null,
141 E('td', {}, renderFilterVal(i
, 0)),
142 E('td', {}, renderFilterVal(i
, 1)),
143 E('td', {}, renderFilterVal(i
, 2)),
144 E('td', {}, renderFilterVal(i
, 3)),
145 E('td', {}, renderFilterVal(i
, 4)),
146 E('td', {}, renderFilterVal(i
, 5))
150 var table
= E('table', { 'class': 'lldpd-filter', 'id': this.cbid(section_id
) }, [
153 E('th', { 'rowspan': 2 }),
154 E('th', { 'rowspan': 2 }, _('Filter')),
155 E('th', { 'colspan': 3 }, _('Incoming')),
156 E('th', { 'colspan': 3 }, _('Outgoing'))
167 E('tbody', {}, tbody
)
175 return new Promise(function(resolveFn
, rejectFn
) {
176 var data
= session
.getLocalData('luci-app-lldpd');
183 return uci
.load('luci').then(function() {
184 session
.setLocalData('luci-app-lldpd', data
);
190 return L
.Class
.extend({
191 cbiFilterSelect
: cbiFilterSelect
,