diff options
author | Ted Trask <ttrask01@yahoo.com> | 2010-10-28 13:47:54 +0000 |
---|---|---|
committer | Ted Trask <ttrask01@yahoo.com> | 2010-10-28 13:47:54 +0000 |
commit | 5c93a38c2cc263727be345ff5a197ea9bc78595b (patch) | |
tree | a7524afa5f02d77f1effa6625d249d8968000341 /provisioning-controller.lua | |
download | acf-provisioning-5c93a38c2cc263727be345ff5a197ea9bc78595b.tar.bz2 acf-provisioning-5c93a38c2cc263727be345ff5a197ea9bc78595b.tar.xz |
Starting to develop provisioning application.
It has the basics for creating/editing/deleting devices/templates/classes/groups/parameters.
Diffstat (limited to 'provisioning-controller.lua')
-rw-r--r-- | provisioning-controller.lua | 97 |
1 files changed, 97 insertions, 0 deletions
diff --git a/provisioning-controller.lua b/provisioning-controller.lua new file mode 100644 index 0000000..31a1c43 --- /dev/null +++ b/provisioning-controller.lua @@ -0,0 +1,97 @@ +module (..., package.seeall) + +require("controllerfunctions") + +default_action = "listdevices" + +listtemplates = function( self ) + return self.model.list_templates() +end + +edittemplate = function( self ) + return controllerfunctions.handle_form(self, function() return self.model.get_template(self.clientdata.template_id) end, self.model.update_template, self.clientdata, "Save", "Edit Template", "Template Saved") +end + +createtemplate = function( self ) + return controllerfunctions.handle_form(self, function() return self.model.get_template(nil, self.clientdata.filename) end, self.model.create_template, self.clientdata, "Create", "Create Template", "Template Created") +end + +deletetemplate = function( self ) + return self:redirect_to_referrer(self.model.delete_template(self.clientdata.template_id)) +end + +listclasses = function( self ) + return self.model.list_classes() +end + +editclass = function( self ) + return controllerfunctions.handle_form(self, function() return self.model.get_class(self.clientdata.class_id) end, self.model.update_class, self.clientdata, "Save", "Edit Class", "Class Saved") +end + +createclass = function( self ) + return controllerfunctions.handle_form(self, self.model.get_class, self.model.create_class, self.clientdata, "Create", "Create Class", "Class Created") +end + +deleteclass = function( self ) + return self:redirect_to_referrer(self.model.delete_class(self.clientdata.class_id)) +end + +listgroups = function( self ) + return self.model.list_groups() +end + +editgroup = function( self ) + return controllerfunctions.handle_form(self, function() return self.model.get_group(self.clientdata.group_id) end, self.model.update_group, self.clientdata, "Save", "Edit Parameter Group", "Parameter Group Saved") +end + +creategroup = function( self ) + return controllerfunctions.handle_form(self, self.model.get_group, self.model.create_group, self.clientdata, "Create", "Create Parameter Group", "Parameter Group Created") +end + +deletegroup = function( self ) + return self:redirect_to_referrer(self.model.delete_group(self.clientdata.group_id)) +end + +listparams = function( self ) + return self.model.list_params() +end + +editparam = function( self ) + return controllerfunctions.handle_form(self, function() return self.model.get_param(self.clientdata.param_id) end, self.model.update_param, self.clientdata, "Save", "Edit Parameter", "Parameter Saved") +end + +createparam = function( self ) + return controllerfunctions.handle_form(self, self.model.get_param, self.model.create_param, self.clientdata, "Create", "Create Parameter", "Parameter Created") +end + +deleteparam = function( self ) + return self:redirect_to_referrer(self.model.delete_param(self.clientdata.param_id)) +end + +listdevices = function( self ) + return self.model.list_devices() +end + +editdevice = function( self ) + return controllerfunctions.handle_form(self, function() return self.model.get_device(self.clientdata.device_id) end, self.model.update_device, self.clientdata, "Save", "Edit Device", "Device Saved") +end + +createdevice = function( self ) + return controllerfunctions.handle_form(self, self.model.get_device, self.model.create_device, self.clientdata, "Create", "Create Device", "Device Created") +end + +deletedevice = function( self ) + return self:redirect_to_referrer(self.model.delete_device(self.clientdata.device_id)) +end + +editdeviceparams = function( self ) + return controllerfunctions.handle_form(self, function() return self.model.get_editable_device_params(self.clientdata.device_id) end, self.model.set_editable_device_params, self.clientdata, "Save", "Edit Device Parameters", "Device Parameters Saved") +end + +overridedeviceparams = function( self ) + return controllerfunctions.handle_form(self, function() return self.model.get_device_params(self.clientdata.device_id) end, self.model.set_device_params, self.clientdata, "Save", "Override Device Parameters", "Device Parameters Saved") +end + +getdevicevalues = function( self ) + return self.model.get_device_values(self.clientdata.name) +end |