luci-app-travelmate: support new workflow & re-ordering fix

* Remove SimpleForm stuff from Interface Wizard
* adapt Travelmate to support new cbi apply workflow
* fix station re-odering
* tested successfully with old & new workflow

Signed-off-by: Dirk Brenken <dev@brenken.org>
This commit is contained in:
Dirk Brenken 2018-05-03 07:53:48 +02:00
parent fa2975d7c5
commit e7edcb4057
2 changed files with 15 additions and 26 deletions

View file

@ -18,8 +18,11 @@ m = Map("travelmate", translate("Travelmate"),
.. translatef("For further information " .. translatef("For further information "
.. "<a href=\"%s\" target=\"_blank\">" .. "<a href=\"%s\" target=\"_blank\">"
.. "see online documentation</a>", "https://github.com/openwrt/packages/blob/master/net/travelmate/files/README.md")) .. "see online documentation</a>", "https://github.com/openwrt/packages/blob/master/net/travelmate/files/README.md"))
m:chain("network")
m:chain("firewall")
m.apply_on_parse = true
function m.on_after_commit(self) function m.on_apply(self)
luci.sys.call("env -i /etc/init.d/travelmate restart >/dev/null 2>&1") luci.sys.call("env -i /etc/init.d/travelmate restart >/dev/null 2>&1")
luci.http.redirect(luci.dispatcher.build_url("admin", "services", "travelmate")) luci.http.redirect(luci.dispatcher.build_url("admin", "services", "travelmate"))
end end
@ -28,39 +31,25 @@ end
if uplink == "" then if uplink == "" then
ds = m:section(NamedSection, "global", "travelmate", translate("Interface Wizard")) ds = m:section(NamedSection, "global", "travelmate", translate("Interface Wizard"))
o = ds:option(Value, "trm_iface", translate("Create Uplink interface"),
o = ds:option(Value, "", translate("Uplink interface")) translate("Create a new wireless wan uplink interface, configure it to use dhcp and ")
.. translate("add it to the wan zone of the firewall.<br />")
.. translate("This step has only to be done once."))
o.datatype = "and(uciname,rangelength(3,15))" o.datatype = "and(uciname,rangelength(3,15))"
o.default = trmiface o.default = trmiface
o.rmempty = false o.rmempty = false
btn = ds:option(Button, "trm_iface", translate("Create Uplink Interface"), function o.validate(self, value)
translate("Create a new wireless wan uplink interface, configure it to use dhcp and ") if value then
.. translate("add it to the wan zone of the firewall. This step has only to be done once.")) local net = nw:add_network(value, { proto = "dhcp" })
btn.inputtitle = translate("Add Interface")
btn.inputstyle = "apply"
btn.disabled = false
function btn.write(self, section)
local iface = o:formvalue(section)
if iface then
uci:set("travelmate", section, "trm_iface", iface)
uci:save("travelmate")
uci:commit("travelmate")
local net = nw:add_network(iface, { proto = "dhcp" })
if net then if net then
nw:save("network")
nw:commit("network")
local zone = fw:get_zone_by_network("wan") local zone = fw:get_zone_by_network("wan")
if zone then if zone then
zone:add_network(iface) zone:add_network(value)
fw:save("firewall")
fw:commit("firewall")
end end
end end
luci.sys.call("env -i /bin/ubus call network reload >/dev/null 2>&1")
end end
luci.http.redirect(luci.dispatcher.build_url("admin", "services", "travelmate")) return value
end end
return m return m
end end

View file

@ -46,8 +46,8 @@ This is free software, licensed under the Apache License, Version 2.0
<td style="<%=style%>"><%=bssid%></td> <td style="<%=style%>"><%=bssid%></td>
<td style="<%=style%>"><%=encryption%></td> <td style="<%=style%>"><%=encryption%></td>
<td class="cbi-value-field" style="width:80px"> <td class="cbi-value-field" style="width:80px">
<input class="cbi-button cbi-button-up" type="button" value="" onclick="location.href='<%=luci.dispatcher.build_url('admin/services/travelmate/wifiorder')%>?cfg=<%=section%>;dir=up'" alt="<%:Move up%>" title="<%:Move up%>"/> <input class="cbi-button cbi-button-up" type="button" value="" onclick="location.href='<%=luci.dispatcher.build_url('admin/services/travelmate/wifiorder')%>?cfg=<%=section%>&dir=up'" alt="<%:Move up%>" title="<%:Move up%>"/>
<input class="cbi-button cbi-button-down" type="button" value="" onclick="location.href='<%=luci.dispatcher.build_url('admin/services/travelmate/wifiorder')%>?cfg=<%=section%>;dir=down'" alt="<%:Move down%>" title="<%:Move down%>"/> <input class="cbi-button cbi-button-down" type="button" value="" onclick="location.href='<%=luci.dispatcher.build_url('admin/services/travelmate/wifiorder')%>?cfg=<%=section%>&dir=down'" alt="<%:Move down%>" title="<%:Move down%>"/>
</td> </td>
<td class="cbi-value-field" style="width:150px"> <td class="cbi-value-field" style="width:150px">
<input type="button" class="cbi-button cbi-button-edit" onclick="location.href='<%=luci.dispatcher.build_url('admin/services/travelmate/wifiedit')%>?cfg=<%=section%>'" title="<%:Edit this Uplink%>" value="<%:Edit%>"/> <input type="button" class="cbi-button cbi-button-edit" onclick="location.href='<%=luci.dispatcher.build_url('admin/services/travelmate/wifiedit')%>?cfg=<%=section%>'" title="<%:Edit this Uplink%>" value="<%:Edit%>"/>