summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMika Havela <mika.havela@gmail.com>2008-04-04 13:00:17 +0000
committerMika Havela <mika.havela@gmail.com>2008-04-04 13:00:17 +0000
commitc69ac570705d815f6c0406169f307c71b8376398 (patch)
tree94621c01f0e1e290f3f3153a2c002cadd2f04824
parentbf7784e516f27f72fc3443873a2ac04f4d6e7e19 (diff)
downloadacf-alpine-conf-c69ac570705d815f6c0406169f307c71b8376398.tar.bz2
acf-alpine-conf-c69ac570705d815f6c0406169f307c71b8376398.tar.xz
Showing config errors in expert tab.
git-svn-id: svn://svn.alpinelinux.org/acf/alpine-conf/trunk@922 ab2d0c66-481e-0410-8bed-d214d4d58bed
-rw-r--r--lbu-controller.lua2
-rw-r--r--lbu-expert-html.lsp14
-rw-r--r--lbu-model.lua62
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")
<h1>CONFIGURATION</h1>
-<H2>Expert config</H2>
-<h3>File details</h3>
+<form name="myform" action="" method="POST">
+<H2>EXPERT CONFIGURATION</H2>
+<H3>FILE DETAILS</H3>
<?
local myform = form.file
-local tags = { "name", "size", "mtime", }
+local tags = { "filename", "filesize", "mtime", "sumerrors" }
displayinfo(myform,tags,"viewonly")
?>
-
-<h3>File content</h3>
-<form name="myform" action="" method="POST">
+<H3>FILE CONTENT</H3>
<?
-local myform = form.file.modifications
-io.write(html.form[myform.type](myform))
+io.write(html.form[myform.filecontent.type](myform.filecontent))
?>
<H2>Save and apply above settings</H2>
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