round out queue and call with individual call input and clearing
This commit is contained in:
+83
-65
@@ -1,66 +1,84 @@
|
|||||||
PluginInfo = {
|
PluginInfo = {
|
||||||
Name = "Caller",
|
Name = "Caller",
|
||||||
Version = "0.1.0-master",
|
Version = "0.1.0-master",
|
||||||
Id = "Caller.plugin.0.1.0-master",
|
Id = "Caller.plugin.0.1.0-master",
|
||||||
Description = "Plugin for taking a name and input and producing a call output",
|
Description = "Plugin for taking a name and input and producing a call output",
|
||||||
Author = "Joel Wetzell"
|
Author = "Joel Wetzell"
|
||||||
}
|
}
|
||||||
require("json")
|
require("json")
|
||||||
|
|
||||||
function GetPrettyName()
|
function GetPrettyName()
|
||||||
return "Caller"
|
return "Caller"
|
||||||
end
|
end
|
||||||
|
|
||||||
function GetProperties()
|
function GetProperties()
|
||||||
local props = {}
|
local props = {}
|
||||||
return props
|
return props
|
||||||
end
|
end
|
||||||
|
|
||||||
function RectifyProperties(props)
|
function RectifyProperties(props)
|
||||||
return props
|
return props
|
||||||
end
|
end
|
||||||
|
|
||||||
function GetControls(props)
|
function GetControls(props)
|
||||||
local controls = {
|
local controls = {
|
||||||
{
|
{
|
||||||
Name = "QueueUp",
|
Name = "Clear",
|
||||||
ControlType = "Button",
|
ControlType = "Button",
|
||||||
ButtonType = "Toggle",
|
ButtonType = "Trigger",
|
||||||
PinStyle = "Both",
|
PinStyle = "Input",
|
||||||
UserPin = true
|
UserPin = true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name = "CallOut",
|
Name = "QueueUp",
|
||||||
ControlType = "Text",
|
ControlType = "Button",
|
||||||
PinStyle = "Output",
|
ButtonType = "Toggle",
|
||||||
UserPin = true
|
PinStyle = "Both",
|
||||||
},
|
UserPin = true
|
||||||
{
|
},
|
||||||
Name = "CallerName",
|
{
|
||||||
ControlType = "Text",
|
Name = "CallOut",
|
||||||
PinStyle = "Input",
|
ControlType = "Text",
|
||||||
UserPin = true
|
PinStyle = "Output",
|
||||||
}
|
UserPin = true
|
||||||
}
|
},
|
||||||
return controls
|
{
|
||||||
end
|
Name = "CallerName",
|
||||||
|
ControlType = "Text",
|
||||||
function Initialize()
|
PinStyle = "Input",
|
||||||
end
|
UserPin = true
|
||||||
|
}
|
||||||
function SetupControlHandlers()
|
}
|
||||||
Controls["QueueUp"].EventHandler = function (ctrl)
|
return controls
|
||||||
local call = {
|
end
|
||||||
Queue = ctrl.Boolean,
|
|
||||||
Name = Controls["CallerName"].String,
|
function Initialize()
|
||||||
Time = os.time()
|
end
|
||||||
}
|
|
||||||
local callString = json.encode(call)
|
function CreateCall(name, queue)
|
||||||
Controls["CallOut"].String = json.encode(call)
|
local call = {
|
||||||
end
|
Queue = queue,
|
||||||
end
|
Name = name,
|
||||||
|
Time = os.time()
|
||||||
if(Controls) then
|
}
|
||||||
Initialize()
|
return call
|
||||||
SetupControlHandlers()
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function SetupControlHandlers()
|
||||||
|
Controls["QueueUp"].EventHandler = function (ctrl)
|
||||||
|
local call = CreateCall(Controls["CallerName"].String, Controls["QueueUp"].Boolean)
|
||||||
|
Controls["CallOut"].String = json.encode(call)
|
||||||
|
end
|
||||||
|
|
||||||
|
Controls["Clear"].EventHandler = function (ctrl)
|
||||||
|
Controls["QueueUp"].Boolean = false
|
||||||
|
local call = CreateCall(Controls["CallerName"].String, false)
|
||||||
|
Controls["CallOut"].String = json.encode(call)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if(Controls) then
|
||||||
|
Initialize()
|
||||||
|
SetupControlHandlers()
|
||||||
end
|
end
|
||||||
+151
-128
@@ -1,129 +1,152 @@
|
|||||||
PluginInfo = {
|
PluginInfo = {
|
||||||
Name = "CallQueue",
|
Name = "CallQueue",
|
||||||
Version = "0.1.0-master",
|
Version = "0.1.0-master",
|
||||||
Id = "callqueue.plugin.0.1.0-master",
|
Id = "callqueue.plugin.0.1.0-master",
|
||||||
Description = "Plugin for taking incoming call objects and maintaining a queue",
|
Description = "Plugin for taking incoming call objects and maintaining a queue",
|
||||||
Author = "Joel Wetzell"
|
Author = "Joel Wetzell"
|
||||||
}
|
}
|
||||||
require("json")
|
require("json")
|
||||||
function GetPrettyName()
|
function GetPrettyName()
|
||||||
return "Call Queue"
|
return "Call Queue"
|
||||||
end
|
end
|
||||||
|
|
||||||
function GetProperties()
|
function GetProperties()
|
||||||
local props = {
|
local props = {
|
||||||
{
|
{
|
||||||
Name = "Call Count",
|
Name = "Call Count",
|
||||||
Type = "integer",
|
Type = "integer",
|
||||||
Min = 0,
|
Min = 0,
|
||||||
Max = 20,
|
Max = 20,
|
||||||
Value = 1
|
Value = 1
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
return props
|
return props
|
||||||
end
|
end
|
||||||
|
|
||||||
function RectifyProperties(props)
|
function RectifyProperties(props)
|
||||||
return props
|
return props
|
||||||
end
|
end
|
||||||
|
|
||||||
function GetControls(props)
|
function GetControls(props)
|
||||||
local controls = {
|
local controls = {
|
||||||
{
|
{
|
||||||
Name = "PopCall",
|
Name = "PopCall",
|
||||||
ControlType = "Button",
|
ControlType = "Button",
|
||||||
ButtonType = "Trigger",
|
ButtonType = "Trigger",
|
||||||
PinStyle = "Input",
|
PinStyle = "Input",
|
||||||
UserPin = true
|
UserPin = true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name = "TopCallName",
|
Name = "CallList",
|
||||||
ControlType = "Text",
|
ControlType = "Text",
|
||||||
PinStyle = "Output",
|
PinStyle = "Output",
|
||||||
UserPin = true
|
UserPin = true
|
||||||
},
|
},
|
||||||
}
|
{
|
||||||
for i=1,props["Call Count"].Value do
|
Name = "ClearAll",
|
||||||
print(i)
|
ControlType = "Button",
|
||||||
local name = "Call" .. i
|
ButtonType = "Trigger",
|
||||||
table.insert(controls, {
|
Pinstyle = "Input",
|
||||||
Name = name,
|
UserPin = true
|
||||||
ControlType = "Text",
|
}
|
||||||
PinStyle = "Input",
|
}
|
||||||
UserPin = true
|
for i=1,props["Call Count"].Value do
|
||||||
})
|
local name = "Call" .. i
|
||||||
end
|
table.insert(controls, {
|
||||||
return controls
|
Name = name .. "In",
|
||||||
end
|
ControlType = "Text",
|
||||||
|
PinStyle = "Input",
|
||||||
function ClearCalls()
|
UserPin = true
|
||||||
CallList = {}
|
})
|
||||||
end
|
table.insert(controls, {
|
||||||
|
Name = name .. "Clear",
|
||||||
function UpdateOutputs()
|
ControlType = "Button",
|
||||||
local topCall = CallList[1]
|
ButttonType = "Trigger",
|
||||||
if topCall == nil then
|
PinStyle = "Output",
|
||||||
Controls["TopCallName"].String = ""
|
UserPin = true
|
||||||
else
|
})
|
||||||
Controls["TopCallName"].String = topCall.Name
|
end
|
||||||
end
|
return controls
|
||||||
end
|
end
|
||||||
|
|
||||||
function PushCall(call)
|
function ClearCalls()
|
||||||
for i, value in pairs(CallList) do
|
CallList = {}
|
||||||
if value.Position == call.Position then
|
for i=1, Properties["Call Count"].Value do
|
||||||
print("call already in queue for position " .. call.Position)
|
Controls["Call"..i.."Clear"]:Trigger()
|
||||||
return
|
end
|
||||||
end
|
UpdateOutputs()
|
||||||
end
|
end
|
||||||
table.insert(CallList, call)
|
|
||||||
print("call for " .. call.Name .. " at position " .. call.Position .. " pushed")
|
function UpdateOutputs()
|
||||||
UpdateOutputs()
|
local listString = ""
|
||||||
end
|
if (#CallList > 0) then
|
||||||
|
for i, v in pairs(CallList) do
|
||||||
function PopCall()
|
listString = listString .. v.Name .. "\n"
|
||||||
call = table.remove(CallList,1)
|
end
|
||||||
if call then
|
end
|
||||||
print("call for " .. call.Name .. " at position " .. call.Position .. " popped")
|
Controls["CallList"].String = listString
|
||||||
end
|
end
|
||||||
UpdateOutputs()
|
|
||||||
end
|
function PushCall(call)
|
||||||
|
for i, value in pairs(CallList) do
|
||||||
function RemoveCall(call)
|
if value.Position == call.Position then
|
||||||
for i, value in pairs(CallList) do
|
print("call already in queue for position " .. call.Position)
|
||||||
if value.Position == call.Position then
|
return
|
||||||
print("removing call for position " .. call.Position)
|
end
|
||||||
table.remove(CallList, i)
|
end
|
||||||
return
|
table.insert(CallList, call)
|
||||||
end
|
print("call for " .. call.Name .. " at position " .. call.Position .. " pushed")
|
||||||
end
|
UpdateOutputs()
|
||||||
end
|
end
|
||||||
|
|
||||||
function Initialize()
|
function PopCall()
|
||||||
ClearCalls()
|
call = table.remove(CallList,1)
|
||||||
end
|
if call then
|
||||||
|
print("call for " .. call.Name .. " at position " .. call.Position .. " popped")
|
||||||
function SetupControlHandlers()
|
Controls["Call"..call.Position.."Clear"]:Trigger()
|
||||||
Controls["PopCall"].EventHandler = function (ctrl)
|
end
|
||||||
PopCall()
|
UpdateOutputs()
|
||||||
end
|
end
|
||||||
|
|
||||||
for i=1, Properties["Call Count"].Value do
|
function RemoveCall(call)
|
||||||
Controls["Call"..i].EventHandler = function (ctrl)
|
for i, value in pairs(CallList) do
|
||||||
if ctrl.String ~= "" then
|
if value.Position == call.Position then
|
||||||
local call = json.decode(ctrl.String)
|
print("removing call for position " .. call.Position)
|
||||||
call.Position = i
|
table.remove(CallList, i)
|
||||||
if call.Queue then
|
end
|
||||||
PushCall(call)
|
end
|
||||||
else
|
UpdateOutputs()
|
||||||
RemoveCall(call)
|
end
|
||||||
end
|
|
||||||
end
|
function Initialize()
|
||||||
end
|
ClearCalls()
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
function SetupControlHandlers()
|
||||||
if(Controls) then
|
Controls["PopCall"].EventHandler = function (ctrl)
|
||||||
Initialize()
|
PopCall()
|
||||||
SetupControlHandlers()
|
end
|
||||||
|
|
||||||
|
Controls["ClearAll"].EventHandler = function (ctrl)
|
||||||
|
ClearCalls()
|
||||||
|
end
|
||||||
|
|
||||||
|
for i=1, Properties["Call Count"].Value do
|
||||||
|
Controls["Call"..i.."In"].EventHandler = function (ctrl)
|
||||||
|
if ctrl.String ~= "" then
|
||||||
|
local call = json.decode(ctrl.String)
|
||||||
|
call.Position = i
|
||||||
|
if call.Queue then
|
||||||
|
PushCall(call)
|
||||||
|
else
|
||||||
|
RemoveCall(call)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if(Controls) then
|
||||||
|
Initialize()
|
||||||
|
SetupControlHandlers()
|
||||||
end
|
end
|
||||||
Reference in New Issue
Block a user