1
0
Fork 0
mirror of https://github.com/Ysurac/openmptcprouter-feeds.git synced 2025-03-09 15:40:03 +00:00

Add macvlan support

This commit is contained in:
Ycarus 2018-01-23 15:36:03 +01:00
parent 40fdd921b9
commit 9f8643647e
255 changed files with 134998 additions and 0 deletions

View file

@ -0,0 +1,43 @@
<% export("cbi_apply_xhr", function(id, configs, redirect) -%>
<fieldset class="cbi-section" id="cbi-apply-<%=id%>">
<legend><%:Applying changes%></legend>
<script type="text/javascript">//<![CDATA[
var apply_xhr = new XHR();
apply_xhr.post('<%=url('servicectl/restart', table.concat(configs, ","))%>', { token: '<%=token%>' },
function() {
var checkfinish = function() {
apply_xhr.get('<%=url('servicectl/status')%>', null,
function(x) {
if( x.responseText == 'finish' )
{
var e = document.getElementById('cbi-apply-<%=id%>-status');
if( e )
{
e.innerHTML = '<%:Configuration applied.%>';
window.setTimeout(function() {
e.parentNode.style.display = 'none';
<% if redirect then %>location.href='<%=redirect%>';<% end %>
}, 1000);
}
}
else
{
var e = document.getElementById('cbi-apply-<%=id%>-status');
if( e && x.responseText ) e.innerHTML = x.responseText;
window.setTimeout(checkfinish, 1000);
}
}
);
}
window.setTimeout(checkfinish, 1000);
}
);
//]]></script>
<img src="<%=resource%>/icons/loading.gif" alt="<%:Loading%>" style="vertical-align:middle" />
<span id="cbi-apply-<%=id%>-status"><%:Waiting for changes to be applied...%></span>
</fieldset>
<%- end) %>

View file

@ -0,0 +1,7 @@
<% local v = self:cfgvalue(section) -%>
<%+cbi/valueheader%>
<input class="cbi-input-text" type="text"<%= attr("value", v) .. attr("name", cbid) .. attr("id", cbid) %> />
<script type="text/javascript">
cbi_browser_init('<%=cbid%>', '<%=resource%>', '<%=url('admin/filebrowser')%>'<%=self.default_path and ", '"..self.default_path.."'"%>);
</script>
<%+cbi/valuefooter%>

View file

@ -0,0 +1,7 @@
<%+cbi/valueheader%>
<% if self:cfgvalue(section) ~= false then %>
<input class="cbi-button cbi-input-<%=self.inputstyle or "button" %>" type="submit"<%= attr("name", cbid) .. attr("id", cbid) .. attr("value", self.inputtitle or self.title)%> />
<% else %>
-
<% end %>
<%+cbi/valuefooter%>

View file

@ -0,0 +1,2 @@
</div>
</td>

View file

@ -0,0 +1,2 @@
<td class="cbi-value-field<% if self.error and self.error[section] then %> cbi-value-error<% end %>">
<div id="cbi-<%=self.config.."-"..section.."-"..self.option%>" data-index="<%=self.index%>" data-depends="<%=pcdata(self:deplist2json(section))%>">

View file

@ -0,0 +1 @@
<%- self:render_children() %>

View file

@ -0,0 +1,24 @@
<%- self.active:render() %>
<div class="cbi-page-actions">
<input type="hidden" name="cbi.delg.current" value="<%=self.current%>" />
<% for _, x in ipairs(self.chain) do %>
<input type="hidden" name="cbi.delg.path" value="<%=x%>" />
<% end %>
<% if not self.disallow_pageactions then %>
<% if self.allow_finish and not self:get_next(self.current) then %>
<input class="cbi-button cbi-button-finish" type="submit" value="<%:Finish%>" />
<% elseif self:get_next(self.current) then %>
<input class="cbi-button cbi-button-next" type="submit" value="<%:Next »%>" />
<% end %>
<% if self.allow_cancel then %>
<input class="cbi-button cbi-button-cancel" type="submit" name="cbi.cancel" value="<%:Cancel%>" />
<% end %>
<% if self.allow_reset then %>
<input class="cbi-button cbi-button-reset" type="reset" value="<%:Reset%>" />
<% end %>
<% if self.allow_back and self:get_prev(self.current) then %>
<input class="cbi-button cbi-button-back" type="submit" name="cbi.delg.back" value="<%:« Back%>" />
<% end %>
<% end %>
<script type="text/javascript">cbi_d_update();</script>
</div>

View file

@ -0,0 +1,13 @@
<%+cbi/valueheader%>
<% if self.href then %><a href="<%=self.href%>"><% end -%>
<%
local val = self:cfgvalue(section) or self.default or ""
if not self.rawhtml then
write(pcdata(val))
else
write(val)
end
%>
<%- if self.href then %></a><%end%>
<input type="hidden" id="<%=cbid%>" value="<%=pcdata(self:cfgvalue(section) or self.default or "")%>" />
<%+cbi/valuefooter%>

View file

