--- /dev/null
+--[[
+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
--- /dev/null
+--[[
+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
--- /dev/null
+<%
+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