mirror of https://github.com/MISP/misp-dashboard
feature: Added draft support of discussion in Trendings
parent
7ebeed6012
commit
b17d480360
12
server.py
12
server.py
|
@ -538,6 +538,18 @@ def getTrendingSightings():
|
||||||
data = trendings_helper.getTrendingSightings(dateS, dateE)
|
data = trendings_helper.getTrendingSightings(dateS, dateE)
|
||||||
return jsonify(data)
|
return jsonify(data)
|
||||||
|
|
||||||
|
@app.route("/_getTrendingDisc")
|
||||||
|
def getTrendingDisc():
|
||||||
|
try:
|
||||||
|
dateS = datetime.datetime.fromtimestamp(float(request.args.get('dateS')))
|
||||||
|
dateE = datetime.datetime.fromtimestamp(float(request.args.get('dateE')))
|
||||||
|
except:
|
||||||
|
dateS = datetime.datetime.now() - datetime.timedelta(days=7)
|
||||||
|
dateE = datetime.datetime.now()
|
||||||
|
|
||||||
|
|
||||||
|
data = trendings_helper.getTrendingDisc(dateS, dateE)
|
||||||
|
return jsonify(data)
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
app.run(host='localhost', port=8001, threaded=True)
|
app.run(host='localhost', port=8001, threaded=True)
|
||||||
|
|
|
@ -8,6 +8,7 @@ var categLine = ["#categLine"];
|
||||||
var tagPie = ["#tagPie"];
|
var tagPie = ["#tagPie"];
|
||||||
var tagLine = ["#tagLine"];
|
var tagLine = ["#tagLine"];
|
||||||
var sightingLineWidget;
|
var sightingLineWidget;
|
||||||
|
var discLine = ["#discussionLine"];
|
||||||
|
|
||||||
/* OPTIONS */
|
/* OPTIONS */
|
||||||
var datePickerOptions = {
|
var datePickerOptions = {
|
||||||
|
@ -192,7 +193,7 @@ function updatePie(pie, data) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateLine(line, data) {
|
function updateLine(line, data, chartOptions) {
|
||||||
lineID = line[0];
|
lineID = line[0];
|
||||||
lineWidget = line[1];
|
lineWidget = line[1];
|
||||||
|
|
||||||
|
@ -203,7 +204,10 @@ function updateLine(line, data) {
|
||||||
lineWidget.setupGrid();
|
lineWidget.setupGrid();
|
||||||
lineWidget.draw();
|
lineWidget.draw();
|
||||||
} else {
|
} else {
|
||||||
lineWidget = $.plot(lineID, toPlot, lineChartOption);
|
if (chartOptions === undefined) {
|
||||||
|
chartOptions = lineChartOption;
|
||||||
|
}
|
||||||
|
lineWidget = $.plot(lineID, toPlot, chartOptions);
|
||||||
line.push(lineWidget);
|
line.push(lineWidget);
|
||||||
$(lineID).bind("plothover", function (event, pos, item) {
|
$(lineID).bind("plothover", function (event, pos, item) {
|
||||||
if (item) {
|
if (item) {
|
||||||
|
@ -258,6 +262,15 @@ function updatePieLine(pie, line, url) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function updateDisc() {
|
||||||
|
var lineChartOptionDisc = jQuery.extend(true, {}, lineChartOption);
|
||||||
|
lineChartOptionDisc['legend']['show'] = true;
|
||||||
|
lineChartOptionDisc['legend']['position'] = 'nw';
|
||||||
|
$.getJSON( url_getTrendingDisc+"?dateS="+parseInt(dateStart.getTime()/1000)+"&dateE="+parseInt(dateEnd.getTime()/1000), function( data ) {
|
||||||
|
updateLine(discLine, data, lineChartOptionDisc);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function dateChanged() {
|
function dateChanged() {
|
||||||
dateStart = datePickerWidgetStart.datepicker( "getDate" );
|
dateStart = datePickerWidgetStart.datepicker( "getDate" );
|
||||||
dateEnd = datePickerWidgetEnd.datepicker( "getDate" );
|
dateEnd = datePickerWidgetEnd.datepicker( "getDate" );
|
||||||
|
@ -265,6 +278,7 @@ function dateChanged() {
|
||||||
updatePieLine(categPie, categLine, url_getTrendingCateg);
|
updatePieLine(categPie, categLine, url_getTrendingCateg);
|
||||||
updatePieLine(tagPie, tagLine, url_getTrendingTag);
|
updatePieLine(tagPie, tagLine, url_getTrendingTag);
|
||||||
updateSignthingsChart();
|
updateSignthingsChart();
|
||||||
|
updateDisc();
|
||||||
}
|
}
|
||||||
|
|
||||||
$(document).ready(function () {
|
$(document).ready(function () {
|
||||||
|
@ -282,7 +296,7 @@ $(document).ready(function () {
|
||||||
updatePieLine(categPie, categLine, url_getTrendingCateg)
|
updatePieLine(categPie, categLine, url_getTrendingCateg)
|
||||||
updatePieLine(tagPie, tagLine, url_getTrendingTag)
|
updatePieLine(tagPie, tagLine, url_getTrendingTag)
|
||||||
updateSignthingsChart();
|
updateSignthingsChart();
|
||||||
|
updateDisc();
|
||||||
|
|
||||||
$("<div id='tooltip'></div>").css({
|
$("<div id='tooltip'></div>").css({
|
||||||
position: "absolute",
|
position: "absolute",
|
||||||
|
|
|
@ -185,10 +185,10 @@ small {
|
||||||
<div class="col-lg-6">
|
<div class="col-lg-6">
|
||||||
<div class="panel panel-default" style="">
|
<div class="panel panel-default" style="">
|
||||||
<div class="panel-heading bg-info" style="font-weight: bold;">
|
<div class="panel-heading bg-info" style="font-weight: bold;">
|
||||||
<b>Empty</b>
|
<b>Discussion</b>
|
||||||
</div>
|
</div>
|
||||||
<div id="panelbody" class="panel-body" style="">
|
<div id="panelbody" class="panel-body" style="">
|
||||||
<div id="" style="width:100%; height: 20vh;"></div>
|
<div id="discussionLine" style="width:100%; height: 20vh;"></div>
|
||||||
</div>
|
</div>
|
||||||
</div><!-- /.panel-body -->
|
</div><!-- /.panel-body -->
|
||||||
</div>
|
</div>
|
||||||
|
@ -212,6 +212,7 @@ small {
|
||||||
var url_getTrendingCateg = "{{ url_for('getTrendingCategs') }}";
|
var url_getTrendingCateg = "{{ url_for('getTrendingCategs') }}";
|
||||||
var url_getTrendingTag = "{{ url_for('getTrendingTags') }}";
|
var url_getTrendingTag = "{{ url_for('getTrendingTags') }}";
|
||||||
var url_getTrendingSightings = "{{ url_for('getTrendingSightings') }}";
|
var url_getTrendingSightings = "{{ url_for('getTrendingSightings') }}";
|
||||||
|
var url_getTrendingDisc = "{{ url_for('getTrendingDisc') }}";
|
||||||
|
|
||||||
/* DATA FROM CONF */
|
/* DATA FROM CONF */
|
||||||
|
|
||||||
|
|
|
@ -29,6 +29,9 @@ class Trendings_helper:
|
||||||
def addTrendingCateg(self, categName, timestamp):
|
def addTrendingCateg(self, categName, timestamp):
|
||||||
self.addGenericTrending('TRENDINGS_CATEGS', categName, timestamp)
|
self.addGenericTrending('TRENDINGS_CATEGS', categName, timestamp)
|
||||||
|
|
||||||
|
def addTrendingDisc(self, eventName, timestamp):
|
||||||
|
self.addGenericTrending('TRENDINGS_DISC', eventName, timestamp)
|
||||||
|
|
||||||
def addTrendingTags(self, tags, timestamp):
|
def addTrendingTags(self, tags, timestamp):
|
||||||
for tag in tags:
|
for tag in tags:
|
||||||
ordDic = OrderedDict() #keep fields with the same layout in redis
|
ordDic = OrderedDict() #keep fields with the same layout in redis
|
||||||
|
@ -95,3 +98,6 @@ class Trendings_helper:
|
||||||
fp = 0 if fp is None else int(fp.decode('utf8'))
|
fp = 0 if fp is None else int(fp.decode('utf8'))
|
||||||
to_ret.append([util.getTimestamp(curDate), { 'sightings': sight, 'false_positive': fp}])
|
to_ret.append([util.getTimestamp(curDate), { 'sightings': sight, 'false_positive': fp}])
|
||||||
return to_ret
|
return to_ret
|
||||||
|
|
||||||
|
def getTrendingDisc(self, dateS, dateE):
|
||||||
|
return self.getGenericTrending('TRENDINGS_DISC', dateS, dateE)
|
||||||
|
|
|
@ -145,7 +145,7 @@ def handleContribution(zmq_name, org, contribType, categ, action, pntMultiplier=
|
||||||
pnts_to_add = DEFAULT_PNTS_REWARD
|
pnts_to_add = DEFAULT_PNTS_REWARD
|
||||||
|
|
||||||
# if there is a contribution, there is a login (even if ti comes from the API)
|
# if there is a contribution, there is a login (even if ti comes from the API)
|
||||||
users_helper.add_user_login(timestamp, org)
|
users_helper.add_user_login(nowSec, org)
|
||||||
|
|
||||||
# is a valid contribution
|
# is a valid contribution
|
||||||
if categ is not None:
|
if categ is not None:
|
||||||
|
@ -214,11 +214,15 @@ def handler_conversation(zmq_name, jsonevent):
|
||||||
org = jsonpost['org_name']
|
org = jsonpost['org_name']
|
||||||
categ = None
|
categ = None
|
||||||
action = 'add'
|
action = 'add'
|
||||||
|
eventName = 'no name or id yet...'
|
||||||
handleContribution(zmq_name, org,
|
handleContribution(zmq_name, org,
|
||||||
'Discussion',
|
'Discussion',
|
||||||
None,
|
None,
|
||||||
action,
|
action,
|
||||||
isLabeled=False)
|
isLabeled=False)
|
||||||
|
# add Discussion
|
||||||
|
nowSec = int(time.time())
|
||||||
|
trendings_helper.addTrendingDisc(eventName, nowSec)
|
||||||
|
|
||||||
def handler_object(zmq_name, jsondata):
|
def handler_object(zmq_name, jsondata):
|
||||||
print('obj')
|
print('obj')
|
||||||
|
|
Loading…
Reference in New Issue