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