Merge pull request #31 from mokaddem/tooltip_timeline

Timeline tooltip and redirect
pull/37/head
Alexandre Dulaunoy 2018-01-16 09:41:25 +01:00 committed by GitHub
commit 2e316994ed
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 18 additions and 5 deletions

View File

@ -218,9 +218,11 @@ def trendings():
maxNum = int(maxNum)
except:
maxNum = 15
url_misp_event = cfg.get('RedisGlobal', 'misp_web_url')
return render_template('trendings.html',
maxNum=maxNum
maxNum=maxNum,
url_misp_event=url_misp_event
)
''' INDEX '''

View File

@ -416,10 +416,11 @@ function updateDisc() {
});
}
var items_timeline = [];
function updateTimeline() {
var selected = $( "#timeline_selector" ).val();
$.getJSON( url_getGenericTrendingOvertime+"?dateS="+parseInt(dateStart.getTime()/1000)+"&dateE="+parseInt(dateEnd.getTime()/1000)+"&choice="+selected, function( data ) {
var items = [];
items_timeline = [];
var groups = new vis.DataSet();
var dico_groups = {};
var i = 1;
@ -431,25 +432,34 @@ function updateTimeline() {
dico_groups[obj.name] = g;
g++;
}
items.push({
items_timeline.push({
id: i,
content: getOnlyName(obj.name),
title: obj.name,
start: obj.start*1000,
end: obj.end*1000,
group: dico_groups[obj.name]
});
i++;
}
items = new vis.DataSet(items);
items_timeline = new vis.DataSet(items_timeline);
if (timeline === undefined) { // create timeline
timeline = new vis.Timeline(document.getElementById('timeline'));
// set listener for tooltip
timeline.on('doubleClick', function (properties) {
var type = $( "#timeline_selector" ).val();
var itemValue = items_timeline.get(properties.item).content;
if (type.localeCompare('events') == 0 || type.localeCompare('tags') == 0) { // Do not open a tab for categ
window.open(url_misp+'/'+type+'/index/searchall:'+itemValue, '_blank'); // as we do not have index for the moment, search it
}
});
}
var dateEndExtended = new Date(dateEnd).setDate(dateEnd.getDate()+1); // dateEnd+1
timeline_option.start = dateStart;
timeline_option.end = dateEndExtended;
timeline.setOptions(timeline_option);
timeline.setGroups(groups);
timeline.setItems(items);
timeline.setItems(items_timeline);
});
}

View File

@ -248,6 +248,7 @@ small {
var url_getGenericTrendingOvertime = "{{ url_for('getGenericTrendingOvertime') }}";
var url_getTypeaheadData = "{{ url_for('getTypeaheadData') }}";
var url_misp = "{{ url_misp_event }}";
/* DATA FROM CONF */