diff options
Diffstat (limited to 'modules/base/luasrc/view')
36 files changed, 1219 insertions, 0 deletions
diff --git a/modules/base/luasrc/view/cbi/apply_xhr.htm b/modules/base/luasrc/view/cbi/apply_xhr.htm new file mode 100644 index 000000000..1814c9393 --- /dev/null +++ b/modules/base/luasrc/view/cbi/apply_xhr.htm @@ -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.get('<%=luci.dispatcher.build_url("servicectl", "restart", table.concat(configs, ","))%>', null, + function() { + var checkfinish = function() { + apply_xhr.get('<%=luci.dispatcher.build_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) %> diff --git a/modules/base/luasrc/view/cbi/browser.htm b/modules/base/luasrc/view/cbi/browser.htm new file mode 100644 index 000000000..e4a4077d5 --- /dev/null +++ b/modules/base/luasrc/view/cbi/browser.htm @@ -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%>', '<%=luci.dispatcher.build_url("admin", "filebrowser")%>'<%=self.default_path and ", '"..self.default_path.."'"%>); + </script> +<%+cbi/valuefooter%> diff --git a/modules/base/luasrc/view/cbi/button.htm b/modules/base/luasrc/view/cbi/button.htm new file mode 100644 index 000000000..30f8ddfda --- /dev/null +++ b/modules/base/luasrc/view/cbi/button.htm @@ -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%> diff --git a/modules/base/luasrc/view/cbi/cell_valuefooter.htm b/modules/base/luasrc/view/cbi/cell_valuefooter.htm new file mode 100644 index 000000000..220ebd42b --- /dev/null +++ b/modules/base/luasrc/view/cbi/cell_valuefooter.htm @@ -0,0 +1,20 @@ +</div> +<div id="cbip-<%=self.config.."-"..section.."-"..self.option%>"></div> +</td> + +<% if #self.deps > 0 then -%> + <script type="text/javascript"> + <% for j, d in ipairs(self.deps) do -%> + cbi_d_add("cbi-<%=self.config.."-"..section.."-"..self.option..d.add%>", { + <%- + for k,v in pairs(d.deps) do + -%> + <%-=string.format('"cbid.%s.%s.%s"', self.config, section, k) .. ":" .. string.format("%q", v)-%> + <%-if next(d.deps, k) then-%>,<%-end-%> + <%- + end + -%> + }, "cbip-<%=self.config.."-"..section.."-"..self.option%>"); + <%- end %> + </script> +<%- end %> diff --git a/modules/base/luasrc/view/cbi/cell_valueheader.htm b/modules/base/luasrc/view/cbi/cell_valueheader.htm new file mode 100644 index 000000000..9e2e145dd --- /dev/null +++ b/modules/base/luasrc/view/cbi/cell_valueheader.htm @@ -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%>"> diff --git a/modules/base/luasrc/view/cbi/compound.htm b/modules/base/luasrc/view/cbi/compound.htm new file mode 100644 index 000000000..12d02bb1d --- /dev/null +++ b/modules/base/luasrc/view/cbi/compound.htm @@ -0,0 +1 @@ +<%- self:render_children() %> diff --git a/modules/base/luasrc/view/cbi/delegator.htm b/modules/base/luasrc/view/cbi/delegator.htm new file mode 100644 index 000000000..4fd19265d --- /dev/null +++ b/modules/base/luasrc/view/cbi/delegator.htm @@ -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> diff --git a/modules/base/luasrc/view/cbi/dvalue.htm b/modules/base/luasrc/view/cbi/dvalue.htm new file mode 100644 index 000000000..78e6f323d --- /dev/null +++ b/modules/base/luasrc/view/cbi/dvalue.htm @@ -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%> diff --git a/modules/base/luasrc/view/cbi/dynlist.htm b/modules/base/luasrc/view/cbi/dynlist.htm new file mode 100644 index 000000000..fd626a4ec --- /dev/null +++ b/modules/base/luasrc/view/cbi/dynlist.htm @@ -0,0 +1,26 @@ +<%+cbi/valueheader%> +<div> +<% + 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)%>" onchange="cbi_d_update(this.id)" 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> +<script type="text/javascript"> +cbi_dynlist_init( + '<%=cbid%>', '<%=resource%>', '<%=self.datatype%>', + <%=tostring(self.optional or self.rmempty)%> + <%- if #self.keylist > 0 then -%>, [{ + <%- for i, k in ipairs(self.keylist) do -%> + <%-=string.format("%q", k) .. ":" .. string.format("%q", self.vallist[i])-%> + <%-if i<#self.keylist then-%>,<%-end-%> + <%- end -%> + }, '<%: -- custom -- %>']<% end -%>); +</script> +<%+cbi/valuefooter%> diff --git a/modules/base/luasrc/view/cbi/filebrowser.htm b/modules/base/luasrc/view/cbi/filebrowser.htm new file mode 100644 index 000000000..a79beebba --- /dev/null +++ b/modules/base/luasrc/view/cbi/filebrowser.htm @@ -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> diff --git a/modules/base/luasrc/view/cbi/firewall_zoneforwards.htm b/modules/base/luasrc/view/cbi/firewall_zoneforwards.htm new file mode 100644 index 000000000..2a433b569 --- /dev/null +++ b/modules/base/luasrc/view/cbi/firewall_zoneforwards.htm @@ -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> +  ⇒  + <% 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>  + <% end %> + <% if empty then %> + <label class="zonebadge zonebadge-empty"> + <strong><%=zone:forward():upper()%></strong> + </label> + <% end %> +</div> +<% end %> + +<%+cbi/valuefooter%> diff --git a/modules/base/luasrc/view/cbi/firewall_zonelist.htm b/modules/base/luasrc/view/cbi/firewall_zonelist.htm new file mode 100644 index 000000000..7973437f4 --- /dev/null +++ b/modules/base/luasrc/view/cbi/firewall_zonelist.htm @@ -0,0 +1,89 @@ +<%+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" onclick="cbi_d_update(this.id)" onchange="cbi_d_update(this.id)"<%=attr("type", self.widget or "radio") .. attr("id", cbid .. "_empty") .. attr("name", cbid) .. attr("value", "") .. ifattr(checked[""], "checked", "checked")%> />   + <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" onclick="cbi_d_update(this.id)" onchange="cbi_d_update(this.id)"<%=attr("type", self.widget or "radio") .. attr("id", cbid .. "_any") .. attr("name", cbid) .. attr("value", "*") .. ifattr(checked["*"], "checked", "checked")%> />   + <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" onclick="cbi_d_update(this.id)" onchange="cbi_d_update(this.id)"<%=attr("type", self.widget or "radio") .. attr("id", cbid .. "." .. zone:name()) .. attr("name", cbid) .. attr("value", zone:name()) .. ifattr(checked[zone:name()], "checked", "checked")%> />   + <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" onclick="cbi_d_update(this.id)" onchange="cbi_d_update(this.id)" type="radio"<%=attr("id", cbid .. "_new") .. attr("name", cbid) .. attr("value", "-") .. ifattr(not selected, "checked", "checked")%> />   + <div onclick="document.getElementById('<%=cbid%>_new').checked=true" class="zonebadge" style="background-color:<%=fwm.zone.get_color()%>"> + <em><%:unspecified -or- create:%> </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%> diff --git a/modules/base/luasrc/view/cbi/footer.htm b/modules/base/luasrc/view/cbi/footer.htm new file mode 100644 index 000000000..2c34028e5 --- /dev/null +++ b/modules/base/luasrc/view/cbi/footer.htm @@ -0,0 +1,26 @@ + <%- 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="reset" value="<%:Reset%>" /> + <% end %> + + <script type="text/javascript">cbi_d_update();</script> + </div> + <%- end -%> +</form> +<%+footer%> diff --git a/modules/base/luasrc/view/cbi/full_valuefooter.htm b/modules/base/luasrc/view/cbi/full_valuefooter.htm new file mode 100644 index 000000000..4876fbcc9 --- /dev/null +++ b/modules/base/luasrc/view/cbi/full_valuefooter.htm @@ -0,0 +1,59 @@ + <% 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> + + +<% if #self.deps > 0 or #self.subdeps > 0 then -%> + <script type="text/javascript" id="cbip-<%=self.config.."-"..section.."-"..self.option%>"> + <% for j, d in ipairs(self.subdeps) do -%> + cbi_d_add("cbi-<%=self.config.."-"..section.."-"..self.option..d.add%>", { + <%- + for k,v in pairs(d.deps) do + local depk + if k:find("!", 1, true) then + depk = string.format('"%s"', k) + elseif k:find(".", 1, true) then + depk = string.format('"cbid.%s"', k) + else + depk = string.format('"cbid.%s.%s.%s"', self.config, section, k) + end + -%> + <%-= depk .. ":" .. string.format("%q", v)-%> + <%-if next(d.deps, k) then-%>,<%-end-%> + <%- + end + -%> + }, "cbip-<%=self.config.."-"..section.."-"..self.option..d.add%>"); + <%- end %> + <% for j, d in ipairs(self.deps) do -%> + cbi_d_add("cbi-<%=self.config.."-"..section.."-"..self.option..d.add%>", { + <%- + for k,v in pairs(d.deps) do + local depk + if k:find("!", 1, true) then + depk = string.format('"%s"', k) + elseif k:find(".", 1, true) then + depk = string.format('"cbid.%s"', k) + else + depk = string.format('"cbid.%s.%s.%s"', self.config, section, k) + end + -%> + <%-= depk .. ":" .. string.format("%q", v)-%> + <%-if next(d.deps, k) then-%>,<%-end-%> + <%- + end + -%> + }, "cbip-<%=self.config.."-"..section.."-"..self.option..d.add%>"); + <%- end %> + </script> +<%- end %> diff --git a/modules/base/luasrc/view/cbi/full_valueheader.htm b/modules/base/luasrc/view/cbi/full_valueheader.htm new file mode 100644 index 000000000..aaf085473 --- /dev/null +++ b/modules/base/luasrc/view/cbi/full_valueheader.htm @@ -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%>"> + <%- 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 -%> diff --git a/modules/base/luasrc/view/cbi/fvalue.htm b/modules/base/luasrc/view/cbi/fvalue.htm new file mode 100644 index 000000000..a1e0808e8 --- /dev/null +++ b/modules/base/luasrc/view/cbi/fvalue.htm @@ -0,0 +1,9 @@ +<%+cbi/valueheader%> + <input type="hidden" value="1"<%= + attr("name", "cbi.cbe." .. self.config .. "." .. section .. "." .. self.option) + %> /> + <input class="cbi-input-checkbox" onclick="cbi_d_update(this.id)" onchange="cbi_d_update(this.id)" 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") + %> /> +<%+cbi/valuefooter%> diff --git a/modules/base/luasrc/view/cbi/header.htm b/modules/base/luasrc/view/cbi/header.htm new file mode 100644 index 000000000..2bddaba61 --- /dev/null +++ b/modules/base/luasrc/view/cbi/header.htm @@ -0,0 +1,7 @@ +<%+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"></script> + <input type="hidden" name="cbi.submit" value="1" /> + <input type="submit" value="<%:Save%>" class="hidden" /> + </div> diff --git a/modules/base/luasrc/view/cbi/lvalue.htm b/modules/base/luasrc/view/cbi/lvalue.htm new file mode 100644 index 000000000..8cc086db4 --- /dev/null +++ b/modules/base/luasrc/view/cbi/lvalue.htm @@ -0,0 +1,18 @@ +<%+cbi/valueheader%> +<% if self.widget == "select" then %> + <select class="cbi-input-select" onchange="cbi_d_update(this.id)"<%= attr("id", cbid) .. attr("name", cbid) .. ifattr(self.size, "size") %>> + <% for i, key in pairs(self.keylist) do -%> + <option id="cbi-<%=self.config.."-"..section.."-"..self.option.."-"..key%>"<%= attr("value", key) .. ifattr(tostring(self:cfgvalue(section) or self.default) == key, "selected", "selected") %>><%=striptags(self.vallist[i])%></option> + <%- end %> + </select> +<% elseif self.widget == "radio" then + local c = 0 + for i, key in pairs(self.keylist) do + c = c + 1 +%> + <input class="cbi-input-radio" onclick="cbi_d_update(this.id)" onchange="cbi_d_update(this.id)" type="radio"<%= attr("id", cbid..c) .. attr("name", cbid) .. attr("value", key) .. ifattr((self:cfgvalue(section) or self.default) == key, "checked", "checked") %> /> + <label<%= attr("for", cbid..c) %>><%=self.vallist[i]%></label> +<% if c == self.size then c = 0 %><% if self.orientation == "horizontal" then %> <% else %><br /><% end %> +<% end end %> +<% end %> +<%+cbi/valuefooter%> diff --git a/modules/base/luasrc/view/cbi/map.htm b/modules/base/luasrc/view/cbi/map.htm new file mode 100644 index 000000000..053220d18 --- /dev/null +++ b/modules/base/luasrc/view/cbi/map.htm @@ -0,0 +1,13 @@ +<%- 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><a id="content" name="content"><%=self.title%></a></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 -%> + <%- self:render_children() %> + <br /> +</div> diff --git a/modules/base/luasrc/view/cbi/mvalue.htm b/modules/base/luasrc/view/cbi/mvalue.htm new file mode 100644 index 000000000..6a0b3881d --- /dev/null +++ b/modules/base/luasrc/view/cbi/mvalue.htm @@ -0,0 +1,19 @@ +<% local v = self:valuelist(section) or {} -%> +<%+cbi/valueheader%> +<% if self.widget == "select" then %> + <select class="cbi-input-select" multiple="multiple" onclick="cbi_d_update(this.id)" onchange="cbi_d_update(this.id)"<%= attr("name", cbid) .. ifattr(self.size, "size") %>> + <% for i, key in pairs(self.keylist) do -%> + <option<%= attr("value", key) .. ifattr(luci.util.contains(v, key), "selected", "selected") %>><%=striptags(self.vallist[i])%></option> + <%- end %> + </select> +<% elseif self.widget == "checkbox" then + local c = 0; + for i, key in pairs(self.keylist) do + c = c + 1 +%> + <input class="cbi-input-checkbox" type="checkbox" onclick="cbi_d_update(this.id)" onchange="cbi_d_update(this.id)"<%= attr("id", cbid..c) .. attr("name", cbid) .. attr("value", key) .. ifattr(luci.util.contains(v, key), "checked", "checked") %> /> + <label<%= attr("for", cbid..c) %>><%=self.vallist[i]%></label><br /> +<% if c == self.size then c = 0 %><br /> +<% end end %> +<% end %> +<%+cbi/valuefooter%> diff --git a/modules/base/luasrc/view/cbi/network_ifacelist.htm b/modules/base/luasrc/view/cbi/network_ifacelist.htm new file mode 100644 index 000000000..643d849a5 --- /dev/null +++ b/modules/base/luasrc/view/cbi/network_ifacelist.htm @@ -0,0 +1,81 @@ +<%+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"%>" onclick="cbi_d_update(this.id)" onchange="cbi_d_update(this.id)"<%= + attr("type", self.widget or "radio") .. + attr("id", cbid .. "." .. iface:name()) .. + attr("name", cbid) .. attr("value", iface:name()) .. + ifattr(checked[iface:name()], "checked", "checked") + %> />   + <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"%>" onclick="cbi_d_update(this.id)" onchange="cbi_d_update(this.id)"<%= + attr("type", self.widget or "radio") .. + attr("id", cbid .. "_custom") .. + attr("name", cbid) .. + attr("value", " ") + %> />   + <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%> diff --git a/modules/base/luasrc/view/cbi/network_netinfo.htm b/modules/base/luasrc/view/cbi/network_netinfo.htm new file mode 100644 index 000000000..4fd84112a --- /dev/null +++ b/modules/base/luasrc/view/cbi/network_netinfo.htm @@ -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%> diff --git a/modules/base/luasrc/view/cbi/network_netlist.htm b/modules/base/luasrc/view/cbi/network_netlist.htm new file mode 100644 index 000000000..7e23d149a --- /dev/null +++ b/modules/base/luasrc/view/cbi/network_netlist.htm @@ -0,0 +1,81 @@ +<%+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"%>" onclick="cbi_d_update(this.id)" onchange="cbi_d_update(this.id)"<%= + attr("type", self.widget or "radio") .. + attr("id", cbid .. "." .. net:name()) .. + attr("name", cbid) .. attr("value", net:name()) .. + ifattr(checked[net:name()], "checked", "checked") + %> />   + <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"%>" onclick="cbi_d_update(this.id)" onchange="cbi_d_update(this.id)"<%=attr("type", self.widget or "radio") .. attr("id", cbid .. "_new") .. attr("name", cbid) .. attr("value", "-") .. ifattr(not value and self.widget ~= "checkbox", "checked", "checked")%> />   + <div style="padding:0.5em; display:inline"> + <label<%=attr("for", cbid .. "_new")%>><em> + <%- if self.widget == "checkbox" then -%> + <%:create:%> + <%- else -%> + <%:unspecified -or- create:%> + <%- end -%> </em></label> + <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"%>" onclick="cbi_d_update(this.id)" onchange="cbi_d_update(this.id)"<%= + attr("type", self.widget or "radio") .. + attr("id", cbid .. "_uns") .. + attr("name", cbid) .. + attr("value", "") .. + ifattr(not value or #value == 0, "checked", "checked") + %> />   + <div style="padding:0.5em; display:inline"> + <label<%=attr("for", cbid .. "_uns")%>><em><%:unspecified%></em></label> + </div> + </li> + <% end %> +</ul> + +<%+cbi/valuefooter%> diff --git a/modules/base/luasrc/view/cbi/nsection.htm b/modules/base/luasrc/view/cbi/nsection.htm new file mode 100644 index 000000000..95e765882 --- /dev/null +++ b/modules/base/luasrc/view/cbi/nsection.htm @@ -0,0 +1,31 @@ +<% if self:cfgvalue(self.section) then section = self.section %> + <fieldset class="cbi-section" id="cbi-<%=self.config%>-<%=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" 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-add" name="cbi.cns.<%=self.config%>.<%=self.section%>" value="<%:Add%>" /> + </fieldset> + <%- end %> +<% end %> +<!-- /nsection --> diff --git a/modules/base/luasrc/view/cbi/nullsection.htm b/modules/base/luasrc/view/cbi/nullsection.htm new file mode 100644 index 000000000..bd4895095 --- /dev/null +++ b/modules/base/luasrc/view/cbi/nullsection.htm @@ -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" id="cbi-<%=self.config%>-<%=tostring(self):sub(8)%>"> + <div> + <% 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 +%> diff --git a/modules/base/luasrc/view/cbi/simpleform.htm b/modules/base/luasrc/view/cbi/simpleform.htm new file mode 100644 index 000000000..5216cd50f --- /dev/null +++ b/modules/base/luasrc/view/cbi/simpleform.htm @@ -0,0 +1,57 @@ +<% 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="cbi.submit" value="1" /> + </div> +<% end %> + <div class="cbi-map" id="cbi-<%=self.config%>"> + <% if self.title and #self.title > 0 then %><h2><a id="content" name="content"><%=self.title%></a></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 %> diff --git a/modules/base/luasrc/view/cbi/tabcontainer.htm b/modules/base/luasrc/view/cbi/tabcontainer.htm new file mode 100644 index 000000000..38c435d6a --- /dev/null +++ b/modules/base/luasrc/view/cbi/tabcontainer.htm @@ -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 %> diff --git a/modules/base/luasrc/view/cbi/tabmenu.htm b/modules/base/luasrc/view/cbi/tabmenu.htm new file mode 100644 index 000000000..b96ac9ce4 --- /dev/null +++ b/modules/base/luasrc/view/cbi/tabmenu.htm @@ -0,0 +1,13 @@ +<%- 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 %> + <script type="text/javascript">cbi_c['container.<%=self.config%>.<%=section%>.<%=tab%>'] = <%=#self.tabs[tab].childs%>;</script> + <%- 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 -%> diff --git a/modules/base/luasrc/view/cbi/tblsection.htm b/modules/base/luasrc/view/cbi/tblsection.htm new file mode 100644 index 000000000..d92879116 --- /dev/null +++ b/modules/base/luasrc/view/cbi/tblsection.htm @@ -0,0 +1,146 @@ +<%- +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> </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"> </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%>" /> + <script type="text/javascript">cbi_validate_field('cbi.cts.<%=self.config%>.<%=self.sectiontype%>.<%=section%>', true, 'uciname');</script> + <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 --> diff --git a/modules/base/luasrc/view/cbi/tsection.htm b/modules/base/luasrc/view/cbi/tsection.htm new file mode 100644 index 000000000..087548bf2 --- /dev/null +++ b/modules/base/luasrc/view/cbi/tsection.htm @@ -0,0 +1,48 @@ +<fieldset class="cbi-section" id="cbi-<%=self.config%>-<%=self.sectiontype%>"> + <% if self.title and #self.title > 0 then -%> + <legend><%=self.title%></legend> + <%- end %> + <div class="cbi-section-descr"><%=self.description%></div> + <% 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%>" /> + <script type="text/javascript">cbi_validate_field('cbi.cts.<%=self.config%>.<%=self.sectiontype%>.<%=section%>', true, 'uciname');</script> + <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> diff --git a/modules/base/luasrc/view/cbi/tvalue.htm b/modules/base/luasrc/view/cbi/tvalue.htm new file mode 100644 index 000000000..fcf7a6c94 --- /dev/null +++ b/modules/base/luasrc/view/cbi/tvalue.htm @@ -0,0 +1,5 @@ +<%+cbi/valueheader%> + <textarea class="cbi-input-textarea" <% if not self.size then %> style="width: 100%"<% else %> cols="<%=self.size%>"<% end %> onchange="cbi_d_update(this.id)"<%= attr("name", cbid) .. attr("id", cbid) .. ifattr(self.rows, "rows") .. ifattr(self.wrap, "wrap") %>> + <%-=pcdata(self:cfgvalue(section))-%> + </textarea> +<%+cbi/valuefooter%> diff --git a/modules/base/luasrc/view/cbi/ucisection.htm b/modules/base/luasrc/view/cbi/ucisection.htm new file mode 100644 index 000000000..3b69f12f2 --- /dev/null +++ b/modules/base/luasrc/view/cbi/ucisection.htm @@ -0,0 +1,75 @@ +<%- + 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"> + <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"> + <% if self.dynamic then %> + <input type="text" id="cbi.opt.<%=self.config%>.<%=section%>" name="cbi.opt.<%=self.config%>.<%=section%>" /> + <% if self.optionals[section] and #self.optionals[section] > 0 then %> + <script type="text/javascript"> + cbi_combobox_init('cbi.opt.<%=self.config%>.<%=section%>', { + <%- + for i, val in pairs(self.optionals[section]) do + -%> + <%-=string.format("%q", val.option) .. ":" .. string.format("%q", striptags(val.title))-%> + <%-if next(self.optionals[section], i) then-%>,<%-end-%> + <%- + end + -%> + }, '', '<%-: -- custom -- -%>'); + </script> + <% end %> + <% else %> + <select id="cbi.opt.<%=self.config%>.<%=section%>" name="cbi.opt.<%=self.config%>.<%=section%>"> + <option><%: -- Additional Field -- %></option> + <% for key, val in pairs(self.optionals[section]) do -%> + <option id="cbi-<%=self.config.."-"..section.."-"..val.option%>" value="<%=val.option%>"><%=striptags(val.title)%></option> + <%- end %> + </select> + <script type="text/javascript"><% for key, val in pairs(self.optionals[section]) do %> + <% if #val.deps > 0 then %><% for j, d in ipairs(val.deps) do -%> + cbi_d_add("cbi-<%=self.config.."-"..section.."-"..val.option..d.add%>", { + <%- + for k,v in pairs(d.deps) do + -%> + <%-=string.format('"cbid.%s.%s.%s"', self.config, section, k) .. ":" .. string.format("%q", v)-%> + <%-if next(d.deps, k) then-%>,<%-end-%> + <%- + end + -%> + }); + <%- end %><% end %> + <% end %></script> + <% end %> + <input type="submit" class="cbi-button cbi-button-fieldadd" value="<%:Add%>" /> + </div> +<% end %> diff --git a/modules/base/luasrc/view/cbi/upload.htm b/modules/base/luasrc/view/cbi/upload.htm new file mode 100644 index 000000000..777093411 --- /dev/null +++ b/modules/base/luasrc/view/cbi/upload.htm @@ -0,0 +1,14 @@ +<% + 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)%>) + <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" /> + <% else %> + <input class="cbi-input-file" type="file"<%= attr("name", cbid) .. attr("id", cbid) %> /> + <% end %> +<%+cbi/valuefooter%> diff --git a/modules/base/luasrc/view/cbi/value.htm b/modules/base/luasrc/view/cbi/value.htm new file mode 100644 index 000000000..d1a7bea5c --- /dev/null +++ b/modules/base/luasrc/view/cbi/value.htm @@ -0,0 +1,35 @@ +<%+cbi/valueheader%> + <input type="<%=self.password and 'password" class="cbi-input-password' or 'text" class="cbi-input-text' %>" onchange="cbi_d_update(this.id)"<%= + attr("name", cbid) .. attr("id", cbid) .. attr("value", self:cfgvalue(section) or self.default) .. + ifattr(self.size, "size") .. ifattr(self.placeholder, "placeholder") + %> /> + <% 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 %> + <% if #self.keylist > 0 or self.datatype then -%> + <script type="text/javascript">//<![CDATA[ + <% if #self.keylist > 0 then -%> + cbi_combobox_init('<%=cbid%>', { + <%- + for i, k in ipairs(self.keylist) do + -%> + <%-=string.format("%q", k) .. ":" .. string.format("%q", self.vallist[i])-%> + <%-if i<#self.keylist then-%>,<%-end-%> + <%- + end + -%> + }, '<%- if not self.rmempty and not self.optional then -%> + <%-: -- Please choose -- -%> + <%- elseif self.placeholder then -%> + <%-= pcdata(self.placeholder) -%> + <%- end -%>', ' + <%- if self.combobox_manual then -%> + <%-=self.combobox_manual-%> + <%- else -%> + <%-: -- custom -- -%> + <%- end -%>'); + <%- end %> + <% if self.datatype then -%> + cbi_validate_field('<%=cbid%>', <%=tostring((self.optional or self.rmempty) == true)%>, '<%=self.datatype:gsub("'", "\\'")%>'); + <%- end %> + //]]></script> + <% end -%> +<%+cbi/valuefooter%> diff --git a/modules/base/luasrc/view/cbi/valuefooter.htm b/modules/base/luasrc/view/cbi/valuefooter.htm new file mode 100644 index 000000000..805312e45 --- /dev/null +++ b/modules/base/luasrc/view/cbi/valuefooter.htm @@ -0,0 +1 @@ +<% include( valuefooter or "cbi/full_valuefooter" ) %> diff --git a/modules/base/luasrc/view/cbi/valueheader.htm b/modules/base/luasrc/view/cbi/valueheader.htm new file mode 100644 index 000000000..761a54aed --- /dev/null +++ b/modules/base/luasrc/view/cbi/valueheader.htm @@ -0,0 +1 @@ +<% include( valueheader or "cbi/full_valueheader" ) %> |