From fda2d10b6f99aff341301a5f6f5aa72e15f76f7b Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Fri, 11 Aug 2017 21:36:14 +0200 Subject: [PATCH] gluon-web-admin: simplify info.html template --- .../files/lib/gluon/web/view/admin/info.html | 41 ++++++++----------- 1 file changed, 17 insertions(+), 24 deletions(-) diff --git a/package/gluon-web-admin/files/lib/gluon/web/view/admin/info.html b/package/gluon-web-admin/files/lib/gluon/web/view/admin/info.html index 6ad2855e..4b1f966c 100644 --- a/package/gluon-web-admin/files/lib/gluon/web/view/admin/info.html +++ b/package/gluon-web-admin/files/lib/gluon/web/view/admin/info.html @@ -9,38 +9,31 @@ local platform = require 'gluon.platform' local util = require "gluon.util" + local _ = translate - local keys = { - hostname = translate('Hostname'), - primary_mac = translate('MAC address'), - model = translate('Hardware model'), - version = translate('Gluon version'), - release = translate('Firmware release'), - site = translate('Site'), - pubkey = translate('Public VPN key'), - } - - local values = { - hostname = pretty_hostname.get(uci), - primary_mac = sysconfig.primary_mac, - model = platform.get_model(), - version = util.trim(fs.readfile('/lib/gluon/gluon-version')), - release = util.trim(fs.readfile('/lib/gluon/release')), - site = site.site_name(), - pubkey = 'n/a', - } + local pubkey local meshvpn_enabled = uci:get_bool("fastd", "mesh_vpn", "enabled") if meshvpn_enabled then - local pubkey = util.trim(lutil.exec('/etc/init.d/fastd show_key mesh_vpn')) - if pubkey ~= '' then - values.pubkey = pubkey + pubkey = util.trim(lutil.exec('/etc/init.d/fastd show_key mesh_vpn')) + if pubkey == '' then + pubkey = nil end end + + local values = { + { _('Hostname'), pretty_hostname.get(uci) }, + { _('MAC address'), sysconfig.primary_mac }, + { _('Hardware model'), platform.get_model() }, + { _('Gluon version'), util.trim(fs.readfile('/lib/gluon/gluon-version')) }, + { _('Firmware release'), util.trim(fs.readfile('/lib/gluon/release')) }, + { _('Site'), site.site_name() }, + { _('Public VPN key'), pubkey }, + } -%>

<%:Information%>

-<% for _, key in ipairs({'hostname', 'primary_mac', 'model', 'version', 'release', 'site', 'pubkey'}) do %> +<% for _, v in ipairs(values) do %>
-
<%=keys[key]%>
<%=pcdata(values[key] or 'n/a')%>
+
<%=v[1]%>
<%=pcdata(v[2] or 'n/a')%>
<% end %>