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

Update to latest luci-base and luci-mod-admin-full

This commit is contained in:
Ycarus 2018-06-08 10:51:00 +02:00
parent 613042b0a0
commit b218a47995
17 changed files with 2882 additions and 221 deletions

View file

@ -1417,6 +1417,12 @@ function AbstractValue.parse(self, section, novld)
self:add_error(section, "invalid", val_err)
end
if self.alias then
self.section.aliased = self.section.aliased or {}
self.section.aliased[section] = self.section.aliased[section] or {}
self.section.aliased[section][self.alias] = true
end
if fvalue and (self.forcewrite or not (fvalue == cvalue)) then
if self:write(section, fvalue) then
-- Push events
@ -1426,10 +1432,16 @@ function AbstractValue.parse(self, section, novld)
end
else -- Unset the UCI or error
if self.rmempty or self.optional then
if self:remove(section) then
-- Push events
self.section.changed = true
--luci.util.append(self.map.events, self.events)
if not self.alias or
not self.section.aliased or
not self.section.aliased[section] or
not self.section.aliased[section][self.alias]
then
if self:remove(section) then
-- Push events
self.section.changed = true
--luci.util.append(self.map.events, self.events)
end
end
elseif cvalue ~= fvalue and not novld then
-- trigger validator with nil value to get custom user error msg.
@ -1455,7 +1467,7 @@ function AbstractValue.cfgvalue(self, section)
if self.tag_error[section] then
value = self:formvalue(section)
else
value = self.map:get(section, self.option)
value = self.map:get(section, self.alias or self.option)
end
if not value then
@ -1496,12 +1508,12 @@ AbstractValue.transform = AbstractValue.validate
-- Write to UCI
function AbstractValue.write(self, section, value)
return self.map:set(section, self.option, value)
return self.map:set(section, self.alias or self.option, value)
end
-- Remove from UCI
function AbstractValue.remove(self, section)
return self.map:del(section, self.option)
return self.map:del(section, self.alias or self.option)
end
@ -1834,6 +1846,15 @@ function DynamicList.formvalue(self, section)
end
DropDown = class(MultiValue)
function DropDown.__init__(self, ...)
ListValue.__init__(self, ...)
self.template = "cbi/dropdown"
self.delimiter = " "
end
--[[
TextValue - A multi-line value
rows: Rows

View file

@ -8,7 +8,7 @@ local table = require "table"
local setmetatable, rawget, rawset = setmetatable, rawget, rawset
local require, getmetatable, assert = require, getmetatable, assert
local error, pairs, ipairs = error, pairs, ipairs
local error, pairs, ipairs, select = error, pairs, ipairs, select
local type, tostring, tonumber, unpack = type, tostring, tonumber, unpack
-- The typical workflow for UCI is: Get a cursor instance from the
@ -106,7 +106,7 @@ function changes(self, config)
local _, change
for _, change in ipairs(changes) do
local operation, section, option, value = unpack(change)
if option and value and operation ~= "add" then
if option and operation ~= "add" then
res[package][section] = res[package][section] or { }
if operation == "list-add" then
@ -373,15 +373,15 @@ function add(self, config, stype)
return self:section(config, stype)
end
function set(self, config, section, option, value)
if value == nil then
function set(self, config, section, option, ...)
if select('#', ...) == 0 then
local sname, err = self:section(config, option, section)
return (not not sname), err
else
local _, err = call("set", {
config = config,
section = section,
values = { [option] = value }
values = { [option] = select(1, ...) }
})
return (err == nil), ERRSTR[err]
end

View file

@ -0,0 +1,42 @@
<%+cbi/valueheader%>
<%-
local selected = { }
if self.multiple then
local val
for val in luci.util.imatch(self:cfgvalue(section)) do
selected[val] = true
end
else
selected[self:cfgvalue(section)] = true
end
if not next(selected) and self.default then
selected[self.default] = true
end
-%>
<div class="cbi-dropdown"<%=
attr("name", cbid) ..
attr("display-items", self.display or self.size or 3) ..
attr("dropdown-items", self.dropdown or self.display or self.size or 5) ..
attr("placeholder", self.placeholder or translate("-- please select --")) ..
ifattr(self.multiple, "multiple", "multiple") ..
ifattr(self.optional or self.rmempty, "optional", "optional")
%>>
<ul>
<% local i, key; for i, key in pairs(self.keylist) do %>
<li<%=
attr("data-index", i) ..
attr("data-depends", self:deplist2json(section, self.deplist[i])) ..
attr("value", key) ..
ifattr(selected[key], "selected", "selected")
%>>
<%=pcdata(self.vallist[i])%>
</li>
<% end %>
</ul>
</div>
<%+cbi/valuefooter%>

View file

@ -24,26 +24,42 @@
end
-%>
<span>
<ul style="margin:0; list-style-type:none; text-align:left">
<div class="cbi-dropdown" dropdown-items="5" placeholder="<%:-- please select -- %>"<%=
attr("name", cbid) ..
ifattr(self.widget == "checkbox", "multiple", "multiple") ..
ifattr(self.rmempty or self.optional, "optional", "optional")
%>>
<script type="item-template"><!--
<li value="{{value}}">
<span class="zonebadge" style="background:repeating-linear-gradient(45deg,rgba(204,204,204,0.5),rgba(204,204,204,0.5) 5px,rgba(255,255,255,0.5) 5px,rgba(255,255,255,0.5) 10px)">
<strong>{{value}}:</strong><em>(<%:create%>)</em>
</span>
</li>
--></script>
<ul>
<% 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">
<li value=""<%=ifattr(checked[""], "selected", "selected")%>>
<span style="background-color:<%=fwm.zone.get_color()%>" class="zonebadge">
<strong><%:Device%></strong>
<% if self.allowany and self.allowlocal then %>(<%:input%>)<% end %>
</label>
<% if self.allowany and self.allowlocal then -%>
(<%= self.alias ~= "dest"
and translate("output") or translate("input") %>)
<%- end %>
</span>
</li>
<% elseif self.widget ~= "checkbox" and (self.rmempty or self.optional) then %>
<li value=""<%=ifattr(checked[""], "selected", "selected")%>>
<span class="zonebadge">
<em><%:unspecified%></em>
</span>
</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">
<li value="*"<%=ifattr(checked["*"], "selected", "selected")%>>
<span style="background-color:<%=fwm.zone.get_color()%>" class="zonebadge">
<strong><%:Any zone%></strong>
<% if self.allowany and self.allowlocal then %>(<%:forward%>)<% end %>
</label>
</span>
</li>
<% end %>
<%
@ -51,45 +67,42 @@
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">
<li<%=attr("value", zone:name()) .. ifattr(checked[zone:name()], "selected", "selected")%>>
<span 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" />
<img<%=attr("title", iface:get_i18n())%> src="<%=resource%>/icons/<%=iface:type()%><%=iface:is_up() and "" or "_disabled"%>.png" />
<% end %>
<% if nempty then %><em><%:(empty)%></em><% end %>
<% if nempty then %><em><%:(empty)%></em><% end -%>
</span>
<% end end %>
<% if zempty then %><em><%:(empty)%></em><% end %>
</label>
<%- end end -%>
<%- if zempty then %><em><%:(empty)%></em><% end -%>
</span>
</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 value="-">
<span class="zonebadge">
<em><%:create%>:</em>
<input type="password" style="display:none" />
<input class="create-item-input" type="text" />
</span>
</li>
<% end %>
</ul>
</span>
</div>
<%+cbi/valuefooter%>

View file

@ -19,7 +19,9 @@
if value then
for value in utl.imatch(value) do
checked[value] = true
for value in utl.imatch(value) do
checked[value] = true
end
end
else
local n = self.network and net:get_network(self.network)
@ -33,57 +35,51 @@
-%>
<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>
<div class="cbi-dropdown" display-items="5" placeholder="<%:-- please select -- %>"<%=
attr("name", cbid) ..
ifattr(self.widget == "checkbox", "multiple", "multiple") ..
ifattr(self.widget == "checkbox", "optional", "optional")
%>>
<script type="item-template"><!--
<li value="{{value}}">
<img title="<%:Custom Interface%>: &quot;{{value}}&quot;" src="<%=resource%>/icons/ethernet_disabled.png" />
<span class="hide-open">{{value}}</span>
<span class="hide-close"><%:Custom Interface%>: "{{value}}"</span>
</li>
--></script>
<ul>
<% for _, iface in ipairs(ifaces) do
if (not self.nobridges or not iface:is_bridge()) and
(not self.noinactive or iface:is_up()) and
iface:name() ~= self.exclude
then %>
<li<%=
attr("value", iface:name()) ..
ifattr(checked[iface:name()], "selected", "selected")
%>>
<img<%=attr("title", iface:get_i18n())%> src="<%=resource%>/icons/<%=iface:type()%><%=iface:is_up() and "" or "_disabled"%>.png" />
<span class="hide-open"><%=pcdata(iface:name())%></span>
<span class="hide-close">
<%=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 %>
</span>
</li>
<% end end %>
<% if not self.nocreate then %>
<li value="">
<img title="<%:Custom Interface%>" src="<%=resource%>/icons/ethernet_disabled.png" />
<span><%:Custom Interface%>:</span>
<input type="password" style="display:none" />
<input class="create-item-input" type="text" />
</li>
<% end %>
</ul>
</div>
<%+cbi/valuefooter%>

View file

@ -20,66 +20,62 @@
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())%>>
<div class="cbi-dropdown" display-items="5" placeholder="<%:-- please select -- %>"<%=
attr("name", cbid) ..
ifattr(self.widget == "checkbox", "multiple", "multiple") ..
ifattr(self.widget == "checkbox", "optional", "optional")
%>>
<script type="item-template"><!--
<li value="{{value}}">
<span class="ifacebadge" style="background:repeating-linear-gradient(45deg,rgba(204,204,204,0.5),rgba(204,204,204,0.5) 5px,rgba(255,255,255,0.5) 5px,rgba(255,255,255,0.5) 10px)">
{{value}}: <em>(<%:create%>)</em>
</span>
</li>
--></script>
<ul>
<% if self.widget ~= "checkbox" then %>
<li value=""<%= ifattr(not value, "selected", "selected") %>>
<em><%:unspecified%></em>
</li>
<% end %>
<% 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<%= attr("value", net:name()) .. ifattr(checked[net:name()], "selected", "selected") %>>
<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 %>
<%- end end %>
<% if empty then %>
<em class="hide-close"><%:(no interfaces attached)%></em>
<em class="hide-open">-</em>
<% end %>
</span>
</label>
</li>
<% end end %>
</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 not self.nocreate then %>
<li value="-"<%= ifattr(not value and self.widget ~= "checkbox", "selected", "selected") %>>
<em>
<%- if self.widget == "checkbox" then -%>
<%:create:%>
<%- else -%>
<%:unspecified -or- create:%>
<%- end -%>&#160;</em></label>
<%- end -%>
</em>
<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>
<input class="create-item-input" type="text" />
</li>
<% end %>
</ul>
</div>
<%+cbi/valuefooter%>