Skip to content

Commit 9c25575

Browse files
committed
Improved UI, Changed Scan Path
* Dropdown cards work well in the details page * Re-arranged html code * Changed Scan path from /scan/ to /scantext/ Signed-off-by: Akhil Raj <lf32.dev@gmail.com>
1 parent 4c1483a commit 9c25575

File tree

10 files changed

+938
-325
lines changed

10 files changed

+938
-325
lines changed

scancodeio/settings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
ALLOWED_HOSTS = env.list("ALLOWED_HOSTS", default=[".localhost", "127.0.0.1", "[::1]"])
4646

4747
# SECURITY WARNING: don't run with debug turned on in production
48-
DEBUG = env.bool("SCANCODEIO_DEBUG", default=True)
48+
DEBUG = env.bool("SCANCODEIO_DEBUG", default=False)
4949

5050
SCANCODEIO_REQUIRE_AUTHENTICATION = env.bool(
5151
"SCANCODEIO_REQUIRE_AUTHENTICATION", default=False

scancodeio/urls.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
path("admin/", admin.site.urls),
5353
path("api/", include(api_router.urls)),
5454
path("license/", include(licenses.urls)),
55-
path("scan/", include("scantext.urls")),
55+
path("scantext/", include("scantext.urls")),
5656
path("", include("scanpipe.urls")),
5757
path("", RedirectView.as_view(url="project/")),
5858
]

scantext/forms.py

Lines changed: 8 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -27,38 +27,16 @@ class EditorForm(forms.Form):
2727
input_text = forms.CharField(
2828
widget=forms.Textarea(
2929
attrs={
30-
"rows": 30,
30+
"rows": 25,
3131
"class": "textarea has-fixed-size",
3232
"placeholder": "Paste your license text here.",
3333
}
3434
),
35-
required=True,
35+
required=False,
36+
)
37+
input_file = forms.FileField(
38+
required=False,
39+
widget=forms.ClearableFileInput(
40+
attrs={"class": "file-input", "multiple": False},
41+
),
3642
)
37-
38-
# def clean_input_text(self):
39-
# input_text = self.cleaned_data.get("input_text")
40-
# return " ".join(input_text.split())
41-
42-
# def save(self, *args, **kwargs):
43-
# license = super().save(*args, **kwargs)
44-
# self.handle_input(license)
45-
# return license
46-
47-
# class Media:
48-
# js = ("add-inputs.js",)
49-
50-
# def handle_inputs(self, project):
51-
# input_file = self.files.getlist("input_files")
52-
# input_text = self.cleaned_data.get("input_text")
53-
# print(input_text)
54-
# if input_file:
55-
# license.add_uploads(input_file)
56-
# elif input_text:
57-
# license.add_license(input_text)
58-
59-
# input_files = forms.FileField(
60-
# required=False,
61-
# widget=forms.ClearableFileInput(
62-
# attrs={"class": "file-input", "multiple": False},
63-
# ),
64-
# )
Lines changed: 22 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,27 @@
11
{% load humanize %}
22
<nav class="level is-mobile">
3-
<div class="level-item has-text-centered">
4-
<div>
5-
<p class="heading">Percentage Of License Text</p>
6-
<p class="title">
7-
<span>
8-
{{ expr.percentage_of_license_text }}
9-
</span>
10-
</p>
3+
<div class="level-item has-text-centered">
4+
<div>
5+
<p class="heading">Percentage Of License Text</p>
6+
<p class="title">
7+
<span>{{ expr.percentage_of_license_text }}</span>
8+
</p>
9+
</div>
1110
</div>
12-
</div>
13-
<div class="level-item has-text-centered">
14-
<div>
15-
<p class="heading">License Expressions</p>
16-
<p class="title">
17-
<span>
18-
{{ expr.license_expressions | length }}
19-
20-
</span>
21-
</p>
11+
<div class="level-item has-text-centered">
12+
<div>
13+
<p class="heading">License Expressions</p>
14+
<p class="title">
15+
<span>{{ expr.license_expressions|length }}</span>
16+
</p>
17+
</div>
2218
</div>
23-
</div>
24-
<div class="level-item has-text-centered">
25-
<div>
26-
<p class="heading">Licenses</p>
27-
<p class="title">
28-
<span>
29-
{{ expr.licenses | length }}
30-
31-
</span>
32-
</p>
19+
<div class="level-item has-text-centered">
20+
<div>
21+
<p class="heading">Licenses</p>
22+
<p class="title">
23+
<span>{{ expr.licenses|length }}</span>
24+
</p>
25+
</div>
3326
</div>
34-
</div>
35-
</nav>
27+
</nav>
Lines changed: 75 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -1,107 +1,99 @@
1-
{% extends 'scanpipe/base.html' %}
2-
{% load static humanize %}
3-
4-
5-
{% block extrahead %}
6-
<link rel="stylesheet" href="{% static 'billboard-3.0.1-datalab.min.css' %}" crossorigin="anonymous" />
7-
{% endblock %}
1+
{% extends 'scanpipe/base.html' %}
2+
{% load static humanize %}
83

