summaryrefslogtreecommitdiffstats
path: root/dansguardian-controller.lua
diff options
context:
space:
mode:
Diffstat (limited to 'dansguardian-controller.lua')
-rw-r--r--dansguardian-controller.lua161
1 files changed, 109 insertions, 52 deletions
diff --git a/dansguardian-controller.lua b/dansguardian-controller.lua
index bcb7bed..9b19314 100644
--- a/dansguardian-controller.lua
+++ b/dansguardian-controller.lua
@@ -6,7 +6,20 @@ default_action = "general"
general = function( self )
- local info = { status = { value = "stopped" }, version = { value = self.model.get_dansguardian_version() }, srvctrl = { value = srvctrl} };
+ local service = {}
+ if self.clientdata.srvcmd then
+ local srvcmd = self.clientdata.srvcmd
+ if srvcmd == "start" or srvcmd == "stop" or srvcmd == "restart" then
+ service.srvcmdresult, service.message = self.model.service_control( srvcmd )
+ end
+ end
+
+ local info = {
+ status=self.model.get_status(),
+ version = self.model.get_dansguardian_version(),
+ autostart = self.model.get_autostart(),
+ srvctrl = { value = srvctrl}
+ }
local option = { script = ENV["SCRIPT_NAME"],
prefix = self.conf.prefix,
@@ -15,30 +28,25 @@ general = function( self )
extra = ""
}
- local service = { message="", status="", config="" }
-
- if self.clientdata.srvcmd then
- srvcmd = self.clientdata.srvcmd
- if srvcmd == "start" or srvcmd == "stop" or srvcmd == "restart" then
- service.message = self.model.service_control( srvcmd )
- end
- end
-
- if self.clientdata.cmd then
- if self.clientdata.cmd == "save" then
- local conf = self.clientdata
- local config = { filterip = conf.filterip, filterport = conf.filterport,
- proxyip = conf.proxyip, proxyport = conf.proxyport,
- accessdeniedaddress = conf.accessdeniedaddress,
- naughtynesslimit = conf.naughtynesslimit
- }
-
- self.model.update_general_config( config )
- end
+ -- Add a cmd button to the view
+ service.cmdsave = cfe({ name="cmdsave",
+ label="Save/Apply above settings",
+ value="Save",
+ type="submit",
+ })
+
+ if self.clientdata.cmdsave then
+ local conf = self.clientdata
+ local config = { filterip = conf.filterip, filterport = conf.filterport,
+ proxyip = conf.proxyip, proxyport = conf.proxyport,
+ accessdeniedaddress = conf.accessdeniedaddress,
+ naughtynesslimit = conf.naughtynesslimit
+ }
+ self.model.update_general_config( config )
+ service.cmdsave.descr="* Changes has been saved!"
end
-
+
service.status = self.model.get_status()
- info.status.value = service.status
service.config, service.cfgerr = self.model.get_general_config()
return ( cfe ({ option = option, service = service, info = info }) )
@@ -46,7 +54,20 @@ end
advanced = function( self )
- local info = { status = { value = "stopped" }, version = { value = self.model.get_dansguardian_version() }, srvctrl = { value = srvctrl} };
+ local service = {}
+ if self.clientdata.srvcmd then
+ local srvcmd = self.clientdata.srvcmd
+ if srvcmd == "start" or srvcmd == "stop" or srvcmd == "restart" then
+ service.srvcmdresult, service.message = self.model.service_control( srvcmd )
+ end
+ end
+
+ local info = {
+ status=self.model.get_status(),
+ version = self.model.get_dansguardian_version(),
+ autostart = self.model.get_autostart(),
+ srvctrl = { value = srvctrl}
+ }
local option = { script = ENV["SCRIPT_NAME"],
prefix = self.conf.prefix,
@@ -55,17 +76,7 @@ advanced = function( self )
extra = ""
}
- local service = { message="", status="", config="" }
-
- if self.clientdata.srvcmd then
- srvcmd = self.clientdata.srvcmd
- if srvcmd == "start" or srvcmd == "stop" or srvcmd == "restart" then
- service.message = self.model.service_control( srvcmd )
- end
- end
-
service.status = self.model.get_status()
- info.status.value = service.status
service.config, service.cfgerr = self.model.get_advanced_config()
return ( cfe ({ option = option, service = service, info = info }) )
@@ -73,34 +84,46 @@ end
plain = function( self )
+ local service = {}
+ if self.clientdata.srvcmd then
+ local srvcmd = self.clientdata.srvcmd
+ if srvcmd == "start" or srvcmd == "stop" or srvcmd == "restart" then
+ service.srvcmdresult, service.message = self.model.service_control( srvcmd )
+ end
+ end
+
local option = { script = ENV["SCRIPT_NAME"],
prefix = self.conf.prefix,
controller = self.conf.controller,
action = self.conf.action,
extra = ""
}
+
+ local info = {
+ status=self.model.get_status(),
+ version = self.model.get_dansguardian_version(),
+ autostart = self.model.get_autostart(),
+ srvctrl = { value = srvctrl}
+ }
- local service = { message="", status="", config="" }
-
- if self.clientdata.srvcmd then
- srvcmd = self.clientdata.srvcmd
- if srvcmd == "start" or srvcmd == "stop" or srvcmd == "restart" then
- service.message = self.model.service_control( srvcmd )
- end
- end
-
- if self.clientdata.cmd then
- if self.clientdata.cmd == "save" then
- local conf = self.clientdata
- local config = conf.config
- self.model.update_plain_config( config )
- end
+ -- Add a cmd button to the view
+ service.cmdsave = cfe({ name="cmdsave",
+ label="Save/Apply above settings",
+ value="Save",
+ type="submit",
+ })
+
+ if self.clientdata.cmdsave then
+ local conf = self.clientdata
+ local config = conf.config
+ self.model.update_plain_config( config )
+ service.cmdsave.descr="* Changes has been saved!"
end
service.status = self.model.get_status()
service.config, service.cfgerr = self.model.get_plain_config()
- return ( cfe ({ option = option, service = service }) )
+ return ( cfe ({ option = option, service = service, info = info }) )
end
edit = function( self )
@@ -121,6 +144,7 @@ edit = function( self )
if self.clientdata.cmd then
if self.clientdata.cmd == "save" then
self.model.update_edit_config( self.clientdata.name, self.clientdata.config )
+ redirect( self, "advanced" )
end
end
@@ -137,6 +161,22 @@ end
category = function( self )
+ local service = { message="", status="", config="", cfgerr="" }
+
+ if self.clientdata.srvcmd then
+ local srvcmd = self.clientdata.srvcmd
+ if srvcmd == "start" or srvcmd == "stop" or srvcmd == "restart" then
+ service.srvcmdresult, service.message = self.model.service_control( srvcmd )
+ end
+ end
+
+ local info = {
+ status=self.model.get_status(),
+ version = self.model.get_dansguardian_version(),
+ autostart = self.model.get_autostart(),
+ srvctrl = { value = srvctrl}
+ }
+
local option = { script = ENV["SCRIPT_NAME"],
prefix = self.conf.prefix,
controller = self.conf.controller,
@@ -144,10 +184,27 @@ category = function( self )
extra = ""
}
- local service = { message="", status="", config="", cfgerr="" }
+ -- Add a cmd button to the view
+ service.cmdadd = cfe({
+ name="cmdadd",
+ label="Action",
+ value="Add",
+ type="submit",
+ disabled="yes",
+ errtxt="This button is currently out of order",
+ })
+
+ service.cmddelete = cfe({
+ name="cmddelete",
+ label="Action",
+ value="Delete",
+ type="submit",
+ disabled="yes",
+ errtxt="This button is currently out of order",
+ })
service.config = self.model.get_categories()
- return ( cfe ({ option = option, service = service }) )
+ return ( cfe ({ option = option, service = service, info = info }) )
end