base: webadmin: Don't take substring of nil variable
[project/luci.git] / applications / luci-app-wifischedule / luasrc / controller / wifischedule / wifi_schedule.lua
1 -- Copyright (c) 2016, prpl Foundation
2 --
3 -- Permission to use, copy, modify, and/or distribute this software for any purpose with or without
4 -- fee is hereby granted, provided that the above copyright notice and this permission notice appear
5 -- in all copies.
6 --
7 -- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE
8 -- INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE
9 -- FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
10 -- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
11 -- ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
12 --
13 -- Author: Nils Koenig <openwrt@newk.it>
14
15 module("luci.controller.wifischedule.wifi_schedule", package.seeall)  
16
17 function index()
18      entry({"admin", "wifi_schedule"}, firstchild(), "Wifi Schedule", 60).dependent=false  
19      entry({"admin", "wifi_schedule", "tab_from_cbi"}, cbi("wifischedule/wifi_schedule"), "Schedule", 1)
20      entry({"admin", "wifi_schedule", "wifi_schedule"}, call("wifi_schedule_log"), "View Logfile", 2) 
21      entry({"admin", "wifi_schedule", "cronjob"}, call("view_crontab"), "View Cron Jobs", 3) 
22 end
23
24 function wifi_schedule_log()
25         local logfile = luci.sys.exec("cat /tmp/log/wifi_schedule.log")
26         luci.template.render("wifischedule/file_viewer", {title="Wifi Schedule Logfile", content=logfile})
27 end
28
29 function view_crontab()
30         local crontab = luci.sys.exec("cat /etc/crontabs/root")
31         luci.template.render("wifischedule/file_viewer", {title="Cron Jobs", content=crontab})
32 end