mirror of
https://github.com/ail-project/ail-framework.git
synced 2024-11-10 08:38:28 +00:00
chg: [trackers match] show objects date
This commit is contained in:
parent
406d72bb52
commit
fa57171937
7 changed files with 32 additions and 6 deletions
|
@ -305,6 +305,8 @@ class Item(AbstractObject):
|
||||||
meta['investigations'] = self.get_investigations()
|
meta['investigations'] = self.get_investigations()
|
||||||
if 'link' in options:
|
if 'link' in options:
|
||||||
meta['link'] = self.get_link(flask_context=True)
|
meta['link'] = self.get_link(flask_context=True)
|
||||||
|
if 'last_full_date' in options:
|
||||||
|
meta['last_full_date'] = f"{meta['date'][0:4]}-{meta['date'][5:7]}-{meta['date'][8:10]}"
|
||||||
|
|
||||||
# meta['encoding'] = None
|
# meta['encoding'] = None
|
||||||
return meta
|
return meta
|
||||||
|
|
|
@ -92,6 +92,10 @@ class Message(AbstractObject):
|
||||||
timestamp = self.get_timestamp()
|
timestamp = self.get_timestamp()
|
||||||
return datetime.utcfromtimestamp(float(timestamp)).strftime('%Y%m%d')
|
return datetime.utcfromtimestamp(float(timestamp)).strftime('%Y%m%d')
|
||||||
|
|
||||||
|
def get_last_full_date(self):
|
||||||
|
timestamp = datetime.utcfromtimestamp(float(self.get_timestamp()))
|
||||||
|
return timestamp.strftime('%Y-%m-%d %H:%M:%S')
|
||||||
|
|
||||||
def get_timestamp(self):
|
def get_timestamp(self):
|
||||||
dirs = self.id.split('/')
|
dirs = self.id.split('/')
|
||||||
return dirs[1]
|
return dirs[1]
|
||||||
|
@ -255,6 +259,8 @@ class Message(AbstractObject):
|
||||||
meta['date'] = timestamp.strftime('%Y/%m/%d')
|
meta['date'] = timestamp.strftime('%Y/%m/%d')
|
||||||
meta['hour'] = timestamp.strftime('%H:%M:%S')
|
meta['hour'] = timestamp.strftime('%H:%M:%S')
|
||||||
meta['full_date'] = timestamp.isoformat(' ')
|
meta['full_date'] = timestamp.isoformat(' ')
|
||||||
|
if 'last_full_date' in options:
|
||||||
|
meta['last_full_date'] = meta['full_date']
|
||||||
|
|
||||||
meta['source'] = self.get_source()
|
meta['source'] = self.get_source()
|
||||||
# optional meta fields
|
# optional meta fields
|
||||||
|
|
|
@ -88,6 +88,8 @@ class AbstractDaterangeObject(AbstractObject, ABC):
|
||||||
meta_dict['nb_seen'] = self.get_nb_seen()
|
meta_dict['nb_seen'] = self.get_nb_seen()
|
||||||
if 'sparkline' in options:
|
if 'sparkline' in options:
|
||||||
meta_dict['sparkline'] = self.get_sparkline()
|
meta_dict['sparkline'] = self.get_sparkline()
|
||||||
|
if 'last_full_date'in options:
|
||||||
|
meta_dict['last_full_date'] = self.get_last_full_date()
|
||||||
return meta_dict
|
return meta_dict
|
||||||
|
|
||||||
def set_first_seen(self, first_seen):
|
def set_first_seen(self, first_seen):
|
||||||
|
|
|
@ -67,6 +67,9 @@ class AbstractObject(ABC):
|
||||||
def get_global_id(self):
|
def get_global_id(self):
|
||||||
return f'{self.get_type()}:{self.get_subtype(r_str=True)}:{self.get_id()}'
|
return f'{self.get_type()}:{self.get_subtype(r_str=True)}:{self.get_id()}'
|
||||||
|
|
||||||
|
def get_last_full_date(self):
|
||||||
|
return None
|
||||||
|
|
||||||
def get_default_meta(self, tags=False, link=False):
|
def get_default_meta(self, tags=False, link=False):
|
||||||
dict_meta = {'id': self.get_id(),
|
dict_meta = {'id': self.get_id(),
|
||||||
'type': self.get_type(),
|
'type': self.get_type(),
|
||||||
|
|
|
@ -85,6 +85,11 @@ class AbstractSubtypeObject(AbstractObject, ABC):
|
||||||
else:
|
else:
|
||||||
return int(nb)
|
return int(nb)
|
||||||
|
|
||||||
|
def get_last_full_date(self):
|
||||||
|
last_seen = self.get_last_seen()
|
||||||
|
if last_seen:
|
||||||
|
return f'{last_seen[0:4]}-{last_seen[4:6]}-{last_seen[6:8]}'
|
||||||
|
|
||||||
def _get_meta(self, options=None):
|
def _get_meta(self, options=None):
|
||||||
if options is None:
|
if options is None:
|
||||||
options = set()
|
options = set()
|
||||||
|
|
|
@ -174,7 +174,7 @@ def show_tracker():
|
||||||
if date_from:
|
if date_from:
|
||||||
date_from, date_to = Date.sanitise_daterange(date_from, date_to)
|
date_from, date_to = Date.sanitise_daterange(date_from, date_to)
|
||||||
objs = tracker.get_objs_by_daterange(date_from, date_to)
|
objs = tracker.get_objs_by_daterange(date_from, date_to)
|
||||||
meta['objs'] = ail_objects.get_objects_meta(objs, flask_context=True)
|
meta['objs'] = ail_objects.get_objects_meta(objs, options={'last_full_date'}, flask_context=True)
|
||||||
else:
|
else:
|
||||||
date_from = ''
|
date_from = ''
|
||||||
date_to = ''
|
date_to = ''
|
||||||
|
|
|
@ -258,7 +258,7 @@
|
||||||
<th>Type</th>
|
<th>Type</th>
|
||||||
<th></th>
|
<th></th>
|
||||||
<th>Id</th>
|
<th>Id</th>
|
||||||
<th>Tags</th>
|
<th>Last Date</th>
|
||||||
<th></th>
|
<th></th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
|
@ -280,11 +280,19 @@
|
||||||
<a href="{{ object['link'] }}">
|
<a href="{{ object['link'] }}">
|
||||||
{{ object['id']}}
|
{{ object['id']}}
|
||||||
</a>
|
</a>
|
||||||
</td>
|
{% if object['tags'] %}
|
||||||
<td>
|
<div>
|
||||||
{% for tag in object['tags'] %}
|
{% for tag in object['tags'] %}
|
||||||
<span class="badge badge-{{ bootstrap_label[loop.index0 % 5] }} pull-left">{{ tag }}</span>
|
<span class="badge badge-{{ bootstrap_label[loop.index0 % 5] }} pull-left">{{ tag }}</span>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
</td>
|
||||||
|
|
||||||
|
<td>
|
||||||
|
{% if object['last_full_date'] %}
|
||||||
|
{{ object['last_full_date']}}
|
||||||
|
{% endif %}
|
||||||
</td>
|
</td>
|
||||||
<td class="text-right">
|
<td class="text-right">
|
||||||
{# <a href="{{ url_for('investigations_b.unregister_investigation') }}?uuid={{ meta['uuid']}}&type={{ object['type'] }}&subtype={{ object['subtype']}}&id={{ object['id']}}">#}
|
{# <a href="{{ url_for('investigations_b.unregister_investigation') }}?uuid={{ meta['uuid']}}&type={{ object['type'] }}&subtype={{ object['subtype']}}&id={{ object['id']}}">#}
|
||||||
|
@ -342,7 +350,7 @@
|
||||||
$('#myTable_').DataTable({
|
$('#myTable_').DataTable({
|
||||||
"aLengthMenu": [[5, 10, 15, -1], [5, 10, 15, "All"]],
|
"aLengthMenu": [[5, 10, 15, -1], [5, 10, 15, "All"]],
|
||||||
"iDisplayLength": 10,
|
"iDisplayLength": 10,
|
||||||
"order": [[0, "asc"]]
|
"order": [[3, "desc"]]
|
||||||
});
|
});
|
||||||
|
|
||||||
sparkline("sparkline", {{ meta['sparkline'] }}, {});
|
sparkline("sparkline", {{ meta['sparkline'] }}, {});
|
||||||
|
|
Loading…
Reference in a new issue