diff options
Diffstat (limited to 'kamailio-controller.lua')
-rw-r--r-- | kamailio-controller.lua | 83 |
1 files changed, 83 insertions, 0 deletions
diff --git a/kamailio-controller.lua b/kamailio-controller.lua new file mode 100644 index 0000000..7a98ae3 --- /dev/null +++ b/kamailio-controller.lua @@ -0,0 +1,83 @@ +module(..., package.seeall) + +-- Load libraries +require("controllerfunctions") + +default_action = "status" + +function status(self) + return self.model.getstatus() +end + +function startstop(self) + return controllerfunctions.handle_startstop(self, self.model.startstop_service, self.clientdata) +end + +function listfiles(self) + return self.model.list_files() +end + +function edit(self) + return controllerfunctions.handle_form(self, function() return self.model.get_filedetails(self.clientdata.filename) end, self.model.update_filedetails, self.clientdata, "Save", "Edit File", "File Saved") +end + +function listusers(self) + return self.model.list_users() +end + +function createuser(self) + return controllerfunctions.handle_form(self, self.model.get_new_user, self.model.create_new_user, self.clientdata, "Create", "Create New User") +end + +function deleteuser(self) + return self:redirect_to_referrer(self.model.delete_user(self.clientdata.username)) +end + +function updateuser(self) + return controllerfunctions.handle_form(self, function() return self.model.get_user(self.clientdata.username) end, self.model.update_user, self.clientdata, "Update", "Update User") +end + +function listtables(self) + return self.model.list_tables() +end + +function viewtable(self) + local req_table + if self.clientdata.schema then + req_table = self.clientdata.schema.."."..self.clientdata.table + else + req_table = self.clientdata.table + end + return self.model.list_table_entries(req_table) +end + +function deletetableentry(self) + return self:redirect_to_referrer(self.model.delete_table_entry(self.clientdata.table, self.clientdata.id)) +end + +function updatetableentry(self) + return controllerfunctions.handle_form(self, function() return self.model.get_table_entry(self.clientdata.table, self.clientdata.id) end, self.model.update_table_entry, self.clientdata, "Update", "Update Table Entry", "Entry updated") +end + +function createtableentry(self) + local req_table + if self.clientdata.schema then + req_table = self.clientdata.schema.."."..self.clientdata.table + else + req_table = self.clientdata.table + end + return controllerfunctions.handle_form(self, function() return self.model.get_table_entry(req_table) end, self.model.create_table_entry, self.clientdata, "Create", "Create New Table Entry", "Entry created") +end + +function createdatabase(self) + return self:redirect_to_referrer(self.model.create_database()) +end + +function reloadplan(self) + return self:redirect_to_referrer(self.model.reloadplan()) +end + + +searchdatabase = function( self ) + return self.model.search_database(self.clientdata.id, self.clientdata.value, self.clientdata.comparison) +end |