Browse Source

ffho-luci-ap-timer: fix web gui in case no config is set

this may be improved in the future
Karsten Böddeker 7 years ago
parent
commit
fc9fc86364

+ 12 - 0
ffho/ffho-luci-ap-timer/luasrc/usr/lib/lua/luci/model/cbi/admin/ap-timer.lua

@@ -1,8 +1,15 @@
+local uci = luci.model.uci.cursor()
+
 m = Map('ap-timer', translate('AP Timer'), translate(
   'You can setup the AP Timer here'))
 m.pageaction = false
 m.template = "admin/expertmode"
 
+if not uci:get('ap-timer','settings') then
+  uci:section('ap-timer','ap-timer','settings')
+  uci:save('ap-timer')
+end
+
 s = m:section(NamedSection, 'settings', 'ap-timer', nil)
 s.addremove = false
 s.anonymous = true
@@ -14,6 +21,11 @@ o = s:option(ListValue, 'type', translate('Type'))
 o.default = 'day'
 o:value('day', translate('Daily'))
 
+if not uci:get('ap-timer','all') then
+  uci:section('ap-timer','day','all')
+  uci:save('ap-timer')
+end
+
 s = m:section(NamedSection, 'all', 'day', translate('Daily'))
 s.addremove = false
 s.anonymous = true