mirror of
https://github.com/ntop/ntopng.git
synced 2026-04-29 23:49:33 +00:00
Widget improvements
This commit is contained in:
parent
281012610a
commit
17bbfb7c78
10 changed files with 176 additions and 141 deletions
54
scripts/lua/modules/datamodel_utils.lua
Normal file
54
scripts/lua/modules/datamodel_utils.lua
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
--
|
||||
-- (C) 2020 - ntop.org
|
||||
--
|
||||
|
||||
local datamodel = {}
|
||||
datamodel.__index = datamodel
|
||||
|
||||
-- ######################################
|
||||
|
||||
function datamodel:create(labels)
|
||||
local ret = {}
|
||||
|
||||
setmetatable(ret,datamodel) -- Create the class
|
||||
|
||||
ret.column_labels = labels
|
||||
ret.rows = {}
|
||||
ret.timestamps = {}
|
||||
|
||||
return(ret)
|
||||
end
|
||||
|
||||
-- ######################################
|
||||
|
||||
function datamodel:appendRow(when, row)
|
||||
table.insert(self.timestamps, when)
|
||||
table.insert(self.rows, row)
|
||||
end
|
||||
|
||||
-- ######################################
|
||||
|
||||
-- Return the data formatted as expected by a table widget
|
||||
function datamodel:getAsTable()
|
||||
local ret = {}
|
||||
|
||||
ret.header = self.column_labels
|
||||
ret.rows = self.rows
|
||||
|
||||
return(ret)
|
||||
end
|
||||
|
||||
-- ######################################
|
||||
|
||||
-- Return the data
|
||||
function datamodel:getData(transformation)
|
||||
if(transformation == "table") then
|
||||
return(self:getAsTable())
|
||||
else
|
||||
return({})
|
||||
end
|
||||
end
|
||||
|
||||
-- ######################################
|
||||
|
||||
return(datamodel)
|
||||
Loading…
Add table
Add a link
Reference in a new issue