diff options
author | Mika Havela <mika.havela@gmail.com> | 2008-02-23 09:43:19 +0000 |
---|---|---|
committer | Mika Havela <mika.havela@gmail.com> | 2008-02-23 09:43:19 +0000 |
commit | 122904f71112023b7257ac48239271e05b92fe81 (patch) | |
tree | 99cd41abb01b063f0b2602229b2dd948b1174418 /tinydns-controller.lua | |
parent | c9b0ebbd3f0a467f253606a385235f1a8a1304d0 (diff) | |
download | acf-tinydns-122904f71112023b7257ac48239271e05b92fe81.tar.bz2 acf-tinydns-122904f71112023b7257ac48239271e05b92fe81.tar.xz |
Output can now be filtered in levels (can only be done by modifying in the controller for now).
A problem has appeared - We cant sort the output when the tables are constructed as they are. Next commit will/should have changed the table-layout.
git-svn-id: svn://svn.alpinelinux.org/acf/tinydns/trunk@767 ab2d0c66-481e-0410-8bed-d214d4d58bed
Diffstat (limited to 'tinydns-controller.lua')
-rw-r--r-- | tinydns-controller.lua | 101 |
1 files changed, 80 insertions, 21 deletions
diff --git a/tinydns-controller.lua b/tinydns-controller.lua index 8021ae3..030257f 100644 --- a/tinydns-controller.lua +++ b/tinydns-controller.lua @@ -1,5 +1,7 @@ module(..., package.seeall) +local pvt = {} + local list_redir = function (self) self.conf.action = "status" self.conf.type = "redir" @@ -26,77 +28,134 @@ 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.nsourdomain = cfe ({ + config.settings.nsourdomain = cfe ({ name="nsourdomain", label=availablesigns[prefix], value=self.model.getconfigobjects(self,prefix), }) local prefix = "&" - config.nsdomain = cfe ({ - name="nsdomain", - label=availablesigns[prefix], - value=self.model.getconfigobjects(self,prefix), - }) + config.settings.nsdomain = cfe ({ + name="nsdomain", + label=availablesigns[prefix], + value=self.model.getconfigobjects(self,prefix), + }) local prefix = "=" - config.host = cfe ({ + config.settings.host = cfe ({ name="host", label=availablesigns[prefix], value=self.model.getconfigobjects(self,prefix), }) local prefix = "+" - config.alias = cfe ({ + config.settings.alias = cfe ({ name="alias", label=availablesigns[prefix], value=self.model.getconfigobjects(self,prefix), }) local prefix = "@" - config.mx = cfe ({ + config.settings.mx = cfe ({ name="mx", label=availablesigns[prefix], value=self.model.getconfigobjects(self,prefix), }) local prefix = "^" - config.ptr = cfe ({ - name="ptr", - label=availablesigns[prefix], - value=self.model.getconfigobjects(self,prefix), - }) + config.settings.ptr = cfe ({ + name="ptr", + label=availablesigns[prefix], + value=self.model.getconfigobjects(self,prefix), + }) local prefix = "C" - config.cname = cfe ({ + config.settings.cname = cfe ({ name="cname", label=availablesigns[prefix], value=self.model.getconfigobjects(self,prefix), }) local prefix = "Z" - config.soa = cfe ({ + config.settings.soa = cfe ({ name="soa", label=availablesigns[prefix], value=self.model.getconfigobjects(self,prefix), }) local prefix = ":" - config.generic = cfe ({ - name="generic", - label=availablesigns[prefix], - value=self.model.getconfigobjects(self,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 } |