mirror of https://github.com/CIRCL/AIL-framework
Added top set webpage
parent
0b6828fb16
commit
a5117d7cad
|
@ -227,6 +227,8 @@ def Term_getValueOverRange(word, startDate, num_day):
|
|||
curr_to_return = 0
|
||||
for timestamp in range(startDate, startDate - max(num_day)*oneDay, -oneDay):
|
||||
value = r_serv_term.hget(timestamp, word)
|
||||
print timestamp, word
|
||||
print value
|
||||
curr_to_return += int(value) if value is not None else 0
|
||||
for i in num_day:
|
||||
if passed_days == i-1:
|
||||
|
@ -675,6 +677,37 @@ def terms_plot_tool():
|
|||
return render_template("terms_plot_tool.html")
|
||||
|
||||
|
||||
@app.route("/terms_plot_top/")
|
||||
def terms_plot_top():
|
||||
return render_template("terms_plot_top.html")
|
||||
|
||||
|
||||
@app.route("/terms_plot_top_data/")
|
||||
def terms_plot_top_data():
|
||||
today = datetime.datetime.now()
|
||||
today = today.replace(hour=0, minute=0, second=0, microsecond=0)
|
||||
today_timestamp = calendar.timegm(today.timetuple())
|
||||
|
||||
the_set = request.args.get('set')
|
||||
num_day = int(request.args.get('num_day'))
|
||||
if the_set is None:
|
||||
return "None"
|
||||
else:
|
||||
oneDay = 60*60*24
|
||||
to_return = []
|
||||
for term in r_serv_term.smembers(the_set):
|
||||
value_range = []
|
||||
tot_sum = 0
|
||||
for timestamp in range(today_timestamp, today_timestamp - num_day*oneDay, -oneDay):
|
||||
value = r_serv_term.hget(timestamp, term)
|
||||
curr_value_range = int(value) if value is not None else 0
|
||||
tot_sum += curr_value_range
|
||||
value_range.append([timestamp, curr_value_range])
|
||||
|
||||
to_return.append([term, value_range, tot_sum])
|
||||
|
||||
return jsonify(to_return)
|
||||
|
||||
|
||||
@app.route("/test/") #completely shows the paste in a new tab
|
||||
def test():
|
||||
|
@ -700,6 +733,7 @@ def test():
|
|||
# for e in array2:
|
||||
# stri += "<p>"+ e[0] + "\t" + str(e[1]) +"</p>"
|
||||
|
||||
print stri
|
||||
return stri
|
||||
|
||||
|
||||
|
|
|
@ -15,7 +15,8 @@
|
|||
<span class="caret"></span></a>
|
||||
<ul class="dropdown-menu">
|
||||
<li><a href="{{ url_for('terms_management') }}">Terms managements</a></li>
|
||||
<li><a href="{{ url_for('terms_plot_tool') }}">Terms plot Tool</a></li>
|
||||
<li><a href="{{ url_for('terms_plot_top') }}">Terms plot top</a></li>
|
||||
<li><a href="{{ url_for('terms_plot_tool') }}">Terms plot tool</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
|
|
|
@ -56,7 +56,7 @@
|
|||
<div id="page-wrapper">
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
<h1 class="page-header" data-page="page-termsfrequency" >Terms management interface</h1>
|
||||
<h1 class="page-header" data-page="page-termsfrequency" >Terms frequency: Management interface</h1>
|
||||
</div>
|
||||
<!-- /.col-lg-12 -->
|
||||
</div>
|
||||
|
|
|
@ -0,0 +1,424 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
|
||||
<title>Analysis Information Leak framework Dashboard</title>
|
||||
|
||||
<!-- Core CSS -->
|
||||
<link href="{{ url_for('static', filename='css/bootstrap.min.css') }}" rel="stylesheet">
|
||||
<link href="{{ url_for('static', filename='font-awesome/css/font-awesome.css') }}" rel="stylesheet">
|
||||
<link href="{{ url_for('static', filename='css/sb-admin-2.css') }}" rel="stylesheet">
|
||||
<link href="{{ url_for('static', filename='css/dataTables.bootstrap.css') }}" rel="stylesheet" type="text/css" />
|
||||
<link href="{{ url_for('static', filename='css/jquery-ui.min.css') }}" rel="stylesheet" type="text/css" />
|
||||
<script language="javascript" src="{{ url_for('static', filename='js/jquery.js')}}"></script>
|
||||
<script src="{{ url_for('static', filename='js/bootstrap.min.js') }}"></script>
|
||||
<script src="{{ url_for('static', filename='js/jquery.dataTables.min.js') }}"></script>
|
||||
<script src="{{ url_for('static', filename='js/dataTables.bootstrap.js') }}"></script>
|
||||
<script src="{{ url_for('static', filename='js/jquery.flot.js') }}"></script>
|
||||
<script src="{{ url_for('static', filename='js/jquery.flot.time.js') }}"></script>
|
||||
<script src="{{ url_for('static', filename='js/jquery.flot.stack.js') }}"></script>
|
||||
|
||||
<style>
|
||||
.sparkLineStats ul {
|
||||
padding-left:0;
|
||||
list-style:none
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div id="wrapper">
|
||||
<nav class="navbar navbar-default navbar-static-top" role="navigation" style="margin-bottom: 0">
|
||||
{% include 'header.html' %}
|
||||
<!-- /.navbar-top-links -->
|
||||
<div class="navbar-default sidebar" role="navigation">
|
||||
<div class="sidebar-collapse">
|
||||
<ul class="nav" id="side-menu">
|
||||
<li class="sidebar-search">
|
||||
{% include 'searchbox.html' %}
|
||||
</li>
|
||||
</ul>
|
||||
<!-- /#side-menu -->
|
||||
</div>
|
||||
<!-- /.sidebar-collapse -->
|
||||
<a href="{{ url_for('index') }}"><img src="{{ url_for('static', filename='image/AIL.png') }}" /></a>
|
||||
</div>
|
||||
<!-- /.navbar-static-side -->
|
||||
</nav>
|
||||
</div>
|
||||
|
||||
<div id="page-wrapper">
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
<h1 class="page-header" data-page="page-termsfrequency" >Terms frequency: Top set information</h1>
|
||||
</div>
|
||||
<!-- /.col-lg-12 -->
|
||||
</div>
|
||||
<!-- /.row -->
|
||||
<div class="row">
|
||||
|
||||
<!-- Panel OPTIONS -->
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
<div id="panel-today" class="panel panel-info">
|
||||
<div class="panel-heading">
|
||||
<strong>Today</strong>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<div id="panel-today" class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
<strong>Today top word</strong>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<div class="col-lg-6">
|
||||
<table class="table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Term</th>
|
||||
<th>Value</th>
|
||||
<th>Action</th>
|
||||
<th>Displayed</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="table-today">
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class="col-lg-6">
|
||||
<table class="table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Term</th>
|
||||
<th>Value</th>
|
||||
<th>Action</th>
|
||||
<th>Displayed</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="table-today2">
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<!-- /.panel-body -->
|
||||
</div>
|
||||
<div id="panel-today" class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
<strong>Graph</strong>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<div id="graph-today" style="height: 400px;"></div>
|
||||
</div>
|
||||
<!-- /.panel-body -->
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<!-- /.panel-body -->
|
||||
</div>
|
||||
</div>
|
||||
<!-- /.panel -->
|
||||
</div>
|
||||
<!-- /.panel -->
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Panel OPTIONS -->
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
<div id="panel-today" class="panel panel-info">
|
||||
<div class="panel-heading">
|
||||
<strong>Week</strong>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<div id="panel-week" class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
<strong>Week top word</strong>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<div class="col-lg-6">
|
||||
<table class="table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Term</th>
|
||||
<th>Value</th>
|
||||
<th>Action</th>
|
||||
<th>Displayed</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="table-week">
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class="col-lg-6">
|
||||
<table class="table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Term</th>
|
||||
<th>Value</th>
|
||||
<th>Action</th>
|
||||
<th>Displayed</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="table-week2">
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<!-- /.panel-body -->
|
||||
</div>
|
||||
<div id="panel-week" class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
<strong>Graph</strong>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<div id="graph-week" style="height: 400px;"></div>
|
||||
</div>
|
||||
<!-- /.panel-body -->
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<!-- /.panel-body -->
|
||||
</div>
|
||||
</div>
|
||||
<!-- /.panel -->
|
||||
</div>
|
||||
<!-- /.panel -->
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Panel OPTIONS -->
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
<div id="panel-today" class="panel panel-info">
|
||||
<div class="panel-heading">
|
||||
<strong>Month</strong>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<div id="panel-month" class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
<strong>Month top word</strong>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<div class="col-lg-6">
|
||||
<table class="table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Term</th>
|
||||
<th>Value</th>
|
||||
<th>Action</th>
|
||||
<th>Displayed</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="table-month">
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class="col-lg-6">
|
||||
<table class="table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Term</th>
|
||||
<th>Value</th>
|
||||
<th>Action</th>
|
||||
<th>Displayed</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="table-month2">
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<!-- /.panel-body -->
|
||||
</div>
|
||||
<div id="panel-month" class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
<strong>Graph</strong>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<div id="graph-month" style="height: 400px;"></div>
|
||||
</div>
|
||||
<!-- /.panel-body -->
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<!-- /.panel-body -->
|
||||
</div>
|
||||
</div>
|
||||
<!-- /.panel -->
|
||||
</div>
|
||||
<!-- /.panel -->
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<!-- /.row -->
|
||||
</div>
|
||||
<!-- /#page-wrapper -->
|
||||
</div>
|
||||
|
||||
|
||||
<!-- import graph function -->
|
||||
<script>
|
||||
$(document).ready(function(){
|
||||
activePage = $('h1.page-header').attr('data-page');
|
||||
$("#"+activePage).addClass("active");
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
<script>
|
||||
var graph_options = {
|
||||
series: {
|
||||
lines: {
|
||||
show: true,
|
||||
lineWidth: 2
|
||||
},
|
||||
bars: {show: false, barWidth: 60*60*1000},
|
||||
shadowSize: 0
|
||||
},
|
||||
grid: {
|
||||
hoverable: true,
|
||||
clickable: true,
|
||||
tickColor: "#f9f9f9",
|
||||
borderWidth: 0
|
||||
},
|
||||
xaxis: {
|
||||
mode: "time",
|
||||
timeformat: "%m/%d",
|
||||
minTickSize: [1, "day"]
|
||||
},
|
||||
yaxis: {
|
||||
autoscaleMargin: 0.1,
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
set_today = "TopTermFreq_set_day";
|
||||
set_week = "TopTermFreq_set_week";
|
||||
set_month = "TopTermFreq_set_month";
|
||||
|
||||
var promises = []; // Used to know when everything has been received
|
||||
|
||||
promises.push($.getJSON("{{ url_for('terms_plot_top_data') }}", { set: set_today, num_day: 1 }, function(data, status){
|
||||
//console.log(data);
|
||||
data.sort(function(a, b){return b[2]-a[2];});
|
||||
// Sort data
|
||||
var table_today = $("#table-today")
|
||||
var table_today2 = $("#table-today2")
|
||||
var to_plot = [];
|
||||
for(i=0; i<data.length; i++) {
|
||||
var curr_data = [];
|
||||
for(j=0; j<data[i][1].length; j++) {
|
||||
curr_data.push([data[i][1][j][0]*1000, data[i][1][j][1]]);
|
||||
}
|
||||
to_plot.push({ data: curr_data, label: data[i][0]});
|
||||
if ( i < (data.length/2))
|
||||
table_today.append("<tr><td>"+data[i][0]+"</td><td>"+data[i][2]+"</td><td>"+addbuttons(data[i][0])+"</td><td>"+addcheckbox("graph-today", data[i][0])+"</td></tr>")
|
||||
else
|
||||
table_today2.append("<tr><td>"+data[i][0]+"</td><td>"+data[i][2]+"</td><td>"+addbuttons(data[i][0])+"</td><td>"+addcheckbox("graph-today", data[i][0])+"</td></tr>")
|
||||
}
|
||||
var plot_today = $.plot($("#graph-today"), to_plot, graph_options);
|
||||
}));
|
||||
|
||||
promises.push($.getJSON("{{ url_for('terms_plot_top_data') }}", { set: set_week, num_day: 7 }, function(data, status){
|
||||
console.log(data);
|
||||
data.sort(function(a, b){return b[2]-a[2];});
|
||||
// Sort data
|
||||
var table = $("#table-week")
|
||||
var table2 = $("#table-week2")
|
||||
var to_plot = [];
|
||||
for(i=0; i<data.length; i++) {
|
||||
var curr_data = [];
|
||||
for(j=0; j<data[i][1].length; j++) {
|
||||
curr_data.push([data[i][1][j][0]*1000, data[i][1][j][1]]);
|
||||
}
|
||||
to_plot.push({ data: curr_data, label: data[i][0]});
|
||||
if ( i < (data.length/2))
|
||||
table.append("<tr><td>"+data[i][0]+"</td><td>"+data[i][2]+"</td><td>"+addbuttons(data[i][0])+"</td><td>"+addcheckbox("graph-week", data[i][0])+"</td></tr>")
|
||||
else
|
||||
table2.append("<tr><td>"+data[i][0]+"</td><td>"+data[i][2]+"</td><td>"+addbuttons(data[i][0])+"</td><td>"+addcheckbox("graph-week", data[i][0])+"</td></tr>")
|
||||
}
|
||||
var plot_week = $.plot($("#graph-week"), to_plot, graph_options);
|
||||
}));
|
||||
|
||||
promises.push($.getJSON("{{ url_for('terms_plot_top_data') }}", { set: set_month, num_day: 31 }, function(data, status){
|
||||
console.log(data);
|
||||
data.sort(function(a, b){return b[2]-a[2];});
|
||||
// Sort data
|
||||
var table = $("#table-month")
|
||||
var table2 = $("#table-month2")
|
||||
var to_plot = [];
|
||||
for(i=0; i<data.length; i++) {
|
||||
var curr_data = [];
|
||||
for(j=0; j<data[i][1].length; j++) {
|
||||
curr_data.push([data[i][1][j][0]*1000, data[i][1][j][1]]);
|
||||
}
|
||||
to_plot.push({ data: curr_data, label: data[i][0]});
|
||||
if ( i < (data.length/2))
|
||||
table.append("<tr><td>"+data[i][0]+"</td><td>"+data[i][2]+"</td><td>"+addbuttons(data[i][0])+"</td><td>"+addcheckbox("graph-month", data[i][0])+"</td></tr>")
|
||||
else
|
||||
table2.append("<tr><td>"+data[i][0]+"</td><td>"+data[i][2]+"</td><td>"+addbuttons(data[i][0])+"</td><td>"+addcheckbox("graph-month", data[i][0])+"</td></tr>")
|
||||
}
|
||||
var plot_month = $.plot($("#graph-month"), to_plot, graph_options);
|
||||
}));
|
||||
|
||||
/* When everything has been received, start adding tooltip */
|
||||
$.when.apply($, promises).done( function (arg) {
|
||||
$('[data-toggle="tooltip"]').tooltip();
|
||||
|
||||
$(".btn-interaction").unbind("click.interaction");
|
||||
$(".btn-interaction").bind("click.interaction", perform_operation);
|
||||
$(".check-interaction").unbind("click.interaction");
|
||||
$(".check-interaction").bind("click.interaction", hide_or_show);
|
||||
});
|
||||
|
||||
|
||||
function addbuttons(term) {
|
||||
return "<button class=\"fa fa-eye btn-interaction\" data-toggle=\"tooltip\" data-placement=\"right\" title=\"Add to tracked list\" style=\"margin-right: 5px;\""+
|
||||
"data-section=\"followTerm\" data-term=\""+term+"\"></button>"+
|
||||
"<button class=\"fa fa-eye-slash btn-interaction\" data-toggle=\"tooltip\" data-placement=\"right\" title=\"Add to black-list\""+
|
||||
"data-section=\"blacklistTerm\" data-term=\""+term+"\"></button>";
|
||||
}
|
||||
|
||||
function addcheckbox(graph, term) {
|
||||
return "<input type=checkbox checked class=\"check-interaction\" data-term=\""+term+"\" data-graph=\""+graph+"\"></input>";
|
||||
}
|
||||
|
||||
function perform_operation(){
|
||||
alert("are u sure?");
|
||||
var curr_section = $(this).attr('data-section');
|
||||
var curr_term = $(this).attr('data-term');
|
||||
|
||||
var data_to_send = { section: curr_section, action:"add", term: curr_term};
|
||||
|
||||
console.log(data_to_send);
|
||||
$.get("{{ url_for('terms_management_action') }}", data_to_send, function(data, status){
|
||||
if(status == "success") {
|
||||
location.reload();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function hide_or_show() {
|
||||
var curr_term = $(this).attr('data-term');
|
||||
var graph = $(this).attr('data-graph');
|
||||
var checked = $(this).prop('checked')
|
||||
console.log(curr_term + ' ' + graph + ' ' + checked);
|
||||
|
||||
// graph, hide curve
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in New Issue