Skip to content
Snippets Groups Projects
Commit 404643e9 authored by Tim Fechner's avatar Tim Fechner Committed by Tim Fechner
Browse files

Introduce #13, could be improved a lot!

parent 42a3f1c2
No related branches found
No related tags found
No related merge requests found
......@@ -65,6 +65,11 @@ class Domain(MarkdownContent):
def minion_count(self):
return len(self.minion.all())
def worst_grade(self):
if self.ssl_lab_status.get('grades', []):
return max([g for g in self.ssl_lab_status.get('grades', [])])
return '0'
def save(self, *args, **kwargs):
if not self.id:
self.check_if_valid(commit=False)
......@@ -117,6 +122,12 @@ class Minion(MarkdownContent):
def outdated_package_count(self):
return len([p for p, v in self.data.get('packages', {}).items() if v['latest_version']])
def fullest_partition_percentage(self):
try:
return max([p.get('percent', 0) for p in self.data.get('mounted_devices', [])])
except AttributeError:
return 0
def __str__(self):
return self.fqdn
......
......@@ -6,10 +6,76 @@
{% block home-content %}
<div class="row">
<div class="col-md-10">
<div class="col-md-6 col-lg-8">
</div>
<div class="col-md-2">
<div class="col-md-6 col-lg-4">
<div class="panel panel-danger">
<div class="panel-heading">
<h3 class="panel-title">Fullest 5 Minions</h3>
</div>
<table class="table">
<thead>
<tr>
<th>Minion ID</th>
<th>Percentage</th>
</tr>
</thead>
<tbody>
{% for m in w5_fullest_minions %}
<tr>
<td><a href="{% url 'minion-detail' m.fqdn %}">{{ m.fqdn }}</a></td>
<td>{{ m.fullest_partition_percentage }} %</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
<div class="panel panel-info">
<div class="panel-heading">
<h3 class="panel-title">Worst 5 outdated Minions</h3>
</div>
<table class="table">
<thead>
<tr>
<th>Minion ID</th>
<th>Packages</th>
</tr>
</thead>
<tbody>
{% for m in w5_outdated_minions %}
<tr>
<td><a href="{% url 'minion-detail' m.fqdn %}">{{ m.fqdn }}</a></td>
<td>{{ m.outdated_package_count }}</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
<div class="panel panel-info">
<div class="panel-heading">
<h3 class="panel-title">Worst 5 Certs</h3>
</div>
<table class="table">
<thead>
<tr>
<th>Domain</th>
<th>Grade</th>
</tr>
</thead>
<tbody>
{% for d in w5_domain_ssl_grades %}
<tr>
<td><a href="{% url 'domain-detail' d.fqdn %}">{{ d.fqdn }}</a></td>
<td><span class="ssllabgrade {{ d.worst_grade|first|lower }}">{{ d.worst_grade }}</span></td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
</div>
......
......@@ -68,6 +68,15 @@ class Logout(View):
class Dashboard(TemplateView):
template_name = 'home/dashboard.html'
def get_context_data(self, *args, **kwargs):
ctx = super().get_context_data(*args, **kwargs)
ctx.update({
'w5_outdated_minions': sorted(Minion.objects.all(), key=lambda m: m.outdated_package_count(), reverse=True)[:5],
'w5_fullest_minions': sorted(Minion.objects.all(), key=lambda m: m.fullest_partition_percentage(), reverse=True)[:5],
'w5_domain_ssl_grades': sorted(Domain.objects.all(), key=lambda d: d.worst_grade(), reverse=True)[:5],
})
return ctx
class VisualNetwork(TemplateView):
template_name = 'home/visual_network.html'
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment