diff options
author | Florian Eckert <fe@dev.tdt.de> | 2021-07-02 15:23:39 +0200 |
---|---|---|
committer | Florian Eckert <fe@dev.tdt.de> | 2021-07-09 08:38:11 +0200 |
commit | f5f6b3e4f8e3faed4e9c9926e283c9cf226d4bd8 (patch) | |
tree | e2718f194ede046a90274443f6b61198f35a0961 /applications/luci-app-mwan3/htdocs/luci-static/resources/view/status/include | |
parent | 12067c8308936abb567001650105b33bec9a56a9 (diff) |
luci-app-mwan3: convert to JS
Signed-off-by: Florian Eckert <fe@dev.tdt.de>
Diffstat (limited to 'applications/luci-app-mwan3/htdocs/luci-static/resources/view/status/include')
-rw-r--r-- | applications/luci-app-mwan3/htdocs/luci-static/resources/view/status/include/90_mwan3.js | 117 |
1 files changed, 117 insertions, 0 deletions
diff --git a/applications/luci-app-mwan3/htdocs/luci-static/resources/view/status/include/90_mwan3.js b/applications/luci-app-mwan3/htdocs/luci-static/resources/view/status/include/90_mwan3.js new file mode 100644 index 0000000000..0fc11550e9 --- /dev/null +++ b/applications/luci-app-mwan3/htdocs/luci-static/resources/view/status/include/90_mwan3.js @@ -0,0 +1,117 @@ +'use strict'; +'require baseclass'; +'require rpc'; + +var callMwan3Status = rpc.declare({ + object: 'mwan3', + method: 'status', + expect: { }, +}); + +document.querySelector('head').appendChild(E('link', { + 'rel': 'stylesheet', + 'type': 'text/css', + 'href': L.resource('view/mwan3/mwan3.css') +})); + +return baseclass.extend({ + title: _('MultiWAN Manager'), + + load: function() { + return Promise.all([ + callMwan3Status(), + ]); + }, + + render: function (result) { + if (!result[0].interfaces) + return null; + + var container = E('div', { 'id': 'mwan3-service-status' }); + var iface; + for ( iface in result[0].interfaces) { + var state = ''; + var css = ''; + var time = ''; + var tname = ''; + switch (result[0].interfaces[iface].status) { + case 'online': + state = _('Online'); + css = 'alert-message success'; + time = '%t'.format(result[0].interfaces[iface].online); + tname = _('Uptime'); + break; + case 'offline': + state = _('Offline'); + css = 'alert-message danger'; + time = '%t'.format(result[0].interfaces[iface].offline); + tname = _('Downtime'); + break; + case 'notracking': + state = _('No Tracking'); + if ((result[0].interfaces[iface].uptime) > 0) { + css = 'alert-message success'; + time = '%t'.format(result[0].interfaces[iface].uptime); + tname = _('Uptime'); + } + else { + css = 'alert-message warning'; + time = ''; + tname = ''; + } + break; + default: + css = 'alert-message warning'; + state = _('Disabled'); + time = ''; + tname = ''; + break; + } + + if (time !== '' ) { + container.appendChild( + E('div', { 'class': css }, [ + E('div', {}, [ + E('strong', {}, [ + _('Interface'), ':', ' ' + ]), + iface + ]), + E('div', {}, [ + E('strong', {}, [ + _('Status'), ':', ' ' + ]), + state + ]), + E('div', {}, [ + E('strong', {}, [ + tname, ':', ' ' + ]), + time + ]) + ]) + ); + } + else { + container.appendChild( + E('div', { 'class': css }, [ + E('div', {}, [ + E('strong', {}, [ + _('Interface'), ':', ' ' + ]), + iface + ]), + E('div', {}, [ + E('strong', {}, [ + _('Status'), ':', ' ' + ]), + state + ]) + ]) + ); + } + } + + return container; + } +}); |