From 92ca7f33c28f217a6ea1121558de8029539cd72b Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Fri, 31 Jul 2009 00:18:13 +0000 Subject: [PATCH] luci-0.9: merge r5176-r5182 --- .../luasrc/statistics/i18n.lua | 24 ++++++------- libs/cbi/luasrc/cbi.lua | 34 +++++++++++++------ libs/cbi/luasrc/view/cbi/delegator.htm | 2 ++ .../luasrc/model/cbi/admin_system/system.lua | 1 + .../luasrc/model/cbi/mini/system.lua | 1 + 5 files changed, 39 insertions(+), 23 deletions(-) diff --git a/applications/luci-statistics/luasrc/statistics/i18n.lua b/applications/luci-statistics/luasrc/statistics/i18n.lua index 4cbcdd4cf..213131bd3 100644 --- a/applications/luci-statistics/luasrc/statistics/i18n.lua +++ b/applications/luci-statistics/luasrc/statistics/i18n.lua @@ -43,13 +43,13 @@ end function Instance.title( self, plugin, pinst, dtype, dinst ) - local title = self.i18n.translate( + local title = self.i18n.string( string.format( "stat_dg_title_%s_%s_%s", plugin, pinst, dtype ), - self.i18n.translate( + self.i18n.string( string.format( "stat_dg_title_%s_%s", plugin, pinst ), - self.i18n.translate( + self.i18n.string( string.format( "stat_dg_title_%s__%s", plugin, dtype ), - self.i18n.translate( + self.i18n.string( string.format( "stat_dg_title_%s", plugin ), self.graph:_mkpath( plugin, pinst, dtype ) ) @@ -68,13 +68,13 @@ end function Instance.label( self, plugin, pinst, dtype, dinst ) - local label = self.i18n.translate( + local label = self.i18n.string( string.format( "stat_dg_label_%s_%s_%s", plugin, pinst, dtype ), - self.i18n.translate( + self.i18n.string( string.format( "stat_dg_label_%s_%s", plugin, pinst ), - self.i18n.translate( + self.i18n.string( string.format( "stat_dg_label_%s__%s", plugin, dtype ), - self.i18n.translate( + self.i18n.string( string.format( "stat_dg_label_%s", plugin ), self.graph:_mkpath( plugin, pinst, dtype ) ) @@ -93,13 +93,13 @@ end function Instance.ds( self, source ) - local label = self.i18n.translate( + local label = self.i18n.string( string.format( "stat_ds_%s_%s_%s", source.type, source.instance, source.ds ), - self.i18n.translate( + self.i18n.string( string.format( "stat_ds_%s_%s", source.type, source.instance ), - self.i18n.translate( + self.i18n.string( string.format( "stat_ds_label_%s__%s", source.type, source.ds ), - self.i18n.translate( + self.i18n.string( string.format( "stat_ds_%s", source.type ), source.type .. "_" .. source.instance:gsub("[^%w]","_") .. "_" .. source.ds ) diff --git a/libs/cbi/luasrc/cbi.lua b/libs/cbi/luasrc/cbi.lua index f3c481cf8..83f5c27e7 100644 --- a/libs/cbi/luasrc/cbi.lua +++ b/libs/cbi/luasrc/cbi.lua @@ -60,17 +60,18 @@ function load(cbimap, ...) local upldir = "/lib/uci/upload/" local cbidir = luci.util.libpath() .. "/model/cbi/" - - assert(fs.stat(cbimap) or - fs.stat(cbidir..cbimap..".lua") or - fs.stat(cbidir..cbimap..".lua.gz"), - "Model not found!") - - local func, err = loadfile(cbimap) - if not func then - func, err = loadfile(cbidir..cbimap..".lua") or - loadfile(cbidir..cbimap..".lua.gz") + local func, err + + if fs.access(cbimap) then + func, err = loadfile(cbimap) + elseif fs.access(cbidir..cbimap..".lua") then + func, err = loadfile(cbidir..cbimap..".lua") + elseif fs.access(cbidir..cbimap..".lua.gz") then + func, err = loadfile(cbidir..cbimap..".lua.gz") + else + func, err = nil, "Model '" .. cbimap .. "' not found!" end + assert(func, err) luci.i18n.loadc("cbi") @@ -286,6 +287,11 @@ function Template.render(self) luci.template.render(self.template, {self=self}) end +function Template.parse(self, readinput) + self.readinput = (readinput ~= false) + return Map.formvalue(self, "cbi.submit") and FORM_DONE or FORM_NODATA +end + --[[ Map - A map describing a configuration file @@ -499,6 +505,7 @@ function Delegator.__init__(self, ...) self.defaultpath = {} self.pageaction = false self.readinput = true + self.allow_reset = false self.allow_back = false self.allow_finish = false self.template = "cbi/delegator" @@ -572,9 +579,14 @@ function Delegator.parse(self, ...) else newcurrent = self:get_next(self.current) end + elseif stat < FORM_PROCEED then + return stat end + - if not newcurrent or not self:get(newcurrent) then + if not Map.formvalue(self, "cbi.submit") then + return FORM_NODATA + elseif not newcurrent or not self:get(newcurrent) then return FORM_DONE else self.current = newcurrent diff --git a/libs/cbi/luasrc/view/cbi/delegator.htm b/libs/cbi/luasrc/view/cbi/delegator.htm index 523eebcda..95fd270f8 100644 --- a/libs/cbi/luasrc/view/cbi/delegator.htm +++ b/libs/cbi/luasrc/view/cbi/delegator.htm @@ -20,7 +20,9 @@ $Id$ <% if self.allow_back and self:get_prev(self.current) then %> <% end %> +<% if self.allow_reset then %> +<% end %> <% if self.allow_finish and not self:get_next(self.current) then %> <% elseif self:get_next(self.current) then %> diff --git a/modules/admin-full/luasrc/model/cbi/admin_system/system.lua b/modules/admin-full/luasrc/model/cbi/admin_system/system.lua index 1d35dee7f..da51b452d 100644 --- a/modules/admin-full/luasrc/model/cbi/admin_system/system.lua +++ b/modules/admin-full/luasrc/model/cbi/admin_system/system.lua @@ -40,6 +40,7 @@ s:option(DummyValue, "_memtotal", translate("m_i_memory")).value = tostring(translate("mem_buffered", "")), 100 * memfree / memtotal, tostring(translate("mem_free", "")) +) s:option(DummyValue, "_systime", translate("m_i_systemtime")).value = os.date("%c") diff --git a/modules/admin-mini/luasrc/model/cbi/mini/system.lua b/modules/admin-mini/luasrc/model/cbi/mini/system.lua index 4ef97e48e..4e7f9568b 100644 --- a/modules/admin-mini/luasrc/model/cbi/mini/system.lua +++ b/modules/admin-mini/luasrc/model/cbi/mini/system.lua @@ -43,6 +43,7 @@ s:option(DummyValue, "_memtotal", translate("m_i_memory")).value = tostring(translate("mem_buffered", "")), 100 * memfree / memtotal, tostring(translate("mem_free", "")) +) s:option(DummyValue, "_systime", translate("m_i_systemtime")).value = os.date("%c") -- 2.25.1