summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--modules/niu/Makefile2
-rw-r--r--modules/niu/luasrc/controller/niu/dashboard.lua44
-rw-r--r--modules/niu/luasrc/controller/niu/network.lua22
-rw-r--r--modules/niu/luasrc/model/cbi/niu/network/lan.lua8
-rw-r--r--modules/niu/luasrc/model/cbi/niu/network/lan1.lua106
-rw-r--r--modules/niu/luasrc/view/niu/dashboard.htm22
-rw-r--r--modules/niu/luasrc/view/niu/network.htm32
-rw-r--r--modules/niu/luasrc/view/niu/null.htm1
8 files changed, 237 insertions, 0 deletions
diff --git a/modules/niu/Makefile b/modules/niu/Makefile
new file mode 100644
index 000000000..81a96f6a8
--- /dev/null
+++ b/modules/niu/Makefile
@@ -0,0 +1,2 @@
+include ../../build/config.mk
+include ../../build/module.mk \ No newline at end of file
diff --git a/modules/niu/luasrc/controller/niu/dashboard.lua b/modules/niu/luasrc/controller/niu/dashboard.lua
new file mode 100644
index 000000000..e3270e4c6
--- /dev/null
+++ b/modules/niu/luasrc/controller/niu/dashboard.lua
@@ -0,0 +1,44 @@
+--[[
+LuCI - Lua Development Framework
+
+Copyright 2009 Steven Barth <steven@midlink.org>
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+$Id$
+]]--
+
+local req = require
+module "luci.controller.niu.dashboard"
+
+function index()
+ local translate = require "luci.i18n".translate
+ local uci = require "luci.model.uci"
+
+ local root = node()
+ if not root.lock then
+ root.target = alias("niu")
+ root.index = true
+ end
+
+ entry({"niu"}, alias("niu", "dashboard"), "NIU", 10)
+ entry({"niu", "dashboard"}, call("dashboard"), "Dashboard", 1)
+end
+
+local require = req
+
+function dashboard()
+ local dsp = require "luci.dispatcher"
+ local tpl = require "luci.template"
+ local utl = require "luci.util"
+ local uci = require "luci.model.uci"
+ local str = require "luci.store"
+ str.uci_state = str.uci_state or uci.cursor()
+
+ local nds = dsp.node("niu").nodes
+ tpl.render("niu/dashboard", {utl = utl, nodes = nds, dsp = dsp, tpl = tpl})
+end
diff --git a/modules/niu/luasrc/controller/niu/network.lua b/modules/niu/luasrc/controller/niu/network.lua
new file mode 100644
index 000000000..11f87fc3c
--- /dev/null
+++ b/modules/niu/luasrc/controller/niu/network.lua
@@ -0,0 +1,22 @@
+--[[
+LuCI - Lua Development Framework
+
+Copyright 2009 Steven Barth <steven@midlink.org>
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+$Id$
+]]--
+
+local req = require
+module "luci.controller.niu.network"
+
+function index()
+ entry({"niu", "network"}, alias("admin", "network"), "Network")
+ .dbtemplate = "niu/network"
+ entry({"niu", "network", "lan"}, cbi("niu/network/lan"), "Configure LAN")
+end
diff --git a/modules/niu/luasrc/model/cbi/niu/network/lan.lua b/modules/niu/luasrc/model/cbi/niu/network/lan.lua
new file mode 100644
index 000000000..acbfe4fb4
--- /dev/null
+++ b/modules/niu/luasrc/model/cbi/niu/network/lan.lua
@@ -0,0 +1,8 @@
+local d = Delegator()
+d.allow_finish = true
+d.allow_back = true
+d.allow_cancel = true
+
+d:add("lan1", load("niu/network/lan1"))
+
+return d \ No newline at end of file
diff --git a/modules/niu/luasrc/model/cbi/niu/network/lan1.lua b/modules/niu/luasrc/model/cbi/niu/network/lan1.lua
new file mode 100644
index 000000000..727526b78
--- /dev/null
+++ b/modules/niu/luasrc/model/cbi/niu/network/lan1.lua
@@ -0,0 +1,106 @@
+--[[
+LuCI - Lua Configuration Interface
+
+Copyright 2009 Steven Barth <steven@midlink.org>
+Copyright 2009 Jo-Philipp Wich <xm@subsignal.org>
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+$Id$
+]]--
+
+local nw = require "luci.model.network"
+local fw = require "luci.model.firewall"
+
+local has_ipv6 = nw:has_ipv6()
+
+m = Map("network", translate("interfaces"), translate("a_n_ifaces1"))
+m:chain("firewall")
+
+nw.init(m.uci)
+fw.init(m.uci)
+
+s = m:section(NamedSection, "lan", "interface")
+s.addremove = false
+
+s:tab("general", translate("niu_general", "General Settings"))
+
+ipaddr = s:taboption("general", Value, "ipaddr", translate("ipaddress"))
+
+nm = s:taboption("general", Value, "netmask", translate("netmask"))
+nm:value("255.255.255.0")
+nm:value("255.255.0.0")
+nm:value("255.0.0.0")
+
+
+
+s:tab("expert", translate("niu_expert", "Expert Settings"))
+
+mac = s:taboption("expert", Value, "macaddr", translate("macaddress"))
+
+mtu = s:taboption("expert", Value, "mtu", "MTU")
+mtu.isinteger = true
+
+dns = s:taboption("expert", Value, "dns", translate("dnsserver"))
+dns:depends("peerdns", "")
+
+
+gw = s:taboption("expert", Value, "gateway", translate("gateway"))
+bcast = s:taboption("expert", Value, "bcast", translate("broadcast"))
+
+
+if has_ipv6 then
+ ip6addr = s:taboption("expert", Value, "ip6addr", translate("ip6address"), translate("cidr6"))
+ ip6gw = s:taboption("expert", Value, "ip6gw", translate("gateway6"))
+end
+
+
+br = s:taboption("expert", Flag, "type", translate("a_n_i_bridge"), translate("a_n_i_bridge1"))
+br.enabled = "bridge"
+br.rmempty = true
+
+stp = s:taboption("expert", Flag, "stp", translate("a_n_i_stp"),
+ translate("a_n_i_stp1", "Enables the Spanning Tree Protocol on this bridge"))
+stp:depends("type", "1")
+stp.rmempty = true
+
+ifname_single = s:taboption("expert", Value, "ifname_single", translate("interface"))
+ifname_single.template = "cbi/network_ifacelist"
+ifname_single.widget = "radio"
+ifname_single.nobridges = true
+ifname_single.rmempty = true
+ifname_single:depends("type", "")
+
+function ifname_single.cfgvalue(self, s)
+ return self.map.uci:get("network", s, "ifname")
+end
+
+function ifname_single.write(self, s, val)
+ local n = nw:get_network(s)
+ if n then n:ifname(val) end
+end
+
+
+ifname_multi = s:taboption("expert", MultiValue, "ifname_multi", translate("interface"))
+ifname_multi.template = "cbi/network_ifacelist"
+ifname_multi.nobridges = true
+ifname_multi.widget = "checkbox"
+ifname_multi:depends("type", "1")
+ifname_multi.cfgvalue = ifname_single.cfgvalue
+ifname_multi.write = ifname_single.write
+
+for _, d in ipairs(nw:get_interfaces()) do
+ if not d:is_bridge() then
+ ifname_single:value(d:name())
+ ifname_multi:value(d:name())
+ end
+end
+
+
+
+
+return m
diff --git a/modules/niu/luasrc/view/niu/dashboard.htm b/modules/niu/luasrc/view/niu/dashboard.htm
new file mode 100644
index 000000000..cdd65663f
--- /dev/null
+++ b/modules/niu/luasrc/view/niu/dashboard.htm
@@ -0,0 +1,22 @@
+<%+header%>
+
+<%
+local function cmp(a, b)
+ return (a.order or 100) < (b.order or 100)
+end
+for k, v in utl.spairs(nodes, cmp) do
+ if v.dbtemplate then
+ %>
+ <fieldset style="float: left; margin: 1em; padding: 0.5em">
+ <legend><%=v.title%></legend>
+ <%
+ tpl.render(v.dbtemplate)
+ %>
+ </fieldset>
+ <%
+ end
+end
+
+%>
+
+<%+footer%> \ No newline at end of file
diff --git a/modules/niu/luasrc/view/niu/network.htm b/modules/niu/luasrc/view/niu/network.htm
new file mode 100644
index 000000000..71296371f
--- /dev/null
+++ b/modules/niu/luasrc/view/niu/network.htm
@@ -0,0 +1,32 @@
+<%
+local dsp = require "luci.dispatcher"
+local utl = require "luci.util"
+local str = require "luci.store"
+
+local nws = {}
+str.uci_state:foreach("network", "interface", function(s)
+ nws[#nws+1] = s
+end)
+
+local function cmp(a, b)
+ return (a.order or 100) < (b.order or 100)
+end
+%>
+<div>Status:</div>
+<table>
+<%
+for _, v in ipairs(nws) do if v[".name"] ~= "loopback" then
+%>
+<tr><td><%=v[".name"]%></td><td><%=v.ipaddr%></td></tr>
+<% end end %>
+</table>
+<br />
+<ul>
+<%
+for k, v in utl.spairs(dsp.node("niu", "network").nodes, cmp) do
+%>
+<li><a href="<%=dsp.build_url("niu", "network", k)%>"><%=v.title%></a></li>
+<%
+end
+%>
+</ul> \ No newline at end of file
diff --git a/modules/niu/luasrc/view/niu/null.htm b/modules/niu/luasrc/view/niu/null.htm
new file mode 100644
index 000000000..fe3a0735d
--- /dev/null
+++ b/modules/niu/luasrc/view/niu/null.htm
@@ -0,0 +1 @@
+NULL \ No newline at end of file