summaryrefslogtreecommitdiffstats
path: root/rrdtool-controller.lua
blob: 28a94f0e494362a756b615429f196fed13080cce (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
module(..., package.seeall)

-- Load libraries
require("controllerfunctions")

default_action = "status"

function status(self)
	return self.model.getstatus()
end

function config(self)
	return controllerfunctions.handle_form(self, self.model.read_config, self.model.update_config, self.clientdata, "Save", "Edit Config", "Configuration Saved")
end

function startstop(self)
	return controllerfunctions.handle_startstop(self, self.model.startstop_service, self.clientdata)
end

function expert(self)
	return controllerfunctions.handle_form(self, self.model.getconfigfile, self.model.setconfigfile, self.clientdata, "Save", "Edit Config", "Configuration Saved")
end

function listrrd(self)
	local configfiles = self.model.getrrdlist()
	local config = {}

	return cfe({ type="list", value=configfiles.value, label="View/Edit RoundRobinDatabase (rrd) files" })
end

function createrrd(self)
	return controllerfunctions.handle_form(self, self.model.createnewrrd, function(value)
			return self.model.savenewrrd(self, value, sessiondata.userinfo.userid)
		end, self.clientdata, "Save", "Create new RRD", "File saved")
end

function delete(self)
	return self:redirect_to_referrer(self.model.remove_file(self, self.clientdata.filename, sessiondata.userinfo.userid))
end

function rrdinfo(self)
	return self:redirect_to_referrer(self.model.rrd_info(self, self.clientdata.filename, sessiondata.userinfo.userid))
end

function listgraphs(self)
	return self.model.list_graphs()
end

function viewgraph(self)
	self.conf.viewtype = "popup"
	return self.model.view_graph(self, self.clientdata.group, self.clientdata.id)
end

function listgraphcfg(self)
	local configfiles = self.model.getgraphlist()
	local config = {}

	return cfe({ type="list", value=configfiles.value, label="View/Edit graph files" })
end

function config(self)
	return nil
end

function editgraphcfg(self)
	return 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")
end