o = s:taboption("logging", ListValue, "conloglevel", translate("Log output level"))
o:value(8, translate("Debug"))
o:value(7, translate("Info"))
o:value(6, translate("Notice"))
o:value(5, translate("Warning"))
o:value(4, translate("Error"))
o:value(3, translate("Critical"))
o:value(2, translate("Alert"))
o:value(1, translate("Emergency"))
对应的选择菜单:
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
o = s:taboption("logging", Value, "log_port", translate("External system log server port"))
o.optional = true
o.placeholder = 514
o.datatype = "port"
普通的input
------------------------------------------------------------------------------------------------------------------------------------------------------------------
运用到其他的信息:
o = s:taboption("general", DummyValue, "_systime", translate("Local Time"))
o.template = "admin_system/clock_status"
运用了 htm 的模版
其中这个htm的文件是:
<%+cbi/valueheader%>
<script type="text/javascript">//<![CDATA[
XHR.poll(5, '<%=url('admin/system/clock_status')%>', null,
function(x, rv)
{
var s = document.getElementById('<%=self.option%>-clock-status');
if (s)
{
s.innerHTML = rv.timestring || '?';
}
}
);
function sync_clock(btn)
{
btn.disabled = true;
btn.value = '<%:Synchronizing...%>';
(new XHR()).post('<%=url('admin/system/clock_status')%>',
{ token: '<%=token%>', set: Math.floor((new Date()).getTime() / 1000) },
function()
{
btn.disabled = false;
btn.value = '<%:Sync with browser%>';
}
);
return false;
}
//]]></script>
<span id="<%=self.option%>-clock-status"><em><%:Collecting data...%></em></span>
<input type="button" class="cbi-button cbi-button-apply" value="<%:Sync with browser%>" οnclick="return sync_clock(this)" />
<%+cbi/valuefooter%>
有空细细的研究研究
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
o = s:taboption("general", DummyValue, "hostname", translate("Hostname"))
function o.write(self, section, value)
Value.write(self, section, value)
sys.hostname(value)
end
展示的是信息, 不可编辑 , 比如:
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
选择按钮:
local o = s:option( Flag, "enabled", translate("IPsec Service Switch"))
o.width = "auto"
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
制作一个表格
local s = m:section( TypedSection, "ipsec")
s.template = "cbi/tblsection"
s.addremove = true
s.anonymous = true
s.sectionhead=translate("Name")
s.extedit = luci.dispatcher.build_url(
"admin", "services", "ipsec", "rule", "%s"
)
local name = s:option( DummyValue, "name", translate("NameId") )
local left = s:option( DummyValue, "left", translate("Local Interface") )
function left.cfgvalue(self, section)
local val = AbstractValue.cfgvalue(self, section)
if val == "3g-wan" then
return "Modem"
else
return translate("Wire")
end
end
local right = s:option( DummyValue, "right", translate("Remote IP") )
function right.cfgvalue(self, section)
local val = AbstractValue.cfgvalue(self, section)
return val or "any"
end
local status = s:option( DummyValue, "enabled", translate("Status") )
function status.cfgvalue(self, section)
local val = AbstractValue.cfgvalue(self, section)
if val == '1' then
return translate("Enabled")
end
return translate("Disabled")
end
--添加按钮配置信息
function s.create(self)
local cfgid = uci:section(
"ipsec", "ipsec", nil, {
name = "tunnel01",
left = "wan",
right = "218.85.157.66",
enabled = '0'})
uci:save("ipsec")
luci.http.redirect(luci.dispatcher.build_url("admin", "services", "ipsec", "rule", cfgid))
end
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
一个小标题
s = m:section(TypedSection, "defaults", translate("General Settings"))