mirror of https://github.com/MISP/misp-dashboard
Added typeahead plot for events
parent
39d83ebc9b
commit
914514023b
|
@ -497,7 +497,8 @@ def getTrendingEvents():
|
||||||
dateS = datetime.datetime.now() - datetime.timedelta(days=7)
|
dateS = datetime.datetime.now() - datetime.timedelta(days=7)
|
||||||
dateE = datetime.datetime.now()
|
dateE = datetime.datetime.now()
|
||||||
|
|
||||||
data = trendings_helper.getTrendingEvents(dateS, dateE)
|
specificLabel = request.args.get('specificLabel')
|
||||||
|
data = trendings_helper.getTrendingEvents(dateS, dateE, specificLabel)
|
||||||
return jsonify(data)
|
return jsonify(data)
|
||||||
|
|
||||||
@app.route("/_getTrendingCategs")
|
@app.route("/_getTrendingCategs")
|
||||||
|
|
|
@ -70,7 +70,7 @@ var typeaheadOption_event = {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
updater: function(theevent) {
|
updater: function(theevent) {
|
||||||
console.log(theevent);
|
updateLineForLabel(eventLine, theevent, undefined, url_getTrendingEvent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var typeaheadOption_categ = {
|
var typeaheadOption_categ = {
|
||||||
|
@ -166,7 +166,7 @@ function generateEmptyAndFillData(data, specificLabel, colorMapping) {
|
||||||
for(var item_arr of items) {
|
for(var item_arr of items) {
|
||||||
var count = item_arr[1];
|
var count = item_arr[1];
|
||||||
var itemStr = JSON.stringify(item_arr[0]);
|
var itemStr = JSON.stringify(item_arr[0]);
|
||||||
if (specificLabel === undefined || specificLabel == itemStr) {
|
if (specificLabel === undefined || specificLabel == item_arr[0]) {
|
||||||
if(toPlot_obj[itemStr] === undefined)
|
if(toPlot_obj[itemStr] === undefined)
|
||||||
toPlot_obj[itemStr] = {};
|
toPlot_obj[itemStr] = {};
|
||||||
toPlot_obj[itemStr][date] = count;
|
toPlot_obj[itemStr][date] = count;
|
||||||
|
@ -273,7 +273,7 @@ function updatePie(pie, line, data, url) {
|
||||||
var specificLabel = obj.series.label;
|
var specificLabel = obj.series.label;
|
||||||
colorMapping[specificLabel] = {};
|
colorMapping[specificLabel] = {};
|
||||||
colorMapping[specificLabel] = { colour: obj.series.color };
|
colorMapping[specificLabel] = { colour: obj.series.color };
|
||||||
updateLineForLabel(line, specificLabel, colorMapping, url);
|
updateLineForLabel(line, specificLabel.substring(1, specificLabel.length-1), colorMapping, url);
|
||||||
});
|
});
|
||||||
for (item of pieWidget.getData()) {
|
for (item of pieWidget.getData()) {
|
||||||
colorMapping[item.label] = {colour: item.color};
|
colorMapping[item.label] = {colour: item.color};
|
||||||
|
@ -344,7 +344,7 @@ function updateSignthingsChart() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateLineForLabel(line, specificLabel, colorMapping, url) {
|
function updateLineForLabel(line, specificLabel, colorMapping, url) {
|
||||||
$.getJSON( url+"?dateS="+parseInt(dateStart.getTime()/1000)+"&dateE="+parseInt(dateEnd.getTime()/1000), function( data ) {
|
$.getJSON( url+"?dateS="+parseInt(dateStart.getTime()/1000)+"&dateE="+parseInt(dateEnd.getTime()/1000)+"&specificLabel="+specificLabel, function( data ) {
|
||||||
updateLine(line, data, undefined, specificLabel, colorMapping);
|
updateLine(line, data, undefined, specificLabel, colorMapping);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,8 +65,21 @@ class Trendings_helper:
|
||||||
to_ret.append([util.getTimestamp(curDate), data])
|
to_ret.append([util.getTimestamp(curDate), data])
|
||||||
return to_ret
|
return to_ret
|
||||||
|
|
||||||
def getTrendingEvents(self, dateS, dateE):
|
def getSpecificTrending(self, trendingType, dateS, dateE, specificLabel=''):
|
||||||
return self.getGenericTrending('TRENDINGS_EVENTS', dateS, dateE)
|
to_ret = []
|
||||||
|
prev_days = (dateE - dateS).days
|
||||||
|
for curDate in util.getXPrevDaysSpan(dateE, prev_days):
|
||||||
|
keyname = "{}:{}".format(trendingType, util.getDateStrFormat(curDate))
|
||||||
|
data = self.serv_redis_db.zscore(keyname, specificLabel)
|
||||||
|
data = [[specificLabel, data]] if data is not None else []
|
||||||
|
to_ret.append([util.getTimestamp(curDate), data])
|
||||||
|
return to_ret
|
||||||
|
|
||||||
|
def getTrendingEvents(self, dateS, dateE, specificLabel=None):
|
||||||
|
if specificLabel is None:
|
||||||
|
return self.getGenericTrending('TRENDINGS_EVENTS', dateS, dateE)
|
||||||
|
else:
|
||||||
|
return self.getSpecificTrending('TRENDINGS_EVENTS', dateS, dateE, specificLabel)
|
||||||
|
|
||||||
def getTrendingCategs(self, dateS, dateE):
|
def getTrendingCategs(self, dateS, dateE):
|
||||||
return self.getGenericTrending('TRENDINGS_CATEGS', dateS, dateE)
|
return self.getGenericTrending('TRENDINGS_CATEGS', dateS, dateE)
|
||||||
|
|
Loading…
Reference in New Issue