require("lua_utils") local template = require "template_utils" local host_pools_utils = require "host_pools_utils" local ifstats = interface.getStats() local function hasBridgeConfiguration(captive_portal_active) return captive_portal_active or (#host_pools_utils.getPoolsList(ifstats.id, true) > 1) or (not table.empty(getCaptivePortalUsers())) end local captive_portal_supported = isCaptivePortalSupported(ifstats, prefs) local captive_portal_active = isCaptivePortalActive(ifstats, prefs) local configuration_found = hasBridgeConfiguration(captive_portal_active) local config_overwrite_warning = ""..string.upper(i18n("warning"))..": "..i18n("bridge_wizard.warning_configuration_exist") local no_local_networks if not captive_portal_supported then no_local_networks = true for net in pairs(ntop.getLocalNetworks()) do if not starts(net, "127.0.0.0") then no_local_networks = false break end end else no_local_networks = false end local no_local_networks_warning = ""..string.upper(i18n("error"))..": "..i18n("bridge_wizard.no_local_networks") local captive_portal_status if captive_portal_active then captive_portal_status = i18n("bridge_wizard.captive_portal_running") elseif captive_portal_supported then captive_portal_status = i18n("bridge_wizard.captive_portal_available") else captive_portal_status = i18n("bridge_wizard.captive_portal_unavailable") end local steps = { { -- Step 1 title = i18n("bridge_wizard.start"), content = i18n("bridge_wizard.intro_1", {iface=ifstats.name}).."

"..captive_portal_status..[[
]]..ternary(configuration_found, "
"..config_overwrite_warning, "")..[[

]]..ternary(no_local_networks, "
"..no_local_networks_warning, "

"..i18n("bridge_wizard.click_on_next")), size = 2, }, { -- Step 2 title = i18n("bridge_wizard.configure_host_pools"), content = i18n("bridge_wizard.host_pool_info")..[[


]]..i18n("bridge_wizard.also_create_these_pools")..[[
]], size = 3, }, { -- Step 3 title = i18n("bridge_wizard.configure_user"), content = i18n("bridge_wizard.configure_user_message", {pool=''})..[[

]]..i18n("bridge_wizard.predefined_users_message", { guests = i18n("bridge_wizard.guests"), guests_username = "guest", guests_password = "guest", children = i18n("bridge_wizard.safe_search_guest"), children_username = "children", children_password = "children", })..[[ ]], disabled = not captive_portal_supported, size = 3, on_show = [[ $("#wizard_credentials_pool_name").html($("#wizard_custom_pool_name").val()); $("#wizard_guests_creds").css("display", $("#wizard_create_guests_pool").prop("checked") ? "" : "none"); ]], }, { -- Step 4 title = i18n("bridge_wizard.policy"), content = i18n("bridge_wizard.define_policy", {pool=''})..[[



]]..i18n("bridge_wizard.fine_tune", {url=ntop.getHttpPrefix().."/lua/if_stats.lua?page=filtering"}), size = 2, on_show = [[ $("#wizard_policy_pool_name").html($("#wizard_custom_pool_name").val()); ]], }, { -- Step 5 title = i18n("bridge_wizard.done"), content = i18n("bridge_wizard.configuration_complete", {iface=ifstats.name})..[[ ]]..ternary(configuration_found, "
"..config_overwrite_warning.."
", ""), size = 2, } } local wizard = { id = "bridgeWizardModal", title = "Bridge Configuration Wizard", style = "width: 50em;", body_style = "height: 36em;", validator_options = [[{ custom: { member: memberValueValidator, pool_name: poolNameValidator, username: usernameValidator, }, errors: { member: "]]..i18n("host_pools.invalid_member")..[[.", pool_name: "]]..i18n("bridge_wizard.pool_name_error")..[[.", username: "]]..i18n("bridge_wizard.username_error")..[[.", } }]], steps = steps, cannot_proceed = no_local_networks, form_action = ntop.getHttpPrefix().."/lua/pro/init_bridge.lua?ifid="..ifstats.id, form_onsubmit = "checkBridgeWizardForm", } print[[ ]] print(template.gen("wizard_dialog.html", {wizard = wizard}))