local mymodule = {}
posix = require("posix")

mymodule.default_action = "status"

-- Public methods

mymodule.status = function (self )
	return self.model.get()
end

mymodule.delete = function (self)
	return self.handle_form(self, self.model.get_delete, self.model.delete, self.clientdata, "Delete", "Delete File", "File Deleted")
end

mymodule.view = function (self)
	return self.model.get_filedetails(self.clientdata.filename or "", self.clientdata.grep)
end

mymodule.download = function (self)
	local filestatus = mymodule.view(self)
	local filecontent = filestatus.value.filecontent
	filecontent.label = posix.basename(filestatus.value.filename.value)
	return filecontent
end

mymodule.tail = function (self)
	return self.model.tail(self.clientdata.filename, self.clientdata.offset, self.clientdata.grep)
end

return mymodule
