chg: [UI correlation graph] popover: add loading status + chg css

pull/453/head
Terrtia 2019-12-10 15:41:47 +01:00
parent 9702c12b7f
commit d45d02b667
No known key found for this signature in database
GPG Key ID: 1E1B1F50D84613D0
5 changed files with 37 additions and 12 deletions

View File

@ -52,7 +52,7 @@ def get_object_metadata(object_type, correlation_id, type_id=None):
if object_type == 'domain':
return Domain.Domain(correlation_id).get_domain_metadata()
elif object_type == 'paste':
return Item.get_item({"id": correlation_id, "date": True, "tags": True})[0]
return Item.get_item({"id": correlation_id, "date": True, "date_separator": True, "tags": True})[0]
elif object_type == 'decoded':
return Decoded.get_decoded_metadata(correlation_id, nb_seen=True, size=True, file_type=True)
elif object_type == 'pgp':

View File

@ -34,9 +34,12 @@ def exist_item(item_id):
def get_item_id(full_path):
return full_path.replace(PASTES_FOLDER, '', 1)
def get_item_date(item_id):
def get_item_date(item_id, add_separator=False):
l_directory = item_id.split('/')
return '{}{}{}'.format(l_directory[-4], l_directory[-3], l_directory[-2])
if add_separator:
return '{}/{}/{}'.format(l_directory[-4], l_directory[-3], l_directory[-2])
else:
return '{}{}{}'.format(l_directory[-4], l_directory[-3], l_directory[-2])
def get_source(item_id):
return item_id.split('/')[-5]
@ -94,7 +97,10 @@ def get_item(request_dict):
dict_item['id'] = item_id
date = request_dict.get('date', True)
if date:
dict_item['date'] = get_item_date(item_id)
add_separator = False
if request_dict.get('date_separator', False):
add_separator = True
dict_item['date'] = get_item_date(item_id, add_separator=add_separator)
tags = request_dict.get('tags', True)
if tags:
dict_item['tags'] = Tag.get_item_tags(item_id)

View File

@ -216,7 +216,7 @@ def get_description():
# check if correlation_id exist
# # TODO: return error json
if not Correlate_object.exist_object(object_type, correlation_id, type_id=type_id):
abort(404) # return 404
return Response(json.dumps({"status": "error", "reason": "404 Not Found"}, indent=2, sort_keys=True), mimetype='application/json'), 404
# oject exist
else:
res = Correlate_object.get_object_metadata(object_type, correlation_id, type_id=type_id)

View File

@ -23,7 +23,7 @@
</svg>
{{ dict_object["metadata"]["type_id"] }}
</td>
<td>{{ dict_object["metadata"]['date'][0:4] }}/{{ dict_object["metadata"]['date'][4:6] }}/{{ dict_object["metadata"]['date'][6:8] }}</td>
<td>{{ dict_object["metadata"]['date'] }}</td>
</tr>
</tbody>
</table>

View File

@ -427,10 +427,10 @@ if (d.popover) {
.style("opacity", .9);
} else {
//console.log(d);
var pop_header = "<b>"+ sanitize_text(d.text) + "</b><br><br>"
var pop_header = "<div class=\"card text-white\" style=\"max-width: 25rem;\"><div class=\"card-header bg-dark pb-0 border-white\"><h6>"+ sanitize_text(d.text) +"</h6></div>"
var spinner = "<div class=\"card-body bg-dark pt-0\"><div class=\"spinner-border text-warning\" role=\"status\"></div> Loading...</div>"
div.html(pop_header)
div.html(pop_header + spinner)
.style("left", (d3_pageX) + "px")
.style("top", (d3_pageY - 28) + "px");
@ -440,14 +440,33 @@ if (d.popover) {
$.getJSON("{{ url_for('correlation.get_description') }}?object_id="+ d.id,
function(data){
var desc = pop_header
var desc = pop_header + "<div class=\"card-body bg-dark pb-1 pt-2\"><dl class=\"row py-0 my-0\">"
Object.keys(data).forEach(function(key) {
desc = desc + key + ": " + sanitize_text(data[key]) + "<br>"
})
if (key=="status") {
desc = desc + "<dt class=\"col-sm-3 px-0\">status</dt><dd class=\"col-sm-9 px-0\"><div class=\"badge badge-pill badge-light flex-row-reverse\" style=\"color:Green;\"><i class=\"fas fa-check-circle\"></i>UP</div></dd>"
} else if (key!="tags" && key!="id") {
desc = desc + "<dt class=\"col-sm-3 px-0\">" + sanitize_text(key) + "</dt><dd class=\"col-sm-9 px-0\">" + sanitize_text(data[key]) + "</dd>"
}
});
desc = desc + "</dl>"
if (data["tags"]) {
data["tags"].forEach(function(tag) {
desc = desc + "<span class=\"badge badge-primary\">"+ sanitize_text(tag) +"</span>";
});
}
desc = desc + "</div>"
div.html(desc)
.style("left", (d3_pageX) + "px")
.style("top", (d3_pageY - 28) + "px");
d.popover = desc
})
.fail(function(error) {
desc = pop_header + "<div class=\"card-body bg-dark pt-0\"><i class=\"fas fa-3x fa-times text-danger\"></i>"+ error.statusText +"</div>"
div.html(desc)
.style("left", (d3_pageX) + "px")
.style("top", (d3_pageY - 28) + "px");
});
}
}