modules/admin-full: Prepare Button / LED configuration
[project/luci.git] / modules / admin-full / luasrc / model / cbi / admin_system / leds.lua
1 --[[
2 LuCI - Lua Configuration Interface
3
4 Copyright 2008 Steven Barth <steven@midlink.org>
5
6 Licensed under the Apache License, Version 2.0 (the "License");
7 you may not use this file except in compliance with the License.
8 You may obtain a copy of the License at
9
10         http://www.apache.org/licenses/LICENSE-2.0
11
12 $Id$
13 ]]--
14 m = Map("system", translate("leds"), translate("leds_desc"))
15
16 s = m:section(TypedSection, "led", "")
17 s.anonymous = true
18 s.addremove = true
19
20
21 s:option(Value, "name")
22
23 sysfs = s:option(ListValue, "sysfs")
24 for k, v in pairs(luci.fs.dir("/sys/class/leds/")) do
25         if v ~= "." and v ~= ".." then
26                 sysfs:value(v)
27         end
28 end
29
30 s:option(Flag, "default").rmempty = true
31
32 trigger = s:option(Value, "trigger")
33 trigger.rmempty = true
34 trigger:value("netdev")
35
36
37 dev = s:option(ListValue, "dev")
38 dev.rmempty = true
39 dev:value("")
40 dev:depends("trigger", "netdev")
41 for k, v in pairs(luci.sys.net.devices()) do
42         if v ~= "lo" then
43                 dev:value(v)
44         end
45 end
46
47 mode = s:option(Value, "mode")
48 mode.rmempty = true
49 mode:value("link")
50 mode:depends("trigger", "netdev")