diff options
Diffstat (limited to 'logfiles-model.lua')
-rw-r--r-- | logfiles-model.lua | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/logfiles-model.lua b/logfiles-model.lua index a43de6c..95bcb19 100644 --- a/logfiles-model.lua +++ b/logfiles-model.lua @@ -1,5 +1,5 @@ -- acf model for displaying logfiles -module (..., package.seeall) +local mymodule = {} posix = require("posix") modelfunctions = require("modelfunctions") @@ -80,9 +80,9 @@ local do_grep = function(filecontent, grep) end end -get_filedetails = function (path, grep) +mymodule.get_filedetails = function (path, grep) local success = false - local available_files = get() + local available_files = mymodule.get() for i,file in ipairs(available_files.value) do if file.value.filename.value == path then success = true @@ -106,14 +106,14 @@ get_filedetails = function (path, grep) return filedetails end -tail = function(path, offset, grep) +mymodule.tail = function(path, offset, grep) local filename = cfe({ value=path, label="File name", errtxt="File not found" }) local filesize = cfe({ value="0", label="File size" }) local filecontent = cfe({ type="longtext", label="File content" }) local fileoffset = cfe({ value="0", label="File offset" }) local filegrep = cfe({ value=grep or "", label="Grep" }) - local available_files = get() + local available_files = mymodule.get() for i,file in ipairs(available_files.value) do if ( file.value.filename.value == path ) then filename.errtxt = nil @@ -141,15 +141,15 @@ tail = function(path, offset, grep) return cfe({ type="group", value={filename=filename, filecontent=filecontent, filesize=filesize, fileoffset=fileoffset, grep=filegrep}, label="Tail Config file details" }) end -get = function () +mymodule.get = function () -- These folders (and their subfolers) are going to be listed return list_files( "/var/log", "/tmp/squid/log" ) end -get_delete = function() +mymodule.get_delete = function() local filename = cfe({ type="select", label="File name", option={} }) -- Get a list of files that could be deleted - local available_files = get() + local available_files = mymodule.get() for i,file in ipairs(available_files.value) do filename.option[#filename.option+1] = file.value.filename.value end @@ -158,7 +158,7 @@ get_delete = function() end -- Function to check if a file is deletable, and if it is, then delete it. -delete = function (self, filetodelete) +mymodule.delete = function (self, filetodelete) local success = modelfunctions.validateselect(filetodelete.value.filename) if success then @@ -182,9 +182,9 @@ delete = function (self, filetodelete) if not success then filetodelete.errtxt = "Failed to delete file" -self.logevent(filetodelete.value.filename.errtxt) end return filetodelete end +return mymodule |