@ -0,0 +1,27 @@
<%+cbi/valueheader%>
<div<%=
attr("data-prefix", cbid) ..
attr("data-browser-path", self.default_path) ..
attr("data-dynlist", luci.util.serialize_json({
self.keylist, self.vallist,
self.datatype, self.optional or self.rmempty
})) ..
ifattr(self.size, "data-size", self.size) ..
ifattr(self.placeholder, "data-placeholder", self.placeholder)
%>>
<%
local vals = self:cfgvalue(section) or {}
for i=1, #vals + 1 do
local val = vals[i]
if (val and #val > 0) or (i == 1) then
%>
<input class="cbi-input-text" value="<%=pcdata(val)%>" data-update="change" type="text"<%=
attr("id", cbid .. "." .. i) ..
attr("name", cbid) ..
ifattr(self.size, "size") ..
ifattr(i == 1 and self.placeholder, "placeholder", self.placeholder)
%> /><br />
<% end end %>
</div>
<%+cbi/valuefooter%>

View file

@ -0,0 +1,19 @@
<div class="cbi-map" id="cbi-<%=self.config%>">
<% if self.title and #self.title > 0 then %><h2 name="content"><%=self.title%></h2><% end %>
<% if self.description and #self.description > 0 then %><div class="cbi-map-descr"><%=self.description%></div><% end %>
<p class="alert-message danger">
<%: The configuration file could not be loaded due to the following error: %><br />
<code><%=pcdata(self.error)%></code>
</p>
<textarea name="cbi.source" style="width:100%; margin-bottom:1em" rows="<%=math.max(self.source:cmatch("\n"), 10)%>"><%=pcdata(self.source)%></textarea>
<p class="alert-message">
<%: Edit the raw configuration data above to fix any error and hit "Save" to reload the page. %>
</p>
<div class="cbi-page-actions">
<input class="cbi-button cbi-button-apply" type="submit" name="cbi.save" value="<%:Save%>" />
</div>
</div>

View file

@ -0,0 +1,108 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Filebrowser - LuCI</title>
<style type="text/css">
#path, #listing {
font-size: 85%;
}
ul {
padding-left: 0;
list-style-type: none;
}
li img {
vertical-align: bottom;
margin-right: 0.2em;
}
</style>
<script type="text/javascript">
function callback(path) {
if( window.opener ) {
var input = window.opener.document.getElementById('<%=luci.http.formvalue('field')%>');
if( input ) {
input.value = path;
window.close();
}
}
}
</script>
</head>
<body>
<%
require("nixio.fs")
require("nixio.util")
require("luci.http")
require("luci.dispatcher")
local field = luci.http.formvalue('field')
local request = luci.dispatcher.context.args
local path = { '' }
for i = 1, #request do
if request[i] ~= '..' and #request[i] > 0 then
path[#path+1] = request[i]
end
end
local filepath = table.concat( path, '/' )
local filestat = nixio.fs.stat( filepath )
local baseurl = luci.dispatcher.build_url('admin', 'filebrowser')
if filestat and filestat.type == "reg" then
table.remove( path, #path )
filepath = table.concat( path, '/' ) .. '/'
elseif not ( filestat and filestat.type == "dir" ) then
path = { '' }
filepath = '/'
else
filepath = filepath .. '/'
end
local entries = nixio.util.consume((nixio.fs.dir(filepath)))
-%>
<div id="path">
Location:
<% for i, dir in ipairs(path) do %>
<% if i == 1 then %>
<a href="<%=baseurl%>?field=<%=field%>">(root)</a>
<% elseif next(path, i) then %>
<% baseurl = baseurl .. '/' .. dir %>
/ <a href="<%=baseurl%>?field=<%=field%>"><%=dir%></a>
<% else %>
<% baseurl = baseurl .. '/' .. dir %>
/ <%=dir%>
<% end %>
<% end %>
</div>
<hr />
<div id="listing">
<ul>
<% for _, e in luci.util.vspairs(entries) do
local stat = nixio.fs.stat(filepath..e)
if stat and stat.type == 'dir' then
-%>
<li class="dir">
<img src="<%=resource%>/cbi/folder.gif" alt="<%:Directory%>" />
<a href="<%=baseurl%>/<%=e%>?field=<%=field%>"><%=e%>/</a>
</li>
<% end end -%>
<% for _, e in luci.util.vspairs(entries) do
local stat = nixio.fs.stat(filepath..e)
if stat and stat.type ~= 'dir' then
-%>
<li class="file">
<img src="<%=resource%>/cbi/file.gif" alt="<%:File%>" />
<a href="#" onclick="callback('<%=filepath..e%>')"><%=e%></a>
</li>
<% end end -%>
</ul>
</div>
</body>
</html>

View file

@ -0,0 +1,59 @@
<%+cbi/valueheader%>
<%-
local utl = require "luci.util"
local fwm = require "luci.model.firewall".init()
local nwm = require "luci.model.network".init()
local zone, fwd, fz
local value = self:formvalue(section)
if not value or value == "-" then
value = self:cfgvalue(section) or self.default
end
local def = fwm:get_defaults()
local zone = fwm:get_zone(value)
local empty = true
-%>
<% if zone then %>
<div style="white-space:nowrap">
<label class="zonebadge" style="background-color:<%=zone:get_color()%>">
<strong><%=zone:name()%>:</strong>
<%-
local zempty = true
for _, net in ipairs(zone:get_networks()) do
net = nwm:get_network(net)
if net then
zempty = false
-%>
<span class="ifacebadge<% if net:name() == self.network then %> ifacebadge-active<% end %>"><%=net:name()%>:
<%
local nempty = true
for _, iface in ipairs(net:is_bridge() and net:get_interfaces() or { net:get_interface() }) do
nempty = false
%>
<img<%=attr("title", iface:get_i18n())%> style="width:16px; height:16px; vertical-align:middle" src="<%=resource%>/icons/<%=iface:type()%><%=iface:is_up() and "" or "_disabled"%>.png" />
<% end %>
<% if nempty then %><em><%:(empty)%></em><% end %>
</span>
<%- end end -%>
<%- if zempty then %><em><%:(empty)%></em><% end -%>
</label>
&#160;&#8658;&#160;
<% for _, fwd in ipairs(zone:get_forwardings_by("src")) do
fz = fwd:dest_zone()
empty = false %>
<label class="zonebadge" style="background-color:<%=fz:get_color()%>">
<strong><%=fz:name()%></strong>
</label>&#160;
<% end %>
<% if empty then %>
<label class="zonebadge zonebadge-empty">
<strong><%=zone:forward():upper()%></strong>
</label>
<% end %>
</div>
<% end %>
<%+cbi/valuefooter%>

View file

@ -0,0 +1,93 @@
<%+cbi/valueheader%>
<%-
local utl = require "luci.util"
local fwm = require "luci.model.firewall".init()
local nwm = require "luci.model.network".init()
local zone, net, iface
local zones = fwm:get_zones()
local value = self:formvalue(section)
if not value or value == "-" then
value = self:cfgvalue(section) or self.default
end
local selected = false
local checked = { }
for value in utl.imatch(value) do
checked[value] = true
end
if not next(checked) then
checked[""] = true
end
-%>
<ul style="margin:0; list-style-type:none; text-align:left">
<% if self.allowlocal then %>
<li style="padding:0.5em">
<input class="cbi-input-radio" data-update="click change"<%=attr("type", self.widget or "radio") .. attr("id", cbid .. "_empty") .. attr("name", cbid) .. attr("value", "") .. ifattr(checked[""], "checked", "checked")%> /> &#160;
<label<%=attr("for", cbid .. "_empty")%>></label>
<label<%=attr("for", cbid .. "_empty")%> style="background-color:<%=fwm.zone.get_color()%>" class="zonebadge">
<strong><%:Device%></strong>
<% if self.allowany and self.allowlocal then %>(<%:input%>)<% end %>
</label>
</li>
<% end %>
<% if self.allowany then %>
<li style="padding:0.5em">
<input class="cbi-input-radio" data-update="click change"<%=attr("type", self.widget or "radio") .. attr("id", cbid .. "_any") .. attr("name", cbid) .. attr("value", "*") .. ifattr(checked["*"], "checked", "checked")%> /> &#160;
<label<%=attr("for", cbid .. "_any")%>></label>
<label<%=attr("for", cbid .. "_any")%> style="background-color:<%=fwm.zone.get_color()%>" class="zonebadge">
<strong><%:Any zone%></strong>
<% if self.allowany and self.allowlocal then %>(<%:forward%>)<% end %>
</label>
</li>
<% end %>
<%
for _, zone in utl.spairs(zones, function(a,b) return (zones[a]:name() < zones[b]:name()) end) do
if zone:name() ~= self.exclude then
selected = selected or (value == zone:name())
%>
<li style="padding:0.5em">
<input class="cbi-input-radio" data-update="click change"<%=attr("type", self.widget or "radio") .. attr("id", cbid .. "." .. zone:name()) .. attr("name", cbid) .. attr("value", zone:name()) .. ifattr(checked[zone:name()], "checked", "checked")%> /> &#160;
<label<%=attr("for", cbid .. "." .. zone:name())%>></label>
<label<%=attr("for", cbid .. "." .. zone:name())%> style="background-color:<%=zone:get_color()%>" class="zonebadge">
<strong><%=zone:name()%>:</strong>
<%
local zempty = true
for _, net in ipairs(zone:get_networks()) do
net = nwm:get_network(net)
if net then
zempty = false
%>
<span class="ifacebadge<% if net:name() == self.network then %> ifacebadge-active<% end %>"><%=net:name()%>:
<%
local nempty = true
for _, iface in ipairs(net:is_bridge() and net:get_interfaces() or { net:get_interface() }) do
nempty = false
%>
<img<%=attr("title", iface:get_i18n())%> style="width:16px; height:16px; vertical-align:middle" src="<%=resource%>/icons/<%=iface:type()%><%=iface:is_up() and "" or "_disabled"%>.png" />
<% end %>
<% if nempty then %><em><%:(empty)%></em><% end %>
</span>
<% end end %>
<% if zempty then %><em><%:(empty)%></em><% end %>
</label>
</li>
<% end end %>
<% if self.widget ~= "checkbox" and not self.nocreate then %>
<li style="padding:0.5em">
<input class="cbi-input-radio" data-update="click change" type="radio"<%=attr("id", cbid .. "_new") .. attr("name", cbid) .. attr("value", "-") .. ifattr(not selected, "checked", "checked")%> /> &#160;
<label<%=attr("for", cbid .. "_new")%>></label>
<div onclick="document.getElementById('<%=cbid%>_new').checked=true" class="zonebadge" style="background-color:<%=fwm.zone.get_color()%>">
<em><%:unspecified -or- create:%>&#160;</em>
<input type="text"<%=attr("name", cbid .. ".newzone") .. ifattr(not selected, "value", luci.http.formvalue(cbid .. ".newzone") or self.default)%> onfocus="document.getElementById('<%=cbid%>_new').checked=true" />
</div>
</li>
<% end %>
</ul>
<%+cbi/valuefooter%>

View file

@ -0,0 +1,27 @@
<%- if pageaction then -%>
<div class="cbi-page-actions">
<% if redirect then %>
<div style="float:left">
<input class="cbi-button cbi-button-link" type="button" value="<%:Back to Overview%>" onclick="location.href='<%=pcdata(redirect)%>'" />
</div>
<% end %>
<% if flow.skip then %>
<input class="cbi-button cbi-button-skip" type="submit" name="cbi.skip" value="<%:Skip%>" />
<% end %>
<% if not autoapply and not flow.hideapplybtn then %>
<input class="cbi-button cbi-button-apply" type="submit" name="cbi.apply" value="<%:Save & Apply%>" />
<% end %>
<% if not flow.hidesavebtn then %>
<input class="cbi-button cbi-button-save" type="submit" value="<%:Save%>" />
<% end %>
<% if not flow.hideresetbtn then %>
<input class="cbi-button cbi-button-reset" type="button" value="<%:Reset%>" onclick="location.href='<%=REQUEST_URI%>'" />
<% end %>
</div>
<%- end -%>
</form>
<script type="text/javascript">cbi_init();</script>
<%+footer%>

View file

@ -0,0 +1,13 @@
<% if self.description and #self.description > 0 then -%>
<% if not luci.util.instanceof(self, luci.cbi.DynamicList) and (not luci.util.instanceof(self, luci.cbi.Flag) or self.orientation == "horizontal") then -%>
<br />
<%- end %>
<div class="cbi-value-description">
<span class="cbi-value-helpicon"><img src="<%=resource%>/cbi/help.gif" alt="<%:help%>" /></span>
<%=self.description%>
</div>
<%- end %>
<%- if self.title and #self.title > 0 then -%>
</div>
<%- end -%>
</div>

View file

@ -0,0 +1,9 @@
<div class="cbi-value<% if self.error and self.error[section] then %> cbi-value-error<% end %><% if self.last_child then %> cbi-value-last<% end %>" id="cbi-<%=self.config.."-"..section.."-"..self.option%>" data-index="<%=self.index%>" data-depends="<%=pcdata(self:deplist2json(section))%>">
<%- if self.title and #self.title > 0 then -%>
<label class="cbi-value-title"<%= attr("for", cbid) %>>
<%- if self.titleref then -%><a title="<%=self.titledesc or translate('Go to relevant configuration page')%>" class="cbi-title-ref" href="<%=self.titleref%>"><%- end -%>
<%-=self.title-%>
<%- if self.titleref then -%></a><%- end -%>
</label>
<div class="cbi-value-field">
<%- end -%>

View file

@ -0,0 +1,10 @@
<%+cbi/valueheader%>
<input type="hidden" value="1"<%=
attr("name", "cbi.cbe." .. self.config .. "." .. section .. "." .. self.option)
%> />
<input class="cbi-input-checkbox" data-update="click change" type="checkbox"<%=
attr("id", cbid) .. attr("name", cbid) .. attr("value", self.enabled or 1) ..
ifattr((self:cfgvalue(section) or self.default) == self.enabled, "checked", "checked")
%> />
<label<%= attr("for", cbid)%>></label>
<%+cbi/valuefooter%>

View file

@ -0,0 +1,19 @@
<%+header%>
<form method="post" name="cbi" action="<%=REQUEST_URI%>" enctype="multipart/form-data" onreset="return cbi_validate_reset(this)" onsubmit="return cbi_validate_form(this, '<%:Some fields are invalid, cannot save values!%>')">
<div>
<script type="text/javascript" src="<%=resource%>/cbi.js"<%=
attr("data-strings", luci.util.serialize_json({
label = {
choose = translate('-- Please choose --'),
custom = translate('-- custom --'),
},
path = {
resource = resource,
browser = url("admin/filebrowser")
}
}))
%>></script>
<input type="hidden" name="token" value="<%=token%>" />
<input type="hidden" name="cbi.submit" value="1" />
<input type="submit" value="<%:Save%>" class="hidden" />
</div>

View file

@ -0,0 +1,43 @@
<%
local i, key
local br = self.orientation == "horizontal" and '&#160;' or '<br />'
%>
<%+cbi/valueheader%>
<% if self.widget == "select" then %>
<select class="cbi-input-select" data-update="change"<%=
attr("id", cbid) ..
attr("name", cbid) ..
ifattr(self.size, "size")
%>>
<% for i, key in pairs(self.keylist) do -%>
<option<%=
attr("id", cbid.."-"..key) ..
attr("value", key) ..
attr("data-index", i) ..
attr("data-depends", self:deplist2json(section, self.deplist[i])) ..
ifattr(tostring(self:cfgvalue(section) or self.default) == key, "selected", "selected")
%>><%=pcdata(self.vallist[i])%></option>
<%- end %>
</select>
<% elseif self.widget == "radio" then %>
<div>
<% for i, key in pairs(self.keylist) do %>
<label<%=
attr("data-index", i) ..
attr("data-depends", self:deplist2json(section, self.deplist[i]))
%>>
<input class="cbi-input-radio" data-update="click change" type="radio"<%=
attr("id", cbid.."-"..key) ..
attr("name", cbid) ..
attr("value", key) ..
ifattr((self:cfgvalue(section) or self.default) == key, "checked", "checked")
%> />
<label<%= attr("for", cbid.."-"..key)%>></label>
<%=pcdata(self.vallist[i])%>
</label>
<% if i == self.size then write(br) end %>
<% end %>
</div>
<% end %>
<%+cbi/valuefooter%>

View file

@ -0,0 +1,47 @@
<%- if firstmap and messages then local msg; for _, msg in ipairs(messages) do -%>
<div class="errorbox"><%=pcdata(msg)%></div>
<%- end end -%>
<%-+cbi/apply_xhr-%>
<div class="cbi-map" id="cbi-<%=self.config%>">
<% if self.title and #self.title > 0 then %><h2 name="content"><%=self.title%></h2><% end %>
<% if self.description and #self.description > 0 then %><div class="cbi-map-descr"><%=self.description%></div><% end %>
<%- if firstmap and applymap then cbi_apply_xhr(self.config, parsechain, redirect) end -%>
<% if self.tabbed then %>
<ul class="cbi-tabmenu map">
<%- self.selected_tab = luci.http.formvalue("tab.m-" .. self.config) %>
<% for i, section in ipairs(self.children) do %>
<%- if not self.selected_tab then self.selected_tab = section.sectiontype end %>
<li id="tab.m-<%=self.config%>.<%=section.section or section.sectiontype%>" class="cbi-tab<%=(section.sectiontype == self.selected_tab) and '' or '-disabled'%>">
<a onclick="this.blur(); return cbi_t_switch('m-<%=self.config%>', '<%=section.section or section.sectiontype%>')" href="<%=REQUEST_URI%>?tab.m-<%=self.config%>=<%=section.section or section.sectiontype%>"><%=section.title or section.section or section.sectiontype %></a>
<% if section.sectiontype == self.selected_tab then %><input type="hidden" id="tab.m-<%=self.config%>" name="tab.m-<%=self.config%>" value="<%=section.section or section.sectiontype%>" /><% end %>
</li>
<% end %>
</ul>
<br />
<% for i, section in ipairs(self.children) do %>
<div class="cbi-tabcontainer" id="container.m-<%=self.config%>.<%=section.section or section.sectiontype%>"<% if section.sectiontype ~= self.selected_tab then %> style="display:none"<% end %>>
<% section:render() %>
</div>
<script type="text/javascript">cbi_t_add('m-<%=self.config%>', '<%=section.section or section.sectiontype%>')</script>
<% end %>
<% if not self.save then -%>
<div class="cbi-section-error">
<% for _, section in ipairs(self.children) do %>
<% if section.error and section.error[section.section] then -%>
<ul><li>
<%:One or more invalid/required values on tab%>:&nbsp;<%=section.title or section.section or section.sectiontype%>
</li></ul>
<%- end %>
<% end %>
</div>
<%- end %>
<% else %>
<%- self:render_children() %>
<% end %>
<br />
</div>

View file

@ -0,0 +1,43 @@
<%
local i, key
local v = self:valuelist(section) or {}
-%>
<%+cbi/valueheader%>
<% if self.widget == "select" then %>
<select class="cbi-input-select" multiple="multiple" data-update="click change"<%=
attr("id", cbid) ..
attr("name", cbid) ..
ifattr(self.size, "size")
%>>
<% for i, key in pairs(self.keylist) do -%>
<option<%=
attr("id", cbid.."-"..key) ..
attr("value", key) ..
attr("data-index", i) ..
attr("data-depends", self:deplist2json(section, self.deplist[i])) ..
ifattr(luci.util.contains(v, key), "selected", "selected")
%>><%=pcdata(self.vallist[i])%></option>
<%- end %>
</select>
<% elseif self.widget == "checkbox" then %>
<div>
<% for i, key in pairs(self.keylist) do %>
<label<%=
attr("data-index", i) ..
attr("data-depends", self:deplist2json(section, self.deplist[i]))
%>>
<input class="cbi-input-checkbox" type="checkbox" data-update="click change"<%=
attr("id", cbid.."-"..key) ..
attr("name", cbid) ..
attr("value", key) ..
ifattr(luci.util.contains(v, key), "checked", "checked")
%> />
<label<%= attr("for", cbid.."-"..key)%>></label>
<%=pcdata(self.vallist[i])%>
</label>
<% if self.size and (i % self.size) == 0 then write('<br />') end %>
<% end %>
</div>
<% end %>
<%+cbi/valuefooter%>

View file

@ -0,0 +1,89 @@
<%+cbi/valueheader%>
<%-
local utl = require "luci.util"
local net = require "luci.model.network".init()
local cbeid = luci.cbi.FEXIST_PREFIX .. self.config .. "." .. section .. "." .. self.option
local iface
local ifaces = net:get_interfaces()
local value
if self.map:formvalue(cbeid) == "1" then
value = self:formvalue(section) or self.default or ""
else
value = self:cfgvalue(section) or self.default
end
local checked = { }
if value then
for value in utl.imatch(value) do
checked[value] = true
end
else
local n = self.network and net:get_network(self.network)
if n then
local i
for _, i in ipairs(n:get_interfaces() or { n:get_interface() }) do
checked[i:name()] = true
end
end
end
-%>
<input type="hidden" name="<%=cbeid%>" value="1" />
<ul style="margin:0; list-style-type:none">
<% for _, iface in ipairs(ifaces) do
local link = iface:adminlink()
if (not self.nobridges or not iface:is_bridge()) and
(not self.noinactive or iface:is_up()) and
iface:name() ~= self.exclude
then %>
<li>
<input class="cbi-input-<%=self.widget or "radio"%>" data-update="click change"<%=
attr("type", self.widget or "radio") ..
attr("id", cbid .. "." .. iface:name()) ..
attr("name", cbid) .. attr("value", iface:name()) ..
ifattr(checked[iface:name()], "checked", "checked")
%> />
<%- if not self.widget or self.widget == "checkbox" or self.widget == "radio" then -%>
<label<%=attr("for", cbid .. "." .. iface:name())%>></label>
<%- end -%>
&#160;
<label<%=attr("for", cbid .. "." .. iface:name())%>>
<% if link then -%><a href="<%=link%>"><% end -%>
<img<%=attr("title", iface:get_i18n())%> style="width:16px; height:16px; vertical-align:middle" src="<%=resource%>/icons/<%=iface:type()%><%=iface:is_up() and "" or "_disabled"%>.png" />
<% if link then -%></a><% end -%>
<%=pcdata(iface:get_i18n())%>
<% local ns = iface:get_networks(); if #ns > 0 then %>(
<%- local i, n; for i, n in ipairs(ns) do -%>
<%-= (i>1) and ', ' -%>
<a href="<%=n:adminlink()%>"><%=n:name()%></a>
<%- end -%>
)<% end %>
</label>
</li>
<% end end %>
<% if not self.nocreate then %>
<li>
<input class="cbi-input-<%=self.widget or "radio"%>" data-update="click change"<%=
attr("type", self.widget or "radio") ..
attr("id", cbid .. "_custom") ..
attr("name", cbid) ..
attr("value", " ")
%> />
<%- if not self.widget or self.widget == "checkbox" or self.widget == "radio" then -%>
<label<%=attr("for", cbid .. "_custom")%>></label>
<%- end -%>
&#160;
<label<%=attr("for", cbid .. "_custom")%>>
<img title="<%:Custom Interface%>" style="width:16px; height:16px; vertical-align:middle" src="<%=resource%>/icons/ethernet_disabled.png" />
<%:Custom Interface%>:
</label>
<input type="text" style="width:50px" onfocus="document.getElementById('<%=cbid%>_custom').checked=true" onblur="var x=document.getElementById('<%=cbid%>_custom'); x.value=this.value; x.checked=true" />
</li>
<% end %>
</ul>
<%+cbi/valuefooter%>

View file

@ -0,0 +1,27 @@
<%+cbi/valueheader%>
<%-
local value = self:formvalue(section)
if not value or value == "-" then
value = self:cfgvalue(section) or self.default
end
local nwm = require "luci.model.network".init()
local net = nwm:get_network(value)
-%>
<% if net then %>
<span class="ifacebadge"><%=net:name()%>:
<%
local empty = true
for _, iface in ipairs(net:get_interfaces() or { net:get_interface() }) do
if not iface:is_bridge() then
empty = false
%>
<img<%=attr("title", iface:get_i18n())%> style="width:16px; height:16px; vertical-align:middle" src="<%=resource%>/icons/<%=iface:type()%><%=iface:is_up() and "" or "_disabled"%>.png" />
<% end end %>
<% if empty then %><em><%:(no interfaces attached)%></em><% end %>
</span>
<% end %>
<%+cbi/valuefooter%>

View file

@ -0,0 +1,85 @@
<%+cbi/valueheader%>
<%-
local utl = require "luci.util"
local nwm = require "luci.model.network".init()
local net, iface
local networks = nwm:get_networks()
local value = self:formvalue(section)
self.cast = nil
if not value or value == "-" then
value = self:cfgvalue(section) or self.default
end
local checked = { }
for value in utl.imatch(value) do
checked[value] = true
end
-%>
<ul style="margin:0; list-style-type:none; text-align:left">
<% for _, net in ipairs(networks) do
if (net:name() ~= "loopback") and
(net:name() ~= self.exclude) and
(not self.novirtual or not net:is_virtual())
then %>
<li style="padding:0.25em 0">
<input class="cbi-input-<%=self.widget or "radio"%>" data-update="click change"<%=
attr("type", self.widget or "radio") ..
attr("id", cbid .. "." .. net:name()) ..
attr("name", cbid) .. attr("value", net:name()) ..
ifattr(checked[net:name()], "checked", "checked")
%> /> &#160;
<label<%=attr("for", cbid .. "." .. net:name())%>>
<span class="ifacebadge"><%=net:name()%>:
<%
local empty = true
for _, iface in ipairs(net:is_bridge() and net:get_interfaces() or { net:get_interface() }) do
if not iface:is_bridge() then
empty = false
%>
<img<%=attr("title", iface:get_i18n())%> style="width:16px; height:16px; vertical-align:middle" src="<%=resource%>/icons/<%=iface:type()%><%=iface:is_up() and "" or "_disabled"%>.png" />
<% end end %>
<% if empty then %><em><%:(no interfaces attached)%></em><% end %>
</span>
</label>
</li>
<% end end %>
<% if not self.nocreate then %>
<li style="padding:0.25em 0">
<input class="cbi-input-<%=self.widget or "radio"%>" data-update="click change"<%=attr("type", self.widget or "radio") .. attr("id", cbid .. "_new") .. attr("name", cbid) .. attr("value", "-") .. ifattr(not value and self.widget ~= "checkbox", "checked", "checked")%> /> &#160;
<%- if not self.widget or self.widget == "checkbox" or self.widget == "radio" then -%>
<label<%=attr("for", cbid .. "_new")%>></label>
<%- end -%>
<div style="padding:0.5em; display:inline">
<label<%=attr("for", cbid .. "_new")%>><em>
<%- if self.widget == "checkbox" then -%>
<%:create:%>
<%- else -%>
<%:unspecified -or- create:%>
<%- end -%>&#160;</em></label>
<input style="display:none" type="password" />
<input style="width:6em" type="text"<%=attr("name", cbid .. ".newnet")%> onfocus="document.getElementById('<%=cbid%>_new').checked=true" />
</div>
</li>
<% elseif self.widget ~= "checkbox" and self.unspecified then %>
<li style="padding:0.25em 0">
<input class="cbi-input-<%=self.widget or "radio"%>" data-update="click change"<%=
attr("type", self.widget or "radio") ..
attr("id", cbid .. "_uns") ..
attr("name", cbid) ..
attr("value", "") ..
ifattr(not value or #value == 0, "checked", "checked")
%> /> &#160;
<div style="padding:0.5em; display:inline">
<label<%=attr("for", cbid .. "_uns")%>><em><%:unspecified%></em></label>
</div>
</li>
<% end %>
</ul>
<%+cbi/valuefooter%>

View file

@ -0,0 +1,31 @@
<% if self:cfgvalue(self.section) then section = self.section %>
<fieldset class="cbi-section">
<% if self.title and #self.title > 0 then -%>
<legend><%=self.title%></legend>
<%- end %>
<% if self.description and #self.description > 0 then -%>
<div class="cbi-section-descr"><%=self.description%></div>
<%- end %>
<% if self.addremove then -%>
<div class="cbi-section-remove right">
<input type="submit" class="cbi-button" name="cbi.rns.<%=self.config%>.<%=section%>" value="<%:Delete%>" />
</div>
<%- end %>
<%+cbi/tabmenu%>
<div class="cbi-section-node<% if self.tabs then %> cbi-section-node-tabbed<% end %>" id="cbi-<%=self.config%>-<%=section%>">
<%+cbi/ucisection%>
</div>
<br />
</fieldset>
<% elseif self.addremove then %>
<% if self.template_addremove then include(self.template_addremove) else -%>
<fieldset class="cbi-section" id="cbi-<%=self.config%>-<%=self.section%>">
<% if self.title and #self.title > 0 then -%>
<legend><%=self.title%></legend>
<%- end %>
<div class="cbi-section-descr"><%=self.description%></div>
<input type="submit" class="cbi-button cbi-button-add" name="cbi.cns.<%=self.config%>.<%=self.section%>" value="<%:Add%>" />
</fieldset>
<%- end %>
<% end %>
<!-- /nsection -->

View file

@ -0,0 +1,38 @@
<fieldset class="cbi-section">
<% if self.title and #self.title > 0 then -%>
<legend><%=self.title%></legend>
<%- end %>
<% if self.description and #self.description > 0 then -%>
<div class="cbi-section-descr"><%=self.description%></div>
<%- end %>
<div class="cbi-section-node">
<div id="cbi-<%=self.config%>-<%=tostring(self):sub(8)%>">
<% self:render_children(1, scope or {}) %>
</div>
<% if self.error and self.error[1] then -%>
<div class="cbi-section-error">
<ul><% for _, e in ipairs(self.error[1]) do -%>
<li>
<%- if e == "invalid" then -%>
<%:One or more fields contain invalid values!%>
<%- elseif e == "missing" then -%>
<%:One or more required fields have no value!%>
<%- else -%>
<%=pcdata(e)%>
<%- end -%>
</li>
<%- end %></ul>
</div>
<%- end %>
</div>
<br />
</fieldset>
<%-
if type(self.hidden) == "table" then
for k, v in pairs(self.hidden) do
-%>
<input type="hidden" id="<%=k%>" name="<%=k%>" value="<%=pcdata(v)%>" />
<%-
end
end
%>

View file

@ -0,0 +1,58 @@
<% if not self.embedded then %>
<form method="post" enctype="multipart/form-data" action="<%=REQUEST_URI%>">
<div>
<script type="text/javascript" src="<%=resource%>/cbi.js"></script>
<input type="hidden" name="token" value="<%=token%>" />
<input type="hidden" name="cbi.submit" value="1" />
</div>
<% end %>
<div class="cbi-map" id="cbi-<%=self.config%>">
<% if self.title and #self.title > 0 then %><h2 name="content"><%=self.title%></h2><% end %>
<% if self.description and #self.description > 0 then %><div class="cbi-map-descr"><%=self.description%></div><% end %>
<% self:render_children() %>
<br />
</div>
<%- if self.message then %>
<div><%=self.message%></div>
<%- end %>
<%- if self.errmessage then %>
<div class="error"><%=self.errmessage%></div>
<%- end %>
<% if not self.embedded then %>
<div class="cbi-page-actions">
<%-
if type(self.hidden) == "table" then
for k, v in pairs(self.hidden) do
-%>
<input type="hidden" id="<%=k%>" name="<%=k%>" value="<%=pcdata(v)%>" />
<%-
end
end
%>
<% if redirect then %>
<div style="float:left">
<input class="cbi-button cbi-button-link" type="button" value="<%:Back to Overview%>" onclick="location.href='<%=pcdata(redirect)%>'" />
</div>
<% end %>
<%- if self.flow and self.flow.skip then %>
<input class="cbi-button cbi-button-skip" type="submit" name="cbi.skip" value="<%:Skip%>" />
<% end %>
<%- if self.submit ~= false then %>
<input class="cbi-button cbi-button-save" type="submit" value="
<%- if not self.submit then -%><%-:Submit-%><%-else-%><%=self.submit%><%end-%>
" />
<% end %>
<%- if self.reset ~= false then %>
<input class="cbi-button cbi-button-reset" type="reset" value="
<%- if not self.reset then -%><%-:Reset-%><%-else-%><%=self.reset%><%end-%>
" />
<% end %>
<%- if self.cancel ~= false and self.on_cancel then %>
<input class="cbi-button cbi-button-reset" type="submit" name="cbi.cancel" value="
<%- if not self.cancel then -%><%-:Cancel-%><%-else-%><%=self.cancel%><%end-%>
" />
<% end %>
<script type="text/javascript">cbi_d_update();</script>
</div>
</form>
<% end %>

View file

@ -0,0 +1,7 @@
<% for tab, data in pairs(self.tabs) do %>
<div class="cbi-tabcontainer" id="container.<%=self.config%>.<%=section%>.<%=tab%>"<% if tab ~= self.selected_tab then %> style="display:none"<% end %>>
<% if data.description then %><div class="cbi-tab-descr"><%=data.description%></div><% end %>
<% self:render_tab(tab, section, scope or {}) %>
</div>
<script type="text/javascript">cbi_t_add('<%=self.config%>.<%=section%>', '<%=tab%>')</script>
<% end %>

View file

@ -0,0 +1,12 @@
<%- if self.tabs then %>
<ul class="cbi-tabmenu">
<%- self.selected_tab = luci.http.formvalue("tab." .. self.config .. "." .. section) %>
<%- for _, tab in ipairs(self.tab_names) do if #self.tabs[tab].childs > 0 then %>
<%- if not self.selected_tab then self.selected_tab = tab end %>
<li id="tab.<%=self.config%>.<%=section%>.<%=tab%>" class="cbi-tab<%=(tab == self.selected_tab) and '' or '-disabled'%>">
<a onclick="this.blur(); return cbi_t_switch('<%=self.config%>.<%=section%>', '<%=tab%>')" href="<%=REQUEST_URI%>?tab.<%=self.config%>.<%=section%>=<%=tab%>"><%=self.tabs[tab].title%></a>
<% if tab == self.selected_tab then %><input type="hidden" id="tab.<%=self.config%>.<%=section%>" name="tab.<%=self.config%>.<%=section%>" value="<%=tab%>" /><% end %>
</li>
<% end end -%>
</ul>
<% end -%>

View file

@ -0,0 +1,145 @@
<%-
local rowcnt = 1
function rowstyle()
rowcnt = rowcnt + 1
return (rowcnt % 2) + 1
end
function width(o)
if o.width then
if type(o.width) == 'number' then
return ' style="width:%dpx"' % o.width
end
return ' style="width:%s"' % o.width
end
return ''
end
-%>
<!-- tblsection -->
<fieldset class="cbi-section" id="cbi-<%=self.config%>-<%=self.sectiontype%>">
<% if self.title and #self.title > 0 then -%>
<legend><%=self.title%></legend>
<%- end %>
<%- if self.sortable then -%>
<input type="hidden" id="cbi.sts.<%=self.config%>.<%=self.sectiontype%>" name="cbi.sts.<%=self.config%>.<%=self.sectiontype%>" value="" />
<%- end -%>
<div class="cbi-section-descr"><%=self.description%></div>
<div class="cbi-section-node">
<%- local count = 0 -%>
<table class="cbi-section-table">
<tr class="cbi-section-table-titles">
<%- if not self.anonymous then -%>
<%- if self.sectionhead then -%>
<th class="cbi-section-table-cell"><%=self.sectionhead%></th>
<%- else -%>
<th>&#160;</th>
<%- end -%>
<%- end -%>
<%- for i, k in pairs(self.children) do if not k.optional then -%>
<th class="cbi-section-table-cell"<%=width(k)%>>
<%- if k.titleref then -%><a title="<%=self.titledesc or translate('Go to relevant configuration page')%>" class="cbi-title-ref" href="<%=k.titleref%>"><%- end -%>
<%-=k.title-%>
<%- if k.titleref then -%></a><%- end -%>
</th>
<%- count = count + 1; end; end; if self.sortable then -%>
<th class="cbi-section-table-cell"><%:Sort%></th>
<%- end; if self.extedit or self.addremove then -%>
<th class="cbi-section-table-cell">&#160;</th>
<%- count = count + 1; end -%>
</tr>
<tr class="cbi-section-table-descr">
<%- if not self.anonymous then -%>
<%- if self.sectiondesc then -%>
<th class="cbi-section-table-cell"><%=self.sectiondesc%></th>
<%- else -%>
<th></th>
<%- end -%>
<%- end -%>
<%- for i, k in pairs(self.children) do if not k.optional then -%>
<th class="cbi-section-table-cell"<%=width(k)%>><%=k.description%></th>
<%- end; end; if self.sortable then -%>
<th class="cbi-section-table-cell"></th>
<%- end; if self.extedit or self.addremove then -%>
<th class="cbi-section-table-cell"></th>
<%- end -%>
</tr>
<%- local isempty = true
for i, k in ipairs(self:cfgsections()) do
section = k
isempty = false
scope = { valueheader = "cbi/cell_valueheader", valuefooter = "cbi/cell_valuefooter" }
-%>
<tr class="cbi-section-table-row<% if self.extedit or self.rowcolors then %> cbi-rowstyle-<%=rowstyle()%><% end %>" id="cbi-<%=self.config%>-<%=section%>">
<% if not self.anonymous then -%>
<th><h3><%=(type(self.sectiontitle) == "function") and self:sectiontitle(section) or k%></h3></th>
<%- end %>
<%-
for k, node in ipairs(self.children) do
if not node.optional then
node:render(section, scope or {})
end
end
-%>
<%- if self.sortable then -%>
<td class="cbi-section-table-cell">
<input class="cbi-button cbi-button-up" type="button" value="" onclick="return cbi_row_swap(this, true, 'cbi.sts.<%=self.config%>.<%=self.sectiontype%>')" alt="<%:Move up%>" title="<%:Move up%>" />
<input class="cbi-button cbi-button-down" type="button" value="" onclick="return cbi_row_swap(this, false, 'cbi.sts.<%=self.config%>.<%=self.sectiontype%>')" alt="<%:Move down%>" title="<%:Move down%>" />
</td>
<%- end -%>
<%- if self.extedit or self.addremove then -%>
<td class="cbi-section-table-cell">
<%- if self.extedit then -%>
<input class="cbi-button cbi-button-edit" type="button" value="<%:Edit%>"
<%- if type(self.extedit) == "string" then
%> onclick="location.href='<%=self.extedit:format(section)%>'"
<%- elseif type(self.extedit) == "function" then
%> onclick="location.href='<%=self:extedit(section)%>'"
<%- end
%> alt="<%:Edit%>" title="<%:Edit%>" />
<%- end; if self.addremove then %>
<input class="cbi-button cbi-button-remove" type="submit" value="<%:Delete%>" onclick="this.form.cbi_state='del-section'; return true" name="cbi.rts.<%=self.config%>.<%=k%>" alt="<%:Delete%>" title="<%:Delete%>" />
<%- end -%>
</td>
<%- end -%>
</tr>
<%- end -%>
<%- if isempty then -%>
<tr class="cbi-section-table-row">
<td colspan="<%=count%>"><em><br /><%:This section contains no values yet%></em></td>
</tr>
<%- end -%>
</table>
<% if self.error then %>
<div class="cbi-section-error">
<ul><% for _, c in pairs(self.error) do for _, e in ipairs(c) do -%>
<li><%=pcdata(e):gsub("\n","<br />")%></li>
<%- end end %></ul>
</div>
<% end %>
<%- if self.addremove then -%>
<% if self.template_addremove then include(self.template_addremove) else -%>
<div class="cbi-section-create cbi-tblsection-create">
<% if self.anonymous then %>
<input class="cbi-button cbi-button-add" type="submit" value="<%:Add%>" name="cbi.cts.<%=self.config%>.<%=self.sectiontype%>.<%=section%>" title="<%:Add%>" />
<% else %>
<% if self.invalid_cts then -%><div class="cbi-section-error"><% end %>
<input type="text" class="cbi-section-create-name" id="cbi.cts.<%=self.config%>.<%=self.sectiontype%>.<%=section%>" name="cbi.cts.<%=self.config%>.<%=self.sectiontype%>.<%=section%>" data-type="uciname" data-optional="true" />
<input class="cbi-button cbi-button-add" type="submit" onclick="this.form.cbi_state='add-section'; return true" value="<%:Add%>" title="<%:Add%>" />
<% if self.invalid_cts then -%>
<br /><%:Invalid%></div>
<%- end %>
<% end %>
</div>
<%- end %>
<%- end -%>
</div>
</fieldset>
<!-- /tblsection -->

View file

@ -0,0 +1,49 @@
<fieldset class="cbi-section" id="cbi-<%=self.config%>-<%=self.sectiontype%>">
<% if self.title and #self.title > 0 then -%>
<legend><%=self.title%></legend>
<%- end %>
<% if self.description and #self.description > 0 then -%>
<div class="cbi-section-descr"><%=self.description%></div>
<%- end %>
<% local isempty = true for i, k in ipairs(self:cfgsections()) do -%>
<% if self.addremove then -%>
<div class="cbi-section-remove right">
<input type="submit" name="cbi.rts.<%=self.config%>.<%=k%>" onclick="this.form.cbi_state='del-section'; return true" value="<%:Delete%>" class="cbi-button" />
</div>
<%- end %>
<%- section = k; isempty = false -%>
<% if not self.anonymous then -%>
<h3><%=section:upper()%></h3>
<%- end %>
<%+cbi/tabmenu%>
<fieldset class="cbi-section-node<% if self.tabs then %> cbi-section-node-tabbed<% end %>" id="cbi-<%=self.config%>-<%=section%>">
<%+cbi/ucisection%>
</fieldset>
<br />
<%- end %>
<% if isempty then -%>
<em><%:This section contains no values yet%><br /><br /></em>
<%- end %>
<% if self.addremove then -%>
<% if self.template_addremove then include(self.template_addremove) else -%>
<div class="cbi-section-create">
<% if self.anonymous then -%>
<input type="submit" class="cbi-button cbi-button-add" name="cbi.cts.<%=self.config%>.<%=self.sectiontype%>.<%=section%>" value="<%:Add%>" />
<%- else -%>
<% if self.invalid_cts then -%><div class="cbi-section-error"><% end %>
<input type="text" class="cbi-section-create-name" id="cbi.cts.<%=self.config%>.<%=self.sectiontype%>.<%=section%>" name="cbi.cts.<%=self.config%>.<%=self.sectiontype%>.<%=section%>" data-type="uciname" data-optional="true" />
<input type="submit" class="cbi-button cbi-button-add" onclick="this.form.cbi_state='add-section'; return true" value="<%:Add%>" />
<% if self.invalid_cts then -%>
<br /><%:Invalid%></div>
<%- end %>
<%- end %>
</div>
<%- end %>
<%- end %>
</fieldset>

View file

@ -0,0 +1,5 @@
<%+cbi/valueheader%>
<textarea class="cbi-input-textarea" <% if not self.size then %> style="width: 100%"<% else %> cols="<%=self.size%>"<% end %> data-update="change"<%= attr("name", cbid) .. attr("id", cbid) .. ifattr(self.rows, "rows") .. ifattr(self.wrap, "wrap") .. ifattr(self.readonly, "readonly") %>>
<%-=pcdata(self:cfgvalue(section))-%>
</textarea>
<%+cbi/valuefooter%>

View file

@ -0,0 +1,56 @@
<%-
if type(self.hidden) == "table" then
for k, v in pairs(self.hidden) do
-%>
<input type="hidden" id="<%=k%>" name="<%=k%>" value="<%=pcdata(v)%>" />
<%-
end
end
%>
<% if self.tabs then %>
<%+cbi/tabcontainer%>
<% else %>
<% self:render_children(section, scope or {}) %>
<% end %>
<% if self.error and self.error[section] then -%>
<div class="cbi-section-error" data-index="<%=#self.children + 1%>">
<ul><% for _, e in ipairs(self.error[section]) do -%>
<li>
<%- if e == "invalid" then -%>
<%:One or more fields contain invalid values!%>
<%- elseif e == "missing" then -%>
<%:One or more required fields have no value!%>
<%- else -%>
<%=pcdata(e)%>
<%- end -%>
</li>
<%- end %></ul>
</div>
<%- end %>
<% if self.optionals[section] and #self.optionals[section] > 0 or self.dynamic then %>
<div class="cbi-optionals" data-index="<%=#self.children + 1%>">
<%
if self.dynamic then
local keys, vals, name, opt = { }, { }
for name, opt in pairs(self.optionals[section]) do
keys[#keys+1] = name
vals[#vals+1] = opt.title
end
%>
<input type="text" id="cbi.opt.<%=self.config%>.<%=section%>" name="cbi.opt.<%=self.config%>.<%=section%>" data-type="uciname" data-optional="true"<%=
ifattr(#keys > 0, "data-choices", luci.util.json_encode({keys, vals}))
%> />
<% else %>
<select id="cbi.opt.<%=self.config%>.<%=section%>" name="cbi.opt.<%=self.config%>.<%=section%>" data-optionals="true">
<option><%: -- Additional Field -- %></option>
<% for key, val in pairs(self.optionals[section]) do -%>
<option id="cbi-<%=self.config.."-"..section.."-"..val.option%>" value="<%=val.option%>" data-index="<%=val.index%>" data-depends="<%=pcdata(val:deplist2json(section))%>"><%=striptags(val.title)%></option>
<%- end %>
</select>
<% end %>
<input type="submit" class="cbi-button cbi-button-fieldadd" value="<%:Add%>" />
</div>
<% end %>

View file

@ -0,0 +1,24 @@
<%
local t = require("luci.tools.webadmin")
local v = self:cfgvalue(section)
local s = v and nixio.fs.stat(v)
-%>
<%+cbi/valueheader%>
<% if s then %>
<%:Uploaded File%> (<%=t.byte_format(s.size)%>)
<% if self.unsafeupload then %>
<input type="hidden"<%= attr("value", v) .. attr("name", cbid) .. attr("id", cbid) %> />
<input class="cbi-button cbi-input-image" type="image" value="<%:Replace entry%>" name="cbi.rlf.<%=section .. "." .. self.option%>" alt="<%:Replace entry%>" title="<%:Replace entry%>" src="<%=resource%>/cbi/reload.gif" />
<% end %>
<% end %>
<% if not self.unsafeupload then %>
<input type="hidden"<%= attr("value", v) .. attr("name", "cbi.rlf." .. section .. "." .. self.option) .. attr("id", "cbi.rlf." .. section .. "." .. self.option) %> />
<% end %>
<% if (not s) or (s and not self.unsafeupload) then %>
<input class="cbi-input-file" type="file"<%= attr("name", cbid) .. attr("id", cbid) %> />
<% end %>
<input type="text" class="cbi-input-text" data-update="change"<%=
attr("name", cbid .. ".textbox") .. attr("id", cbid .. ".textbox") .. attr("value", luci.cbi.AbstractValue.cfgvalue(self, section) or self.default) .. ifattr(self.size, "size") .. ifattr(self.placeholder, "placeholder") .. ifattr(self.readonly, "readonly") .. ifattr(self.maxlength, "maxlength") %> />
<%+cbi/valuefooter%>

View file

@ -0,0 +1,18 @@
<%+cbi/valueheader%>
<input data-update="change"<%=
attr("id", cbid) ..
attr("name", cbid) ..
attr("type", self.password and "password" or "text") ..
attr("class", self.password and "cbi-input-password" or "cbi-input-text") ..
attr("value", self:cfgvalue(section) or self.default) ..
ifattr(self.size, "size") ..
ifattr(self.placeholder, "placeholder") ..
ifattr(self.readonly, "readonly") ..
ifattr(self.maxlength, "maxlength") ..
ifattr(self.datatype, "data-type", self.datatype) ..
ifattr(self.datatype, "data-optional", self.optional or self.rmempty) ..
ifattr(self.combobox_manual, "data-manual", self.combobox_manual) ..
ifattr(#self.keylist > 0, "data-choices", { self.keylist, self.vallist })
%> />
<% if self.password then %><img src="<%=resource%>/cbi/reload.gif" style="vertical-align:middle" title="<%:Reveal/hide password%>" onclick="var e = document.getElementById('<%=cbid%>'); e.type = (e.type=='password') ? 'text' : 'password';" /><% end %>
<%+cbi/valuefooter%>

View file

@ -0,0 +1 @@
<% include( valuefooter or "cbi/full_valuefooter" ) %>

View file

@ -0,0 +1 @@
<% include( valueheader or "cbi/full_valueheader" ) %>

View file

@ -0,0 +1,24 @@
<%#
Copyright 2015 Jo-Philipp Wich <jow@openwrt.org>
Licensed to the public under the Apache License 2.0.
-%>
<%+header%>
<h2 name="content"><%:Form token mismatch%></h2>
<br />
<p class="alert-message"><%:The submitted security token is invalid or already expired!%></p>
<p><%:
In order to prevent unauthorized access to the system, your request has
been blocked. Click "Continue »" below to return to the previous page.
%></p>
<hr />
<p class="right">
<strong><a href="#" onclick="window.history.back();">Continue »</a></strong>
</p>
<%+footer%>

View file

@ -0,0 +1,11 @@
<%#
Copyright 2008 Steven Barth <steven@midlink.org>
Copyright 2008 Jo-Philipp Wich <jow@openwrt.org>
Licensed to the public under the Apache License 2.0.
-%>
<%+header%>
<h2 name="content">404 <%:Not Found%></h2>
<p><%:Sorry, the object you requested was not found.%></p>
<tt><%:Unable to dispatch%>: <%=luci.http.request.env.PATH_INFO%></tt>
<%+footer%>

View file

@ -0,0 +1,11 @@
<%#
Copyright 2008 Steven Barth <steven@midlink.org>
Copyright 2008 Jo-Philipp Wich <jow@openwrt.org>
Licensed to the public under the Apache License 2.0.
-%>
<%+header%>
<h2 name="content">500 <%:Internal Server Error%></h2>
<p><%:Sorry, the server encountered an unexpected error.%></p>
<pre class="error500"><%=message%></pre>
<%+footer%>

View file

@ -0,0 +1,7 @@
<%#
Copyright 2008 Steven Barth <steven@midlink.org>
Copyright 2008 Jo-Philipp Wich <jow@openwrt.org>
Licensed to the public under the Apache License 2.0.
-%>
<% include("themes/" .. theme .. "/footer") %>

View file

@ -0,0 +1,12 @@
<%#
Copyright 2008 Steven Barth <steven@midlink.org>
Copyright 2008 Jo-Philipp Wich <jow@openwrt.org>
Licensed to the public under the Apache License 2.0.
-%>
<%
if not luci.dispatcher.context.template_header_sent then
include("themes/" .. theme .. "/header")
luci.dispatcher.context.template_header_sent = true
end
%>

View file

@ -0,0 +1,7 @@
<%#
Copyright 2008 Steven Barth <steven@midlink.org>
Copyright 2008 Jo-Philipp Wich <jow@openwrt.org>
Licensed to the public under the Apache License 2.0.
-%>
<% include("themes/" .. theme .. "/indexer") %>

View file

@ -0,0 +1,73 @@
<%#
Copyright 2008 Steven Barth <steven@midlink.org>
Copyright 2008-2012 Jo-Philipp Wich <jow@openwrt.org>
Licensed to the public under the Apache License 2.0.
-%>
<%+header%>
<form method="post" action="<%=pcdata(luci.http.getenv("REQUEST_URI"))%>">
<%- if fuser then %>
<div class="errorbox"><%:Invalid username and/or password! Please try again.%></div>
<% end -%>
<div class="cbi-map">
<h2 name="content"><%:Authorization Required%></h2>
<div class="cbi-map-descr">
<%:Please enter your username and password.%>
</div>
<fieldset class="cbi-section"><fieldset class="cbi-section-node">
<div class="cbi-value">
<label class="cbi-value-title"><%:Username%></label>
<div class="cbi-value-field">
<input class="cbi-input-user" type="text" name="luci_username" value="<%=duser%>" />
</div>
</div>
<div class="cbi-value cbi-value-last">
<label class="cbi-value-title"><%:Password%></label>
<div class="cbi-value-field">
<input class="cbi-input-password" type="password" name="luci_password" />
</div>
</div>
</fieldset></fieldset>
</div>
<div>
<input type="submit" value="<%:Login%>" class="cbi-button cbi-button-apply" />
<input type="reset" value="<%:Reset%>" class="cbi-button cbi-button-reset" />
</div>
</form>
<script type="text/javascript">//<![CDATA[
var input = document.getElementsByName('luci_password')[0];
if (input)
input.focus();
//]]></script>
<%
local uci = require "luci.model.uci".cursor()
local fs = require "nixio.fs"
local https_key = uci:get("uhttpd", "main", "key")
local https_port = uci:get("uhttpd", "main", "listen_https")
if type(https_port) == "table" then
https_port = https_port[1]
end
if https_port and fs.access(https_key) then
https_port = https_port:match("(%d+)$")
%>
<script type="text/javascript">//<![CDATA[
if (document.location.protocol != 'https:') {
var url = 'https://' + window.location.hostname + ':' + '<%=https_port%>' + window.location.pathname;
var img=new Image;
img.onload=function(){window.location = url};
img.src='https://' + window.location.hostname + ':' + '<%=https_port%>' + '<%=resource%>/cbi/up.gif?' + Math.random();;
setTimeout(function(){
img.src=''
}, 5000);
}
//]]></script>
<% end %>
<%+footer%>