File tree Expand file tree Collapse file tree 2 files changed +66
-0
lines changed
Expand file tree Collapse file tree 2 files changed +66
-0
lines changed Original file line number Diff line number Diff line change 44from flask import render_template , Blueprint
55
66from models .host import Host
7+ from models .image import Image
78
89frontend = 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 )
Original file line number Diff line number Diff line change 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 %}
You can’t perform that action at this time.
0 commit comments