94
{% block content %}
105
<div class="container is-widescreen">
116
{% include 'scanpipe/includes/navbar_header.html' %}
127
<div class="mx-5 mb-2">{% include 'scanpipe/includes/messages.html' %}</div>
138

14-
<section class="section pt-0">
15-
<div class="is-flex is-justify-content-space-between mb-2">
16-
<div class="mb-2">
17-
<h1 class="title is-4">License Detection Summary</h1>
18-
</div>
19-
<div>
20-
<a href="{% url 'license_scan' %}" class="button is-link">
21-
Scan Again
22-
</a>
9+
<section class="section p-0">
10+
<div class="is-flex is-justify-content-space-between is-align-items-center mb-2">
11+
<div class="mb-2">
12+
<h1 class="title is-4">License Detection Summary</h1>
13+
</div>
14+
<div>
15+
<a href="{% url 'license_scan' %}" class="button is-link">Scan Again</a>
16+
</div>
2317
</div>
24-
</div>
2518
</section>
2619

2720
<hr class="mx-5">
2821
{% include "scantext/includes/license_summary_level.html" with expr=expr %}
29-
3022
<hr class="mx-5">
3123

32-
<div class="columns">
24+
<div class="columns mb-5">
3325
<div class="column is-half">
34-
<p class="title is-4">Input License Text</p>
35-
<div class="box">
36-
{% for line in text %}
37-
<p>{{line}}</p>
38-
{% endfor %}
39-
</div>
26+
<p class="title is-4">Input License Text</p>
27+
<pre>{{ text }}</pre>
4028
</div>
4129
<div class="column is-half">
42-
<p class="title is-4">Detected License Errors</p>
43-
44-
{% for license in expr.licenses %}
45-
46-
<div class="card">
47-
<div class="card-header">
48-
<div class="card-header-title">
49-
<a class="" href="{{license.homepage_url}}" title="{{license.short_name}}">{{license.name| center:"15"}}</a>
50-
<p class="tag is-6 mx-1 is-light
51-
{% if license.score == 100 %}
52-
is-success
53-
{% else %}
54-
is-warning
55-
{% endif %}
56-
">{{license.score}}</p>
57-
<p class="tag is-6 mx-1 is-light is-info">
58-
{% if license.start_line == license.end_line %}
59-
Line {{license.start_line}}
60-
{% else %}
61-
Lines {{license.start_line}} - {{license.end_line}}
62-
{% endif %}
63-
</p>
64-
<p class="tag is-6 mx-1 is-light is-primary">{{license.category}}</p>
65-
</div>
66-
<p class="card-header-icon" aria-label="more options">
67-
<span class="icon">
68-
<i class="fas fa-angle-down" aria-hidden="true"></i>
69-
</span>
70-
</p>
71-
</div>
72-
{% if license.score < 100 %}
73-
<div class="card-content">
74-
<p class="subtitle is-5">Recommended License</p>
75-
<p class="content">{{license}}</p>
76-
</div>
77-
{% endif %}
30+
<p class="title is-4">Detected Licenses</p>
31+
<div class="card">
32+
{% for license in expr.licenses %}
33+
<div class="licenses-card">
34+
<div class="card-header is-flex is-justify-content-space-between">
35+
<div class="card-header-title" title="{{ license.short_name }}">
36+
{% if license.homepage_url %}
37+
<a href="{{ license.homepage_url }}">{{ license.name }}</a>
38+
{% else %} {{ license.name }} {% endif %}
39+
</div>
40+
<div class="is-flex is-justify-content-row is-align-items-center">
41+
<p class="lines tag is-6 mx-1 is-light is-info">
42+
{% if license.start_line == license.end_line %} Line {{ license.start_line }} {% else %} Lines {{ license.start_line }} - {{ license.end_line }} {% endif %}
43+
</p>
44+
<p class="tag is-6 mx-1 is-light
45+
{% if license.score == 100 %} is-success {% else %} is-warning {% endif %}">{{ license.score }}</p>
46+
<p class="card-header-icon" aria-label="more options">
47+
<span class="icon">
48+
<i class="fas fa-angle-down" aria-hidden="true"></i>
49+
</span>
50+
</p>
51+
</div>
52+
</div>
53+
<div class="card-content is-hidden">
54+
<div class="content">
55+
<div class="is-flex is-justify-content-space-between">
56+
<div>
57+
<p class="subtitle is-5">Matched Text</p>
58+
</div>
59+
<div>
60+
<p class="tag is-6 mx-1 is-light is-primary">{{ license.category }}</p>
61+
<a class="tag is-6 mx-1 is-light is-link" href="{{ license.reference_url }}">ref</a>
62+
<p class="tag is-6 mx-1 is-light is-info">
63+
{% if license.start_line == license.end_line %} Line {{ license.start_line }} {% else %} Lines {{ license.start_line }} - {{ license.end_line }} {% endif %}
64+
</p>
65+
</div>
66+
</div>
67+
<pre>{{ license.matched_text }}</pre>
68+
</div>
69+
</div>
70+
</div>
71+
{% endfor %}
72+
</div>
7873
</div>
79-
<br>
80-
{% endfor %}
81-
</div>
8274
</div>
75+
8376
</div>
84-
{% endblock %}
77+
{% endblock %}
8578

