X-Git-Url: http://git.archive.openwrt.org/?a=blobdiff_plain;f=modules%2Fluci-mod-admin-full%2Fluasrc%2Fmodel%2Fcbi%2Fadmin_system%2Fleds.lua;h=74e2f1a19da8a83bba06e84c823a054f071460e4;hb=926935f83170e38452a5191d13aa8b04021606ff;hp=b912f5ece8b9816a58e54a131c0cc1e399be62b4;hpb=1bb4822dca6113f73e3bc89e2acf15935e6f8e92;p=project%2Fluci.git diff --git a/modules/luci-mod-admin-full/luasrc/model/cbi/admin_system/leds.lua b/modules/luci-mod-admin-full/luasrc/model/cbi/admin_system/leds.lua index b912f5ece..74e2f1a19 100644 --- a/modules/luci-mod-admin-full/luasrc/model/cbi/admin_system/leds.lua +++ b/modules/luci-mod-admin-full/luasrc/model/cbi/admin_system/leds.lua @@ -1,26 +1,17 @@ ---[[ -LuCI - Lua Configuration Interface +-- Copyright 2008 Steven Barth +-- Licensed to the public under the Apache License 2.0. -Copyright 2008 Steven Barth - -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$ -]]-- m = Map("system", translate("LED Configuration"), translate("Customizes the behaviour of the device LEDs if possible.")) local sysfs_path = "/sys/class/leds/" local leds = {} local fs = require "nixio.fs" -local util = require "nixio.util" +local nu = require "nixio.util" +local util = require "luci.util" if fs.access(sysfs_path) then - leds = util.consume((fs.dir(sysfs_path))) + leds = nu.consume((fs.dir(sysfs_path))) end if #leds == 0 then @@ -119,6 +110,33 @@ function usbdev.remove(self, section) end end + +usbport = s:option(MultiValue, "port", translate("USB Ports")) +usbport:depends("trigger", "usbport") +usbport.rmempty = true +usbport.widget = "checkbox" +usbport.cast = "table" +usbport.size = 1 + +function usbport.valuelist(self, section) + local port, ports = nil, {} + for port in util.imatch(m.uci:get("system", section, "port")) do + local b, n = port:match("^usb(%d+)-port(%d+)$") + if not (b and n) then + b, n = port:match("^(%d+)-(%d+)$") + end + if b and n then + ports[#ports+1] = "usb%u-port%u" %{ tonumber(b), tonumber(n) } + end + end + return ports +end + +function usbport.validate(self, value) + return type(value) == "string" and { value } or value +end + + for p in nixio.fs.glob("/sys/bus/usb/devices/[0-9]*/manufacturer") do local id = p:match("%d+-%d+") local mf = nixio.fs.readfile("/sys/bus/usb/devices/" .. id .. "/manufacturer") or "?" @@ -126,4 +144,12 @@ for p in nixio.fs.glob("/sys/bus/usb/devices/[0-9]*/manufacturer") do usbdev:value(id, "%s (%s - %s)" %{ id, mf, pr }) end +for p in nixio.fs.glob("/sys/bus/usb/devices/*/usb[0-9]*-port[0-9]*") do + local bus, port = p:match("usb(%d+)-port(%d+)") + if bus and port then + usbport:value("usb%u-port%u" %{ tonumber(bus), tonumber(port) }, + "Hub %u, Port %u" %{ tonumber(bus), tonumber(port) }) + end +end + return m