mirror of https://github.com/MISP/misp-dashboard
Added draft support of dynamic marker placement
parent
b7c75eac79
commit
68aad5dfdf
|
@ -1,12 +1,17 @@
|
||||||
//color: #5f6062
|
//color: #5f6062
|
||||||
var updateInterval = 1000*graph_log_refresh_rate; // 1s
|
var updateInterval = 1000*graph_log_refresh_rate; // 1s
|
||||||
var numPoint = 60;
|
var maxNumPoint = 60;
|
||||||
|
var maxNumCoord = 20;
|
||||||
|
|
||||||
var emptyArray = [];
|
var emptyArray = [];
|
||||||
var dataNumLog = [];
|
var mapCoord = [];
|
||||||
for(i=0; i<numPoint; i++) {
|
var mapVal = [];
|
||||||
dataNumLog.push([i, 0]);
|
for(i=0; i<maxNumPoint; i++) {
|
||||||
emptyArray.push([i, 0]);
|
emptyArray.push([i, 0]);
|
||||||
|
if (i<20) {
|
||||||
|
mapCoord.push([]);
|
||||||
|
mapVal.push(0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class Sources {
|
class Sources {
|
||||||
|
@ -45,7 +50,7 @@ class Sources {
|
||||||
var globMax = 0;
|
var globMax = 0;
|
||||||
for (var src of this._sourceNames) {
|
for (var src of this._sourceNames) {
|
||||||
// res[0] = max, res[1] = slidedArray
|
// res[0] = max, res[1] = slidedArray
|
||||||
var res = slide(this._sourcesArray[src], this._sourcesCount[src]);
|
var res = slideAndMax(this._sourcesArray[src], this._sourcesCount[src]);
|
||||||
// max
|
// max
|
||||||
this._sourcesCountMax[src] = res[0];
|
this._sourcesCountMax[src] = res[0];
|
||||||
globMax = globMax > res[0] ? globMax : res[0];
|
globMax = globMax > res[0] ? globMax : res[0];
|
||||||
|
@ -97,8 +102,8 @@ var optionsLineChart = {
|
||||||
},
|
},
|
||||||
//colors: ["#2fa1db"],
|
//colors: ["#2fa1db"],
|
||||||
yaxis: { min: 0, max: 20 },
|
yaxis: { min: 0, max: 20 },
|
||||||
xaxis: { min: 0, max: numPoint-1 },
|
xaxis: { min: 0, max: maxNumPoint-1 },
|
||||||
ticks: numPoint,
|
ticks: maxNumPoint,
|
||||||
grid: {
|
grid: {
|
||||||
tickColor: "#dddddd",
|
tickColor: "#dddddd",
|
||||||
borderWidth: 0
|
borderWidth: 0
|
||||||
|
@ -213,15 +218,9 @@ function updateLogTable(feedName, log) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//if (tableBody.rows.length > logSel.options[logSel.options.selectedIndex].value){
|
|
||||||
// while (tableBody.rows.length != logSel.options[logSel.options.selectedIndex].value){
|
|
||||||
// tableBody.deleteRow(0);
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function slide(orig, newData) {
|
function slideAndMax(orig, newData) {
|
||||||
var slided = [];
|
var slided = [];
|
||||||
var max = newData;
|
var max = newData;
|
||||||
for (i=1; i<orig.length; i++) {
|
for (i=1; i<orig.length; i++) {
|
||||||
|
@ -237,6 +236,9 @@ function slide(orig, newData) {
|
||||||
function createRow(tableBody, log) {
|
function createRow(tableBody, log) {
|
||||||
var tr = document.createElement('TR');
|
var tr = document.createElement('TR');
|
||||||
var action = document.createElement('TD');
|
var action = document.createElement('TD');
|
||||||
|
var x = log[1];
|
||||||
|
var y = log[2];
|
||||||
|
popupCoord([x,y]);
|
||||||
|
|
||||||
for (var key in log) {
|
for (var key in log) {
|
||||||
if (log.hasOwnProperty(key)) {
|
if (log.hasOwnProperty(key)) {
|
||||||
|
@ -282,3 +284,39 @@ function createHead(callback) {
|
||||||
callback();
|
callback();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* MAP */
|
||||||
|
//var coord = [[30, -84], [-12, 20]];
|
||||||
|
//var names = ['name1', 'name2'];
|
||||||
|
//var val = [5,7];
|
||||||
|
//
|
||||||
|
var mapObj;
|
||||||
|
|
||||||
|
function popupCoord(coord) {
|
||||||
|
mapCoord = mapCoord.slice(1);
|
||||||
|
mapCoord.push(coord);
|
||||||
|
mapVal = mapVal.slice(1);
|
||||||
|
mapVal.push(coord[0]+coord[1]);
|
||||||
|
console.log(coord[0]+coord[1]);
|
||||||
|
mapObj.addMarkers(mapCoord, []);
|
||||||
|
mapObj.series.markers[0].setValues(mapVal);
|
||||||
|
}
|
||||||
|
|
||||||
|
$(function(){
|
||||||
|
$('#feedDiv2').vectorMap({
|
||||||
|
map: 'world_mill',
|
||||||
|
markers: [],
|
||||||
|
series: {
|
||||||
|
markers: [{
|
||||||
|
attribute: 'fill',
|
||||||
|
scale: ['#1A0DAB', '#e50000', '#62ff41'],
|
||||||
|
values: [],
|
||||||
|
min: -180,
|
||||||
|
max: 180
|
||||||
|
}],
|
||||||
|
},
|
||||||
|
})
|
||||||
|
//mapObj = $('#feedDiv2 .jvectormap-container').data('mapObject');
|
||||||
|
mapObj = $("#feedDiv2").vectorMap('get','mapObject');
|
||||||
|
});
|
||||||
|
|
|
@ -21,8 +21,10 @@
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
table {
|
table {
|
||||||
overflow-y: scroll;
|
overflow-y: scroll;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
|
@ -152,26 +154,7 @@ table {
|
||||||
<script src="{{ url_for('static', filename='js/jquery-jvectormap-2.0.3.min.js') }}"></script>
|
<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>
|
<script src="{{ url_for('static', filename='js/jquery-jvectormap-world-mill.js') }}"></script>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
$(function(){
|
|
||||||
$('#feedDiv2').vectorMap({
|
|
||||||
map: 'world_mill',
|
|
||||||
series: {
|
|
||||||
markers: [{
|
|
||||||
attribute: 'fill',
|
|
||||||
scale: ['#FEE5D9', '#A50F15'],
|
|
||||||
values: { "AF": 16.63, "AL": 11.58, "DZ": 158.97},
|
|
||||||
min: 11,
|
|
||||||
max: 160
|
|
||||||
},{
|
|
||||||
attribute: 'r',
|
|
||||||
scale: [5, 20],
|
|
||||||
values: { "BE": 16.63, "DE": 11.58, "IT": 158.97},
|
|
||||||
min: 11,
|
|
||||||
max: 160
|
|
||||||
}],
|
|
||||||
}
|
|
||||||
})
|
|
||||||
});
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
|
|
|
@ -31,8 +31,11 @@ pubsub = redis_server.pubsub(ignore_subscribe_messages=True)
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
rdm = random.randint(1,3)
|
rdm = random.randint(1,3)
|
||||||
time.sleep(float(rdm / 10))
|
time.sleep(float(rdm / 3))
|
||||||
|
lat = random.randint(-90,90)
|
||||||
|
lon = random.randint(-90,90)
|
||||||
content = ["rdm "+str(rdm)]
|
content = ["rdm "+str(rdm)]
|
||||||
|
content = [lat,lon]
|
||||||
jsonContent = json.dumps(content)
|
jsonContent = json.dumps(content)
|
||||||
to_send = { 'name': 'feeder'+str(rdm), 'log': jsonContent }
|
to_send = { 'name': 'feeder'+str(rdm), 'log': jsonContent }
|
||||||
redis_server.publish(channel, json.dumps(to_send))
|
redis_server.publish(channel, json.dumps(to_send))
|
||||||
|
|
Loading…
Reference in New Issue