diff options
author | Ted Trask <ttrask01@yahoo.com> | 2015-12-30 13:57:32 +0000 |
---|---|---|
committer | Ted Trask <ttrask01@yahoo.com> | 2015-12-30 13:57:32 +0000 |
commit | 24b4ce7925a99e6e10ecbea5d880fd24ab69a02b (patch) | |
tree | 1e8d9c629436b8fea7392df6f3b3a2e915be9e40 | |
parent | 7532f841ff628bbd76f1a013ddd3824c80f5154d (diff) | |
download | acf-dhcp-24b4ce7925a99e6e10ecbea5d880fd24ab69a02b.tar.bz2 acf-dhcp-24b4ce7925a99e6e10ecbea5d880fd24ab69a02b.tar.xz |
Change listfiles filesize to size, size and mtime not user-friendly, use posix.stat over fs.stat, use new format functions
-rw-r--r-- | dhcp-listfiles-html.lsp | 18 | ||||
-rw-r--r-- | dhcp-model.lua | 7 |
2 files changed, 6 insertions, 19 deletions
diff --git a/dhcp-listfiles-html.lsp b/dhcp-listfiles-html.lsp index 9af11cd..f12e321 100644 --- a/dhcp-listfiles-html.lsp +++ b/dhcp-listfiles-html.lsp @@ -3,20 +3,6 @@ htmlviewfunctions = require("htmlviewfunctions") html = require("acf.html") %> -<% -function convertsize(size) - if string.find(size, "k$") then - return tonumber(string.match(size, "[%d.]*")) * 1024.0 - elseif string.find(size, "M$") then - return tonumber(string.match(size, "[%d.]*")) * 1024.0 * 1024.0 - elseif string.find(size, "G$") then - return tonumber(string.match(size, "[%d.]*")) + 1024.0 * 1024.0 * 1024.0 - else - return tonumber(string.match(size, "[%d.]*")) - end -end -%> - <script type="text/javascript"> if (typeof jQuery == 'undefined') { document.write('<script type="text/javascript" src="<%= html.html_escape(page_info.wwwprefix) %>/js/jquery-latest.js"><\/script>'); @@ -57,8 +43,8 @@ end %> <tr> <td><% htmlviewfunctions.displayitem(cfe({type="link", value={filename=filename, redir=redir}, label="", option="Edit", action="expert"}), page_info, -1) %></td> <td><%= html.html_escape(file.filename) %></td> - <td><span class="hide"><%= convertsize(file.filesize) %>b</span><%= html.html_escape(file.filesize) %></td> - <td><%= html.html_escape(file.mtime) %></td> + <td><span class="hide"><%= html.html_escape(file.size or 0) %>b</span><%= format.formatfilesize(file.size) %></td> + <td><%= format.formattime(file.mtime) %></td> </tr> <% end %> </tbody></table> diff --git a/dhcp-model.lua b/dhcp-model.lua index 5f84e8e..1c20aed 100644 --- a/dhcp-model.lua +++ b/dhcp-model.lua @@ -790,12 +790,13 @@ end mymodule.listconfigfiles = function() local listed_files = {} for i,name in ipairs(filelist) do - local filedetails = fs.stat(name) or {} - table.insert ( listed_files , {filename=name, mtime=filedetails.mtime or "---", filesize=filedetails.size or "0"} ) + local filedetails = posix.stat(name) or {} + filedetails.filename = name + table.insert(listed_files, filedetails) end table.sort(listed_files, function (a,b) return (a.filename < b.filename) end ) - return cfe({ type="list", value=listed_files, label="DHCP File List" }) + return cfe({ type="structure", value=listed_files, label="DHCP File List" }) end mymodule.getconfigfile = function(self, clientdata) |