summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMika Havela <mika.havela@gmail.com>2009-07-09 11:54:27 +0000
committerMika Havela <mika.havela@gmail.com>2009-07-09 11:54:27 +0000
commita08c1bd2894983d7453af0118795edf85788cf0f (patch)
tree2dd600c5bdd63fbaa10909bf0d13868d5d26dd39
parentc6b5228ab2bdf1578a32ffb9cb06b2962cfcb5c6 (diff)
downloadacf-rrdtool-a08c1bd2894983d7453af0118795edf85788cf0f.tar.bz2
acf-rrdtool-a08c1bd2894983d7453af0118795edf85788cf0f.tar.xz
Edit existing and create new graph-files
Putting back full path on graph-files to get standard functions to work propperly
-rw-r--r--rrdtool-controller.lua12
-rw-r--r--rrdtool-listgraphcfg-html.lsp2
-rw-r--r--rrdtool-model.lua24
3 files changed, 28 insertions, 10 deletions
diff --git a/rrdtool-controller.lua b/rrdtool-controller.lua
index 28a94f0..7efd8fa 100644
--- a/rrdtool-controller.lua
+++ b/rrdtool-controller.lua
@@ -63,8 +63,14 @@ function config(self)
end
function editgraphcfg(self)
- return controllerfunctions.handle_form(self,
+ config = controllerfunctions.handle_form(self,
function() return self.model.getgraphfile(self.clientdata.filename) end,
- function() return self.model.setgraphfile() end,
- self.clientdata, "Save", "Edit Config", "Configuration Saved")
+ function(value)
+ return self.model.set_filedetails(self, value, sessiondata.userinfo.userid)
+ end, self.clientdata, "Save", "Edit Config File", "Config File Saved")
+
+ if self.clientdata.linenumber and validator.is_integer(self.clientdata.linenumber) then
+ config.value.filecontent.linenumber = self.clientdata.linenumber
+ end
+ return config
end
diff --git a/rrdtool-listgraphcfg-html.lsp b/rrdtool-listgraphcfg-html.lsp
index 7ca6df5..e4c4a84 100644
--- a/rrdtool-listgraphcfg-html.lsp
+++ b/rrdtool-listgraphcfg-html.lsp
@@ -39,7 +39,7 @@ function javascript_confirm_graph(formID,filename) {
<A STYLE="cursor: pointer;" onclick="javascript_confirm_graph('confirmDisplay','<% io.write(file.value.filename.value) %>')">Delete</A>
<% end %>
<%
- if session.permissions[page_info.controller].edit then io.write(html.link{value = "editgraphcfg?filename=" .. string.gsub(file.value.filename.value, "^.*/", "").."&redir="..page_info.orig_action, label="Edit " }) end
+ if session.permissions[page_info.controller].edit then io.write(html.link{value = "editgraphcfg?filename=" .. file.value.filename.value, label="Edit " }) end
%>
</TD>
<TD style="padding-right:20px;white-space:nowrap;text-align:right;"><%= html.html_escape(file.value.filesize.value) %></TD>
diff --git a/rrdtool-model.lua b/rrdtool-model.lua
index 16ba2be..e915a4a 100644
--- a/rrdtool-model.lua
+++ b/rrdtool-model.lua
@@ -228,21 +228,33 @@ function getgraphlist()
end
function getgraphfile(path)
- if (path) then
- path = graphpath .. "/" .. path
- end
if (path) and not (validfilename(path)) then
path = nil
end
local filedetails = modelfunctions.getfiledetails(path)
local output = {value={filename=filedetails.value.filename,
filecontent=filedetails.value.filecontent,}}
- output.value.filename.value = string.gsub(filedetails.value.filename.value, "^.*/", "")
-- output.value.filecontent.rows="30" -- FIXME: For some reason I can't control the size of a textarea
if not (path) then
output.value.filename.errtxt=nil
- else
- output.value.filename.disabled="true"
end
return output
end
+
+function set_filedetails (self, filedetails, userid)
+ if not (string.match(filedetails.value.filename.value, "^" .. graphpath)) then
+ filedetails.value.filename.value = graphpath .. "/" .. string.gsub(filedetails.value.filename.value,"^.*/", "")
+ end
+ if not (string.match(filedetails.value.filename.value, "\.graph$")) then
+ filedetails.value.filename.value = filedetails.value.filename.value .. ".graph"
+ end
+
+ filedetails = modelfunctions.setfiledetails(filedetails, getgraphlist)
+ filedetails.value.filesize = nil
+ filedetails.value.mtime = nil
+ return filedetails
+end
+
+function setgraphfile(filedetails,file)
+ return modelfunctions.setfiledetails(filedetails, {file})
+end