From 4260dd6353273dab0d0bb444915320f161851e50 Mon Sep 17 00:00:00 2001 From: Ted Trask Date: Wed, 22 Oct 2008 18:50:22 +0000 Subject: Modified viewfunctions to split displayform, creating displayformstart and displayformend, to provide flexibility while still using the library. Also added support for hidden fields - including a common redir field. Removed redirectOnSuccess from controllerfunctions handle_form, and replaced it with the redir field. Removed redirectOnSuccess from controllers that used it and added handlecommandresults and redir entries to links and forms throughout many views. This will cause a redirect to the originating view when a form is successfully completed. acf_www-controller now includes orig_action in page_info to report the original action launched by the user. git-svn-id: svn://svn.alpinelinux.org/acf/dhcp/trunk@1560 ab2d0c66-481e-0410-8bed-d214d4d58bed --- dhcp-home-html.lsp | 3 +++ dhcp-listhosts-html.lsp | 5 ++++- dhcp-listsubnets-html.lsp | 7 +++++-- dhcp-model.lua | 2 ++ dhcp-settings-html.lsp | 3 ++- 5 files changed, 16 insertions(+), 4 deletions(-) diff --git a/dhcp-home-html.lsp b/dhcp-home-html.lsp index 4962d4f..ab7ff26 100644 --- a/dhcp-home-html.lsp +++ b/dhcp-home-html.lsp @@ -1,6 +1,8 @@ <% local view, viewlibrary, page_info, session = ... %> <% require("viewfunctions") %> +<% displaycommandresults({"settings", "edithost", "delhost", "createhost", "editsubnet", "delsubnet", "createsubnet"}, session) %> + <% if viewlibrary and viewlibrary.dispatch_component then viewlibrary.dispatch_component("status") end %> @@ -10,6 +12,7 @@ end %>
Edit global settings
" method="POST"> +
diff --git a/dhcp-listhosts-html.lsp b/dhcp-listhosts-html.lsp index 2ef1646..6b92ecb 100644 --- a/dhcp-listhosts-html.lsp +++ b/dhcp-listhosts-html.lsp @@ -1,6 +1,8 @@ <% local view, viewlibrary, page_info, session = ... %> <% require("viewfunctions") %> +<% displaycommandresults({"edithost", "delhost", "createhost"}, session) %> +

Host Declarations

@@ -12,7 +14,7 @@ <% for i,host in ipairs(view.value) do %> - <%= html.link{value=page_info.script..page_info.prefix..page_info.controller.."/edithost?host="..host, label="Edit "} %> + <%= html.link{value=page_info.script..page_info.prefix..page_info.controller.."/edithost?host="..host.."&redir="..page_info.orig_action, label="Edit "} %> <%= html.link{value=page_info.script..page_info.prefix..page_info.controller.."/delhost?host="..host, label="Delete "} %> <%= host %> @@ -22,6 +24,7 @@
Add new host
" method="POST"> +
diff --git a/dhcp-listsubnets-html.lsp b/dhcp-listsubnets-html.lsp index 4eb4285..242afe1 100644 --- a/dhcp-listsubnets-html.lsp +++ b/dhcp-listsubnets-html.lsp @@ -1,6 +1,8 @@ <% local view, viewlibrary, page_info, session = ... %> <% require("viewfunctions") %> +<% displaycommandresults({"editsubnet", "delsubnet", "createsubnet"}, session) %> +

Subnet Declarations

@@ -12,8 +14,8 @@ <% for i,subnet in ipairs(view.value) do %> - <%= html.link{value=page_info.script..page_info.prefix..page_info.controller.."/editsubnet?subnet="..subnet, label="Edit "} %> - <%= html.link{value=page_info.script..page_info.prefix..page_info.controller.."/delsubnet?subnet="..subnet, label="Delete "} %> + <%= html.link{value=page_info.script..page_info.prefix..page_info.controller.."/editsubnet?subnet="..subnet.."&redir="..page_info.orig_action, label="Edit "} %> + <%= html.link{value=page_info.script..page_info.prefix..page_info.controller.."/delsubnet?subnet="..subnet.."&redir="..page_info.orig_action, label="Delete "} %> <%= subnet %> @@ -22,6 +24,7 @@
Add new subnet
" method="POST"> +
diff --git a/dhcp-model.lua b/dhcp-model.lua index 4d3ff5e..f542554 100644 --- a/dhcp-model.lua +++ b/dhcp-model.lua @@ -492,6 +492,7 @@ host_delete = function(name) file = string.sub(file, 1, start-1) .. string.sub(file, endd+1, -1) fs.write_file(configfile, string.gsub(file, "\n*$", "")) config = nil + cmdresult.value = "Host Deleted" end end @@ -650,6 +651,7 @@ subnet_delete = function(name) file = string.sub(file, 1, start-1) .. string.sub(file, endd+1, -1) fs.write_file(configfile, string.gsub(file, "\n*$", "")) config = nil + cmdresult.value = "Subnet Deleted" end end diff --git a/dhcp-settings-html.lsp b/dhcp-settings-html.lsp index 796f565..098bb78 100644 --- a/dhcp-settings-html.lsp +++ b/dhcp-settings-html.lsp @@ -1,8 +1,9 @@ -<% local form = ... %> +<% local form, viewlibrary, page_info = ... %> <% require("viewfunctions") %>

<%= form.label %>

<% + form.action = page_info.script .. page_info.prefix .. page_info.controller .. "/" .. page_info.action local order = {"domainname", "domainnameservers", "defleasetime", "maxleasetime"} displayform(form, order) %> -- cgit v1.2.3