round out queue and call with individual call input and clearing

This commit is contained in:
2026-05-02 00:11:02 +00:00
parent 453940146b
commit 3f19c32acc
2 changed files with 234 additions and 193 deletions
+24 -6
View File
@@ -22,6 +22,13 @@ end
function GetControls(props) function GetControls(props)
local controls = { local controls = {
{
Name = "Clear",
ControlType = "Button",
ButtonType = "Trigger",
PinStyle = "Input",
UserPin = true
},
{ {
Name = "QueueUp", Name = "QueueUp",
ControlType = "Button", ControlType = "Button",
@@ -48,14 +55,25 @@ end
function Initialize() function Initialize()
end end
function CreateCall(name, queue)
local call = {
Queue = queue,
Name = name,
Time = os.time()
}
return call
end
function SetupControlHandlers() function SetupControlHandlers()
Controls["QueueUp"].EventHandler = function (ctrl) Controls["QueueUp"].EventHandler = function (ctrl)
local call = { local call = CreateCall(Controls["CallerName"].String, Controls["QueueUp"].Boolean)
Queue = ctrl.Boolean, Controls["CallOut"].String = json.encode(call)
Name = Controls["CallerName"].String, end
Time = os.time()
} Controls["Clear"].EventHandler = function (ctrl)
local callString = json.encode(call) Controls["QueueUp"].Boolean = false
local call = CreateCall(Controls["CallerName"].String, false)
Controls["CallOut"].String = json.encode(call) Controls["CallOut"].String = json.encode(call)
end end
end end
+33 -10
View File
@@ -37,36 +37,54 @@ function GetControls(props)
UserPin = true UserPin = true
}, },
{ {
Name = "TopCallName", Name = "CallList",
ControlType = "Text", ControlType = "Text",
PinStyle = "Output", PinStyle = "Output",
UserPin = true UserPin = true
}, },
{
Name = "ClearAll",
ControlType = "Button",
ButtonType = "Trigger",
Pinstyle = "Input",
UserPin = true
}
} }
for i=1,props["Call Count"].Value do for i=1,props["Call Count"].Value do
print(i)
local name = "Call" .. i local name = "Call" .. i
table.insert(controls, { table.insert(controls, {
Name = name, Name = name .. "In",
ControlType = "Text", ControlType = "Text",
PinStyle = "Input", PinStyle = "Input",
UserPin = true UserPin = true
}) })
table.insert(controls, {
Name = name .. "Clear",
ControlType = "Button",
ButttonType = "Trigger",
PinStyle = "Output",
UserPin = true
})
end end
return controls return controls
end end
function ClearCalls() function ClearCalls()
CallList = {} CallList = {}
for i=1, Properties["Call Count"].Value do
Controls["Call"..i.."Clear"]:Trigger()
end
UpdateOutputs()
end end
function UpdateOutputs() function UpdateOutputs()
local topCall = CallList[1] local listString = ""
if topCall == nil then if (#CallList > 0) then
Controls["TopCallName"].String = "" for i, v in pairs(CallList) do
else listString = listString .. v.Name .. "\n"
Controls["TopCallName"].String = topCall.Name end
end end
Controls["CallList"].String = listString
end end
function PushCall(call) function PushCall(call)
@@ -85,6 +103,7 @@ function PopCall()
call = table.remove(CallList,1) call = table.remove(CallList,1)
if call then if call then
print("call for " .. call.Name .. " at position " .. call.Position .. " popped") print("call for " .. call.Name .. " at position " .. call.Position .. " popped")
Controls["Call"..call.Position.."Clear"]:Trigger()
end end
UpdateOutputs() UpdateOutputs()
end end
@@ -94,9 +113,9 @@ function RemoveCall(call)
if value.Position == call.Position then if value.Position == call.Position then
print("removing call for position " .. call.Position) print("removing call for position " .. call.Position)
table.remove(CallList, i) table.remove(CallList, i)
return
end end
end end
UpdateOutputs()
end end
function Initialize() function Initialize()
@@ -108,8 +127,12 @@ function SetupControlHandlers()
PopCall() PopCall()
end end
Controls["ClearAll"].EventHandler = function (ctrl)
ClearCalls()
end
for i=1, Properties["Call Count"].Value do for i=1, Properties["Call Count"].Value do
Controls["Call"..i].EventHandler = function (ctrl) Controls["Call"..i.."In"].EventHandler = function (ctrl)
if ctrl.String ~= "" then if ctrl.String ~= "" then
local call = json.decode(ctrl.String) local call = json.decode(ctrl.String)
call.Position = i call.Position = i