Possible fix for issue #6962

This commit is contained in:
MatteoBiscosi 2022-11-07 10:55:50 +01:00
parent 05e5b50662
commit b7cb9a3481
3 changed files with 11 additions and 4 deletions

View file

@ -31,8 +31,8 @@ if(host and host.cardinality) then
series[#series + 1] = tonumber(host.cardinality.num_contacted_hosts_as_client or 0)
series[#series + 1] = tonumber(host.cardinality.num_contacted_hosts_as_server or 0)
else
series[#series + 1] = {}
series[#series + 1] = {}
series[#series + 1] = 0
series[#series + 1] = 0
end
colors[#colors + 1] = graph_utils.get_html_color(#colors + 1)

View file

@ -66,6 +66,13 @@ rsp["series"] = series
rsp["labels"] = labels
rsp["colors"] = colors
-- Just in case no data were found put an empty serie
if table.len(rsp["series"]) == 0 then
rsp["series"] = { 0 }
rsp["labels"] = { i18n('no_data_available') }
rsp["colors"] = { graph_utils.get_html_color(#colors + 1) }
end
-- ##################################
rest_utils.answer(rest_utils.consts.success.ok, rsp)

View file

@ -19,7 +19,7 @@ local rsp = {}
-- Applications
if view == 'applications' and host then
local host_applications = host["ndpi"]
local host_applications = host["ndpi"] or {}
-- Calculate the total bytes sent and received, to calculate the percentages
for _, v in pairs(host_applications) do
@ -45,7 +45,7 @@ if view == 'applications' and host then
elseif host then
-- Categories
local categories_utils = require "categories_utils"
local host_categories = host["ndpi_categories"]
local host_categories = host["ndpi_categories"] or {}
-- Calculate the total bytes sent and received, to calculate the percentages
for _, v in pairs(host_categories) do