mirror of https://github.com/MISP/misp-dashboard
Added multiple fields in dataTable row
parent
d7a60139f7
commit
99542c5316
|
@ -10,7 +10,8 @@ size_openStreet_pannel_perc = 55
|
||||||
size_world_pannel_perc = 35
|
size_world_pannel_perc = 35
|
||||||
|
|
||||||
[Log]
|
[Log]
|
||||||
fieldname_order=["id", "category", "type", "value"]
|
fieldname_order=["id", "category", "type", ["value", "comment"]]
|
||||||
|
char_separator=||
|
||||||
|
|
||||||
[RedisLog]
|
[RedisLog]
|
||||||
host=localhost
|
host=localhost
|
||||||
|
|
15
server.py
15
server.py
|
@ -32,8 +32,14 @@ eventNumber = 0
|
||||||
class LogItem():
|
class LogItem():
|
||||||
|
|
||||||
FIELDNAME_ORDER = []
|
FIELDNAME_ORDER = []
|
||||||
|
FIELDNAME_ORDER_HEADER = []
|
||||||
FIELDNAME_ORDER.append("time")
|
FIELDNAME_ORDER.append("time")
|
||||||
|
FIELDNAME_ORDER_HEADER.append("time")
|
||||||
for item in json.loads(cfg.get('Log', 'fieldname_order')):
|
for item in json.loads(cfg.get('Log', 'fieldname_order')):
|
||||||
|
if type(item) is list:
|
||||||
|
FIELDNAME_ORDER_HEADER.append(" | ".join(item))
|
||||||
|
else:
|
||||||
|
FIELDNAME_ORDER_HEADER.append(item)
|
||||||
FIELDNAME_ORDER.append(item)
|
FIELDNAME_ORDER.append(item)
|
||||||
|
|
||||||
def __init__(self, feed):
|
def __init__(self, feed):
|
||||||
|
@ -46,18 +52,18 @@ class LogItem():
|
||||||
|
|
||||||
def get_head_row(self):
|
def get_head_row(self):
|
||||||
to_ret = []
|
to_ret = []
|
||||||
for fn in LogItem.FIELDNAME_ORDER:
|
for fn in LogItem.FIELDNAME_ORDER_HEADER:
|
||||||
to_ret.append(fn[0].upper()+fn[1:])
|
to_ret.append(fn[0].upper()+fn[1:])
|
||||||
return to_ret
|
return to_ret
|
||||||
|
|
||||||
def get_row(self):
|
def get_row(self):
|
||||||
to_ret = {}
|
to_ret = {}
|
||||||
#Number to keep them sorted (jsonify sort keys)
|
#Number to keep them sorted (jsonify sort keys)
|
||||||
for i in range(len(LogItem.FIELDNAME_ORDER)):
|
for item in range(len(LogItem.FIELDNAME_ORDER)):
|
||||||
try:
|
try:
|
||||||
to_ret[i] = self.fields[i]
|
to_ret[item] = self.fields[item]
|
||||||
except IndexError: # not enough field in rcv item
|
except IndexError: # not enough field in rcv item
|
||||||
to_ret[i] = ''
|
to_ret[item] = ''
|
||||||
return to_ret
|
return to_ret
|
||||||
|
|
||||||
|
|
||||||
|
@ -91,6 +97,7 @@ def index():
|
||||||
return render_template('index.html',
|
return render_template('index.html',
|
||||||
pannelSize=pannelSize,
|
pannelSize=pannelSize,
|
||||||
graph_log_refresh_rate=cfg.getint('Dashboard' ,'graph_log_refresh_rate'),
|
graph_log_refresh_rate=cfg.getint('Dashboard' ,'graph_log_refresh_rate'),
|
||||||
|
char_separator=cfg.get('Log', 'char_separator'),
|
||||||
rotation_wait_time=cfg.getint('Dashboard' ,'rotation_wait_time'),
|
rotation_wait_time=cfg.getint('Dashboard' ,'rotation_wait_time'),
|
||||||
max_img_rotation=cfg.getint('Dashboard' ,'max_img_rotation'),
|
max_img_rotation=cfg.getint('Dashboard' ,'max_img_rotation'),
|
||||||
hours_spanned=cfg.getint('Dashboard' ,'hours_spanned'),
|
hours_spanned=cfg.getint('Dashboard' ,'hours_spanned'),
|
||||||
|
|
|
@ -224,12 +224,16 @@ function slideAndMax(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');
|
|
||||||
|
|
||||||
for (var key in log) {
|
for (var key in log) {
|
||||||
if (log.hasOwnProperty(key)) {
|
if (log.hasOwnProperty(key)) {
|
||||||
var td = document.createElement('TD');
|
var td = document.createElement('TD');
|
||||||
td.appendChild(document.createTextNode(log[key]));
|
var textToAddArray = log[key].split(char_separator);
|
||||||
|
for(var i in textToAddArray){
|
||||||
|
if (i > 0)
|
||||||
|
td.appendChild(document.createElement("br"));
|
||||||
|
td.appendChild(document.createTextNode(textToAddArray[i]));
|
||||||
|
}
|
||||||
tr.appendChild(td);
|
tr.appendChild(td);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -245,10 +249,6 @@ function createRow(tableBody, log) {
|
||||||
tr.className = "danger"
|
tr.className = "danger"
|
||||||
}
|
}
|
||||||
|
|
||||||
// action
|
|
||||||
//action.appendChild(document.createTextNode("ACTION"));
|
|
||||||
//tr.appendChild(action);
|
|
||||||
|
|
||||||
tableBody.appendChild(tr);
|
tableBody.appendChild(tr);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -234,6 +234,7 @@ small {
|
||||||
|
|
||||||
/* DATA FROM CONF */
|
/* DATA FROM CONF */
|
||||||
var graph_log_refresh_rate = {{ graph_log_refresh_rate }};
|
var graph_log_refresh_rate = {{ graph_log_refresh_rate }};
|
||||||
|
var char_separator = "{{ char_separator }}";
|
||||||
var rotation_wait_time = {{ rotation_wait_time }};
|
var rotation_wait_time = {{ rotation_wait_time }};
|
||||||
var max_img_rotation = {{ max_img_rotation }};
|
var max_img_rotation = {{ max_img_rotation }};
|
||||||
var hours_spanned = {{ hours_spanned }};
|
var hours_spanned = {{ hours_spanned }};
|
||||||
|
|
|
@ -104,8 +104,11 @@ def handler_attribute(jsonattr):
|
||||||
jsonattr = jsonattr['Attribute']
|
jsonattr = jsonattr['Attribute']
|
||||||
to_push = []
|
to_push = []
|
||||||
for field in json.loads(cfg.get('Log', 'fieldname_order')):
|
for field in json.loads(cfg.get('Log', 'fieldname_order')):
|
||||||
to_push.append(jsonattr[field])
|
if type(field) is list:
|
||||||
to_push.append("blabla")
|
to_add = cfg.get('Log', 'char_separator').join([ jsonattr[subField] for subField in field ])
|
||||||
|
else:
|
||||||
|
to_add = jsonattr[field]
|
||||||
|
to_push.append(to_add)
|
||||||
|
|
||||||
#try to get coord
|
#try to get coord
|
||||||
if jsonattr['category'] == "Network activity":
|
if jsonattr['category'] == "Network activity":
|
||||||
|
|
Loading…
Reference in New Issue