Skip to content

Commit 00423d1

Browse files
committed
frontend: images view
1 parent 73ff28a commit 00423d1

File tree

2 files changed

+66
-0
lines changed

2 files changed

+66
-0
lines changed

server/routes/frontend.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from flask import render_template, Blueprint
55

66
from models.host import Host
7+
from models.image import Image
78

89
frontend = Blueprint('frontend', __name__)
910

@@ -108,3 +109,23 @@ def get_host(host_id):
108109
})
109110

110111
return render_template('host.html', data=data)
112+
113+
114+
@frontend.route('/images', methods=['GET'])
115+
def get_images():
116+
images = Image.query.all()
117+
118+
data = []
119+
for image in images:
120+
is_eol = is_image_eol(image)
121+
trivy_findings = count_trivy_findings_image(image)
122+
usage_count = len(image.containers)
123+
124+
data.append({
125+
'name': image.name,
126+
'image_eol': is_eol,
127+
'trivy_findings': trivy_findings,
128+
'usage_count': usage_count,
129+
})
130+
131+
return render_template('images.html', data=data)

server/templates/images.html

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
{% extends 'base.html.j2' %}
2+
3+
{% block page %}Images{% endblock %}
4+
5+
{% block body %}
6+
<h1>Images Overview</h1>
7+
<table class="table table-zebra">
8+
<thead>
9+
<tr>
10+
<th>Image Name</th>
11+
<th>Result of XEOL</th>
12+
<th>Result of Trivy</th>
13+
<th>Usage by Containers</th>
14+
</tr>
15+
</thead>
16+
<tbody>
17+
{% for image in data %}
18+
<tr class="hover" onclick="openImage('{{ image.id }}')">
19+
<td>{{ image.name }}</td>
20+
<td>
21+
{% if image.image_eol %}
22+
<span class="text-error">EOL</span>
23+
{% else %}
24+
<span class="text-success"></span>
25+
{% endif %}
26+
</td>
27+
<td>
28+
<span class="text-error">{{ image.trivy_findings['high'] }}</span> |
29+
<span class="text-warning">{{ image.trivy_findings['medium'] }}</span> |
30+
<span class="text-info">{{ image.trivy_findings['low'] }}</span>
31+
</td>
32+
<td>{{ image.usage_count }}</td>
33+
</tr>
34+
{% endfor %}
35+
</tbody>
36+
</table>
37+
{% endblock %}
38+
39+
{% block scripts %}
40+
<script>
41+
function openImage(id) {
42+
window.location.href = "/images/" + id;
43+
}
44+
</script>
45+
{% endblock %}

0 commit comments

Comments
 (0)