mirror of
https://github.com/ntop/ntopng.git
synced 2026-05-03 17:30:11 +00:00
* add label for each hooks into scripts table * fix for issue #3212, refactored scripts-list-utils code * add render function itemslist * add items_list template to script_list-utils.js * label for new template
66 lines
No EOL
2.1 KiB
JavaScript
66 lines
No EOL
2.1 KiB
JavaScript
$.fn.dataTable.ext.buttons.filterScripts = {
|
|
className: "filter-scripts-button",
|
|
init: function (dt, node, config) {
|
|
// get button script type
|
|
const button_id = config.attr.id;
|
|
// remove styles pre-rendered
|
|
$(node).removeClass("btn").removeClass("btn-secondary");
|
|
// change text by scripts count
|
|
const button_text = $(node).html();
|
|
|
|
let count = 0;
|
|
|
|
// count scripts inside table
|
|
if (button_id == "all-scripts") {
|
|
// count all scripts
|
|
count = dt.data().length;
|
|
}
|
|
else if (button_id == "enabled-scripts") {
|
|
dt.data().each(d => {
|
|
|
|
// count all enabled scripts
|
|
const parsed = d.is_enabled;
|
|
if (parsed) count += 1;
|
|
|
|
});
|
|
}
|
|
else if (button_id == "disabled-scripts") {
|
|
dt.data().each(d => {
|
|
|
|
// count all disabled scripts
|
|
const parsed = d.is_enabled;
|
|
if (!parsed) count += 1;
|
|
|
|
});
|
|
}
|
|
|
|
$(node).html(`${button_text} (${count})`);
|
|
},
|
|
action: function (e, dt, node, config) {
|
|
|
|
// get button script type
|
|
const button_id = config.attr.id;
|
|
|
|
$("#all-scripts, #enabled-scripts, #disabled-scripts").removeClass('active');
|
|
|
|
if (button_id == "all-scripts") {
|
|
dt.columns().search("").draw();
|
|
window.history.replaceState(undefined, undefined, "#all");
|
|
}
|
|
else if (button_id == "enabled-scripts") {
|
|
// draw all enabled scripts
|
|
dt.columns(2).search("true").draw();
|
|
window.history.replaceState(undefined, undefined, "#enabled");
|
|
}
|
|
else if (button_id == "disabled-scripts") {
|
|
// draw all disabled scripts
|
|
dt.columns(2).search("false").draw();
|
|
window.history.replaceState(undefined, undefined, "#disabled");
|
|
}
|
|
|
|
// delagate tooltips
|
|
$(`span[data-toggle='popover']`).popover({trigger: 'hover'});
|
|
|
|
$(`#${button_id}`).addClass("active");
|
|
}
|
|
}; |