fix: [UI showDomain] fix down domain history

This commit is contained in:
Terrtia 2019-12-16 15:55:50 +01:00
parent fffb4464c6
commit b4f49f9e81
No known key found for this signature in database
GPG key ID: 1E1B1F50D84613D0
4 changed files with 69 additions and 64 deletions

View file

@ -283,6 +283,7 @@ def get_domain_items_crawled(domain, domain_type, port, epoch=None, items_link=F
item_crawled['epoch'] = item_root['epoch']
item_crawled['date'] = time.strftime('%Y/%m/%d - %H:%M.%S', time.gmtime(item_root['epoch']))
item_crawled['items'] = []
if item_root['root_item'] != str(item_root['epoch']):
for item in get_domain_items(domain, item_root['root_item']):
dict_item = {"id": item}
if items_link:
@ -540,7 +541,7 @@ class Domain(object):
def __init__(self, domain, port=None):
self.domain = str(domain)
self.type = get_domain_type(domain)
if self.is_domain_up():
if self.domain_was_up():
self.current_port = sanathyse_port(port, self.domain, self.type)
def get_domain_name(self):

View file

@ -61,7 +61,7 @@ def showDomain():
dict_domain = domain.get_domain_metadata()
dict_domain['domain'] = domain_name
if domain.is_domain_up():
if domain.domain_was_up():
dict_domain = {**dict_domain, **domain.get_domain_correlation()}
dict_domain['correlation_nb'] = Domain.get_domain_total_nb_correlation(dict_domain)
dict_domain['origin_item'] = domain.get_domain_last_origin()
@ -69,6 +69,7 @@ def showDomain():
dict_domain['tags_safe'] = Tag.is_tags_safe(dict_domain['tags'])
dict_domain['history'] = domain.get_domain_history_with_status()
dict_domain['crawler_history'] = domain.get_domain_items_crawled(items_link=True, epoch=epoch, item_screenshot=True, item_tag=True) # # TODO: handle multiple port
if dict_domain['crawler_history']['items']:
dict_domain['crawler_history']['random_item'] = random.choice(dict_domain['crawler_history']['items'])
return render_template("showDomain.html", dict_domain=dict_domain, bootstrap_label=bootstrap_label,

View file

@ -449,7 +449,7 @@ if (d.popover) {
} else {
desc = desc + "Red"
}
desc = desc + ";\"><i class=\"fas"
desc = desc + ";\"><i class=\"fas "
if (data["status"]) {
desc = desc + "fa-check-circle"
} else {

View file

@ -287,11 +287,12 @@
{{dict_domain["crawler_history"]["port"]}}
</span>
</div>
<h5>Crawled Items</h5>
<h5>Crawled Items {% if not dict_domain["crawler_history"]["items"] %}: DOWN{% endif %}</h5>
</div>
</div>
{% if dict_domain["crawler_history"]["items"] %}
<table class="table table-striped table-bordered table-hover" id="myTable_1">
<thead class="thead-dark">
<tr>
@ -334,6 +335,7 @@
</a>
</div>
{%endif%}
{%endif%}
{% if dict_domain["history"] %}
<table class="table table-hover mt-2" id="myTable_2">
@ -456,18 +458,19 @@ img.addEventListener("error", img_error);
var draw_img = false;
{%if "crawler_history" in dict_domain%}
{%if "random_item" in dict_domain['crawler_history']%}
{%if dict_domain['crawler_history']['random_item']['screenshot']%}
var screenshot = "{{dict_domain['crawler_history']['random_item']['screenshot']}}";
var selected_icon = $("#"+screenshot.replace(/\//g, ""));
selected_icon.addClass("icon_selected");
selected_icon.removeClass("icon_img");
$("#screenshot_link").attr("href", screenshot_href + "{{dict_domain['crawler_history']['random_item']['id']}}");
$("#screenshot_link").text("{{dict_domain['crawler_history']['random_item']['link']}}");
{%else%}
var screenshot = "";
{%endif%}
{%endif%}
{%else%}
var screenshot = "";
{%endif%}