From c69ac570705d815f6c0406169f307c71b8376398 Mon Sep 17 00:00:00 2001 From: Mika Havela Date: Fri, 4 Apr 2008 13:00:17 +0000 Subject: Showing config errors in expert tab. git-svn-id: svn://svn.alpinelinux.org/acf/alpine-conf/trunk@922 ab2d0c66-481e-0410-8bed-d214d4d58bed --- lbu-controller.lua | 2 +- lbu-expert-html.lsp | 14 ++++++------ lbu-model.lua | 62 +++++++++++++++++++++++++++++++++++++---------------- 3 files changed, 50 insertions(+), 28 deletions(-) diff --git a/lbu-controller.lua b/lbu-controller.lua index 304b0ac..6bca902 100644 --- a/lbu-controller.lua +++ b/lbu-controller.lua @@ -183,7 +183,7 @@ function commit(self) url = url, } ) end expert = function (self) - local modifications = self.clientdata.modifications or "" + local modifications = self.clientdata.filecontent or "" if ( self.clientdata.cmdsave) then modifications = self.model:update_filecontent(modifications) end diff --git a/lbu-expert-html.lsp b/lbu-expert-html.lsp index cea7e4c..219d748 100644 --- a/lbu-expert-html.lsp +++ b/lbu-expert-html.lsp @@ -42,21 +42,19 @@ displayinfo(myform,tags,"viewonly")

CONFIGURATION

-

Expert config

-

File details

+
+

EXPERT CONFIGURATION

+

FILE DETAILS

- -

File content

- +

FILE CONTENT

Save and apply above settings

diff --git a/lbu-model.lua b/lbu-model.lua index 044d877..da5e22c 100644 --- a/lbu-model.lua +++ b/lbu-model.lua @@ -287,35 +287,59 @@ function editconfig (self,variable,value) return value end function get_filedetails() - local filedetails = {} local path = configfile - local filestats = fs.stat(path) - filedetails.name = cfe ({ - name="name", + local file = {} + local filedetails = {} + local config = {} + local filenameerrtxt + if (fs.is_file(path)) then + filedetails = fs.stat(path) + config = getconfig(path) + else + config = {} + config.filename = {} + config["filename"]["errtxt"]="Config file '".. path .. "' is missing!" + end + + file["filename"] = cfe({ + name="filename", + label="File name", value=path, - label="File name" + errtxt=filenameerrtxt }) - - filedetails.size = cfe ({ - name="size", - value=filestats.size or "0", + file["filesize"] = cfe({ + name="filesize", label="File size", + value=filedetails.size or 0, }) - - filedetails.mtime = cfe ({ + file["mtime"] = cfe({ name="mtime", - value=filestats.mtime or "---", - label="File modified", + label="File date", + value=filedetails.mtime or "---", }) - - filedetails.modifications = cfe ({ - name="modifications", - value=fs.read_file(path), - label="File content", + file["filecontent"] = cfe({ type="longtext", + name="filecontent", + label="File content", + value=fs.read_file(path), }) - return filedetails + -- Sum all errors into one cfe + local sumerrors = "" + for k,v in pairs(config) do + if (config[k]) and (config[k]["errtxt"]) and (config[k]["errtxt"] ~= "") then + sumerrors = sumerrors .. config[k]["errtxt"] .. "\n" + end + end + if (sumerrors ~= "") then + file["sumerrors"] = cfe ({ + name="sumerrors", + label = "Configuration errors", + errtxt = string.match(sumerrors, "(.-)\n$"), + }) + end + + return file end function update_filecontent (self, modifications) local path = configfile -- cgit v1.2.3