Move alerts configuration under the triangle icon

This commit is contained in:
emanuele-f 2019-07-26 10:58:56 +02:00
parent afe2e5111e
commit 988e3eaab6
8 changed files with 153 additions and 165 deletions

View file

@ -1860,8 +1860,6 @@ elseif (page == "quotas" and ntop.isEnterprise() and host_pool_id ~= host_pools_
host_pools_utils.printQuotas(host_pool_id, host, page_params)
elseif (page == "config") then
local trigger_alerts = true
if(not isAdministrator()) then
return
end
@ -1869,38 +1867,8 @@ elseif (page == "config") then
local top_hiddens = ntop.getMembersCache(getHideFromTopSet(ifId) or {})
local is_top_hidden = swapKeysValues(top_hiddens)[hostkey_compact] ~= nil
local host_key = hostinfo2hostkey(host_info, nil, true --[[show vlan]])
local host_bitmap_key = string.format("ntopng.prefs.alerts.ifid_%d.disabled_status.host_%s", ifId, host_key)
local cur_bitmap = tonumber(ntop.getPref(host_bitmap_key)) or 0
if _SERVER["REQUEST_METHOD"] == "POST" then
if _POST["trigger_alerts"] ~= "1" then
trigger_alerts = false
else
trigger_alerts = true
end
ntop.setHashCache(get_alerts_suppressed_hash_name(getInterfaceId(ifname)), hostkey, tostring(trigger_alerts))
interface.select(ifname)
interface.refreshHostsAlertsConfiguration(host_ip, host_vlan)
local bitmap = 0
if not isEmptyString(_POST["disabled_status"]) then
local status_selection = split(_POST["disabled_status"], ",") or { _POST["disabled_status"] }
for _, status in pairs(status_selection) do
bitmap = ntop.bitmapSet(bitmap, tonumber(status))
end
end
if(bitmap ~= cur_bitmap) then
ntop.setPref(host_bitmap_key, string.format("%u", bitmap))
cur_bitmap = bitmap
interface.reloadHostDisableFlowAlertTypes(host_key)
end
if(ifstats.inline and (host.localhost or host.systemhost)) then
local drop_host_traffic = _POST["drop_host_traffic"]
local host_key = hostinfo2hostkey(host_info)
@ -1930,18 +1898,6 @@ elseif (page == "config") then
end
end
local trigger_alerts_checked
trigger_alerts = ntop.getHashCache(get_alerts_suppressed_hash_name(getInterfaceId(ifname)), hostkey)
if trigger_alerts == "false" then
trigger_alerts = false
trigger_alerts_checked = ""
else
trigger_alerts = true
trigger_alerts_checked = "checked"
end
print[[
<form id="host_config" class="form-inline" method="post">
<input name="csrf" type="hidden" value="]] print(ntop.getRandomCSRFValue()) print[[" />
@ -1970,36 +1926,6 @@ elseif (page == "config") then
]] print(i18n("host_config.hide_host_from_top_descr", {host=host["name"]})) print[[
</input>
</td>
</tr><tr>
<th>]] print(i18n("host_config.trigger_host_alerts")) print[[</th>
<td>
<input type="checkbox" name="trigger_alerts" value="1" ]] print(trigger_alerts_checked) print[[>
<i class="fa fa-exclamation-triangle fa-lg"></i>
]] print(i18n("host_config.trigger_alerts_for_host",{host=host["name"]})) print[[
</input>
</td>
</tr><tr>
<td width="30%">
<b>]] print(i18n("host_details.status_ignore")) print[[</b> <i class="fa fa-info-circle" title="]] print(i18n("host_details.disabled_flow_status_help")) print[["></i>
<br><br>
<i>]] print(i18n("host_details.multiple_selection")) print[[</i>
</td>
<td>
<input id="status_trigger_alert" name="disabled_status" type="hidden" />
<select onchange="convertMultiSelect()" id="status_trigger_alert_select" multiple class="form-control" style="width:40em; height:10em; display:inline;">]]
for status_id, label in pairsByKeys(getFlowStatusTypes()) do
print[[<option value="]] print(string.format("%d", status_id))
if ntop.bitmapIsSet(cur_bitmap, tonumber(status_id)) then
print[[" selected="selected]]
end
print[[">]]
print(label)
print[[</option>]]
end
print[[</select><button type="button" class="btn btn-default" style="margin-left:1em;" onclick="resetMultiSelect()">]] print(i18n("reset")) print[[</button>
</td>
</tr>]]
if(ifstats.inline and (host.localhost or host.systemhost)) then
@ -2045,28 +1971,6 @@ elseif (page == "config") then
<button class="btn btn-primary" style="float:right; margin-right:1em;" disabled="disabled" type="submit">]] print(i18n("save_settings")) print[[</button><br><br>
</form>
<script>
function convertMultiSelect() {
var values = [];
$("#status_trigger_alert_select option:selected").each(function(idx, item) {
values.push($(item).val());
});
$("#status_trigger_alert").val(values.join(","));
$("#status_trigger_alert").trigger("change");
}
function resetMultiSelect() {
$("#status_trigger_alert_select option:selected").each(function(idx, item) {
item.selected = "";
});
convertMultiSelect();
}
/* Run after page load */
$(convertMultiSelect);
aysHandleForm("#host_config");
</script>]]