mirror of
https://github.com/ntop/ntopng.git
synced 2026-04-29 07:29:32 +00:00
Widget improvements
This commit is contained in:
parent
281012610a
commit
17bbfb7c78
10 changed files with 176 additions and 141 deletions
|
|
@ -138,6 +138,16 @@ function datasources_utils.delete_source(hash_source)
|
|||
return true
|
||||
end
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- Get a datasource stored in redis
|
||||
-- @return The searched datasources stored in redis, or nil in case of error
|
||||
-------------------------------------------------------------------------------
|
||||
function datasources_utils.get(ds_hash)
|
||||
local ds = ntop.getHashCache(REDIS_BASE_KEY, ds_hash) or "{}"
|
||||
|
||||
return(json.decode(ds))
|
||||
end
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- Get all datasources stored in redis
|
||||
-- @return An array of datasources stored in redis, if no any sources was found
|
||||
|
|
@ -160,20 +170,20 @@ function datasources_utils.get_all_sources()
|
|||
end
|
||||
|
||||
function datasources_utils.prepareResponse(datasets, timestamps, unit)
|
||||
|
||||
local response = {}
|
||||
if (datasets == nil) then return {} end
|
||||
|
||||
if (timestamps ~= nil) then
|
||||
response.timestamps = timestamps
|
||||
end
|
||||
if (unit ~= nil) then
|
||||
response.unit = unit
|
||||
end
|
||||
|
||||
response.data = datasets
|
||||
|
||||
return response
|
||||
local response = {}
|
||||
|
||||
if (datasets == nil) then return {} end
|
||||
|
||||
if (timestamps ~= nil) then
|
||||
response.timestamps = timestamps
|
||||
end
|
||||
if (unit ~= nil) then
|
||||
response.unit = unit
|
||||
end
|
||||
|
||||
response.data = datasets
|
||||
|
||||
return response
|
||||
end
|
||||
|
||||
return datasources_utils
|
||||
return datasources_utils
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue