Refactor JS code into class NtopngUtils

Implements #3735
This commit is contained in:
Simone Mainardi 2020-08-18 11:43:22 +02:00
parent 8a0525702e
commit e61f9ffe68
56 changed files with 1168 additions and 1210 deletions

View file

@ -1210,7 +1210,7 @@ function deleteAlertById(alert_key) {
params.status = getCurrentStatus();
params.csrf = "]] print(ntop.getRandomCSRFValue()) print[[";
var form = paramsToForm('<form method="post"></form>', params);
var form = NtopngUtils.paramsToForm('<form method="post"></form>', params);
form.appendTo('body').submit();
}
@ -1221,8 +1221,8 @@ function prepareToggleAlertsDialog(table_id, idx) {
var row = table_data[idx];
alert_to_toggle = row;
$(".toggle-alert-id").html(noHtml(row.column_type).trim());
$(".toggle-alert-entity-value").html(noHtml(row.column_entity_formatted).trim())
$(".toggle-alert-id").html(NtopngUtils.noHtml(row.column_type).trim());
$(".toggle-alert-entity-value").html(NtopngUtils.noHtml(row.column_entity_formatted).trim())
}
var alert_to_release = null;
@ -1242,7 +1242,7 @@ function releaseAlert(idx) {
"csrf": "]] print(ntop.getRandomCSRFValue()) print[[",
};
var form = paramsToForm('<form method="post"></form>', params);
var form = NtopngUtils.paramsToForm('<form method="post"></form>', params);
form.appendTo('body').submit();
}
@ -1256,7 +1256,7 @@ function toggleAlert(disable) {
"csrf": "]] print(ntop.getRandomCSRFValue()) print[[",
};
var form = paramsToForm('<form method="post"></form>', params);
var form = NtopngUtils.paramsToForm('<form method="post"></form>', params);
form.appendTo('body').submit();
}
</script>
@ -1527,7 +1527,7 @@ function toggleAlert(disable) {
$("form", this).submit(function() {
// add "status" parameter to the form
var get_params = paramsExtend(]] print(tableToJsObject(alert_utils.getTabParameters(url_params, nil))) print[[, {status:getCurrentStatus()});
var get_params = NtopngUtils.paramsExtend(]] print(tableToJsObject(alert_utils.getTabParameters(url_params, nil))) print[[, {status:getCurrentStatus()});
$(this).attr("action", "?" + $.param(get_params));
return true;
@ -1620,7 +1620,7 @@ $("[clicked=1]").trigger("click");
<script>
paramsToForm('#modalDeleteForm', ]] print(tableToJsObject(delete_params)) print[[);
NtopngUtils.paramsToForm('#modalDeleteForm', ]] print(tableToJsObject(delete_params)) print[[);
function getTabSpecificParams() {
var tab_specific = {status:getCurrentStatus()};
@ -1634,7 +1634,7 @@ function getTabSpecificParams() {
}
// merge the general parameters to the tab specific ones
return paramsExtend(]] print(tableToJsObject(alert_utils.getTabParameters(url_params, nil))) print[[, tab_specific);
return NtopngUtils.paramsExtend(]] print(tableToJsObject(alert_utils.getTabParameters(url_params, nil))) print[[, tab_specific);
}
function checkModalDelete() {
@ -1644,7 +1644,7 @@ function checkModalDelete() {
post_params.id_to_delete = "__all__";
// this actually performs the request
var form = paramsToForm('<form method="post"></form>', post_params);
var form = NtopngUtils.paramsToForm('<form method="post"></form>', post_params);
form.attr("action", "?" + $.param(get_params));
form.appendTo('body').submit();
return false;