diff options
author | Jo-Philipp Wich <jo@mein.io> | 2021-11-18 19:34:56 +0100 |
---|---|---|
committer | Jo-Philipp Wich <jo@mein.io> | 2021-11-18 19:34:56 +0100 |
commit | 8ae208dce6fc6d6891b412355df0b9824eabd31e (patch) | |
tree | 1642114bcb23317795b34332749ff09bc0bc0782 /applications/luci-app-wireguard/htdocs/luci-static/resources/view/wireguard | |
parent | 6507b1f04b3c92f151f19d7b59294a826c485872 (diff) |
luci-app-wireguard: show a hint when nothing is configured
When no wireguard interface is configured, the wireguard status page will
simply display a blank page only containing a heading.
Print a short notice stating that no interfaces are configured. Also
use actual table elements for table markup while we're at it.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'applications/luci-app-wireguard/htdocs/luci-static/resources/view/wireguard')
-rw-r--r-- | applications/luci-app-wireguard/htdocs/luci-static/resources/view/wireguard/status.js | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/applications/luci-app-wireguard/htdocs/luci-static/resources/view/wireguard/status.js b/applications/luci-app-wireguard/htdocs/luci-static/resources/view/wireguard/status.js index 25d5df9ffb..b9c756de98 100644 --- a/applications/luci-app-wireguard/htdocs/luci-static/resources/view/wireguard/status.js +++ b/applications/luci-app-wireguard/htdocs/luci-static/resources/view/wireguard/status.js @@ -74,19 +74,26 @@ function generatePeerRows(peers) { var peerData = parsePeerData(peer); var iconSrc = getTunnelIcon(peer.latest_handshake); - peerRows.push(E('div', { + peerRows.push(E('tr', { 'class': 'tr cbi-section-table-row' }, [ - E('div', { + E('td', { 'class': 'td peer-name', 'style': 'width: 25%; font-size: 0.9rem;' }, peer.name), - E('div', { 'class': 'td', 'data-section-id': peer.name }, + E('td', { 'class': 'td', 'data-section-id': peer.name }, generatePeerTable(peerData, iconSrc) ) ])); }); + if (!peerRows.length) { + peerRows.push( + E('tr', { 'class': 'tr placeholder' }, + E('td', { 'class': 'td' }, + E('em', _('No peer information available'))))); + } + return peerRows; } @@ -124,6 +131,7 @@ return view.extend({ load: function () { return callGetWgInstances(); }, + poll_status: function (nodes, ifaces) { Object.keys(ifaces).forEach(function (ifaceName) { var iface = ifaces[ifaceName]; @@ -164,6 +172,7 @@ return view.extend({ }); }); }, + render: function (ifaces) { var m, s, o, ss; @@ -171,6 +180,7 @@ return view.extend({ m.tabbed = true; var ifaceNames = Object.keys(ifaces); + for (var i = ifaceNames.length - 1; i >= 0; i--) { var ifaceName = ifaceNames[i]; var iface = ifaces[ifaceName]; @@ -193,13 +203,16 @@ return view.extend({ ss.render = L.bind(function (view, section_id) { return E('div', { 'class': 'cbi-section' }, [ E('h3', _('Peers')), - E('div', { 'class': 'table cbi-section-table' }, + E('table', { 'class': 'table cbi-section-table' }, generatePeerRows(this.peers)) ]); }, iface, this); } return m.render().then(L.bind(function (m, nodes) { + if (!ifaceNames.length) + nodes.appendChild(E('p', {}, E('em', _('No WireGuard interfaces configured.')))); + poll.add(L.bind(function () { return callGetWgInstances().then( L.bind(this.poll_status, this, nodes) @@ -208,6 +221,7 @@ return view.extend({ return nodes; }, this, m)); }, + handleReset: null, handleSaveApply: null, handleSave: null |