Merge pull request #841 from SauroPollastrini/dev

Choice of which alerts has to be notified to Slack based on gravity. Slack related fields on preferences disapperar if Slack notifications are OFF
This commit is contained in:
Luca Deri 2016-12-01 23:43:35 +01:00 committed by GitHub
commit 73d0fc0186
5 changed files with 115 additions and 14 deletions

View file

@ -210,11 +210,31 @@ function printAlerts()
"Off", "0", "danger", -- Off for enabled alerts implies 1 for disable_alerts_generation
"toggle_slack_notification", "ntopng.alerts.notification_enabled", "0")
prefsInputFieldPrefs("Notification Sender Username",
"Set the username of the sender of slack notifications", "ntopng.alerts.", "sender_username", "ntopng Webhook", nil, showElements, false)
local showSlackNotificationPrefs = false
if ntop.getPref("ntopng.alerts.notification_enabled") == "1" then
showSlackNotificationPrefs = true
else
showSlackNotificationPrefs = false
end
prefsInputFieldPrefs("Notification Wekhook",
"Send your notification to this slack URL", "ntopng.alerts.", "slack_webhook", "", nil, showElements, true, true)
if (showSlackNotificationPrefs) then
---[[
local labels = {"Errors","Errors and Warnings","All"}
local values = {"only_errors","errors_and_warnings","all_alerts"}
local retVal = multipleTableButtonPrefs("Notification Preference Based On Severity",
"Errors (errors only), Errors and Warnings (errors and warnings, no info), All (every kind of alerts will be notified).",
labels, values, "only_errors", "primary", "slack_notification_severity_preference", "ntopng.prefs.slack_alert_severity", nil, nil, nil, nil)
--]]
prefsInputFieldPrefs("Notification Sender Username",
"Set the username of the sender of slack notifications", "ntopng.alerts.", "sender_username", "ntopng Webhook", nil, showElements, false)
prefsInputFieldPrefs("Notification Wekhook",
"Send your notification to this slack URL", "ntopng.alerts.", "slack_webhook", "", nil, showElements, true, true)
end
if (ntop.isPro()) then
print('<tr><th colspan=2 class="info">Nagios Integration</th></tr>')