diff options
author | Mika Havela <mika.havela@gmail.com> | 2008-04-04 12:55:11 +0000 |
---|---|---|
committer | Mika Havela <mika.havela@gmail.com> | 2008-04-04 12:55:11 +0000 |
commit | 4a2da345f00f3e387bcbf2e2436f33a99c61ece8 (patch) | |
tree | 6b59b9eecc0648108f7b960ff7e333c354482a10 | |
parent | a80960d4f26c82077b9c587f1c7ccca829b94057 (diff) | |
download | acf-opennhrp-4a2da345f00f3e387bcbf2e2436f33a99c61ece8.tar.bz2 acf-opennhrp-4a2da345f00f3e387bcbf2e2436f33a99c61ece8.tar.xz |
Showing config errors in expert tab.
git-svn-id: svn://svn.alpinelinux.org/acf/opennhrp/trunk@919 ab2d0c66-481e-0410-8bed-d214d4d58bed
-rw-r--r-- | opennhrp-model.lua | 60 |
1 files changed, 49 insertions, 11 deletions
diff --git a/opennhrp-model.lua b/opennhrp-model.lua index 6b3b0ae..41c1569 100644 --- a/opennhrp-model.lua +++ b/opennhrp-model.lua @@ -152,34 +152,72 @@ function getstatus() return status end -function get_filedetails() - local path = configfile - local filedetails = fs.stat(path) +function getconfig() + local config = {} + return config +end + +function get_filedetails(self,num) + local path + if (num == "2") then + path = configfile2 + else + path = configfile + end local file = {} + local filedetails = {} + local config = {} + local filenameerrtxt + if (path) and (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", + file["filename" .. (num or "")] = cfe({ + name="filename" .. (num or ""), label="File name", value=path, + errtxt=filenameerrtxt }) - file["filesize"] = cfe({ - name="filesize", + file["filesize" .. (num or "")] = cfe({ + name="filesize" .. (num or ""), label="File size", value=filedetails.size or 0, }) - file["mtime"] = cfe({ - name="mtime", + file["mtime" .. (num or "")] = cfe({ + name="mtime" .. (num or ""), label="File date", value=filedetails.mtime or "---", }) - file["filecontent"] = cfe({ + file["filecontent" .. (num or "")] = cfe({ type="longtext", - name="filecontent", + name="filecontent" .. (num or ""), label="File content", value=fs.read_file(path), }) + + -- 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" .. (num or "")] = cfe ({ + name="sumerrors" .. (num or ""), + label = "Configuration errors", + errtxt = string.match(sumerrors, "(.-)\n$"), + }) + end + return file end + function update_filecontent (self, modifications) local path = configfile local file_result,err = fs.write_file(path, format.dostounix(modifications)) |