diff --git a/package/mtk/applications/luci-app-turboacc-mtk/htdocs/luci-static/resources/view/turboacc.js b/package/mtk/applications/luci-app-turboacc-mtk/htdocs/luci-static/resources/view/turboacc.js index 2514b453f3..51bd300807 100644 --- a/package/mtk/applications/luci-app-turboacc-mtk/htdocs/luci-static/resources/view/turboacc.js +++ b/package/mtk/applications/luci-app-turboacc-mtk/htdocs/luci-static/resources/view/turboacc.js @@ -32,6 +32,12 @@ var getTCPCCAStat = rpc.declare({ expect: { '': {} } }); +var getMTKPPEStat = rpc.declare({ + object: 'luci.turboacc', + method: 'getMTKPPEStat', + expect: { '': {} } +}); + function getServiceStatus() { return Promise.all([ L.resolveDefault(getFastPathStat(), {}), @@ -40,6 +46,25 @@ function getServiceStatus() { ]); } +function getMTKPPEStatus() { + return Promise.all([ + L.resolveDefault(getMTKPPEStat(), {}) + ]); +} + +function progressbar(value, max, byte) { + var vn = parseInt(value) || 0, + mn = parseInt(max) || 100, + fv = byte ? String.format('%1024.2mB', value) : value, + fm = byte ? String.format('%1024.2mB', max) : max, + pc = Math.floor((100 / mn) * vn); + + return E('div', { + 'class': 'cbi-progressbar', + 'title': '%s / %s (%d%%)'.format(fv, fm, pc) + }, E('div', { 'style': 'width:%.2f%%'.format(pc) })); +} + function renderStatus(stats) { var spanTemp = '%s'; var renderHTML = []; @@ -62,13 +87,15 @@ return view.extend({ load: function() { return Promise.all([ uci.load('turboacc'), - L.resolveDefault(getSystemFeatures(), {}) + L.resolveDefault(getSystemFeatures(), {}), + L.resolveDefault(getMTKPPEStat(), {}) ]); }, render: function(data) { var m, s, o; var features = data[1]; + var ppe_stats = data[2]; m = new form.Map('turboacc', _('TurboACC settings'), _('Open source flow offloading engine (fast path or hardware NAT).')); @@ -87,22 +114,47 @@ return view.extend({ }); }); + var acc_status = E('table', { 'class': 'table', 'width': '100%', 'cellspacing': '10' }, [ + E('tr', {}, [ + E('td', { 'width': '33%' }, _('FastPath Engine')), + E('td', { 'id': 'fastpath_state' }, E('em', {}, _('Collecting data...'))) + ]), + E('tr', {}, [ + E('td', { 'width': '33%' }, _('Full Cone NAT')), + E('td', { 'id': 'fullcone_state' }, E('em', {}, _('Collecting data...'))) + ]), + E('tr', {}, [ + E('td', { 'width': '33%' }, _('TCP CCA')), + E('td', { 'id': 'tcpcca_state' }, E('em', {}, _('Collecting data...'))) + ]) + ]); + + if (ppe_stats.hasOwnProperty('PPE_NUM')) { + poll.add(function () { + return L.resolveDefault(getMTKPPEStatus()).then(function (res) { + var ppe_num = parseInt(res[0].PPE_NUM); + for (var i=0; i