noderole.lua 847 B

12345678910111213141516171819202122232425262728
  1. local f, s, o
  2. local site = require 'gluon.site_config'
  3. local uci = require("simple-uci").cursor()
  4. local config = 'gluon-node-info'
  5. -- where to read the configuration from
  6. local role = uci:get(config, uci:get_first(config, "system"), "role")
  7. f = Form(translate("Node role"))
  8. s = f:section(Section, nil, translate(
  9. "If this node has a special role within the freifunk network you can specify this role here. "
  10. .. "Please find out about the available roles and their impact first. "
  11. .. "Only change the role if you know what you are doing."
  12. ))
  13. o = s:option(ListValue, "role", translate("Role"))
  14. o.default = role
  15. for _, role in ipairs(site.roles.list) do
  16. o:value(role, translate('gluon-web-node-role:role:' .. role))
  17. end
  18. function o:write(data)
  19. uci:set(config, uci:get_first(config, "system"), "role", data)
  20. uci:commit(config)
  21. end
  22. return f