Added assets dashboard

This commit is contained in:
Matteo Biscosi 2025-03-12 17:08:37 +01:00
parent 97ca40a349
commit 5f876167e5
25 changed files with 2311 additions and 1191 deletions

View file

@ -664,6 +664,7 @@ function graph_utils.convert_pie_data(res, new_charts, js_formatter)
local labels = {}
local series = {}
local colors = {}
local urls = {}
for _, v in ipairs(res) do
labels[#labels + 1] = v.label
@ -675,7 +676,7 @@ function graph_utils.convert_pie_data(res, new_charts, js_formatter)
value = v.value
end
series[#series + 1] = value
urls[#urls + 1] = v.url or ''
colors[#colors + 1] = graph_utils.get_html_color(#colors)
end
@ -694,6 +695,7 @@ function graph_utils.convert_pie_data(res, new_charts, js_formatter)
formatter = js_formatter
}
},
urls = urls,
extra_x_tooltip_label = 'None'
}
@ -702,6 +704,53 @@ end
-- #################################################
-- Convert to the format accepted by the vue Chart/Bar component
-- js_formatter: render function (e.g. 'format_bytes')
-- Input format (res):
-- [ { label = 'xxx', count = yyy }, ... ]
-- Output format:
-- { series = [{ data = [ yyy, ... ] }], xaxis = { categories = [ 'xxx'] } }
function graph_utils.convert_bar_data(res, new_charts, js_formatter)
if not new_charts then
return res
end
local labels = {}
local series = {}
local urls = {}
for _, v in ipairs(res) do
labels[#labels + 1] = v.label
local value = 0
if v.count then
value = v.count
elseif v.value then
value = v.value
end
urls[#urls + 1] = v.url or ''
series[#series + 1] = value
end
res = {
series = {{
data = series
}},
xaxis = {
categories = labels,
},
urls = urls,
tooltip = {
y = {
formatter = js_formatter
}
},
}
return res
end
-- #################################################
-- Merge pie data from 2 data sources (compute top of tops)
function graph_utils.merge_pie_data(aggregated_data, data, max_values)
-- Merge in temporary table