mirror of
https://github.com/ntop/ntopng.git
synced 2026-04-30 07:59:35 +00:00
Cleanup widgets code
This commit is contained in:
parent
c4172a8e51
commit
0e9f848788
4 changed files with 0 additions and 177 deletions
|
|
@ -62,51 +62,6 @@ end
|
|||
|
||||
-- ##############################################
|
||||
|
||||
-- @brief Parses params
|
||||
-- @param params_table A table with submitted params
|
||||
-- @return An integer dataset id upon success, nil otherwise
|
||||
function datasource:add_dataset(params_table)
|
||||
if not params_table then
|
||||
return nil
|
||||
end
|
||||
|
||||
local cur_params = {}
|
||||
for _, param in pairs(self.meta.params or {}) do
|
||||
local parsed_param = params_table[param]
|
||||
|
||||
-- Assumes all params mandatory and not empty
|
||||
-- May override this behavior in subclasses
|
||||
if isEmptyString(parsed_param) then
|
||||
return nil
|
||||
end
|
||||
|
||||
cur_params[param] = parsed_param
|
||||
end
|
||||
|
||||
-- Ok, parsing has been successful
|
||||
self._dataset_params[#self._dataset_params + 1] = cur_params
|
||||
|
||||
-- The id is basically the position in the array of dataset_params
|
||||
return #self._dataset_params
|
||||
end
|
||||
|
||||
-- ##############################################
|
||||
|
||||
-- @brief Fetches data of every added dataset
|
||||
function datasource:fetch_data()
|
||||
-- Instantiate the datamodel
|
||||
self._datamodel_instance = self.meta.datamodel.new(
|
||||
self.meta.i18n_title
|
||||
)
|
||||
|
||||
-- Fetch datasets data
|
||||
for dataset_id, dataset_params in ipairs(self._dataset_params) do
|
||||
self:_fetch(dataset_id, dataset_params)
|
||||
end
|
||||
end
|
||||
|
||||
-- ##############################################
|
||||
|
||||
-- @brief Parses params submitted along with the REST endpoint request. If parsing fails, a REST error is sent.
|
||||
-- @param params_table A table with submitted params, either _POST or _GET
|
||||
-- @return True if parameters parsing is successful, false otherwise
|
||||
|
|
@ -195,16 +150,6 @@ end
|
|||
|
||||
-- ##############################################
|
||||
|
||||
-- @brief Transform data according to the specified transformation
|
||||
-- @param data The data to be transformed
|
||||
-- @param transformation The transformation to be applied
|
||||
-- @return transformed data
|
||||
function datasource:transform_data(transformation)
|
||||
return self._datamodel_instance:datasets_get_data(transformation)
|
||||
end
|
||||
|
||||
-- ##############################################
|
||||
|
||||
return datasource
|
||||
|
||||
-- ##############################################
|
||||
|
|
|
|||
|
|
@ -92,25 +92,6 @@ end
|
|||
|
||||
-- #######################################################
|
||||
|
||||
-- New version, throw fetch() when done
|
||||
function packet_distro:_fetch(dataset_id, dataset_params)
|
||||
-- Assumes all parameters listed in self.meta.params have been parsed successfully
|
||||
-- and are available in dataset_params
|
||||
|
||||
interface.select(tostring(dataset_params.ifid))
|
||||
local ifstats = interface.getStats()
|
||||
local size_bins = ifstats["pktSizeDistribution"]["size"]
|
||||
|
||||
for bin, num_packets in pairsByKeys(size_bins) do
|
||||
self._datamodel_instance:dataset_append(dataset_id, packet_distro.slices[bin], num_packets)
|
||||
end
|
||||
|
||||
-- Add metadata to the dataset
|
||||
self._datamodel_instance:dataset_metadata(dataset_id, getHumanReadableInterfaceName(getInterfaceName(ifstats.id)) --[[ This is the label --]])
|
||||
end
|
||||
|
||||
-- #######################################################
|
||||
|
||||
-- Checks if this module is being loaded as part of a REST request to this endpoint or not.
|
||||
-- If the module is being loaded as part of a REST request, then a response is sent, otherwise nothing is done.
|
||||
-- Must call this to ensure REST responses are sent when necessary
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue