travelmate.lua 2.4 KB

1234567891011121314151617181920212223242526272829303132333435
  1. -- Copyright 2017 Dirk Brenken (dev@brenken.org)
  2. -- This is free software, licensed under the Apache License, Version 2.0
  3. module("luci.controller.travelmate", package.seeall)
  4. local fs = require("nixio.fs")
  5. local util = require("luci.util")
  6. local i18n = require("luci.i18n")
  7. local templ = require("luci.template")
  8. function index()
  9. if not nixio.fs.access("/etc/config/travelmate") then
  10. return
  11. end
  12. entry({"admin", "services", "travelmate"}, firstchild(), _("Travelmate"), 40).dependent = false
  13. entry({"admin", "services", "travelmate", "tab_from_cbi"}, cbi("travelmate/overview_tab", {hideresetbtn=true, hidesavebtn=true}), _("Overview"), 10).leaf = true
  14. entry({"admin", "services", "travelmate", "stations"}, template("travelmate/stations"), _("Wireless Stations"), 20).leaf = true
  15. entry({"admin", "services", "travelmate", "logfile"}, call("logread"), _("View Logfile"), 30).leaf = true
  16. entry({"admin", "services", "travelmate", "advanced"}, firstchild(), _("Advanced"), 100)
  17. entry({"admin", "services", "travelmate", "advanced", "configuration"}, cbi("travelmate/configuration_tab"), _("Edit Travelmate Configuration"), 110).leaf = true
  18. entry({"admin", "services", "travelmate", "advanced", "cfg_wireless"}, cbi("travelmate/cfg_wireless_tab"), _("Edit Wireless Configuration"), 120).leaf = true
  19. entry({"admin", "services", "travelmate", "advanced", "cfg_network"}, cbi("travelmate/cfg_network_tab"), _("Edit Network Configuration"), 130).leaf = true
  20. entry({"admin", "services", "travelmate", "advanced", "cfg_firewall"}, cbi("travelmate/cfg_firewall_tab"), _("Edit Firewall Configuration"), 140).leaf = true
  21. entry({"admin", "services", "travelmate", "wifiscan"}, template("travelmate/wifi_scan")).leaf = true
  22. entry({"admin", "services", "travelmate", "wifiadd"}, cbi("travelmate/wifi_add", {hideresetbtn=true, hidesavebtn=true})).leaf = true
  23. entry({"admin", "services", "travelmate", "wifiedit"}, cbi("travelmate/wifi_edit", {hideresetbtn=true, hidesavebtn=true})).leaf = true
  24. entry({"admin", "services", "travelmate", "wifidelete"}, cbi("travelmate/wifi_delete", {hideresetbtn=true, hidesavebtn=true})).leaf = true
  25. entry({"admin", "services", "travelmate", "wifiorder"}, cbi("travelmate/wifi_order", {hideresetbtn=true, hidesavebtn=true})).leaf = true
  26. end
  27. function logread()
  28. local logfile = util.trim(util.exec("logread -e 'travelmate'"))
  29. templ.render("travelmate/logread", {title = i18n.translate("Travelmate Logfile"), content = logfile})
  30. end