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

@ -418,6 +418,33 @@ page_utils.print_navbar(title, url,
}
)
print(
template.gen("modal_confirm_dialog.html", {
dialog={
id = "reset_stats_dialog",
action = "resetCounters(false)",
title = i18n("reset_if_title"),
message = i18n("reset_if_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_if_title"),
message = i18n("reset_drops_if_message"),
confirm = i18n("reset"),
confirm_button = "btn-warning",
}
})
)
if((page == "overview") or (page == nil)) then
local tags = {ifid = ifstats.id}
print("<div class='table-responsive-xl'>")
@ -2266,8 +2293,7 @@ if ifstats.stats.discarded_probing_packets then
end
print [[
var resetInterfaceCounters = function(drops_only) {
function resetCounters(drops_only) {
var action = "reset_all";
if(drops_only) action = "reset_drops";
$.ajax({ type: 'post',
@ -2283,6 +2309,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');
}
setInterval(function() {
$.ajax({
type: 'GET',