8679
{% block scripts %}
8780
<script type="text/javascript">
88-
const cards = document.querySelectorAll('.card')
89-
90-
// const cardsicons = document.querySelectorAll('.card-header-icon')
91-
// cardsicons.forEach(icon => {
92-
// icon.addEventListener('click', (e, index) => {
93-
// e.preventDefault();
94-
// removeActiveCards();
95-
// console.log(e)
96-
// console.log(index)
97-
// icon.parentNode.parentNode.parentNode.querySelector('.card-content').style.display="visible"
98-
// })
99-
// })
100-
101-
// function removeActiveCards() {
102-
// cards.forEach(card => {
103-
// card.parentNode.parentNode.parentNode.querySelector('.card-content').style.display="none"
104-
// })
105-
// }
81+
const cards = document.querySelectorAll('.card-header-icon')
82+
83+
cards.forEach(card => {
84+
card.addEventListener('click', (event) => {
85+
event.preventDefault()
86+
content = card.parentElement.parentElement.parentElement.querySelector('.card-content').classList
87+
lineTag= card.parentElement.querySelector('.lines').classList
88+
if (content.contains('is-hidden')) {
89+
content.remove('is-hidden')
90+
lineTag.add('is-hidden')
91+
} else {
92+
content.add('is-hidden')
93+
lineTag.remove('is-hidden')
94+
}
95+
})
96+
})
97+
10698
</script>
10799
{% endblock %}

0 commit comments

Comments
 (0)