]]
print('\n')
local total_stats = {
tot_elapsed = 0,
tot_num_calls = 0,
}
-- A user module link is currently required for the total
local total_user_module = nil
for mod_k, user_script in pairsByKeys(descr.modules, asc) do
-- Calculate the total stats
for _, mod_benchmark in pairs(user_script.benchmark or {}) do
total_stats.tot_elapsed = total_stats.tot_elapsed + mod_benchmark["tot_elapsed"]
total_stats.tot_num_calls = total_stats.tot_num_calls + mod_benchmark["tot_num_calls"]
end
end
for mod_k, user_script in pairsByKeys(descr.modules, asc) do
local hooks_benchmarks = user_script.benchmark or {}
local num_hooks = table.len(hooks_benchmarks)
local title
local description
local rowspan = ""
if(not total_user_module) then
total_user_module = mod_k
end
if(user_script.gui) then
title = i18n(user_script.gui.i18n_title) or user_script.gui.i18n_title
description = i18n(user_script.gui.i18n_description) or user_script.gui.i18n_description
else
title = user_script.key
description = ""
end
if(expert_view and (num_hooks > 0)) then
rowspan = string.format(' rowspan="%d"', num_hooks)
end
print("
".. title .." ")
print(""..description..".
")
print("
")
if(ts_utils.exists("flow_user_script:duration", {ifid=ifid, user_script=mod_k, subdir="flow"})) then
print('')
end
print("
")
print("
")
if(user_script.gui and user_script.gui.input_builder) then
print(user_script.gui.input_builder(user_script))
else
print('')
end
print("
")
if(expert_view) then
if(num_hooks > 0) then
local ctr = 0
for mod_fn, mod_benchmark in pairsByKeys(hooks_benchmarks, asc) do
print("
")
end
else
if(num_hooks > 0) then
-- Accumulate the stats for each hook
local total_duration = 0
local num_calls = 0
for mod_fn, mod_benchmark in pairsByKeys(user_script.benchmark or {}, asc) do
total_duration = total_duration + mod_benchmark["tot_elapsed"]
num_calls = num_calls + mod_benchmark["tot_num_calls"]
end
local avg_speed = (num_calls / total_duration)
printStatsCols(total_stats, total_duration, num_calls, avg_speed)
else
print("
")
end
end
end
local avg_speed = (total_stats.tot_num_calls / total_stats.tot_elapsed)
-- Print total stats
print("
" .. i18n("total") .. "
")
if(ts_utils.exists("flow_user_script:total_stats", {ifid=ifid, subdir="flow"})) then
print('')
end
print("
]]
end
-- #################################
function flow_callbacks_utils.print_callbacks_config()
local show_advanced_prefs = false
if(_GET["show_advanced_prefs"] == "1") then
show_advanced_prefs = true
end
local ifid = interface.getId()
local descr = user_scripts.load(user_scripts.script_types.flow, ifid, "flow", nil, true --[[ also return disabled ]])
print [[
]]
if table.len(_POST) > 0 then
for mod_key, user_script in pairs(descr.modules) do
local pref_key = "enabled_" .. mod_key
local val = _POST[pref_key]
if(val ~= nil) then
if(val == "on") then
user_scripts.enableModule(ifid, "flow", mod_key)
user_script.enabled = true
else
user_scripts.disableModule(ifid, "flow", mod_key)
user_script.enabled = false
end
end
end
end
print[[]]
print[[
]]
print("