chg: [corellation graph] hide unsafe screenshots

This commit is contained in:
Terrtia 2023-04-21 15:38:48 +02:00
parent 6c6a3b48e2
commit e0899e6e0d
No known key found for this signature in database
GPG key ID: 1E1B1F50D84613D0
3 changed files with 10 additions and 5 deletions

View file

@ -86,8 +86,8 @@ class Screenshot(AbstractObject):
meta = {'id': self.id} meta = {'id': self.id}
meta['img'] = get_screenshot_rel_path(self.id) ######### # TODO: Rename ME ?????? meta['img'] = get_screenshot_rel_path(self.id) ######### # TODO: Rename ME ??????
meta['tags'] = self.get_tags(r_list=True) meta['tags'] = self.get_tags(r_list=True)
# TODO: ADD IN ABSTRACT CLASS if 'tags_safe' in options:
#meta['is_tags_safe'] = Tag.is_tags_safe(metadata_dict['tags']) ################## # TODO: ADD IN ABSTRACT CLASS meta['tags_safe'] = self.is_tags_safe(meta['tags'])
return meta return meta
def get_screenshot_dir(): def get_screenshot_dir():

View file

@ -157,7 +157,8 @@ def get_description():
return Response(json.dumps({"status": "error", "reason": "404 Not Found"}, indent=2, sort_keys=True), mimetype='application/json'), 404 return Response(json.dumps({"status": "error", "reason": "404 Not Found"}, indent=2, sort_keys=True), mimetype='application/json'), 404
# object exist # object exist
else: else:
res = ail_objects.get_object_meta(object_type, type_id, correlation_id, options={'tags'}, flask_context=True) res = ail_objects.get_object_meta(object_type, type_id, correlation_id, options={'tags', 'tags_safe'},
flask_context=True)
if 'tags' in res: if 'tags' in res:
res['tags'] = list(res['tags']) res['tags'] = list(res['tags'])
return jsonify(res) return jsonify(res)

View file

@ -542,10 +542,14 @@ if (d.popover) {
} }
if (data["img"]) { if (data["img"]) {
desc = desc + "<img src={{ url_for('objects_item.screenshot', filename="") }}" + data["img"] +" class=\"img-thumbnail\" />"; if (data["tags_safe"]) {
desc = desc + "<img src={{ url_for('objects_item.screenshot', filename="") }}" + data["img"] +" class=\"img-thumbnail\" />";
} else {
desc = desc + "<span class=\"my-2 fa-stack fa-4x\"><i class=\"fas fa-stack-1x fa-image\"></i><i class=\"fas fa-stack-2x fa-ban\" style=\"color:Red\"></i></span>";
}
} }
desc = desc + "</div>" desc = desc + "</div></div>"
div.html(desc) div.html(desc)
.style("left", (d3_pageX) + "px") .style("left", (d3_pageX) + "px")
.style("top", (d3_pageY - 28) + "px"); .style("top", (d3_pageY - 28) + "px");