-- -- (C) 2020 - ntop.org -- local dirs = ntop.getDirs() package.path = dirs.installdir .. "/scripts/lua/modules/?.lua;" .. package.path package.path = dirs.installdir .. "/pro/scripts/lua/enterprise/modules/?.lua;" .. package.path require "lua_utils" local template_utils = require("template_utils") local infrastructure_utils if (ntop.isEnterpriseL()) then infrastructure_utils = require("infrastructure_utils") end local ui_utils = {} function ui_utils.render_configuration_footer(item) return template_utils.gen('pages/components/manage-configuration-link.template', {item = item}) end --- Single note element: { content = 'note description', hidden = true|false } function ui_utils.render_notes(notes_items) if notes_items == nil then traceError(TRACE_DEBUG, TRACE_CONSOLE, "The notes table is nil!") return "" end return template_utils.gen("pages/components/notes.template", { notes = notes_items }) end function ui_utils.render_pools_dropdown(pools_instance, member, key) if (pools_instance == nil) then traceError(TRACE_DEBUG, TRACE_CONSOLE, "The pools instance is nil!") return "" end if (member == nil) then traceError(TRACE_DEBUG, TRACE_CONSOLE, "The member is nil!") return "" end local selected_pool = pools_instance:get_pool_by_member(member) local selected_pool_id = selected_pool and selected_pool.pool_id or pools_instance.DEFAULT_POOL_ID local all_pools = pools_instance:get_all_pools() return template_utils.gen("pages/components/pool-select.template", { pools = all_pools, selected_pool_id = selected_pool_id, key = key, }) end function ui_utils.create_navbar_title(title, subpage, title_link) if isEmptyString(subpage) then return title end return "".. title .. " / "..subpage.."" end function ui_utils.format_label_am(host) if (ntop.isEnterpriseL()) then -- replace path used inside infrastructure utils return string.gsub(host, "/"..infrastructure_utils.ENDPOINT_TO_EXTRACT_DATA, " ".. i18n("infrastructure_dashboard.infrastructure") .."") end return host end return ui_utils