From 127c1cef5e530fc856b9ef15a3718acd323b8f5e Mon Sep 17 00:00:00 2001 From: Sami Mokaddem Date: Tue, 21 Nov 2017 15:20:07 +0100 Subject: [PATCH] feature: Added a selector for the maximum number of showed items --- server.py | 7 +++++++ static/js/trendings.js | 9 ++++++++- templates/trendings.html | 13 +++++++++++++ 3 files changed, 28 insertions(+), 1 deletion(-) diff --git a/server.py b/server.py index d88622c..dc2e2ec 100755 --- a/server.py +++ b/server.py @@ -205,7 +205,14 @@ def users(): @app.route("/trendings") def trendings(): + maxNum = request.args.get('maxNum') + try: + maxNum = int(maxNum) + except: + maxNum = 15 + return render_template('trendings.html', + maxNum=maxNum ) ''' INDEX ''' diff --git a/static/js/trendings.js b/static/js/trendings.js index 8040985..90319a6 100644 --- a/static/js/trendings.js +++ b/static/js/trendings.js @@ -268,7 +268,8 @@ function updatePie(pie, line, data, url) { } } toPlot.sort(compareObj).reverse(); - toPlot = toPlot.slice(0,15); // take at max 12 elements + var maxNum = $('#num_selector').val(); + toPlot = toPlot.slice(0,maxNum); // take at max 12 elements } if (!(pieWidget === undefined)) { pieWidget.setData(toPlot); @@ -425,6 +426,12 @@ $(document).ready(function () { updateSignthingsChart(); updateDisc(); + $( "#num_selector" ).change(function() { + var sel = parseInt($( this ).val()); + var maxNum = sel; + window.location.href = url_currentPage+'?maxNum='+maxNum; + }); + $("
").css({ position: "absolute", display: "none", diff --git a/templates/trendings.html b/templates/trendings.html index d4d9c47..2fa90c1 100644 --- a/templates/trendings.html +++ b/templates/trendings.html @@ -116,6 +116,18 @@ small {
  • MISP Users
  • MISP Trendings
  • +
    + Max display: + + +
    Date: @@ -212,6 +224,7 @@ small {