module(..., package.seeall) local pvt = {} local list_redir = function (self) self.conf.action = "status" self.conf.type = "redir" error (self.conf) end mvc = {} mvc.on_load = function(self, parent) if (self.worker[self.conf.action] == nil ) or ( self.conf.action == "init" ) then self.worker[self.conf.action] = list_redir(self) end end local function getstatus(self) local status = self.model.getstatus() if (#status.status.value > 0) then status.status.value = "Enabled" else status.status.value = "Disabled" end return status end function status(self) local config = {} config.settings = {} -- local array = {} local locations=self.model.getlocations(self) local availablesigns = self.model.check_signs("prefix") config.locations = cfe ({ name="locations", label="Locations", value=locations, }) --[[ local prefix = "." config.settings.nsourdomain = cfe ({ name="nsourdomain", label=availablesigns[prefix], value=self.model.getconfigobjects(self,prefix), }) local prefix = "&" config.settings.nsdomain = cfe ({ name="nsdomain", label=availablesigns[prefix], value=self.model.getconfigobjects(self,prefix), }) local prefix = "=" config.settings.host = cfe ({ name="host", label=availablesigns[prefix], value=self.model.getconfigobjects(self,prefix), }) local prefix = "+" config.settings.alias = cfe ({ name="alias", label=availablesigns[prefix], value=self.model.getconfigobjects(self,prefix), }) local prefix = "@" config.settings.mx = cfe ({ name="mx", label=availablesigns[prefix], value=self.model.getconfigobjects(self,prefix), }) local prefix = "^" config.settings.ptr = cfe ({ name="ptr", label=availablesigns[prefix], value=self.model.getconfigobjects(self,prefix), }) local prefix = "C" config.settings.cname = cfe ({ name="cname", label=availablesigns[prefix], value=self.model.getconfigobjects(self,prefix), }) local prefix = "Z" config.settings.soa = cfe ({ name="soa", label=availablesigns[prefix], value=self.model.getconfigobjects(self,prefix), }) local prefix = ":" config.settings.generic = cfe ({ name="generic", label=availablesigns[prefix], value=self.model.getconfigobjects(self,prefix), }) --]] config.settings.all = cfe ({ name="generic", label="All available records", value=self.model.getconfigobjects(self), }) local counter -- colapse_output(config.settings, pvt) ---[[ -- We count the rows of the previous columns -- This counter is then used to set the default filter (when user has not entered any values) -- FIXME: This is a uggly way of doing things. It's just a way to get going faster local filterstage = 3 local mytable = config.settings for k1,v1 in pairs(mytable) do if not (counter) then counter = 0 end if (type(v1) == "table") then for k2,v2 in pairs(v1) do if (type(v2) == "table") then for s1,vs1 in pairs(v2) do if (type(vs1) == "table") then for s2,vs2 in pairs(vs1) do if (filterstage) and (filterstage == 2) then mytable[k1][k2][s1][s2] = {} -- Removes stage2 and above else if (type(vs2) == "table") then for s3,vs3 in pairs(vs2) do if (filterstage) and (filterstage == 3) and not (vs3.name) then mytable[k1][k2][s1][s2][s3] = {} -- Removes stage3 and above end end end end end end end end end end end --]] config.debug = cfe ({ name="debug", label="Counted rows", value=pvt, errtxt=" ", }) return { status=getstatus(self), config=config } end function config(self) local config = self.model.getconfigobjects(self) local debug = self.model.getdebug(self) return ({ status=getstatus(self), config=config, debug=debug, }) end