summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--provisioning-controller.lua20
-rw-r--r--provisioning-editdevice-html.lsp2
-rw-r--r--provisioning-editdeviceparams-html.lsp2
-rw-r--r--provisioning-listclasses-html.lsp2
-rw-r--r--provisioning-listclassgroups-html.lsp2
-rw-r--r--provisioning-listdevices-html.lsp2
-rw-r--r--provisioning-listgroups-html.lsp2
-rw-r--r--provisioning-listparams-html.lsp2
-rw-r--r--provisioning-listrequests-html.lsp2
-rw-r--r--provisioning-listtemplates-html.lsp2
-rw-r--r--provisioning-model.lua143
11 files changed, 112 insertions, 69 deletions
diff --git a/provisioning-controller.lua b/provisioning-controller.lua
index da783b1..83210d6 100644
--- a/provisioning-controller.lua
+++ b/provisioning-controller.lua
@@ -15,7 +15,7 @@ createtemplate = function( self )
end
deletetemplate = function( self )
- return self:redirect_to_referrer(self.model.delete_template(self.clientdata.filename))
+ return self.handle_form(self, self.model.get_delete_template, self.model.delete_template, self.clientdata, "Delete", "Delete Template", "Template Deleted")
end
listclassgroups = function( self )
@@ -31,7 +31,7 @@ createclassgroup = function( self )
end
deleteclassgroup = function( self )
- return self:redirect_to_referrer(self.model.delete_class_group(self.clientdata.class_group_id))
+ return self.handle_form(self, self.model.get_delete_class_group, self.model.delete_class_group, self.clientdata, "Delete", "Delete Class Group", "Class Group Deleted")
end
listclasses = function( self )
@@ -47,7 +47,7 @@ createclass = function( self )
end
deleteclass = function( self )
- return self:redirect_to_referrer(self.model.delete_class(self.clientdata.class_id))
+ return self.handle_form(self, self.model.get_delete_class, self.model.delete_class, self.clientdata, "Delete", "Delete Class", "Class Deleted")
end
getclassvalues = function( self )
@@ -66,8 +66,8 @@ creategroup = function( self )
return self.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))
+deletegroup = function(self )
+ return self.handle_form(self, self.model.get_delete_group, self.model.delete_group, self.clientdata, "Delete", "Delete Parameter Group", "Parameter Group Deleted")
end
listparams = function( self )
@@ -83,7 +83,7 @@ createparam = function( self )
end
deleteparam = function( self )
- return self:redirect_to_referrer(self.model.delete_param(self.clientdata.param_id))
+ return self.handle_form(self, self.model.get_delete_param, self.model.delete_param, self.clientdata, "Delete", "Delete Parameter", "Parameter Deleted")
end
listdevices = function( self )
@@ -96,7 +96,7 @@ end
createdevice = function( self )
local retval = self.handle_form(self, self.model.get_device, self.model.create_device, self.clientdata, "Create", "Create Device", "Device Created")
- if retval.value.device_id.value ~= "" and not retval.errtxt then
+ if retval.value.device_id.value ~= "" and not retval.errtxt and self.redirect then
-- Successfully created a device, redirect to edit it
self:redirect("editdevice?device_id="..retval.value.device_id.value.."&redir=".. (self.clientdata.redir or "listdevices"))
end
@@ -108,7 +108,7 @@ duplicatedevice = function( self )
end
deletedevice = function( self )
- return self:redirect_to_referrer(self.model.delete_device(self.clientdata.device_id))
+ return self.handle_form(self, self.model.get_delete_device, self.model.delete_device, self.clientdata, "Delete", "Delete Device", "Device Deleted")
end
editdeviceparams = function( self )
@@ -156,12 +156,12 @@ listrequests = function( self )
end
deleterequest = function( self )
- return self:redirect_to_referrer(self.model.delete_request(self.clientdata.mac))
+ return self.handle_form(self, self.model.get_delete_request, self.model.delete_request, self.clientdata, "Delete", "Delete Request", "Request Deleted")
end
createdevicefromrequest = function( self )
local retval = self.handle_form(self, self.model.get_request, self.model.create_from_request, self.clientdata, "Create", "Create Device", "Device Created")
- if retval.value.device_id and retval.value.device_id.value ~= "" and not retval.errtxt then
+ if retval.value.device_id and retval.value.device_id.value ~= "" and not retval.errtxt and self.redirect then
-- Successfully created a device, redirect to edit it
self:redirect("editdevice?device_id="..retval.value.device_id.value.."&redir=".. (self.clientdata.redir or "listdevices"))
end
diff --git a/provisioning-editdevice-html.lsp b/provisioning-editdevice-html.lsp
index fddc888..a1292e0 100644
--- a/provisioning-editdevice-html.lsp
+++ b/provisioning-editdevice-html.lsp
@@ -16,7 +16,7 @@ require("htmlviewfunctions")
<a href='<%= page_info.script..page_info.prefix..page_info.controller.."/editdeviceparams?device_id="..html.html_escape(form.value.device_id.value) %>'><img src='<%= html.html_escape(page_info.wwwprefix..page_info.staticdir) %>/tango/16x16/actions/document-properties.png' title="Edit Parameters"></img> <big>Edit Parameters </big></a>
<% end %>
<% if viewlibrary.check_permission("deletedevice") then %>
- <a href='<%= page_info.script..page_info.prefix..page_info.controller.."/deletedevice?device_id="..html.html_escape(form.value.device_id.value) %>' class="deletedevice"><img src='<%= html.html_escape(page_info.wwwprefix..page_info.staticdir) %>/tango/16x16/emblems/emblem-unreadable.png' title="Delete this Device"></img> <big>Delete this Device </big></a>
+ <a href='<%= page_info.script..page_info.prefix..page_info.controller.."/deletedevice?submit=true&device_id="..html.html_escape(form.value.device_id.value) %>' class="deletedevice"><img src='<%= html.html_escape(page_info.wwwprefix..page_info.staticdir) %>/tango/16x16/emblems/emblem-unreadable.png' title="Delete this Device"></img> <big>Delete this Device </big></a>
<% end %>
<% end %>
diff --git a/provisioning-editdeviceparams-html.lsp b/provisioning-editdeviceparams-html.lsp
index e19d419..c5cd4ae 100644
--- a/provisioning-editdeviceparams-html.lsp
+++ b/provisioning-editdeviceparams-html.lsp
@@ -14,7 +14,7 @@ require("htmlviewfunctions")
<a href='<%= page_info.script..page_info.prefix..page_info.controller.."/editdevice?device_id="..html.html_escape(form.value.device_id.value) %>'><img src='<%= html.html_escape(page_info.wwwprefix..page_info.staticdir) %>/tango/16x16/categories/applications-system.png' title="Edit Class of Service"></img> <big>Edit Class of Service </big></a>
<% end %>
<% if viewlibrary.check_permission("deletedevice") then %>
- <a href='<%= page_info.script..page_info.prefix..page_info.controller.."/deletedevice?device_id="..html.html_escape(form.value.device_id.value) %>' class="deletedevice"><img src='<%= html.html_escape(page_info.wwwprefix..page_info.staticdir) %>/tango/16x16/emblems/emblem-unreadable.png' title="Delete this Device"></img> <big>Delete this Device </big></a>
+ <a href='<%= page_info.script..page_info.prefix..page_info.controller.."/deletedevice?submit=true&device_id="..html.html_escape(form.value.device_id.value) %>' class="deletedevice"><img src='<%= html.html_escape(page_info.wwwprefix..page_info.staticdir) %>/tango/16x16/emblems/emblem-unreadable.png' title="Delete this Device"></img> <big>Delete this Device </big></a>
<% end %>
<% end %>
diff --git a/provisioning-listclasses-html.lsp b/provisioning-listclasses-html.lsp
index 105e9c6..f04938c 100644
--- a/provisioning-listclasses-html.lsp
+++ b/provisioning-listclasses-html.lsp
@@ -36,7 +36,7 @@ require("htmlviewfunctions")
<TR>
<TD>
<% if viewlibrary.check_permission("deleteclass") then %>
- <%= html.link{value=page_info.script..page_info.prefix..page_info.controller.."/deleteclass?class_id="..v.class_id, label="Delete ", class="deleteclass"} %>
+ <%= html.link{value=page_info.script..page_info.prefix..page_info.controller.."/deleteclass?submit=true&class_id="..v.class_id, label="Delete ", class="deleteclass"} %>
<% end %>
<% if viewlibrary.check_permission("editclass") then %>
<%= html.link{value=page_info.script..page_info.prefix..page_info.controller.."/editclass?class_id="..v.class_id.."&redir="..page_info.orig_action, label="Edit "} %>
diff --git a/provisioning-listclassgroups-html.lsp b/provisioning-listclassgroups-html.lsp
index a1b1ce5..004f77a 100644
--- a/provisioning-listclassgroups-html.lsp
+++ b/provisioning-listclassgroups-html.lsp
@@ -28,7 +28,7 @@ require("htmlviewfunctions")
<TR>
<TD>
<% if viewlibrary.check_permission("deleteclassgroup") then %>
- <%= html.link{value=page_info.script..page_info.prefix..page_info.controller.."/deleteclassgroup?class_group_id="..v.class_group_id, label="Delete ", class="deletegroup"} %>
+ <%= html.link{value=page_info.script..page_info.prefix..page_info.controller.."/deleteclassgroup?submit=true&class_group_id="..v.class_group_id, label="Delete ", class="deletegroup"} %>
<% end %>
<% if viewlibrary.check_permission("editclassgroup") then %>
<%= html.link{value=page_info.script..page_info.prefix..page_info.controller.."/editclassgroup?class_group_id="..v.class_group_id.."&redir="..page_info.orig_action, label="Edit "} %>
diff --git a/provisioning-listdevices-html.lsp b/provisioning-listdevices-html.lsp
index 75d947c..7df1fa4 100644
--- a/provisioning-listdevices-html.lsp
+++ b/provisioning-listdevices-html.lsp
@@ -57,7 +57,7 @@ table.sort(display)
<TR>
<TD>
<% if viewlibrary.check_permission("deletedevice") then %>
- <%= html.link{value=page_info.script..page_info.prefix..page_info.controller.."/deletedevice?device_id="..v.device_id, label="Delete ", class="deletedevice"} %>
+ <%= html.link{value=page_info.script..page_info.prefix..page_info.controller.."/deletedevice?submit=true&device_id="..v.device_id, label="Delete ", class="deletedevice"} %>
<% end %>
<% if viewlibrary.check_permission("editdevice") then %>
<%= html.link{value=page_info.script..page_info.prefix..page_info.controller.."/editdevice?device_id="..v.device_id.."&redir="..page_info.orig_action, label="Edit "} %>
diff --git a/provisioning-listgroups-html.lsp b/provisioning-listgroups-html.lsp
index d3f51f9..9eb22a9 100644
--- a/provisioning-listgroups-html.lsp
+++ b/provisioning-listgroups-html.lsp
@@ -28,7 +28,7 @@ require("htmlviewfunctions")
<TR>
<TD>
<% if viewlibrary.check_permission("deletegroup") then %>
- <%= html.link{value=page_info.script..page_info.prefix..page_info.controller.."/deletegroup?group_id="..v.group_id, label="Delete ", class="deletegroup"} %>
+ <%= html.link{value=page_info.script..page_info.prefix..page_info.controller.."/deletegroup?submit=true&group_id="..v.group_id, label="Delete ", class="deletegroup"} %>
<% end %>
<% if viewlibrary.check_permission("editgroup") then %>
<%= html.link{value=page_info.script..page_info.prefix..page_info.controller.."/editgroup?group_id="..v.group_id.."&redir="..page_info.orig_action, label="Edit "} %>
diff --git a/provisioning-listparams-html.lsp b/provisioning-listparams-html.lsp
index 43b7a17..215d65f 100644
--- a/provisioning-listparams-html.lsp
+++ b/provisioning-listparams-html.lsp
@@ -29,7 +29,7 @@ require("htmlviewfunctions")
<TR>
<TD>
<% if viewlibrary.check_permission("deleteparam") then %>
- <%= html.link{value=page_info.script..page_info.prefix..page_info.controller.."/deleteparam?param_id="..v.param_id, label="Delete ", class="deleteparam"} %>
+ <%= html.link{value=page_info.script..page_info.prefix..page_info.controller.."/deleteparam?submit=true&param_id="..v.param_id, label="Delete ", class="deleteparam"} %>
<% end %>
<% if viewlibrary.check_permission("editparam") then %>
<%= html.link{value=page_info.script..page_info.prefix..page_info.controller.."/editparam?param_id="..v.param_id.."&redir="..page_info.orig_action, label="Edit "} %>
diff --git a/provisioning-listrequests-html.lsp b/provisioning-listrequests-html.lsp
index 8e52bd2..c225d3f 100644
--- a/provisioning-listrequests-html.lsp
+++ b/provisioning-listrequests-html.lsp
@@ -44,7 +44,7 @@ require("htmlviewfunctions")
<TR>
<TD>
<% if viewlibrary.check_permission("deleterequest") then %>
- <%= html.link{value=page_info.script..page_info.prefix..page_info.controller.."/deleterequest?mac="..v.mac, label="Delete ", class="deleterequest"} %>
+ <%= html.link{value=page_info.script..page_info.prefix..page_info.controller.."/deleterequest?submit=true&mac="..v.mac, label="Delete ", class="deleterequest"} %>
<% end %>
<% if v.device_id then %>
<% if viewlibrary.check_permission("searchdevices") then %>
diff --git a/provisioning-listtemplates-html.lsp b/provisioning-listtemplates-html.lsp
index a0b079e..d848d26 100644
--- a/provisioning-listtemplates-html.lsp
+++ b/provisioning-listtemplates-html.lsp
@@ -30,7 +30,7 @@ require("htmlviewfunctions")
<TR>
<TD>
<% if viewlibrary.check_permission("deletetemplate") and v.label then %>
- <%= html.link{value=page_info.script..page_info.prefix..page_info.controller.."/deletetemplate?filename="..v.filename, label="Delete ", class="deletetemplate"} %>
+ <%= html.link{value=page_info.script..page_info.prefix..page_info.controller.."/deletetemplate?submit=true&filename="..v.filename, label="Delete ", class="deletetemplate"} %>
<% end %>
<% if viewlibrary.check_permission("edittemplate") and v.label then %>
<%= html.link{value=page_info.script..page_info.prefix..page_info.controller.."/edittemplate?filename="..v.filename.."&redir="..page_info.orig_action, label="Edit "} %>
diff --git a/provisioning-model.lua b/provisioning-model.lua
index de2f748..2c41810 100644
--- a/provisioning-model.lua
+++ b/provisioning-model.lua
@@ -461,30 +461,36 @@ update_template = function(self, template, action, create)
return template
end
-delete_template = function(filename)
- local result = ""
- local errtxt
+get_delete_template = function(self, clientdata)
+ local retval = {}
+ retval.filename = cfe({ value=clientdata.filename or "", label="File Name" })
+ return cfe({ type="group", value=retval, label="Delete Template" })
+end
+
+delete_template = function(self, delreq)
+ local filename = delreq.value.filename.value
+ delreq.errtxt = "Failed to delete template"
local res, err = pcall(function()
local connected = databaseconnect()
local sql = "SELECT * FROM provisioning_options WHERE param_id=(SELECT param_id FROM provisioning_params WHERE name = 'template') AND value='"..escape(filename).."'"
local tmp = getselectresponse(sql)
if #tmp == 0 then
- errtxt = "Template does not exist"
+ delreq.value.filename.errtxt = "Template does not exist"
else
-- Remove the template
sql = "DELETE FROM provisioning_options WHERE param_id=(SELECT param_id FROM provisioning_params WHERE name = 'template') AND value='"..escape(filename).."'"
runsqlcommand(sql)
-- Delete the template file
os.remove(filename)
- result = "Template Deleted"
+ delreq.errtxt = nil
end
if connected then databasedisconnect() end
end)
if not res and err then
- errtxt = err
+ delreq.errtxt = err
end
- return cfe({ value=result, errtxt=errtxt, label="Delete Template Result" })
+ return delreq
end
list_class_groups = function()
@@ -605,27 +611,33 @@ update_class_group = function(self, group, action, create)
return group
end
-delete_class_group = function(class_group_id)
- local result = ""
- local errtxt
+get_delete_class_group = function(self, clientdata)
+ local retval = {}
+ retval.class_group_id = cfe({ value=clientdata.class_group_id or "", label="Class Group ID" })
+ return cfe({ type="group", value=retval, label="Delete Class Group" })
+end
+
+delete_class_group = function(self, delreq)
+ local class_group_id = delreq.value.class_group_id.value
+ delreq.errtxt = "Failed to delete class group"
local res, err = pcall(function()
local connected = databaseconnect()
local sql = "SELECT * FROM provisioning_class_groups WHERE class_group_id='"..escape(class_group_id).."'"
local tmp = getselectresponse(sql)
if #tmp == 0 then
- errtxt = "Group does not exist"
+ delreq.value.class_group_id.errtxt = "Group does not exist"
else
sql = "DELETE FROM provisioning_class_groups WHERE class_group_id='"..escape(class_group_id).."'"
runsqlcommand(sql)
- result = "Class Group Deleted"
+ delreq.errtxt = nil
end
if connected then databasedisconnect() end
end)
if not res and err then
- errtxt = err
+ delreq.errtxt = err
end
- return cfe({ value=result, errtxt=errtxt, label="Delete Class Group Result" })
+ return delreq
end
list_classes = function()
@@ -779,15 +791,21 @@ update_class = function(self, class, action, create)
return class
end
-delete_class = function(class_id)
- local result = ""
- local errtxt
+get_delete_class = function(self, clientdata)
+ local retval = {}
+ retval.class_id = cfe({ value=clientdata.class_id or "", label="Class ID" })
+ return cfe({ type="group", value=retval, label="Delete Class" })
+end
+
+delete_class = function(self, delreq)
+ local class_id = delreq.value.class_id.value
+ delreq.errtxt = "Failed to delete class"
local res, err = pcall(function()
local connected = databaseconnect()
local sql = "SELECT * FROM provisioning_classes WHERE class_id='"..escape(class_id).."'"
local tmp = getselectresponse(sql)
if #tmp == 0 then
- errtxt = "Class does not exist"
+ delreq.value.class_id.errtxt = "Class does not exist"
else
sql = "BEGIN TRANSACTION"
runsqlcommand(sql)
@@ -795,18 +813,18 @@ delete_class = function(class_id)
runsqlcommand(sql, true)
sql = "DELETE FROM provisioning_classes WHERE class_id='"..escape(class_id).."'"
runsqlcommand(sql, true)
- result = "Class Deleted"
sql = "COMMIT"
runsqlcommand(sql)
+ delreq.errtxt = nil
end
if connected then databasedisconnect() end
end)
if not res and err then
pcall(function() con:execute("ROLLBACK") end)
- errtxt = err
+ delreq.errtxt = err
end
- return cfe({ value=result, errtxt=errtxt, label="Delete Class Result" })
+ return delreq
end
list_groups = function()
@@ -991,15 +1009,21 @@ update_group = function(self, group, action, create)
return group
end
-delete_group = function(group_id)
- local result = ""
- local errtxt
+get_delete_group = function(self, clientdata)
+ local retval = {}
+ retval.group_id = cfe({ value=clientdata.group_id or "", label="Group ID" })
+ return cfe({ type="group", value=retval, label="Delete Group" })
+end
+
+delete_group = function(self, delreq)
+ local group_id = delreq.value.group_id.value
+ delreq.errtxt = "Failed to delete parameter group"
local res, err = pcall(function()
local connected = databaseconnect()
local sql = "SELECT * FROM provisioning_groups WHERE group_id='"..escape(group_id).."'"
local tmp = getselectresponse(sql)
if #tmp == 0 then
- errtxt = "Group does not exist"
+ delreq.value.group_id.errtxt = "Group does not exist"
else
sql = "BEGIN TRANSACTION"
runsqlcommand(sql)
@@ -1007,18 +1031,18 @@ delete_group = function(group_id)
runsqlcommand(sql, true)
sql = "DELETE FROM provisioning_groups WHERE group_id='"..escape(group_id).."'"
runsqlcommand(sql, true)
- result = "Parameter Group Deleted"
sql = "COMMIT"
runsqlcommand(sql)
+ delreq.errtxt = nil
end
if connected then databasedisconnect() end
end)
if not res and err then
pcall(function() con:execute("ROLLBACK") end)
- errtxt = err
+ delreq.errtxt = err
end
- return cfe({ value=result, errtxt=errtxt, label="Delete Parameter Group Result" })
+ return delreq
end
list_params = function()
@@ -1150,15 +1174,21 @@ update_param = function(self, param, action, create)
return param
end
-delete_param = function(param_id)
- local result = ""
- local errtxt
+get_delete_param = function(self, clientdata)
+ local retval = {}
+ retval.param_id = cfe({ value=clientdata.param_id or "", label="Param ID" })
+ return cfe({ type="group", value=retval, label="Delete Param" })
+end
+
+delete_param = function(self, delreq)
+ local param_id = delreq.value.param_id.value
+ delreq.errtxt = "Failed to delete parameter"
local res, err = pcall(function()
local connected = databaseconnect()
local sql = "SELECT * FROM provisioning_params WHERE param_id='"..escape(param_id).."'"
local tmp = getselectresponse(sql)
if #tmp == 0 then
- errtxt = "Parameter does not exist"
+ delreq.value.param_id.errtxt = "Parameter does not exist"
else
sql = "BEGIN TRANSACTION"
runsqlcommand(sql)
@@ -1166,18 +1196,18 @@ delete_param = function(param_id)
runsqlcommand(sql, true)
sql = "DELETE FROM provisioning_params WHERE param_id='"..escape(param_id).."'"
runsqlcommand(sql, true)
- result = "Parameter Deleted"
sql = "COMMIT"
runsqlcommand(sql)
+ delreq.errtxt = nil
end
if connected then databasedisconnect() end
end)
if not res and err then
pcall(function() con:execute("ROLLBACK") end)
- errtxt = err
+ delreq.errtxt = err
end
- return cfe({ value=result, errtxt=errtxt, label="Delete Parameter Result" })
+ return delreq
end
list_devices = function()
@@ -1322,15 +1352,21 @@ update_device = function(self, device, action, create)
return device
end
-delete_device = function(device_id)
- local result = ""
- local errtxt
+get_delete_device = function(self, clientdata)
+ local retval = {}
+ retval.device_id = cfe({ value=clientdata.device_id or "", label="Device ID" })
+ return cfe({ type="group", value=retval, label="Delete Device" })
+end
+
+delete_device = function(self, delreq)
+ local device_id = delreq.value.device_id.value
+ delreq.errtxt = "Failed to delete device"
local res, err = pcall(function()
local connected = databaseconnect()
local sql = "SELECT * FROM devices_to_classes WHERE device_id='"..escape(device_id).."' LIMIT 1"
local tmp = getselectresponse(sql)
if #tmp == 0 then
- errtxt = "Device does not exist"
+ delreq.value.device_id.errtxt = "Device does not exist"
else
if not saved_device_params[device_id] then get_device_params(device_id) end
if not saved_devices[device_id] then get_device(device_id) end
@@ -1341,9 +1377,9 @@ delete_device = function(device_id)
runsqlcommand(sql, true)
sql = "DELETE FROM devices_to_classes WHERE device_id='"..escape(device_id).."'"
runsqlcommand(sql, true)
- result = "Device Deleted"
sql = "COMMIT"
runsqlcommand(sql)
+ delreq.errtxt = nil
callscript(deletedevicescriptfile, saved_devices[device_id], saved_device_params[device_id])
saved_devices[device_id] = nil
@@ -1353,10 +1389,10 @@ delete_device = function(device_id)
end)
if not res and err then
pcall(function() con:execute("ROLLBACK") end)
- errtxt = err
+ delreq.errtxt = err
end
- return cfe({ value=result, errtxt=errtxt, label="Delete Device Result" })
+ return delreq
end
get_editable_device_params = function(self, clientdata, action)
@@ -1996,28 +2032,34 @@ list_requests = function()
return cfe({ type="structure", value=retval, label="List of Requests", errtxt=errtxt })
end
-delete_request = function(mac)
- local result = ""
- local errtxt
+get_delete_request = function(self, clientdata)
+ local retval = {}
+ retval.mac = cfe({ value=clientdata.mac or "", label="MAC Address" })
+ return cfe({ type="group", value=retval, label="Delete Request" })
+end
+
+delete_request = function(self, delreq)
+ local mac = delreq.value.mac.value
+ delreq.errtxt = "Failed to delete request"
local res, err = pcall(function()
local connected = databaseconnect()
local sql = "SELECT * FROM provisioning_requests WHERE mac='"..escape(string.upper(mac)).."'"
local tmp = getselectresponse(sql)
if #tmp == 0 then
- errtxt = "Request does not exist"
+ delreq.value.mac.errtxt = "Request does not exist"
else
-- Remove the request
sql = "DELETE FROM provisioning_requests WHERE mac='"..escape(string.upper(mac)).."'"
runsqlcommand(sql)
- result = "Request Deleted"
+ delreq.errtxt = nil
end
if connected then databasedisconnect() end
end)
if not res and err then
- errtxt = err
+ delreq.errtxt = err
end
- return cfe({ value=result, errtxt=errtxt, label="Delete Request Result" })
+ return delreq
end
get_request = function(self, clientdata)
@@ -2057,7 +2099,8 @@ create_from_request = function(self, request)
end
if params.errtxt then
request.errtxt = params.errtxt
- delete_device(device.value.device_id.value)
+ local req = get_delete_device(self, {device_id = device.value.device_id.value})
+ delete_device(self, req)
else
success = true
request.value.device_id = device.value.device_id