mirror of
https://github.com/ntop/ntopng.git
synced 2026-04-30 16:09:32 +00:00
Added widgets in use in get_datasources.lua
Reconciled widget_utils.lua name
This commit is contained in:
parent
95279f07c6
commit
5294179bf9
5 changed files with 32 additions and 8 deletions
|
|
@ -8,9 +8,33 @@ package.path = dirs.installdir .. "/scripts/lua/modules/?.lua;" .. package.path
|
|||
require "lua_utils"
|
||||
|
||||
local datasources_utils = require("datasources_utils")
|
||||
local widgets_utils = require("widgets_utils")
|
||||
local json = require "dkjson"
|
||||
|
||||
sendHTTPContentTypeHeader('application/json')
|
||||
|
||||
local datasources = datasources_utils.get_all_sources()
|
||||
local widgets = widgets_utils.get_all_widgets()
|
||||
|
||||
-- Now report what datasources are in use
|
||||
|
||||
local ds_in_use = {}
|
||||
for k,v in pairs(widgets) do
|
||||
if(ds_in_use[v.ds_hash] == nil) then
|
||||
ds_in_use[v.ds_hash] = {}
|
||||
end
|
||||
|
||||
table.insert(ds_in_use[v.ds_hash], v.key)
|
||||
end
|
||||
|
||||
for k,v in pairs(datasources) do
|
||||
if(ds_in_use[v.hash] ~= nil) then
|
||||
datasources[k].in_use = true
|
||||
datasources[k].widgets = ds_in_use[v.hash]
|
||||
else
|
||||
datasources[k].in_use = false
|
||||
datasources[k].widgets = {}
|
||||
end
|
||||
end
|
||||
|
||||
print(json.encode(datasources))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue