fix: unknown meta-category do not longer raise an exception (use a default value instead)

pull/3139/head
Sami Mokaddem 2018-04-06 07:37:41 +00:00
parent 721cbe1791
commit 57d4277dfe
1 changed files with 7 additions and 2 deletions

View File

@ -24,7 +24,7 @@ class EventGraph {
this.mapping_meta_fa.set('file', {"meta-category": "file","fa_text": "file","fa-hex": "f15b"});
this.mapping_meta_fa.set('financial', {"meta-category": "financial","fa_text": "money-bil-alt","fa-hex": "f3d1"});
this.mapping_meta_fa.set('network', {"meta-category": "network","fa_text": "server","fa-hex": "f233"});
this.mapping_meta_fa.set('misc', {"meta-category": "misc","fa_text": "cube","fa-hex": "f1b2"});
this.mapping_meta_fa.set('misc', {"meta-category": "misc","fa_text": "cube","fa-hex": "f1b2"}); // Also considered as default
// FIXME
this.nodes = nodes;
this.edges = edges;
@ -59,6 +59,11 @@ class EventGraph {
get_node_color(uuid) {
return this.nodes.get(uuid).icon.color;
}
get_FA_icon(metaCateg) {
var dict = this.mapping_meta_fa.get(metaCateg);
dict = dict === undefined ? this.mapping_meta_fa.get('misc') : dict; // if unknown meta-categ, take default
return String.fromCharCode(parseInt(dict['fa-hex'], 16))
}
// Graph interaction
reset_graphs() {
@ -89,7 +94,7 @@ class EventGraph {
icon: {
color: getRandomColor(),
face: 'FontAwesome',
code: String.fromCharCode(parseInt(this.mapping_meta_fa.get(node['meta-category'])['fa-hex'], 16)),
code: this.get_FA_icon(node['meta-category']),
}
};
dataHandler.mapping_value_to_nodeID.set(striped_value, node.id);