-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathevents.html
203 lines (181 loc) · 8.83 KB
/
events.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
<!DOCTYPE html>
<html>
<head>
<title>Proddle - Events</title>
<link rel="stylesheet" type="text/css" href="css/events.css" />
<link rel="stylesheet" type="text/css" href="css/map.css" />
<link rel="stylesheet" type="text/css" href="css/proddle.css" />
<link rel="stylesheet" type="text/css" href="css/report-table.css" />
<script src="js/proddle.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
</head>
<body>
<?php
include 'php/header.php';
?>
<div id="center">
<div id="usage">
<h3>Usage</h3>
<p>
This page is used to view events for particular domain(s).
The text area should be populated by the domain name
(ex. google.com), if left blank events for all domains
will be displayed. The select menu presents the lowest
timeframe where the event was active. For example, a
duration of '1 Day' means all the events have been active
in the last day.
</p>
<p>
Clicking on an event row in the the table will populate
both the map and the measurements table with information
relevant to the event. Additionally clicking on a
measurement row in the measurements table will display
specific information about that measurement.
</p>
</div>
<div id="searchbar">
Domain: <input type="text" id="domain" value="" />
<select id="duration">
<option value="1">1 Day</option>
<option value="7">1 Week</option>
<option value="31">1 Month</option>
</select>
<input type="button" value="GO" onclick="updateEvents();" />
</div>
</br>
<div class="wrapper">
<caption><b>Proddle Identified Events</b></caption>
<div id="eventsScroll" class="scroll">
<table id="eventsTable" class="report">
<thead>
<th>Domain</th>
<th>Start Time</th>
<th>End Time</th>
<th>Flag Count</th>
</thead>
<tbody id="eventsBody"></tbody>
</table>
</div>
</div>
</br>
<div id="map"></div>
</br>
<div class="wrapper">
<caption><b>Measurements Collected By Proddle</b></caption>
<div id="measurementsScroll" class="scroll">
<table id="measurementsTable" class="report">
<thead>
<th>Timestamp</th>
<th>Vantage</th>
<th>Measurement</th>
<th>Domain</th>
<th>Status</th>
</thead>
<tbody id="measurementsBody">
</tbody>
</table>
</div>
</div>
</br>
<p>
This product includes GeoLite2 data created by MaxMind, available from
<a href="http://www.maxmind.com">http://www.maxmind.com</a>.
</p>
</div>
<script>
var map;
var infoWindow;
var markers = [];
var markerInfo = new Map();
function initMap() {
infoWindow = new google.maps.InfoWindow;
map = new google.maps.Map(document.getElementById('map'), {
center: {lat:0, lng: 0},
zoom: 2
});
updateEvents();
}
function resetPage() {
document.getElementById('eventsBody').innerHTML = '';
resetEvent();
}
function updateEvents() {
resetPage();
var domain = document.getElementById('domain').value;
var duration = document.getElementById('duration');
var eventsBody = document.getElementById('eventsBody');
var mapTable = document.createElement('table');
//query events_report.html
$.get({
url: 'events_report.html?duration=' + duration.options[duration.selectedIndex].value + (domain != '' ? '&domain=' + domain : ''),
dataType: 'json',
success: function(data) {
for (var i=0; i<data.result.length; i++) {
var e = data.result[i];
var tr = eventsBody.insertRow();
tr.onclick = createEventClickHandler(e);
tr.insertCell().appendChild(document.createTextNode(e.domain));
var minimum_timestamp = new Date(e.minimum_timestamp * 1000);
tr.insertCell().appendChild(document.createTextNode(formatDate(minimum_timestamp)));
var maximum_timestamp = new Date(e.maximum_timestamp * 1000);
tr.insertCell().appendChild(document.createTextNode(formatDate(maximum_timestamp)));
tr.insertCell().appendChild(document.createTextNode(e.flag_ids.length));
}
}
});
}
function createEventClickHandler(e) {
return function() {
updateEvent(e.domain, e.minimum_timestamp, e.maximum_timestamp);
};
}
function resetEvent() {
document.getElementById('measurementsBody').innerHTML = '';
for (var i=0; i < markers.length; i++) {
markers[i].setMap(null);
}
markers.length = 0;
markerInfo.clear();
}
function updateEvent(domain, start_time, end_time) {
resetEvent();
var measurementsBody = document.getElementById('measurementsBody');
//query flags_report.html
$.get({
url: 'flags_report.html?domain=' + domain + '&start_time=' + (start_time - 3600) + '&end_time=' + (end_time + 3600),
dataType: 'json',
success: function(data) {
for (var i=0; i < data.length; i++) {
var result = data[i];
var tr = measurementsBody.insertRow();
tr.onclick = createMeasurementClickHandler(result);
var timestamp = new Date(result.timestamp * 1000);
tr.insertCell().appendChild(document.createTextNode(formatDate(timestamp)));
tr.insertCell().appendChild(document.createTextNode(result.hostname + ' (' + result.ip_address + ')'));
tr.insertCell().appendChild(document.createTextNode(result.measurement));
tr.insertCell().appendChild(document.createTextNode(result.domain));
if (result.result != null && result.result.domain_ip != null) {
addMarker(result.domain, result.result.domain_ip, result.result.latitude, result.result.longitude, COLOR.BLUE, markerInfo, markers);
}
if (result.result != null && result.result.error != null) {
tr.insertCell().appendChild(document.createTextNode(result.result.error ? 'down' : 'up'));
} else {
tr.insertCell().appendChild(document.createTextNode(result.error ? 'unknown' : 'up'));
}
//add markers to page
addMarker(result.hostname, result.ip_address, result.latitude, result.longitude, COLOR.RED, markerInfo, markers);
}
plotMarkers(markerInfo, markers);
}
});
}
function createMeasurementClickHandler(result) {
return function() {
alert(JSON.stringify(result, null, 4));
};
}
</script>
<script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyAeCkjmEFtZ0Wuu6muxH6-4RF6f-pzE3qc&callback=initMap"
async defer></script>
</body>
</html>