Skip to content

Commit 34d9a36

Browse files
authored
Merge pull request #335 from sbs2001/revisit_ui
Improve UI
2 parents 1d7b64e + bce1194 commit 34d9a36

10 files changed

Lines changed: 139 additions & 134 deletions

File tree

vulnerabilities/forms.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727

2828
def get_package_types():
2929
pkg_types = [(i.type, i.type) for i in Package.objects.distinct("type").all()]
30-
pkg_types.append((None, "package type"))
30+
pkg_types.append((None, "Any type"))
3131
return pkg_types
3232

3333

@@ -44,10 +44,8 @@ def get_package_namespaces():
4444
class PackageForm(forms.Form):
4545

4646
type = forms.ChoiceField(choices=get_package_types)
47-
namespace = forms.ChoiceField(choices=get_package_namespaces, required=False)
48-
name = forms.CharField(widget=forms.TextInput(attrs={"placeholder": "package name"}))
49-
version = forms.CharField(
50-
widget=forms.TextInput(attrs={"placeholder": "package version"}), required=False
47+
name = forms.CharField(
48+
required=False, widget=forms.TextInput(attrs={"placeholder": "package name"})
5149
)
5250

5351

vulnerabilities/templates/base.html

Lines changed: 29 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -7,64 +7,65 @@
77
<link rel="stylesheet" href="{% static 'css/custom.css' %}"/>
88
<link rel="stylesheet" href="{% static 'css/font-awesome.css' %}"/>
99
<meta name="viewport" content="width=device-width, initial-scale=1">
10-
<body class="Site has-background-light">
11-
<nav class="navbar is-dark is-fixed-top" role="navigation" aria-label="main navigation">
10+
<body class="Site">
11+
<nav class="navbar is-light" role="navigation" aria-label="main navigation">
1212
<div class="navbar-menu">
1313
<div class="navbar-start">
1414
<a class="navbar-item" href="{% url 'home' %}">
15-
Home
15+
Home
1616
</a>
1717
<a class="navbar-item" href="{% url 'swagger-ui' %}">
18-
API Docs
18+
API Docs
1919
</a>
20+
{% if enable_curation %}
2021
<div class="navbar-item has-dropdown is-hoverable">
2122

2223
<a class="navbar-link">
23-
Vulnerabilities
24+
Vulnerabilities
2425
</a>
2526
<div class="navbar-dropdown">
2627
<a class ="navbar-item" href = "{% url 'vulnerability_search' %}" >
27-
Explore
28-
</a>
29-
<a class ="navbar-item" href = "{% url 'vulnerability_create' %}">
30-
Create
28+
Explore
3129
</a>
30+
31+
<a class ="navbar-item" href = "{% url 'vulnerability_create' %}">
32+
Create
33+
</a>
3234
</div>
3335
</div>
34-
36+
{% else %}
37+
<a class="navbar-item" href="{% url 'vulnerability_search' %}">
38+
Vulnerabilities
39+
</a>
40+
{% endif %}
41+
42+
{% if enable_curation %}
3543
<div class="navbar-item has-dropdown is-hoverable">
3644

3745
<a class="navbar-link">
38-
Packages
46+
Packages
3947
</a>
4048
<div class="navbar-dropdown">
4149
<a class ="navbar-item" href = "{% url 'package_search' %}" >
42-
Explore
43-
</a>
44-
<a class ="navbar-item" href = "{% url 'package_create' %}" >
45-
Create
50+
Explore
4651
</a>
52+
<a class ="navbar-item" href = "{% url 'package_create' %}" >
53+
Create
54+
</a>
4755
</div>
4856
</div>
57+
{% else %}
58+
<a class="navbar-item" href="{% url 'package_search' %}">
59+
Packages
60+
</a>
61+
{% endif %}
4962

5063
</div>
51-
<div class="navbar-end">
52-
<div class="navbar-item">
53-
<div class="buttons">
54-
<a class="button is-info">
55-
<strong>Sign up</strong>
56-
</a>
57-
<a class="button is-light">
58-
Log in
59-
</a>
60-
</div>
61-
</div>
62-
</div>
6364
</div>
6465
</nav>
6566
<main class="Site-content">
6667

67-
<section class="section is-medium has-text-centered">
68+
<section class="section is-small has-text-centered">
6869
<div class="container ">
6970
{% block title %}
7071
{% endblock %}

vulnerabilities/templates/index.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ <h1 class="title">
77
{% endblock %}
88

99
{% block content %}
10-
<div class = "hero is-large has-text-centered is-light">
11-
<a class="button is-medium has-background-info-light" href="{% url 'vulnerability_search' %}"> Search Vulnerabilities</a>
12-
<a class="button is-medium has-background-info-light" href="{% url 'package_search' %}"> Search Packages</a>
10+
<div class = "hero is-large has-text-centered">
11+
<a class="button is-medium has-background-light has-text-link" href="{% url 'vulnerability_search' %}"> Search Vulnerabilities</a>
12+
<a class="button is-medium has-background-light has-text-link" href="{% url 'package_search' %}"> Search Packages</a>
1313
</div>
1414
{% endblock %}

vulnerabilities/templates/package_update.html

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22
{% load widget_tweaks %}
33
{% block title %}
44
<h1 class="title">
5-
Curate : {{object}}
5+
{{object}}
66
</h1>
77
{% endblock %}
88

99
{% block content %}
1010
<div class="columns is-5 is-variable mx-6 mb-6">
1111
<div class="column is-half has-text-centered has-background-success-light">
12-
<form method="post" class="card has-background-success-light">
12+
<form method="post" class="card has-background-success-light m">
1313
<header class="card-header mb-3">
1414
<p class="card-header-title">
1515
Package Details
@@ -19,12 +19,14 @@ <h1 class="title">
1919
{% for field in form %}
2020
<div class="field px-3">
2121
<label class="label">{{field.label}}</label>
22-
{% render_field field class="input is-primary" %}
22+
{% render_field field|append_attr:"readonly:readonly" class="input is-primary" %}
2323
</div>
2424
{% endfor %}
25-
<button class="button is-success mb-3", type="submit">
26-
Update
27-
</button>
25+
{% if enable_curation %}
26+
<button class="button is-success mb-3", type="submit">
27+
Update
28+
</button>
29+
{% endif %}
2830
</form>
2931
</div>
3032

@@ -39,15 +41,17 @@ <h1 class="title">
3941
{% for vulnerability in impacted_vuln %}
4042
<span class="tag is-danger is-medium">
4143
<a href="{% url 'vulnerability_view' vulnerability.pk %}" class="has-text-white">{{vulnerability}}</a>
42-
43-
<form method="POST" action="{% url 'impacted_package_delete' object.pk vulnerability.pk %}"">
44-
{% csrf_token %}<button class="delete is-small" type="submit"></button>
45-
</form>
44+
{% if enable_curation %}
45+
<form method="POST" action="{% url 'impacted_package_delete' object.pk vulnerability.pk %}"">
46+
{% csrf_token %}<button class="delete is-small" type="submit"></button>
47+
</form>
48+
{% endif %}
4649
</span>
4750
{% endfor %}
4851
</div>
4952

5053
<div class="field is-centered">
54+
{% if enable_curation %}
5155
<p class="control pb-3">
5256
<a class="button is-success" href = "{% url 'impacted_package_create' object.pk %}">
5357
<span>Add</span>
@@ -56,6 +60,7 @@ <h1 class="title">
5660
</span>
5761
</a>
5862
</p>
63+
{% endif %}
5964
</div>
6065

6166
</div>
@@ -70,15 +75,18 @@ <h1 class="title">
7075
{% for vulnerability in resolved_vuln %}
7176
<span class="tag is-primary is-medium">
7277
<a href="{% url 'vulnerability_view' vulnerability.pk %}" class="has-text-white">{{vulnerability}}</a>
73-
78+
79+
{% if enable_curation %}
7480
<form method="POST" action="{% url 'resolved_package_delete' object.pk vulnerability.pk %}">
7581
{% csrf_token %}<button class="delete is-small" type="submit"></button>
7682
</form>
83+
{% endif %}
7784
</span>
7885
{% endfor %}
7986
</div>
8087

8188
<div class="field is-centered">
89+
{% if enable_curation %}
8290
<p class="control pb-3">
8391
<a class="button is-success" href= "{% url 'resolved_package_create' object.pk %}" >
8492
<span>Add</span>
@@ -87,6 +95,7 @@ <h1 class="title">
8795
</span>
8896
</a>
8997
</p>
98+
{% endif %}
9099
</div>
91100
</div>
92101
</div>

vulnerabilities/templates/packages.html

Lines changed: 24 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,49 @@
11
{% extends 'base.html' %}
22
{% block title %}
33
<h1 class="title">
4-
Explore/Curate Vulnerable packages
4+
Explore Vulnerable packages
55
</h1>
66
{% endblock %}
77
{% block content %}
88
{% load widget_tweaks %}
99

10-
<section class="columns has-text-centered">
11-
<div class = "column is-three-fifths is-offset-one-fifth">
12-
<form action="{% url 'package_search' %}" method="get">
13-
<div class="field is-horizontal">
14-
{% for field in form %}
15-
{{ field|add_class:"input" }}
16-
{% endfor %}
17-
<button class="button is-success" , type="submit">
18-
Search
19-
</button>
10+
<div class="columns">
11+
<div class="column is-one-third is-offset-one-third">
12+
<form action="{% url 'package_search' %}" method="get">
13+
{% load widget_tweaks %}
14+
<div class="field is-horizontal pd-3">
15+
<div class="select">
16+
{{form.type}}
17+
</div>
18+
{{form.name|add_class:"input"}}
19+
<button class="button is-success", type="submit">
20+
Search
21+
</button>
22+
</div>
2023
</form>
24+
{% if result_size %}
25+
<p class="has-text-centered" id="result_count">{{result_size}} results</p>
26+
{% elif result_size == 0 %}
27+
<p class="has-text-centered" id="result_count">No results found</p>
28+
{% endif %}
2129
</div>
22-
</div>
23-
24-
</section>
30+
</div>
2531

2632
{% if packages %}
2733

28-
<section class="section is-medium has-text-centered">
29-
<div class="container">
30-
<h1 class="title">Results of your query</h1>
31-
<h3 class="subtitle">Total Results {{ total_results }}</h3>
32-
</div>
33-
</section>
34-
35-
<section class="section has-background-dark">
34+
<section class="section">
3635
<div class="content is-medium">
3736
<table class="table is-bordered is-striped is-narrow is-hoverable is-fullwidth">
3837
<tr>
39-
<th>Packages</th>
40-
<th>Patched Vulnerabilities</th>
38+
<th>Package URL</th>
4139
<th>Vulnerabilities</th>
40+
<th>Patched Vulnerabilities</th>
4241
</tr>
4342
{% for package in packages %}
4443
<tr>
4544
<td><a href="{% url 'package_view' package.pk %}">{{package}}</a></td>
46-
<td>{{package.resolved_to.all|length}}</td>
4745
<td>{{package.vulnerable_to.all|length}}</td>
46+
<td>{{package.resolved_to.all|length}}</td>
4847
</tr>
4948
{% endfor %}
5049
</table>

vulnerabilities/templates/vulnerabilities.html

Lines changed: 14 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -8,41 +8,37 @@ <h1 class="title">
88

99
<div class="columns">
1010
<div class="column is-one-third is-offset-one-third">
11-
12-
<form action="{% url 'vulnerability_search' %}" method="get">
11+
<form action="{% url 'vulnerability_search' %}" method="get">
1312
{% load widget_tweaks %}
1413
<div class="field is-horizontal">
15-
{{form.vuln_id|add_class:"input"}}
14+
{% render_field form.vuln_id class="input"%}
1615
<button class="button is-success", type="submit">
1716
Search
1817
</button>
1918
</div>
20-
</form>
21-
</div>
19+
</form>
20+
{% if result_size %}
21+
<p class="has-text-centered" id="result_count">{{result_size}} results</p>
22+
{% elif result_size == 0 %}
23+
<p class="has-text-centered" id="result_count">No results found</p>
24+
{% endif %}
25+
</div>
2226
</div>
2327

2428
{% if vulnerabilities %}
25-
<section class="section is-medium has-text-centered">
26-
<div class="container">
27-
<h1 class="title" id="results">Results of your query "{{searched_for}}"</h1>
28-
<h3 class="subtitle" id="results">Total {{result_size}} results</h3>
29-
</div>
30-
</section>
31-
32-
<section class="section has-background-dark">
33-
29+
<section class="section">
3430
<div class="content is-large">
3531
<table class="table is-bordered is-striped is-narrow is-hoverable is-fullwidth">
3632
<tr>
37-
<th>Vulnerabilities</th>
38-
<th>Patched packages</th>
33+
<th>Vulnerability ID</th>
3934
<th>Vulnerable packages</th>
35+
<th>Patched packages</th>
4036
</tr>
4137
{% for vulnerability in vulnerabilities %}
4238
<tr>
4339
<td><a href="{% url 'vulnerability_view' vulnerability.pk %}">{{vulnerability.cve_id}}</a></td>
44-
<td>{{vulnerability.resolved_to.all|length}}</td>
4540
<td>{{vulnerability.vulnerable_to.all|length}}</td>
41+
<td>{{vulnerability.resolved_to.all|length}}</td>
4642
</tr>
4743
{% endfor %}
4844
</table>
@@ -60,13 +56,6 @@ <h3 class="subtitle" id="results">Total {{result_size}} results</h3>
6056

6157
</section>
6258

63-
{% elif result_size == 0 %}
64-
<section class="section is-medium has-text-centered">
65-
<div class="container">
66-
<h1 class="title" id="results">No result found for "{{searched_for}}"</h1>
67-
</div>
68-
</section>
69-
7059
{% endif %}
7160

72-
{% endblock %}
61+
{% endblock %}

0 commit comments

Comments
 (0)