summaryrefslogtreecommitdiffstats
path: root/interfaces-controller.lua
diff options
context:
space:
mode:
authorMika Havela <mika.havela@gmail.com>2008-04-09 13:21:08 +0000
committerMika Havela <mika.havela@gmail.com>2008-04-09 13:21:08 +0000
commit10d4d3ab01a7ab59b8c07c8acb75c1b3ffd9c754 (patch)
tree95b1dada20bfa24eb983fe7df6ee3ccc3e5e81cf /interfaces-controller.lua
parentb4bb80d491873de680d6b5bee58afeb2e0333edb (diff)
downloadacf-alpine-baselayout-10d4d3ab01a7ab59b8c07c8acb75c1b3ffd9c754.tar.bz2
acf-alpine-baselayout-10d4d3ab01a7ab59b8c07c8acb75c1b3ffd9c754.tar.xz
Created a 'edit' page to edit interfaces.
Fixed so you can delete interfaces (I probably broke this earlier, not knowing it). Added a new tab to create new interface. git-svn-id: svn://svn.alpinelinux.org/acf/alpine-baselayout/trunk@965 ab2d0c66-481e-0410-8bed-d214d4d58bed
Diffstat (limited to 'interfaces-controller.lua')
-rw-r--r--interfaces-controller.lua40
1 files changed, 35 insertions, 5 deletions
diff --git a/interfaces-controller.lua b/interfaces-controller.lua
index 1a33bc2..90f0fe7 100644
--- a/interfaces-controller.lua
+++ b/interfaces-controller.lua
@@ -6,7 +6,7 @@ module (..., package.seeall)
-- We use the self.conf table because it already has prefix,controller,etc
-- The redir code is defined in the application error handler (acf-controller)
local list_redir = function (self)
- self.conf.action = "read"
+ self.conf.action = "config"
self.conf.type = "redir"
error (self.conf)
end
@@ -51,6 +51,18 @@ read = function (self )
return ( { actions = actions, iface = iface, status=status } )
end
+config = function (self )
+ local config = read(self)
+ for k,v in pairs(config.iface) do
+ v['edit']=cfe(
+ {name="edit",
+ label="Edit this record",
+ value="Edit",
+ type="link",
+ })
+ end
+ return ( config )
+end
-- Accepts form info
-- Returns a cfe object (the form)
@@ -82,11 +94,24 @@ update = function(self)
end
end
+ -- If the "cmddelete" button was used, then attempt to delete the interface
+ if self.clientdata.cmddelete then
+ self.conf.action = "delete?iface=" .. tostring(self.clientdata.name)
+ self.conf.type = "redir"
+ error (self.conf)
+ end
+
+ -- Hide the 'name' field
+ data.name.type="hidden"
+
-- If we reach this point in the function, then we are providing a form
-- for the user to edit (either first time in, or validation failed)
-- Add a command button
- data.cmd = cfe({type="action", value="save", label="action"})
+ data.cmd = cfe({type="action", value="Save", name="cmd", label="Save/Apply above settings"})
+
+ -- Add a delete button
+ data.cmddelete = cfe({type="action", value="Delete", name="cmddelete", label="Delete this record"})
return ( cfe ({type="form",
option={ script=ENV["SCRIPT_NAME"],
@@ -94,7 +119,9 @@ update = function(self)
controller = self.conf.controller,
action = "update",
extra = "?iface=" .. data.name.value },
- value = data} ) )
+ value = data,
+ clientdata=clientdata,
+ } ) )
end
@@ -121,7 +148,7 @@ delete = function(self)
-- Otherwise, return a form
local me = {}
- me.iface = cfe({value = self.clientdata.iface })
+ me.iface = cfe({name="iface", type="hidden", value = (self.clientdata.iface or "") })
me.action1 = cfe({name="cmd", type="action", value="delete", label="action"})
me.action2 = cfe({name="cmd", type="action", value="cancel", label="action"})
@@ -131,7 +158,10 @@ delete = function(self)
controller = self.conf.controller,
action = "delete",
extra = "?iface=" .. (self.clientdata.iface or "") },
- value = me} ) )
+ value = me,
+ clientdata=clientdata,
+ iface=iface,
+ } ) )
end