From 4d2325161be2448fb521b1aacc02965e9dfaba64 Mon Sep 17 00:00:00 2001 From: Mika Havela Date: Sat, 26 Apr 2008 09:59:53 +0000 Subject: Saving work for today. Create new configfile starts working. Delete configfile (work in progress - still not working). Added information on filesize/modifydate on each configfile. git-svn-id: svn://svn.alpinelinux.org/acf/tinydns/trunk@1048 ab2d0c66-481e-0410-8bed-d214d4d58bed --- tinydns-confirmaction-html.lsp | 14 +++++++++++ tinydns-controller.lua | 56 ++++++++++++++++++++++++++++++++++++++++-- tinydns-edit-html.lsp | 2 +- tinydns-expert-html.lsp | 30 +++++++++++++++++----- tinydns-model.lua | 22 +++++++++++++++++ tinydns.roles | 2 +- 6 files changed, 116 insertions(+), 10 deletions(-) create mode 100644 tinydns-confirmaction-html.lsp diff --git a/tinydns-confirmaction-html.lsp b/tinydns-confirmaction-html.lsp new file mode 100644 index 0000000..da6753e --- /dev/null +++ b/tinydns-confirmaction-html.lsp @@ -0,0 +1,14 @@ + +DEBUGGING

DEBUG INFO: CFE

") +io.write(html.cfe_unpack(form)) +io.write("
") +--]] +?> + +

DEBUGGING:
+This function still doesn't work.
+Need to get the information on what action we are about to execute and what file to use for this actino.


diff --git a/tinydns-controller.lua b/tinydns-controller.lua index 652f262..e13f001 100644 --- a/tinydns-controller.lua +++ b/tinydns-controller.lua @@ -235,8 +235,47 @@ function expert(self) actionresult, cmdmanagement = self.model:startstop_service( cmdmanagement.action ) end + local configopts = self.model:getconfig() + -- Show buttons/fileds for creation of new confifiles + local create = {} + create.name = cfe ({ + name="name", + label="Name of the new configfile", + value=string.gsub(configopts.baseurl.value, "/$", "") .. "/", + }) + create.cmdnew = cfe ({ + name="cmdnew", + label="Create new file", + type="submit", + value="Create", + }) + + -- In case we are trying to create a new configfile + if (self.clientdata.cmdnew) then + if (self.clientdata.name) and + (#self.clientdata.name > 0) and not + (string.gsub(self.clientdata.name, "/$", "") == string.gsub(create.name.value, "/$", "")) then + local createcreated, createerrtxt = self.model:createconfigfile(self.clientdata.name) + if (createerrtxt) and (#createerrtxt > 0) then + create.name.errtxt = createerrtxt + create.name.value = self.clientdata.name + end + else + create.name.errtxt = "Incorrect filename" + end + if (#create.name.errtxt == 0) then + create.cmdnew.descr = "* File was created" + end + end + local status = getstatus(self) - local config = self.model:getfilelist() + + local configfiles = self.model:getfilelist() + local config = {} + for k,v in pairs(configfiles) do + local filedetails = self.model:get_filedetails(v) + table.insert(config,filedetails) + end -- Management buttons (Hide/show buttons local pidofstatus @@ -261,8 +300,9 @@ function expert(self) management = management, config = config, status = status, + create = create, startstop = startstop, - debugclientdata = self.clientdata, + mhdebug = self.clientdata, } end @@ -291,6 +331,16 @@ function edit(self) value="Save", type="submit", }) + file.cmddelete = cfe({ name="cmddelete", + label="Delete this configfile", + value="Delete", + type="submit", + }) + + if (self.clientdata.cmddelete) then + redirect(self, "confirmaction") + end + if (modifications) then file.cmdsave.descr="* Changes has been saved!" end @@ -310,3 +360,5 @@ function edit(self) } end +function confirmaction(self) +end diff --git a/tinydns-edit-html.lsp b/tinydns-edit-html.lsp index 08dee18..ba9a696 100644 --- a/tinydns-edit-html.lsp +++ b/tinydns-edit-html.lsp @@ -40,7 +40,7 @@ io.write(html.form[myform.filecontent.type](myform.filecontent))

SAVE AND APPLY ABOVE SETTINGS

diff --git a/tinydns-expert-html.lsp b/tinydns-expert-html.lsp index d3248b1..83e8bf7 100644 --- a/tinydns-expert-html.lsp +++ b/tinydns-expert-html.lsp @@ -21,20 +21,38 @@ displayinfo(myform,tags,"viewonly")

CONFIGURATION

Expert config

-

List of files

+

Edit/View existing configfiles

+ - + + + + + + + - + + +
FileSizeLast Modified
+

Create new configfile

+
" method="POST"> +
+ +
+