mirror of
https://github.com/ntop/ntopng.git
synced 2026-05-01 00:19:33 +00:00
Implements flow check modules enable/disable prefs
This commit is contained in:
parent
d672d93750
commit
e2c9e729a4
6 changed files with 143 additions and 54 deletions
|
|
@ -9,16 +9,24 @@ local alerts_api = require "alerts_api"
|
|||
local CALLBACK_EVENTS = {
|
||||
application_detected = {
|
||||
cb = "protocolDetected",
|
||||
i18n = "flow_callbacks.application_detected"},
|
||||
i18n = "flow_callbacks.application_detected",
|
||||
i18n_note = "flow_callbacks.note_flow_application_detected",
|
||||
},
|
||||
status_changed = {
|
||||
cb = "statusChanged",
|
||||
i18n = "flow_callbacks.status_changed",},
|
||||
i18n = "flow_callbacks.status_changed",
|
||||
i18n_note = "flow_callbacks.note_flow_staus_changed",
|
||||
},
|
||||
periodic_update = {
|
||||
cb = "periodicUpdate",
|
||||
i18n = "flow_callbacks.periodic_update"},
|
||||
i18n = "flow_callbacks.periodic_update",
|
||||
i18n_note = "flow_callbacks.note_flow_periodic_update",
|
||||
},
|
||||
idle = {
|
||||
cb = "idle",
|
||||
i18n = "flow_callbacks.idle"}
|
||||
i18n = "flow_callbacks.idle",
|
||||
i18n_note = "flow_callbacks.note_flow_idle",
|
||||
}
|
||||
}
|
||||
|
||||
local flow_callbacks_utils = {}
|
||||
|
|
@ -58,14 +66,19 @@ function flow_callbacks_utils.print_callbacks_config()
|
|||
<table id="callbacks_config_table" class="table table-bordered table-striped" style="clear: both">
|
||||
<thead></thead>
|
||||
<tbody>]]
|
||||
print[[<tr><th width=30%>]] print(i18n("flow_callbacks.callback")) print[[</th><th>]] print(i18n("flow_callbacks.callback_config"))
|
||||
print[[</th></tr>]]
|
||||
print[[<form method="post">]]
|
||||
print[[<tr>]]
|
||||
print[[<th width=30%>]] print(i18n("flow_callbacks.callback")) print[[</th>]]
|
||||
print[[<th width=5% style="text-align:center">]] print(i18n("flow_callbacks.callback_enabled")) print[[</th>]]
|
||||
print[[<th>]] print(i18n("flow_callbacks.callback_config")) print[[</th>]]
|
||||
print[[</tr>]]
|
||||
|
||||
print[[<form id="flow-callbacks-config" class="form-inline" method="post">]]
|
||||
print('<input id="csrf" name="csrf" type="hidden" value="'..ntop.getRandomCSRFValue()..'" />\n')
|
||||
|
||||
local has_modules = false
|
||||
for _, check_module in pairsByKeys(descr, asc) do
|
||||
if check_module[CALLBACK_EVENTS[tab]["cb"]] and check_module.gui then
|
||||
local callback_name = CALLBACK_EVENTS[tab]["cb"]
|
||||
for _, check_module in pairsByKeys(descr[callback_name], asc) do
|
||||
if check_module[callback_name] and check_module.gui then
|
||||
if not has_modules then
|
||||
has_modules = true
|
||||
end
|
||||
|
|
@ -73,6 +86,10 @@ function flow_callbacks_utils.print_callbacks_config()
|
|||
print("<tr><td><b>".. i18n(check_module.gui.i18n_title) .."</b><br>")
|
||||
print("<small>"..i18n(check_module.gui.i18n_description)..".</small>\n")
|
||||
|
||||
print('</td><td align="center">')
|
||||
|
||||
print(alerts_api.checkbox_input_builder(check_module.gui, string.format("enabled_%s", check_module.key), check_module.conf.enabled))
|
||||
|
||||
print("</td><td>")
|
||||
|
||||
print(check_module.gui.input_builder(check_module.gui, nil --[[ current key --]], nil --[[ current val for key --]]))
|
||||
|
|
@ -82,11 +99,24 @@ function flow_callbacks_utils.print_callbacks_config()
|
|||
end
|
||||
|
||||
if not has_modules then
|
||||
print("<tr><td colspan=2><i>"..i18n("flow_callbacks.no_callbacks_defined", {cb = CALLBACK_EVENTS[tab]["cb"]})..".</i></td></tr>")
|
||||
print("<tr><td colspan=3><i>"..i18n("flow_callbacks.no_callbacks_defined", {cb = callback_name})..".</i></td></tr>")
|
||||
end
|
||||
|
||||
print[[</form>]]
|
||||
print[[</tbody></table>]]
|
||||
print[[<button class="btn btn-primary" style="float:right; margin-right:1em;" type="submit">]] print(i18n("save_configuration")) print[[</button>]]
|
||||
print[[</form>]]
|
||||
|
||||
print[[
|
||||
<script>
|
||||
</script>
|
||||
]]
|
||||
|
||||
print("<div style='margin-top:4em;'><b>" .. i18n("flow_callbacks.notes") .. ":</b><ul>")
|
||||
|
||||
print("<li>" .. i18n("flow_callbacks.note_flow_lifecycle") .. "</li>")
|
||||
print("<li>" .. i18n(CALLBACK_EVENTS[tab]["i18n_note"]) .. "</li>")
|
||||
|
||||
print("</ul></div>")
|
||||
end
|
||||
|
||||
return flow_callbacks_utils
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue