Make graphs menu explicit in system scripts and add support for custom graphs

This commit is contained in:
emanuele-f 2019-06-21 13:50:44 +02:00
parent 5f9c61a049
commit 96e371a079
7 changed files with 81 additions and 58 deletions

View file

@ -158,8 +158,6 @@ end
function system_scripts.getAdditionalTimeseries(module_filter)
local old_new_schema_fn = ts_utils.newSchema
local additional_ts = {}
local needs_label = false
local current_probe_label = nil
local default_schema_options = nil
ts_utils.newSchema = function(name, options)
@ -168,25 +166,6 @@ function system_scripts.getAdditionalTimeseries(module_filter)
schema = old_new_schema_fn(name, table.merge(default_schema_options, options))
end
if(options.label == nil) then
traceError(TRACE_ERROR, TRACE_CONSOLE, string.format("Missing schema label in schema '%s'", name))
return nil
end
if needs_label then
needs_label = false
additional_ts[#additional_ts + 1] = {
separator = 1,
label = current_probe_label,
}
end
additional_ts[#additional_ts + 1] = {
schema = name,
label = options.label,
}
return schema
end
@ -201,10 +180,18 @@ function system_scripts.getAdditionalTimeseries(module_filter)
(((module_filter == "system") and (probe.page_script == nil)) or
(probe_name == module_filter) or
(module_filter == nil))) then
needs_label = true
current_probe_label = probe.name or probe_name
probe.loadSchemas(ts_utils)
if(probe.getTimeseriesMenu ~= nil) then
local menu = probe.getTimeseriesMenu(ts_utils) or {}
table.insert(menu, 1, {
separator = 1,
label = probe.name or probe_name,
})
additional_ts = table.merge(additional_ts, menu)
end
end
end
end