From 4fd29b69a10f27c6a48e5bba9d55a10241e6eb5c Mon Sep 17 00:00:00 2001 From: Mika Havela Date: Wed, 8 Jul 2009 13:11:02 +0000 Subject: List graph-files (created the view-file) Updated the validfilename() to be able to modify/delete graph-files too. --- rrdtool-controller.lua | 2 +- rrdtool-listgraphcfg-html.lsp | 68 +++++++++++++++++++++++++++++++++++++++++++ rrdtool-model.lua | 16 +++++++--- 3 files changed, 81 insertions(+), 5 deletions(-) create mode 100644 rrdtool-listgraphcfg-html.lsp diff --git a/rrdtool-controller.lua b/rrdtool-controller.lua index ac0e1cb..100cd9c 100644 --- a/rrdtool-controller.lua +++ b/rrdtool-controller.lua @@ -51,7 +51,7 @@ function viewgraph(self) end function listgraphcfg(self) - local configfiles = self.model.getrrdlist() + local configfiles = self.model.getgraphlist() local config = {} return cfe({ type="list", value=configfiles.value, label="View/Edit graph files" }) diff --git a/rrdtool-listgraphcfg-html.lsp b/rrdtool-listgraphcfg-html.lsp new file mode 100644 index 0000000..b2ad204 --- /dev/null +++ b/rrdtool-listgraphcfg-html.lsp @@ -0,0 +1,68 @@ +<% local form, viewlibrary, page_info, session = ... +require("viewfunctions") +%> +<% +--[[ DEBUG INFORMATION +io.write("

DEBUGGING

DEBUG INFO: CFE

") +io.write(html.cfe_unpack(form)) +io.write("
") +--]] +%> + +<% displaycommandresults({"delete"}, session) %> + + + +

<%= form.label %>

+ +
+ + + + + + + + +<% for i,file in ipairs(form.value) do %> + + + + + + +<% end %> + + <% if session.permissions[page_info.controller].createrrd then %> + + + + + <% end %> + +
ActionSizeLast ModifiedFile
+ <% if session.permissions[page_info.controller].delete then %> + Delete + <% end %> + <% + if session.permissions[page_info.controller].edit then io.write(html.link{value = "edit?filename=" .. file.value.filename.value.."&redir="..page_info.orig_action, label="Edit " }) end + %> + <%= html.html_escape(file.value.filesize.value) %><%= html.html_escape(file.value.mtime.value) %><%= html.html_escape(string.gsub(file.value.filename.value, "^.*/", "")) %>
+ <% io.write(html.link{value = "createrrd", label="Create new DB " }) %> +    
+ +<% if viewlibrary and viewlibrary.dispatch_component and session.permissions[page_info.controller].newfile then + local newfileform = viewlibrary.dispatch_component("newfile", nil, true) %> +

Create new Domain

+<% + newfileform.action = page_info.script .. page_info.prefix .. page_info.controller .. "/newfile" + displayform(newfileform) +end %> diff --git a/rrdtool-model.lua b/rrdtool-model.lua index 2acc464..834cae3 100644 --- a/rrdtool-model.lua +++ b/rrdtool-model.lua @@ -47,10 +47,14 @@ local function list_files (path,search) end local function validfilename(path) - local files = list_files(databases) - for k,v in pairs(files.value) do - if (v["value"]["filename"]["value"] == path) then - return true, tostring(v["value"]["filename"]["value"]) + local files = fs.find_files_as_array(nil, databases) + + for k,v in pairs(fs.find_files_as_array(".*graph",graphpath)) do + table.insert(files,v) + end + for k,v in pairs(files) do + if (v == path) then + return true, tostring(path) end end return false, "Not a valid filename!" @@ -226,3 +230,7 @@ function view_graph(self, graph_grp, graph_id) return settings end + +function getgraphlist() + return list_files(graphpath,".*graph") +end -- cgit v1.2.3