misp-dashboard/templates/geo.html

324 lines
13 KiB
HTML
Raw Normal View History

2017-10-25 16:22:14 +02:00
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="author" content="">
<title>Misp live dashboard</title>
<!-- Bootstrap Core CSS -->
<link href="{{ url_for('static', filename='css/bootstrap.min.css') }}" rel="stylesheet">
<!-- Custom CSS -->
<link href="{{ url_for('static', filename='css/sb-admin-2.css') }}" rel="stylesheet">
<!-- Custom Fonts -->
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.2.0/dist/leaflet.css"
integrity="sha512-M2wvCLH6DSRazYeZRIm1JnYyh22purTM+FDB5CsyxtQJYeKq83arPe5wgbNmcFXGqiSH2XR8dT/fJISVA1r/zQ=="
crossorigin=""/>
<script src="https://unpkg.com/leaflet@1.2.0/dist/leaflet.js"
integrity="sha512-lInM/apFSqyy1o6s89K4iQUKg6ppXEgsVxT35HbzUupEVRh2Eu9Wdl4tHj7dZO0s1uvplcYGmt3498TtHq+log=="
crossorigin=""></script>
</head>
<style>
.panel-body {
padding: 0px;
}
.col-lg-6 {
padding-right: 5px;
padding-left: 5px;
}
.leftSepa {
border-left-color: rgb(221, 221, 221);
border-left-style: solid;
border-left-width: 2px;
padding-left: 8px;
}
.textTopHeader {
height: 50px;
text-align: center;
margin-left: 8px;
float: left;
padding-top: 9px;
2017-10-25 16:22:14 +02:00
}
.center {
display:block;
margin-left:auto;
margin-right:auto;
}
small {
font-size: 100%;
font-weight: bold;
}
</style>
<body>
<div id="wrapper">
<!-- Navigation -->
<nav class="navbar navbar-default navbar-static-top" role="navigation" style="margin-bottom: 0; padding-left: 15px;">
<div class="navbar-header">
<a class="navbar-brand" href="{{ url_for('geo') }}">Misp Geolocalization</a>
<div id="ledsHolder" style="float: right; height: 50px;">
2017-10-26 09:22:03 +02:00
<div class='leftSepa textTopHeader'>
<strong>Zoom level:</strong>
<select id="zoom_selector">
<option value="18">18</option>
<option value="17">17</option>
<option value="15" selected>15</option>
<option value="13">13</option>
<option value="11">11</option>
<option value="9">9</option>
<option value="7">7</option>
</select>
</div>
<div class='leftSepa textTopHeader'>
<strong>Date: <input type="text" id="datepicker" size="30" style="margin-bottom: 5px;"></strong>
</div>
</div>
2017-10-25 16:22:14 +02:00
</div>
<!-- /.navbar-header -->
</nav>
<!-- Page Content -->
<div id="page-wrapper" style="margin: 0px; padding: 0px;">
<div class="container-fluid">
<div class="row">
<div class="col-lg-12">
<div style="height: 10px;"></div>
<div class="col-lg-6">
<div class="col-lg-6">
<div class="panel panel-default" style="">
<div class="panel-heading bg-info" style="font-weight: bold;">
2017-10-25 17:32:06 +02:00
<b id="topMap1Header">1. Top location</b>
2017-10-25 16:22:14 +02:00
</div>
<div id="panelbody" class="panel-body" style="">
<div id="topMap1" style="width:100%; height: calc(75vh / 3);"></div>
</div>
</div><!-- /.panel-body -->
<div class="panel panel-default" style="">
<div class="panel-heading bg-info" style="font-weight: bold;">
2017-10-25 17:32:06 +02:00
<b id="topMap3Header">3. Top location</b>
2017-10-25 16:22:14 +02:00
</div>
<div id="panelbody" class="panel-body" style="">
<div id="topMap3" style="width:100%; height: calc(75vh / 3);"></div>
</div>
</div><!-- /.panel-body -->
<div class="panel panel-default" style="">
<div class="panel-heading bg-info" style="font-weight: bold;">
2017-10-25 17:32:06 +02:00
<b id="topMap5Header">5. Top location</b>
2017-10-25 16:22:14 +02:00
</div>
<div id="panelbody" class="panel-body" style="">
<div id="topMap5" style="width:100%; height: calc(75vh / 3);"></div>
</div>
</div><!-- /.panel-body -->
</div><!-- /.col-lg-6-6 -->
<div class="col-lg-6">
<div class="panel panel-default" style="">
<div class="panel-heading bg-info" style="font-weight: bold;">
2017-10-25 17:32:06 +02:00
<b id="topMap2Header">2. Top location</b>
2017-10-25 16:22:14 +02:00
</div>
<div id="panelbody" class="panel-body" style="">
<div id="topMap2" style="width:100%; height: calc(75vh / 3);"></div>
</div>
</div><!-- /.panel-body -->
<div class="panel panel-default" style="">
<div class="panel-heading bg-info" style="font-weight: bold;">
2017-10-25 17:32:06 +02:00
<b id="topMap4Header">4. Top location</b>
2017-10-25 16:22:14 +02:00
</div>
<div id="panelbody" class="panel-body" style="">
<div id="topMap4" style="width:100%; height: calc(75vh / 3);"></div>
</div>
</div><!-- /.panel-body -->
<div class="panel panel-default" style="">
<div class="panel-heading bg-info" style="font-weight: bold;">
2017-10-25 17:32:06 +02:00
<b id="topMap6Header">6. Top location</b>
2017-10-25 16:22:14 +02:00
</div>
<div id="panelbody" class="panel-body" style="">
<div id="topMap6" style="width:100%; height: calc(75vh / 3);"></div>
</div>
</div><!-- /.panel-body -->
</div><!-- /.col-lg-6-6 -->
</div><!-- /.col-lg-6 -->
<div class="col-lg-6">
<div class="panel panel-default" style="height: 100%;">
<div class="panel-heading bg-info" style="font-weight: bold;">
<b id="worldMapHeader">Hit map </b>
</div>
<div id="panelbody" class="panel-body" style="height: 100%;">
<div id="worldMap" style="width:100%; height: 88vh; position: relative;"></div>
</div>
<!-- /.panel-body -->
</div><!-- /.panel -->
</div><!-- /.col-lg-6 -->
</div><!-- /.col-lg-12 -->
</div><!-- /.row -->
</div> <!-- /.container-fluid -->
</div>
<!-- /#page-wrapper -->
</div>
<!-- /#wrapper -->
<!-- jQuery -->
<script src="{{ url_for('static', filename='js/jquery.min.js') }}"></script>
<!-- jQuery flot -->
<script src="{{ url_for('static', filename='js/jquery.flot.js') }}"></script>
<script src="{{ url_for('static', filename='js/jquery.flot.pie.min.js') }}"></script>
<script src="{{ url_for('static', filename='js/jquery.flot.resize.js') }}"></script>
<!-- Bootstrap Core JavaScript -->
<script src="{{ url_for('static', filename='js/bootstrap.min.js') }}"></script>
<link href="{{ url_for('static', filename='css/font-awesome.min.css') }}" rel="text/css">
<link rel="stylesheet" href="{{ url_for('static', filename='css/jquery-jvectormap-2.0.3.css') }}" type="text/css" media="screen"/>
<script src="{{ url_for('static', filename='js/jquery-jvectormap-2.0.3.min.js') }}"></script>
<script src="{{ url_for('static', filename='js/jquery-jvectormap-world-mill.js') }}"></script>
<link href="{{ url_for('static', filename='css/jquery-ui.min.css') }}" rel="stylesheet" type="text/css" />
<script src="{{ url_for('static', filename='js/jquery-ui.min.js') }}"></script>
2017-10-25 16:22:14 +02:00
<!-- Index -->
<script>
2017-10-25 17:45:00 +02:00
var regionhitsMax = 10;
var regionhits = {};
2017-10-25 16:22:14 +02:00
const OSMURL='http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png';
const OSMATTRIB='Map data © <a href="http://openstreetmap.org">OpenStreetMap</a> contributors';
2017-10-26 09:22:03 +02:00
var ZOOMLEVEL = 15;
2017-10-25 16:22:14 +02:00
var allOpenStreetMap = {};
var datePickerWidget;
2017-10-25 16:22:14 +02:00
for(var i=1; i<7; i++) {
allOpenStreetMap[i] = L.map('topMap'+i).setView([0, 0], 0);
new L.TileLayer(OSMURL, {minZoom: 0, maxZoom: 18}).addTo(allOpenStreetMap[i]);
}
var vectorMapConfig = {
map: 'world_mill',
markers: [],
series: {
markers: [{
attribute: 'fill',
scale: ['#1A0DAB', '#e50000', '#62ff41'],
values: [],
min: 0,
max: 180
}],
regions: [{
values: [],
min: 0,
max: 10,
scale: ['#CD5C5C','#E34234','#D73B3E','#CE1620','#CC0000','#B22222','#B31B1B','#A40000','#800000','#701C1C','#3C1414','#321414'],
normalizeFunction: 'polynomial'
}]
},
2017-10-25 17:45:00 +02:00
onRegionTipShow: function(e, el, code){
el.html(el.html()+' ('+regionhits[code]+')');
}
2017-10-25 16:22:14 +02:00
}
2017-10-25 17:32:06 +02:00
function updateTopMaps(dayNum) {
$.getJSON("{{ url_for('getTopCoord') }}?dayNum="+dayNum, function(list){
for(var i=0; i<6 && i<list.length; i++) {
coordJson = JSON.parse(list[i][0]);
allOpenStreetMap[i+1].flyTo([coordJson.lat, coordJson.lon], ZOOMLEVEL);
var marker = L.marker([coordJson.lat, coordJson.lon]).addTo(allOpenStreetMap[i+1]);
marker.bindPopup('lat: '+coordJson.lat+', lon: '+coordJson.lon+' - '+list[i][1]).openPopup();
}
});
}
2017-10-25 17:45:00 +02:00
function updateWorldMap(dayNum) {
2017-10-25 17:32:06 +02:00
$.getJSON("{{ url_for('getHitMap') }}?dayNum="+dayNum, function(list){
for(var i=0; i<list.length; i++) {
var rCode = list[i][0];
var rNum = list[i][1];
2017-10-25 17:45:00 +02:00
update_region(rCode, rNum);
2017-10-25 17:32:06 +02:00
}
});
}
2017-10-25 17:45:00 +02:00
function update_region(regionCode, num) {
regionhits[regionCode] = num;
// Force recomputation of min and max for correct color scaling
regionhitsMax = regionhitsMax >= regionhits[regionCode] ? regionhitsMax : regionhits[regionCode];
worldMapObj.series.regions[0].params.max = regionhitsMax;
// Update data
worldMapObj.series.regions[0].setValues(regionhits);
}
function days_between(date1, date2) {
var ONEDAY = 60*60*24*1000;
var diff_ms = Math.abs(date1.getTime() - date2.getTime());
return Math.round(diff_ms/ONEDAY);
}
function updateAll() {
var currentDate = datePickerWidget.datepicker( "getDate" );
var now = new Date();
var numDay = days_between(now, currentDate);
updateTopMaps(numDay);
updateWorldMap(numDay);
}
2017-10-25 17:32:06 +02:00
$(document).ready(function () {
$('#worldMap').vectorMap(vectorMapConfig);
worldMapObj = $("#worldMap").vectorMap('get','mapObject');
/* Create the datepicker and button*/
var datePickerOptions = {
showOn: "button",
minDate: -31,
maxDate: 0,
buttonImage: "{{ url_for('static', filename='pics/calendar.gif') }}",
buttonImageOnly: true,
buttonText: "Select date",
showAnim: "slideDown",
onSelect: updateAll
};
datePickerWidget = $( "#datepicker" )
datePickerWidget.datepicker(datePickerOptions);
2017-10-26 09:22:03 +02:00
datePickerWidget.datepicker("setDate", new Date());
$( "#zoom_selector" ).change(function() {
var sel = parseInt($( this ).val());
ZOOMLEVEL = sel;
updateAll();
});
updateAll();
2017-10-25 17:32:06 +02:00
});
2017-10-25 16:22:14 +02:00
</script>
</body>
</html>