diff options
author | Hsing-Wang Liao <kuoruan@gmail.com> | 2017-01-05 16:28:45 +0800 |
---|---|---|
committer | Hsing-Wang Liao <kuoruan@gmail.com> | 2017-01-08 11:30:00 +0800 |
commit | ddfe7c4374e3449eecbca855e2ba1d780182f501 (patch) | |
tree | 0c8968b2e57154bd1f0d54cbbefde3a9b50590a7 /applications/luci-app-wifischedule/luasrc/controller/wifischedule | |
parent | a2dfd21c80eaf815d50ca56a07efa82176f32d5a (diff) |
luci-app-wifischedule: minor changes
* Formatting codes.
* Move to services sub menu.
* Update Simplified Chinese translation.
* And some other small changes.
Signed-off-by: Hsing-Wang Liao <kuoruan@gmail.com>
Diffstat (limited to 'applications/luci-app-wifischedule/luasrc/controller/wifischedule')
-rw-r--r-- | applications/luci-app-wifischedule/luasrc/controller/wifischedule/wifi_schedule.lua | 28 |
1 files changed, 19 insertions, 9 deletions
diff --git a/applications/luci-app-wifischedule/luasrc/controller/wifischedule/wifi_schedule.lua b/applications/luci-app-wifischedule/luasrc/controller/wifischedule/wifi_schedule.lua index 4743453a1d..261cf36d0f 100644 --- a/applications/luci-app-wifischedule/luasrc/controller/wifischedule/wifi_schedule.lua +++ b/applications/luci-app-wifischedule/luasrc/controller/wifischedule/wifi_schedule.lua @@ -12,21 +12,31 @@ -- -- Author: Nils Koenig <openwrt@newk.it> -module("luci.controller.wifischedule.wifi_schedule", package.seeall) +module("luci.controller.wifischedule.wifi_schedule", package.seeall) + +local fs = require "nixio.fs" +local sys = require "luci.sys" +local template = require "luci.template" +local i18n = require "luci.i18n" function index() - entry({"admin", "wifi_schedule"}, firstchild(), _("Wifi Schedule"), 60).dependent=false - entry({"admin", "wifi_schedule", "tab_from_cbi"}, cbi("wifischedule/wifi_schedule"), _("Schedule"), 1) - entry({"admin", "wifi_schedule", "wifi_schedule"}, call("wifi_schedule_log"), _("View Logfile"), 2) - entry({"admin", "wifi_schedule", "cronjob"}, call("view_crontab"), _("View Cron Jobs"), 3) + if not nixio.fs.access("/etc/config/wifi_schedule") then + return + end + entry({"admin", "services", "wifi_schedule"}, firstchild(), _("Wifi Schedule"), 60).dependent=false + entry({"admin", "services", "wifi_schedule", "tab_from_cbi"}, cbi("wifischedule/wifi_schedule"), _("Schedule"), 1) + entry({"admin", "services", "wifi_schedule", "wifi_schedule"}, call("wifi_schedule_log"), _("View Logfile"), 2) + entry({"admin", "services", "wifi_schedule", "cronjob"}, call("view_crontab"), _("View Cron Jobs"), 3) end function wifi_schedule_log() - local logfile = luci.sys.exec("cat /tmp/log/wifi_schedule.log") - luci.template.render("wifischedule/file_viewer", {title="Wifi Schedule Logfile", content=logfile}) + local logfile = fs.readfile("/tmp/log/wifi_schedule.log") or "" + template.render("wifischedule/file_viewer", + {title = i18n.translate("Wifi Schedule Logfile"), content = logfile}) end function view_crontab() - local crontab = luci.sys.exec("cat /etc/crontabs/root") - luci.template.render("wifischedule/file_viewer", {title="Cron Jobs", content=crontab}) + local crontab = fs.readfile("/etc/crontabs/root") or "" + template.render("wifischedule/file_viewer", + {title = i18n.translate("Cron Jobs"), content = crontab}) end |