From 122904f71112023b7257ac48239271e05b92fe81 Mon Sep 17 00:00:00 2001 From: Mika Havela Date: Sat, 23 Feb 2008 09:43:19 +0000 Subject: 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 --- tinydns-controller.lua | 101 ++++++++++++++++++++++++++++++++++++++---------- tinydns-model.lua | 78 +++++++++++++++---------------------- tinydns-status-html.lsp | 10 ++++- 3 files changed, 120 insertions(+), 69 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 } diff --git a/tinydns-model.lua b/tinydns-model.lua index 286689f..a073011 100644 --- a/tinydns-model.lua +++ b/tinydns-model.lua @@ -342,17 +342,21 @@ function getconfigobjects(self,filter_type) end -- Set values and labels for field #4 - local name = "nameserver" - local label = "Name server" + name = "ttl" + label = "Time to live" -- Some configs uses third column in some other way - if (filecontent_table[1] == "=") or (filecontent_table[1] == "+") then - name = "ttl" - label = "Time to live" + if (filecontent_table[1] == ".") or (filecontent_table[1] == "&") then + name = "ns" + label = "Name server" end if (filecontent_table[1] == "@") then name = "mx" label = "Mail exchanger" end + if (filecontent_table[1] == "Z") then + name = "rname" + label = "Contact address" + end if (filecontent_table[4]) and (#filecontent_table[4]> 0) and (name) then table.insert(domaindetails, cfe ({ name=name, @@ -362,21 +366,21 @@ function getconfigobjects(self,filter_type) end -- Set values and labels for field #5 - local name = nil - local label = nil + name = "timestamp" + label = "Time stamp" -- Some configs uses third column in some other way if (filecontent_table[1] == ".") or (filecontent_table[1] == "&") then name = "ttl" label = "Time to live" end - if (filecontent_table[1] == "=") or (filecontent_table[1] == "+") then - name = "timestamp" - label = "Time stamp" - end if (filecontent_table[1] == "@") then name = "dist" label = "Distance" end + if (filecontent_table[1] == "Z") then + name = "ser" + label = "Serial number" + end if (filecontent_table[5]) and (#filecontent_table[5]> 0) and (name) then table.insert(domaindetails, cfe ({ name=name, @@ -386,24 +390,20 @@ function getconfigobjects(self,filter_type) end -- Set values and labels for field #6 - local name = nil - local label = nil + name = "lo" + label = "Location" -- Some configs uses third column in some other way if (filecontent_table[1] == ".") or (filecontent_table[1] == "&") then - name = "ttl" - label = "Time to live" - end - if (filecontent_table[1] == "=") or (filecontent_table[1] == "+") then name = "timestamp" label = "Time stamp" end if (filecontent_table[1] == "@") then - name = "dist" - label = "Distance" + name = "ttl" + label = "Time to live" end if (filecontent_table[1] == "Z") then - name = "ser" - label = "Serial number" + name = "ref" + label = "Refresh time" end if (filecontent_table[6]) and (#filecontent_table[6]> 0) and (name) then @@ -419,22 +419,16 @@ function getconfigobjects(self,filter_type) local label = nil -- Some configs uses third column in some other way if (filecontent_table[1] == ".") or (filecontent_table[1] == "&") then - name = "timestamp" - label = "Time stamp" - end - if (filecontent_table[1] == "=") or (filecontent_table[1] == "+") or - (filecontent_table[1] == "-") or (filecontent_table[1] == "^") or - (filecontent_table[1] == "C") then - name = "location" + name = "lo" label = "Location" end if (filecontent_table[1] == "@") then - name = "ttl" - label = "Time to live" + name = "timestamp" + label = "Timestamp" end if (filecontent_table[1] == "Z") then - name = "ref" - label = "Refresh time" + name = "ret" + label = "Retry time" end if (filecontent_table[7]) and (#filecontent_table[7]> 0) and (name) then table.insert(domaindetails, cfe ({ @@ -448,23 +442,13 @@ function getconfigobjects(self,filter_type) local name = nil local label = nil -- Some configs uses third column in some other way - if (filecontent_table[1] == ".") or (filecontent_table[1] == "&") then - name = "timestamp" - label = "Time stamp" - end - if (filecontent_table[1] == "=") or (filecontent_table[1] == "+") or - (filecontent_table[1] == "-") or (filecontent_table[1] == "^") or - (filecontent_table[1] == "C") then - name = "location" - label = "Location" - end if (filecontent_table[1] == "@") then - name = "ttl" - label = "Time to live" + name = "lo" + label = "Location" end if (filecontent_table[1] == "Z") then - name = "ref" - label = "Refresh time" + name = "exp" + label = "Expire time" end if (filecontent_table[8]) and (#filecontent_table[8]> 0) and (name) then table.insert(domaindetails, cfe ({ @@ -533,6 +517,8 @@ function getconfigobjects(self,filter_type) end -- TODO: Sort the domains table! + -- Sorting is not possible when things is done as they are (se above) + -- problem comese when we use keynames instead of [1], [2], ... return domains end diff --git a/tinydns-status-html.lsp b/tinydns-status-html.lsp index 03767d1..37a7c53 100644 --- a/tinydns-status-html.lsp +++ b/tinydns-status-html.lsp @@ -41,6 +41,12 @@ displayinfo(myform,tags,"viewonly")

PROGRAM SPECIFIC OPTIONS/INFORMATION

") @@ -100,8 +106,8 @@ end ?> ") for k,v in pairs(tags) do local myform = myform[v] -- cgit v1.2.3