Added modal to reset stats button

Implements #4618
This commit is contained in:
Matteo Biscosi 2021-03-04 12:38:22 +01:00
parent dd9ed3958e
commit 6ba47ad0c0
4 changed files with 81 additions and 4 deletions

View file

@ -10,6 +10,8 @@ if((dirs.scriptdir ~= nil) and (dirs.scriptdir ~= "")) then package.path = dirs.
require "lua_utils"
local page_utils = require("page_utils")
local internals_utils = require "internals_utils"
local template = require "template_utils"
if not isAllowedSystemInterface() then
return
@ -28,6 +30,33 @@ local url = ntop.getHttpPrefix() .. "/lua/system_interfaces_stats.lua?ifid="..in
local info = ntop.getInfo()
local title = i18n("system_interfaces_status")
print(
template.gen("modal_confirm_dialog.html", {
dialog={
id = "reset_stats_dialog",
action = "resetCounters(false)",
title = i18n("reset_ifs_title"),
message = i18n("reset_ifs_message"),
confirm = i18n("reset"),
confirm_button = "btn-warning",
}
})
)
print(
template.gen("modal_confirm_dialog.html", {
dialog={
id = "reset_drops_dialog",
action = "resetCounters(true)",
title = i18n("reset_drops_ifs_title"),
message = i18n("reset_drops_ifs_message"),
confirm = i18n("reset"),
confirm_button = "btn-warning",
}
})
)
page_utils.print_navbar(title, url,
{
{
@ -170,7 +199,7 @@ $("#table-system-interfaces-stats").datatable({
},
});
var resetInterfaceCounters = function(drops_only) {
function resetCounters(drops_only) {
var action = "reset_all";
if(drops_only) action = "reset_drops";
$.ajax({ type: 'post',
@ -190,6 +219,13 @@ print [[/lua/reset_stats.lua',
});
}
var resetInterfaceCounters = function(drops_only) {
if(drops_only)
$('#reset_drops_dialog').modal('show');
else
$('#reset_stats_dialog').modal('show');
}
</script>
]]