gluon-web-admin: simplify info.html template

This commit is contained in:
Matthias Schiffer 2017-08-11 21:36:14 +02:00
parent 13b325355d
commit fda2d10b6f
No known key found for this signature in database
GPG Key ID: 16EF3F64CB201D9C

View File

@ -9,38 +9,31 @@
local platform = require 'gluon.platform' local platform = require 'gluon.platform'
local util = require "gluon.util" 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") local meshvpn_enabled = uci:get_bool("fastd", "mesh_vpn", "enabled")
if meshvpn_enabled then if meshvpn_enabled then
local pubkey = util.trim(lutil.exec('/etc/init.d/fastd show_key mesh_vpn')) pubkey = util.trim(lutil.exec('/etc/init.d/fastd show_key mesh_vpn'))
if pubkey ~= '' then if pubkey == '' then
values.pubkey = pubkey pubkey = nil
end end
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 },
}
-%> -%>
<h2><%:Information%></h2> <h2><%:Information%></h2>
<% for _, key in ipairs({'hostname', 'primary_mac', 'model', 'version', 'release', 'site', 'pubkey'}) do %> <% for _, v in ipairs(values) do %>
<div class="gluon-value"> <div class="gluon-value">
<div class="gluon-value-title"><%=keys[key]%></div><div class="gluon-value-field"><%=pcdata(values[key] or 'n/a')%></div> <div class="gluon-value-title"><%=v[1]%></div><div class="gluon-value-field"><%=pcdata(v[2] or 'n/a')%></div>
</div> </div>
<% end %> <% end %>