From 3456da773e17156008cc6767ab425b87b737eafa Mon Sep 17 00:00:00 2001 From: Ted Trask Date: Wed, 18 Apr 2012 16:22:30 +0000 Subject: Fixed startstop to match new method --- fetchcrl-model.lua | 43 +++++++++++++++++++++---------------------- fetchcrl-startstop-html.lsp | 19 +++++++------------ 2 files changed, 28 insertions(+), 34 deletions(-) diff --git a/fetchcrl-model.lua b/fetchcrl-model.lua index 5cd3d62..7b68fd2 100644 --- a/fetchcrl-model.lua +++ b/fetchcrl-model.lua @@ -33,30 +33,29 @@ get_status = function() return cfe({ type="group", value=status, label="Fetch-CRL Status" }) end -function startstop_service(action) - local result = {} - result.actions = cfe({ type="list", value={"Download", "Delete"}, label="Start/Stop actions" }) - if action then - result.result = cfe({ label="Start/Stop result" }) - - if (string.lower(action) == "download") then - local file = io.popen(path .. "fetch-crl 2>&1") - if file ~= nil then - result.result.value = file:read( "*a" ) - file:close() - end - elseif (string.lower(action) == "delete") then - local config = format.parse_ini_file(fs.read_file(configfile) or "", "") - local dir = config.CRLDIR or outputdirectory - for file in fs.find(".*\.r0", dir) do - os.remove(file) - end - result.result.value = "Deleted CRL Files" - else - result.result.errtxt = "Unknown command!" +function get_startstop(clientdata) + local actions = {"Download", "Delete"} + return cfe({ type="group", label="Management", value={}, option=actions }) +end + +function startstop_service(startstop, action) + if (string.lower(action) == "download") then + local file = io.popen(path .. "fetch-crl 2>&1") + if file ~= nil then + startstop.descr = file:read( "*a" ) + file:close() + end + elseif (string.lower(action) == "delete") then + local config = format.parse_ini_file(fs.read_file(configfile) or "", "") + local dir = config.CRLDIR or outputdirectory + for file in fs.find(".*\.r0", dir) do + os.remove(file) end + startstop.descr = "Deleted CRL Files" + else + startstop.errtxt = "Unknown command!" end - return cfe({ type="group", value=result, label="Start/Stop result" }) + return startstop end get_configfile = function() diff --git a/fetchcrl-startstop-html.lsp b/fetchcrl-startstop-html.lsp index 3a5f6f7..438b129 100644 --- a/fetchcrl-startstop-html.lsp +++ b/fetchcrl-startstop-html.lsp @@ -1,20 +1,15 @@ -<% local data, viewlibrary, page_info = ... %> +<% local form, viewlibrary, page_info = ... %>

Management

- -<% if data.value.result then %> -

Previous action result

-<% if data.value.result.value ~= "" then %> -

<%= string.gsub(html.html_escape(data.value.result.value), "\n", "
") %>

-<% end if data.value.result.errtxt then %> -

<%= string.gsub(html.html_escape(data.value.result.errtxt), "\n", "
") %>

-<% end end %> -
+<% +if form.descr then io.write('

' .. string.gsub(html.html_escape(myform.descr), "\n", "
") .. "

\n") end +if form.errtxt then io.write('

' .. string.gsub(html.html_escape(myform.errtxt), "\n", "
") .. "

\n") end +%>
" method="POST">
Download CRL
-
+
Delete Local CRLs
-
+
-- cgit v1.2.3