mirror of
https://github.com/ntop/ntopng.git
synced 2026-04-30 07:59:35 +00:00
Widget improvements
This commit is contained in:
parent
281012610a
commit
17bbfb7c78
10 changed files with 176 additions and 141 deletions
47
scripts/lua/widgets/widget.lua
Normal file
47
scripts/lua/widgets/widget.lua
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
--
|
||||
-- (C) 2020 - ntop.org
|
||||
--
|
||||
|
||||
--
|
||||
-- This is the main widget entrypoint that renders all widgets
|
||||
--
|
||||
|
||||
dirs = ntop.getDirs()
|
||||
package.path = dirs.installdir .. "/scripts/lua/modules/?.lua;" .. package.path
|
||||
require ("lua_utils")
|
||||
|
||||
local dkjson = require("dkjson")
|
||||
local datasources_utils = require("datasources_utils")
|
||||
local widget_utils = require("widget_utils")
|
||||
|
||||
local function reportError(msg)
|
||||
print(dkjson.encode({ success = false, message = msg }))
|
||||
end
|
||||
|
||||
-- ###############################################
|
||||
|
||||
local json = _GET["JSON"]
|
||||
|
||||
local widget_data
|
||||
|
||||
if(json == nil) then
|
||||
widget_data = {}
|
||||
else
|
||||
widget_data = dkjson.decode(json)
|
||||
end
|
||||
|
||||
sendHTTPContentTypeHeader('application/json')
|
||||
|
||||
if(widget_data.widgetKey == nil) then
|
||||
reportError("Missing widget_key parameter")
|
||||
return
|
||||
end
|
||||
|
||||
local widget = widget_utils.get_widget(widget_data.widgetKey)
|
||||
if (widget == nil) then
|
||||
reportError("The requested widget was not found")
|
||||
return
|
||||
end
|
||||
|
||||
-- Generate the widget response
|
||||
print(widget_utils.generate_response(widget, widget_data))
|
||||
Loading…
Add table
Add a link
Reference in a new issue