2016-08-19 11:34:02 +00:00
<!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" / >
< 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
}
2016-08-23 09:20:48 +00:00
2016-08-19 11:34:02 +00:00
.btn-link {
color: #000000
}
2016-08-23 09:20:48 +00:00
.popover-content {
white-space:pre-wrap;
word-wrap:break-word;
}
2016-08-19 11:34:02 +00:00
< / style >
< / head >
< body >
2016-08-22 11:35:49 +00:00
<!-- Modal -->
< div id = "mymodal" class = "modal fade" role = "dialog" >
< div class = "modal-dialog modal-lg" >
<!-- Modal content -->
< div id = "mymodalcontent" class = "modal-content" >
< div id = "mymodalbody" class = "modal-body" max-width = "8500px" >
< p > Loading paste information...< / p >
< img id = "loading-gif-modal" src = "{{url_for('static', filename='image/loading.gif') }}" height = "26" width = "26" style = "margin: 4px;" >
< / div >
< div class = "modal-footer" >
< a id = "button_show_plot" target = "_blank" href = "" > < button type = "button" class = "btn btn-info" > Plot term< / button > < / a >
< button type = "button" class = "btn btn-default" data-dismiss = "modal" > Close< / button >
< / div >
< / div >
< / div >
< / div >
2016-08-19 11:34:02 +00:00
< 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" >
2016-08-20 09:46:22 +00:00
< h1 class = "page-header" data-page = "page-termsfrequency" > Terms frequency: Management interface< / h1 >
2016-08-19 11:34:02 +00:00
< / 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-success" >
< div class = "panel-heading" >
< strong > Manage tracked terms< / strong >
< / div >
< div class = "panel-body" >
< div class = "form-group input-group" style = "margin-bottom: 30px;" >
< span class = "input-group-addon" > < span class = "fa fa-eye" > < / span > < / span >
2016-08-22 11:35:49 +00:00
< input id = "followTermInput" class = "form-control" placeholder = "Term to track" type = "text" style = "max-width: 400px;" >
2016-08-20 14:38:51 +00:00
< button id = "followTermBtn" class = "btn btn-success btn-interaction" style = "margin-left: 10px;" data-section = "followTerm" data-action = "add" > Add term< / button >
2016-08-19 11:34:02 +00:00
< / div >
< table class = "table table-striped table-bordered table-hover" id = "myTable" >
< thead >
< tr >
2016-08-19 14:53:46 +00:00
< th style = "max-width: 800px;" > Term< / th >
< th > Added date< / th >
2016-08-19 11:34:02 +00:00
< th > Day occurence< / th >
< th > Week occurence< / th >
< th > Month occurence< / th >
2016-08-22 11:35:49 +00:00
< th > # Concerned pastes< / th >
2016-08-19 11:34:02 +00:00
< th > Action< / th >
< / tr >
< / thead >
< tbody >
{% set i = 0 %}
{% for term in track_list %}
< tr >
< td > {{ term }}< / td >
2016-08-19 14:53:46 +00:00
< td > {{ track_list_values[i][3] }}< / td >
2016-08-19 12:33:01 +00:00
< td > {{ track_list_values[i][0] }}< / td >
< td > {{ track_list_values[i][1] }}< / td >
< td > {{ track_list_values[i][2] }}< / td >
2016-08-22 11:35:49 +00:00
< td > {{ track_list_num_of_paste[i] }}< / td >
2016-08-19 11:34:02 +00:00
< td > < p style = "margin: 0px;" >
2016-08-22 11:35:49 +00:00
< span data-toggle = "modal" data-target = "#mymodal" data-term = "{{ term }}" > < button class = "btn-link" data-toggle = "tooltip" data-placement = "right" title = "Show concerned paste(s)" > < span class = "glyphicon glyphicon-info-sign" > < / span > < / button > < / span >
< button class = "btn-link btn-interaction" data-toggle = "tooltip" data-placement = "left" title = "Remove this term" data-content = "{{ term }}" data-section = "followTerm" data-action = "delete" > < span class = "glyphicon glyphicon-trash" > < / span > < / button >
2016-08-19 11:34:02 +00:00
< / p > < / td >
< / tr >
{% set i = i + 1 %}
{% endfor %}
< / tbody >
< / table >
<!-- /.panel - body -->
< / div >
< / div >
<!-- /.panel -->
< / div >
<!-- /.panel -->
< / div >
< / div >
<!-- Panel OPTIONS -->
< div class = "col-lg-12" >
< div class = "row" >
< div class = "col-lg-12" >
< div id = "panel-today" class = "panel panel-danger" >
< div class = "panel-heading" >
< strong > Manage blacklisted terms< / strong >
< / div >
< div class = "panel-body" >
< div class = "form-group input-group" style = "margin-bottom: 30px;" >
< span class = "input-group-addon" > < span class = "fa fa-eye-slash " > < / span > < / span >
< input id = "blacklistTermInput" class = "form-control" placeholder = "Term to track" type = "text" style = "max-width: 400px;" >
2016-08-20 14:38:51 +00:00
< button id = "blacklistTermBtn" class = "btn btn-danger btn-interaction" style = "margin-left: 10px;" data-section = "blacklistTerm" data-action = "add" > Black list a term< / button >
2016-08-19 11:34:02 +00:00
< / div >
< table class = "table table-striped table-bordered table-hover" id = "myTable2" >
< thead >
< tr >
2016-08-19 14:53:46 +00:00
< th style = "max-width: 800px;" > Termx< / th >
< th > Added date< / th >
2016-08-19 11:34:02 +00:00
< th > Action< / th >
< / tr >
< / thead >
< tbody >
{% set i = 0 %}
{% for term in black_list %}
< tr >
2016-08-19 14:53:46 +00:00
< td > {{ black_list[i][0] }}< / td >
< td > {{ black_list[i][1] }}< / td >
2016-08-19 11:34:02 +00:00
< td > < p style = "margin: 0px;" >
2016-08-19 14:53:46 +00:00
< button class = "btn-link btn-interaction" data-toggle = "tooltip" data-placement = "right" title = "Remove this term" data-content = "{{ black_list[i][0] }}" data-section = "blacklistTerm" data-action = "delete" > < span class = "glyphicon glyphicon-trash" > < / span > < / button >
2016-08-19 11:34:02 +00:00
< / p > < / td >
< / tr >
{% set i = i + 1 %}
{% endfor %}
< / tbody >
< / table >
<!-- /.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");
$('[data-toggle="tooltip"]').tooltip();
table_track = $('#myTable').DataTable();
table_black = $('#myTable2').DataTable();
2016-08-20 14:38:51 +00:00
$("#followTermInput").keyup(function(event){
if(event.keyCode == 13){
$("#followTermBtn").click();
$("#followTermInput").val("");
}
});
$("#blacklistTermInput").keyup(function(event){
if(event.keyCode == 13){
$("#blacklistTermBtn").click();
$("#blacklistTermInput").val("");
}
});
2016-08-19 11:34:02 +00:00
perform_binding();
2016-08-22 11:35:49 +00:00
// On click, get html content from url and update the corresponding modal
$("[data-toggle='modal']").on("click.openmodal", function (event) {
2016-08-22 11:59:12 +00:00
//console.log(data);
2016-08-22 11:35:49 +00:00
event.preventDefault();
var the_modal=$(this);
var url = "{{ url_for('terms_management_query_paste') }}?term=" + $(this).attr('data-term');
$.getJSON(url, function (data) {
if (data.length != 0) {
2016-08-22 11:59:12 +00:00
var html_to_add = "";
2016-08-26 06:30:09 +00:00
html_to_add += "< table id = \"modal-table\" class = \"table table-striped \ " > ";
2016-08-22 11:59:12 +00:00
html_to_add += "< thead > ";
html_to_add += "< tr > ";
html_to_add += "< th > Source< / th > ";
html_to_add += "< th > Date< / th > ";
html_to_add += "< th > Encoding< / th > ";
html_to_add += "< th > Size (Kb)< / th > ";
2016-08-26 06:30:09 +00:00
html_to_add += "< th > # lines< / th > ";
html_to_add += "< th > Max length< / th > ";
2016-08-22 11:59:12 +00:00
html_to_add += "< th > Preview< / th > ";
html_to_add += "< / tr > ";
html_to_add += "< / thead > ";
html_to_add += "< tbody > ";
2016-08-22 11:35:49 +00:00
for (i=0; i< data.length ; i + + ) {
curr_data = data[i];
html_to_add += "< tr > ";
html_to_add += "< td > "+curr_data.source+"< / td > ";
html_to_add += "< td > "+curr_data.date+"< / td > ";
html_to_add += "< td > "+curr_data.encoding+"< / td > ";
html_to_add += "< td > "+curr_data.size+"< / td > ";
2016-08-26 06:30:09 +00:00
html_to_add += "< td > "+curr_data.lineinfo[0]+"< / td > ";
html_to_add += "< td > "+curr_data.lineinfo[1]+"< / td > ";
2016-08-22 11:35:49 +00:00
html_to_add += "< td > < div class = \"row\" > < button class = \"btn btn-xs btn-default \ " data-toggle = \"popover\" data-placement = \"left\" data-content = \""+curr_data.content+"\" > Preview content< / button > < a target = \"_blank\" href = \"{{ url_for ( ' showsavedpaste ' ) } } ? paste = "+curr_data.path+" & num = 0\" > < button type = \"button\" class = \"btn btn-xs btn-info \ " > Show Paste< / button > < / a > < / div > < / td > ";
html_to_add += "< / tr > ";
}
2016-08-22 11:59:12 +00:00
html_to_add += "< / tbody > ";
html_to_add += "< / table > ";
$("#mymodalbody").html(html_to_add);
$("[data-toggle=popover]").popover();
$("#button_show_plot").attr("href", "{{ url_for('terms_plot_tool')}}"+"?term="+the_modal.attr('data-term') );
2016-08-26 06:30:09 +00:00
$('#modal-table').DataTable();
2016-08-22 11:35:49 +00:00
} else {
$("#mymodalbody").html("No paste containing this term has been received yet.");
$("#button_show_plot").attr("href", "{{ url_for('terms_plot_tool')}}"+"?term="+the_modal.attr('data-term') );
}
});
});
$("#mymodal").on('hidden.bs.modal', function () {
$("#mymodalbody").html("< p > Loading paste information...< / p > ");
var loading_gif = "< img id = 'loading-gif-modal' class = 'img-center' src = \"{{url_for('static', filename = 'image/loading.gif' ) } } \ " height = '26' width = '26' style = 'margin: 4px;' > ";
$("#mymodalbody").append(loading_gif); // Show the loading GIF
});
2016-08-19 11:34:02 +00:00
});
< / script >
< script >
2016-08-20 14:38:51 +00:00
2016-08-19 11:34:02 +00:00
function perform_binding() {
$(".btn-interaction").unbind("click.interaction");
$(".btn-interaction").bind("click.interaction", perform_operation);
}
function perform_operation(){
var curr_section = $(this).attr('data-section');
var curr_action = $(this).attr('data-action');
if (curr_action == "add") {
2016-08-23 07:50:03 +00:00
var curr_term = $('#'+curr_section+'Input').val().toLowerCase();;
2016-08-19 11:34:02 +00:00
} else {
2016-08-23 07:50:03 +00:00
var curr_term = $(this).attr('data-content').toLowerCase();;
2016-08-19 11:34:02 +00:00
}
var data_to_send = { section: curr_section, action:curr_action, term: curr_term};
if (curr_term != "") {
console.log(data_to_send);
$.get("{{ url_for('terms_management_action') }}", data_to_send, function(data, status){
if(status == "success") {
var json = data;
if(json.section == "followTerm") {
if(json.action == "add") {
// query data
2016-08-19 14:53:46 +00:00
$.get("{{ url_for('terms_management_query') }}", { term: json.term, section: json.section }, function(data2, status){
2016-08-22 11:35:49 +00:00
var action_button = "< button class = \"btn-link btn-interaction \ " data-toggle = \"tooltip\" data-placement = \"left\" title = \"Remove this term \ " data-content = \"" + json . term + " \ " data-section = \"followTerm\" data-action = \"delete\" > < span class = \"glyphicon glyphicon-trash \ " > < / span > < / button > "
table_track.row.add( [ json.term, data2[3], data2[0], data2[1], data2[2], 0, action_button ] ).draw( false );
2016-08-19 12:33:01 +00:00
perform_binding();
});
2016-08-19 11:34:02 +00:00
} else if (json.action == "delete") {
// Find indexes of row which have the term in the first column
2016-08-19 14:53:46 +00:00
var index = table_track.rows().eq( 0 ).filter( function (rowIdx) {
return table_track.cell( rowIdx, 0 ).data() === json.term;
2016-08-19 11:34:02 +00:00
} );
2016-08-19 14:53:46 +00:00
table_track.rows(index).remove().draw( false );
2016-08-19 11:34:02 +00:00
}
} else if(json.section == "blacklistTerm"){
if(json.action == "add") {
2016-08-19 14:53:46 +00:00
$.get("{{ url_for('terms_management_query') }}", { term: json.term, section: json.section }, function(data2, status){
console.log(data2);
var action_button = "< button class = \"btn-link btn-interaction \ " data-toggle = \"tooltip\" data-placement = \"right\" title = \"Remove this term \ " data-content = \"" + json . term + " \ " data-section = \"blacklistTerm\" data-action = \"delete\" > < span class = \"glyphicon glyphicon-trash \ " > < / span > < / button > "
table_black.row.add( [ json.term, data2[3], action_button ] ).draw( false );
perform_binding();
});
2016-08-19 11:34:02 +00:00
} else if (json.action == "delete") {
// Find indexes of row which have the term in the first column
2016-08-19 14:53:46 +00:00
var index = table_black.rows().eq( 0 ).filter( function (rowIdx) {
return table_black.cell( rowIdx, 0 ).data() === json.term;
2016-08-19 11:34:02 +00:00
} );
2016-08-19 14:53:46 +00:00
table_black.rows(index).remove().draw( false );
2016-08-19 11:34:02 +00:00
}
}
}
});
}
}
< / script >