Browse Source

replace ffho-luci-ap-timer by ffho-web-ap-timer

Karsten Böddeker 6 years ago
parent
commit
680e2dd889

+ 0 - 4
ffho/ffho-luci-ap-timer/ReadMe.md

@@ -1,4 +0,0 @@
-ffho-luci-ap-timer
-==================
-
-Luci module for ap-timer settings.

+ 0 - 5
ffho/ffho-luci-ap-timer/luasrc/usr/lib/lua/luci/controller/admin/ap-timer.lua

@@ -1,5 +0,0 @@
-module("luci.controller.admin.ap-timer", package.seeall)
-
-function index()
-        entry({"admin", "ap-timer"}, cbi("admin/ap-timer"), _("AP Timer"), 30)
-end

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

@@ -1,41 +0,0 @@
-local uci = luci.model.uci.cursor()
-
-if not uci:get('ap-timer','settings') then
-  uci:section('ap-timer','ap-timer','settings')
-  uci:save('ap-timer')
-end
-
-if not uci:get('ap-timer','all') then
-  uci:section('ap-timer','day','all')
-  uci:save('ap-timer')
-end
-
-m = Map('ap-timer', translate('AP Timer'), translate(
-  'You can setup the AP Timer here'))
-m.pageaction = false
-m.template = "cbi/simpleform"
-
-s = m:section(NamedSection, 'settings', 'ap-timer', nil)
-s.addremove = false
-s.anonymous = true
-
-o = s:option(Flag, 'enabled', translate('Enabled'))
-o.rmempty = false
-
-o = s:option(ListValue, 'type', translate('Type'))
-o.default = 'day'
-o:value('day', translate('Daily'))
-
-s = m:section(NamedSection, 'all', 'day', translate('Daily'))
-s.addremove = false
-s.anonymous = true
-
-o = s:option(DynamicList, 'on', translate('ON'))
-o.placeholder = '06:30'
-o.datatype = 'rangelength(5, 5)'
-
-o = s:option(DynamicList, 'off', translate('OFF'))
-o.placeholder = '23:00'
-o.datatype = 'rangelength(5, 5)'
-
-return m

+ 7 - 7
ffho/ffho-luci-ap-timer/Makefile → ffho/ffho-web-ap-timer/Makefile

@@ -1,6 +1,6 @@
 include $(TOPDIR)/rules.mk
 
-PKG_NAME:=ffho-luci-ap-timer
+PKG_NAME:=ffho-web-ap-timer
 PKG_VERSION:=1
 PKG_RELEASE:=$(GLUON_VERSION).$(GLUON_SITE_CODE)-$(GLUON_RELEASE).$(GLUON_CONFIG_VERSION)
 
@@ -10,11 +10,11 @@ include $(TOPDIR)/../package/gluon.mk
 
 PKG_CONFIG_DEPENDS += $(GLUON_I18N_CONFIG)
 
-define Package/ffho-luci-ap-timer
+define Package/ffho-web-ap-timer
   SECTION:=ffho
   CATEGORY:=FFHO
   TITLE:=Luci module for ap-timer settings
-  DEPENDS:=+gluon-luci-admin
+  DEPENDS:=+gluon-web-admin
   MAINTAINER:=Freifunk Hochstift <kontakt@hochstift.freifunk.net>
 endef
 
@@ -26,13 +26,13 @@ define Build/Configure
 endef
 
 define Build/Compile
-	$(call GluonBuildI18N,ffho-luci-ap-timer,i18n)
+	$(call GluonBuildI18N,ffho-web-ap-timer,i18n)
 	$(call GluonSrcDiet,./luasrc,$(PKG_BUILD_DIR)/luadest/)
 endef
 
-define Package/ffho-luci-ap-timer/install
+define Package/ffho-web-ap-timer/install
 	$(CP) $(PKG_BUILD_DIR)/luadest/* $(1)/
-	$(call GluonInstallI18N,ffho-luci-ap-timer,$(1))
+	$(call GluonInstallI18N,ffho-web-ap-timer,$(1))
 endef
 
-$(eval $(call BuildPackage,ffho-luci-ap-timer))
+$(eval $(call BuildPackage,ffho-web-ap-timer))

+ 4 - 0
ffho/ffho-web-ap-timer/ReadMe.md

@@ -0,0 +1,4 @@
+ffho-web-ap-timer
+=================
+
+Gluon-web module for ap-timer settings.

+ 0 - 0
ffho/ffho-luci-ap-timer/i18n/de.po → ffho/ffho-web-ap-timer/i18n/de.po


+ 0 - 0
ffho/ffho-luci-ap-timer/i18n/ffho-luci-ap-timer.pot → ffho/ffho-web-ap-timer/i18n/ffho-web-ap-timer.pot


+ 1 - 0
ffho/ffho-web-ap-timer/luasrc/lib/gluon/web/controller/admin/ap-timer.lua

@@ -0,0 +1 @@
+entry({"admin", "ap-timer"}, module("admin/ap-timer"), _("AP Timer"), 30)

+ 59 - 0
ffho/ffho-web-ap-timer/luasrc/lib/gluon/web/model/admin/ap-timer.lua

@@ -0,0 +1,59 @@
+local uci = require('simple-uci').cursor()
+
+if not uci:get('ap-timer', 'settings') then
+	uci:section('ap-timer', 'ap-timer', 'settings')
+	uci:save('ap-timer')
+end
+
+if not uci:get('ap-timer', 'all') then
+	uci:section('ap-timer', 'day', 'all')
+	uci:save('ap-timer')
+end
+
+local f = Form(translate('AP Timer'), translate(
+	'You can setup the AP Timer here'))
+
+local s = f:section(Section)
+
+enabled = s:option(Flag, 'enabled', translate('Enabled'))
+enabled.default = uci:get_bool('ap-timer', 'settings', 'enabled')
+enabled.optional = false
+function enabled:write(data)
+	uci:set('ap-timer', 'settings', 'enabled', data)
+end
+
+local timer_type = s:option(ListValue, 'type', translate('Type'))
+timer_type.default = uci:get('ap-timer', 'settings', 'type')
+timer_type:depends(enabled, true)
+timer_type:value('day', translate('Daily'))
+function timer_type:write(data)
+	uci:set('ap-timer', 'settings', 'type', data)
+end
+
+local s = f:section(Section)
+
+o = s:option(DynamicList, 'on', translate('ON'))
+o.default = uci:get_list('ap-timer', 'all', 'on')
+o.placeholder = '06:30'
+o:depends(timer_type, 'day')
+o.optional = false
+o.datatype = 'minlength(5)'
+function o:write(data)
+	uci:set_list('ap-timer', 'all', 'on', data)
+end
+
+o = s:option(DynamicList, 'off', translate('OFF'))
+o.default = uci:get_list('ap-timer', 'all', 'off')
+o.placeholder = '23:00'
+o:depends(timer_type, 'day')
+o.optional = false
+o.datatype = 'minlength(5)'
+function o:write(data)
+	uci:set_list('ap-timer', 'all', 'off', data)
+end
+
+function f:write()
+	uci:commit('ap-timer')
+end
+
+return f