summaryrefslogtreecommitdiffstats
path: root/syslog-controller.lua
blob: 48e7b56a75ec30312c5c842f63f9ab42e761ecb8 (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
module(..., package.seeall)

default_action = "status"

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

function config(self)
	local config
	if self.clientdata.Save then
		config = self.model.updateconfig(self.clientdata)
	else
		config = self.model.getconfig()
	end

	config.type = "form"
	config.label = "Edit config"
	config.option = "Save"

	return config
end

function expert(self)
	-- Save changes
	local config
	local modifications = self.clientdata.filecontent or ""
	if self.clientdata.Save then
		config = self.model:update_filecontent(modifications)
		if not config.errtxt then
			config.descr = "Saved File"
		end
	else
		config = self.model:get_filedetails()
	end

	config.type = "form"
	config.label = "Edit config"
	config.option = "Save"

	return config
end

function startstop(self)
	local result
	if self.clientdata.action then
		result = self.model:startstop_service(self.clientdata.action)
		self.sessiondata.syslogstartstopresult = result
		self.redirect_to_referrer(self)
	end

	local status = self.model.getstatus()
	if self.sessiondata.syslogstartstopresult then
		result = self.sessiondata.syslogstartstopresult
		self.sessiondata.syslogstartstopresult = nil
	end
	
	return cfe({ type="group", value={status=status, result=result} })
end

function basicstatus(self)
	status = self.model.getstatus()
	version = self.model.getversion()
	return cfe({ type="group", value={status=status, version=version} })
end