-- -- (C) 2013-18 - ntop.org -- dirs = ntop.getDirs() package.path = dirs.installdir .. "/scripts/lua/modules/?.lua;" .. package.path require "lua_utils" local format_utils = require "format_utils" local recording_utils = require "recording_utils" local json = require "dkjson" sendHTTPHeader('application/json') if not recording_utils.isAvailable() then return end -- ################################################ -- Table parameters local currentPage = _GET["currentPage"] local perPage = _GET["perPage"] local sortColumn = _GET["sortColumn"] local sortOrder = _GET["sortOrder"] -- ################################################ -- Sorting and Pagination local sortPrefs = "traffic_extraction_jobs" if isEmptyString(sortColumn) or sortColumn == "column_" then sortColumn = getDefaultTableSort(sortPrefs) elseif sortColumn ~= "" then tablePreferences("sort_"..sortPrefs, sortColumn) end if isEmptyString(_GET["sortColumn"]) then sortOrder = getDefaultTableSortOrder(sortPrefs, true) end if _GET["sortColumn"] ~= "column_" and _GET["sortColumn"] ~= "" then tablePreferences("sort_order_"..sortPrefs, sortOrder, true) end if currentPage == nil then currentPage = 1 else currentPage = tonumber(currentPage) end if perPage == nil then perPage = 10 else perPage = tonumber(perPage) tablePreferences("rows_number_policies", perPage) end local to_skip = (currentPage-1) * perPage if sortOrder == "desc" then sOrder = rev_insensitive else sOrder = asc_insensitive end -- ################################################ interface.select(ifname) local ifstats = interface.getStats() local jobs = recording_utils.getExtractionJobs(ifstats.id) local sorter = {} for id,job in pairs(jobs) do sorter[id] = job.time end local res = {} local cur_num = 0 for id, _ in pairsByValues(sorter, sOrder) do cur_num = cur_num + 1 if cur_num <= to_skip then goto continue elseif cur_num > to_skip + perPage then break end local job = jobs[id] local action_links = "" if job.status == "processing" then action_links = action_links..""..i18n("stop").."" else action_links = action_links..""..i18n("delete").."" end if job.status == "completed" or job.status == "stopped" then local job_files = recording_utils.getJobFiles(job.id) if #job_files > 1 then local links = "