ImmortalWrt/package/emortal/autocore/files/generic/rpcd_21_ethinfo.js

60 lines
1.1 KiB
JavaScript
Raw Normal View History

2020-03-16 05:02:00 +08:00
'use strict';
'require rpc';
var callLuciETHInfo = rpc.declare({
object: 'luci',
method: 'getETHInfo',
expect: { '': {} }
});
return L.Class.extend({
title: _('Ethernet Information'),
load: function() {
return Promise.all([
L.resolveDefault(callLuciETHInfo(), {})
]);
},
render: function(data) {
var ethinfo = Array.isArray(data[0].ethinfo) ? data[0].ethinfo : [];
var table = E('table', { 'class': 'table' }, [
E('tr', { 'class': 'tr table-titles' }, [
E('th', { 'class': 'th' }, _('Ethernet Name')),
E('th', { 'class': 'th' }, _('Link Status')),
E('th', { 'class': 'th' }, _('Speed')),
E('th', { 'class': 'th' }, _('Duplex'))
2020-03-16 05:02:00 +08:00
])
]);
cbi_update_table(table, ethinfo.map(function(info) {
var exp1;
var exp2;
if (info.status == "yes")
exp1 = _('Link Up');
else if (info.status == "no")
exp1 = _('Link Down');
if (info.duplex == "Full")
exp2 = _('Full Duplex');
else if (info.duplex == "Half")
exp2 = _('Half Duplex');
else
exp2 = _('-');
return [
info.name,
exp1,
info.speed,
exp2
];
}));
return E([
table
]);
}
});