mirror of
https://github.com/bunkerity/bunkerweb
synced 2026-05-24 09:28:37 +00:00
feat: enhance reports filtering and update DataTable column visibility
This commit is contained in:
parent
51e658cd3e
commit
46c61a5667
2 changed files with 23 additions and 4 deletions
|
|
@ -18,4 +18,8 @@ def reports_page():
|
|||
if date < current_date - timedelta(days=7):
|
||||
break
|
||||
reports[i]["date"] = date.isoformat()
|
||||
return render_template("reports.html", reports=list(filter(lambda x: 400 <= x["status"] < 500, reports))) # TODO: check why we need to filter this
|
||||
|
||||
# Filter reports based on status code OR security_mode="detect"
|
||||
return render_template(
|
||||
"reports.html", reports=[report for report in reports if (400 <= report.get("status", 0) < 500) or (report.get("security_mode") == "detect")]
|
||||
)
|
||||
|
|
|
|||
|
|
@ -301,7 +301,7 @@ $(function () {
|
|||
viewTotal: true,
|
||||
cascadePanes: true,
|
||||
collapse: false,
|
||||
columns: [1, 2, 3, 4, 5, 7, 8],
|
||||
columns: [1, 2, 3, 4, 5, 7, 8, 10],
|
||||
},
|
||||
},
|
||||
topStart: {},
|
||||
|
|
@ -436,7 +436,7 @@ $(function () {
|
|||
const reports_table = new DataTable("#reports", {
|
||||
columnDefs: [
|
||||
{ orderable: false, targets: -1 },
|
||||
{ visible: false, targets: [6, 9] },
|
||||
{ visible: false, targets: [3, 4, 5, 6, 9] },
|
||||
{ type: "ip-address", targets: 1 },
|
||||
{
|
||||
targets: 0,
|
||||
|
|
@ -460,7 +460,7 @@ $(function () {
|
|||
},
|
||||
{
|
||||
searchPanes: { show: true },
|
||||
targets: [1, 2, 3, 4, 5, 7, 8],
|
||||
targets: [1, 2, 3, 4, 5, 7, 8, 10],
|
||||
},
|
||||
],
|
||||
order: [[0, "desc"]],
|
||||
|
|
@ -502,4 +502,19 @@ $(function () {
|
|||
|
||||
// Update tooltips after table draw
|
||||
reports_table.on("draw.dt", updateCountryTooltips);
|
||||
|
||||
const hashValue = location.hash;
|
||||
if (hashValue) {
|
||||
$("#dt-length-0").val(hashValue.replace("#", ""));
|
||||
$("#dt-length-0").trigger("change");
|
||||
}
|
||||
|
||||
$("#dt-length-0").on("change", function () {
|
||||
const value = $(this).val();
|
||||
history.replaceState(
|
||||
null,
|
||||
"",
|
||||
value === "10" ? location.pathname : `#${value}`,
|
||||
);
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue