Skip to content

Commit

Permalink
Report types listed in a modal @ report plugins (#3718)
Browse files Browse the repository at this point in the history
Co-authored-by: stephanie0x00 <[email protected]>
Co-authored-by: Jan Klopper <[email protected]>
  • Loading branch information
3 people authored Nov 20, 2024
1 parent 3592e41 commit 8f41293
Show file tree
Hide file tree
Showing 10 changed files with 126 additions and 31 deletions.
14 changes: 11 additions & 3 deletions rocky/assets/css/components/report.scss
Original file line number Diff line number Diff line change
Expand Up @@ -103,19 +103,27 @@

span {
&.label {
display: inline-flex;
max-width: 18.75rem;
border: 1px solid var(--colors-white);
border-radius: var(--spacing-grid-050);
padding: var(--spacing-grid-050) var(--spacing-grid-100);
font-size: var(--tile-font-size);
font-weight: var(--list-item-completed-font-weight);
margin: var(--spacing-grid-050) var(--spacing-grid-100)
var(--spacing-grid-050) 0;

&.tags-color-grey-2 {
color: var(--colors-grey-800);
background-color: var(--colors-grey-100);
}
}
}

.tile-report-types-link {
font-size: var(--tag-font-size);
text-decoration: none;
font-weight: 700;

.icon {
vertical-align: middle;
margin-left: 0.5rem;
}
}
25 changes: 25 additions & 0 deletions rocky/assets/css/themes/soft/manon/tags.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,28 @@
--tag-font-size: var(--body-text-small-font-size);
--tag-font-weight: bold;
}

ul {
&.tags {
display: inline-flex;
flex-direction: row;
flex-wrap: wrap;
gap: 0.5rem;
padding: 0;

li {
border: none;
padding: 0;

label {
margin-right: 0.5rem;
}

span {
padding: var(--tag-padding);
border-radius: var(--tag-border-radius);
line-height: var(--tag-line-height);
}
}
}
}
31 changes: 31 additions & 0 deletions rocky/katalogus/templates/partials/modal_report_types.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{% load i18n %}

<a href="#{{ plugin_id }}-report-types-modal"
class="tile-report-types-link">{% translate "Required for" %} {{ report_types|length }} {% translate "report types" %}<span aria-hidden="true" class="icon ti-chevron-right"></span></a>
{% with modal_id=plugin.id|add:"-report-types-modal" %}
{% component "modal" modal_id=modal_id size="dialog-medium" %}
{% fill "header" %}
{% translate "Report types for " %}{{ plugin.name }}
{% endfill %}
{% fill "content" %}
<section>
<div>
<ul class="tags report-types">
{% for plugin_id, report_types in plugin_report_types.items %}
{% if plugin_id == plugin.id %}
{% for report_type in report_types %}
<li>
<span class="tags-color-{{ report_type.label_style }}">{{ report_type.name }}</span>
</li>
{% endfor %}
{% endif %}
{% endfor %}
</ul>
</div>
</section>
{% endfill %}
{% fill "footer_buttons" %}
{% endfill %}
{% endcomponent %}
{% component_css_dependencies %}
{% endwith %}
27 changes: 16 additions & 11 deletions rocky/katalogus/templates/partials/plugin_tile.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,23 @@
{% endif %}
<span class="plugin-author-link de-emphasized"><a target="_blank" href="https://openkat.nl" rel="noopener noreferrer">OpenKAT</a></span>
{% if show_report_types %}
<div class="tags">
<p>
<strong>{% translate "Required for:" %}</strong>
</p>
{% for plugin_id, report_types in plugin_report_types.items %}
{% if plugin_id == plugin.id %}
{% for report_type in report_types %}
<span class="label tags-color-{{ report_type.label_style }}">{{ report_type.name }}</span>
{% endfor %}
{% for plugin_id, report_types in plugin_report_types.items %}
{% if plugin_id == plugin.id %}
{% if report_types|length >= 2 %}
{% include "partials/modal_report_types.html" with plugin=plugin %}

{% else %}
<ul class="tags report-types">
{% for report_type in report_types %}
<li>
<label for="report-types-required-for-plugin">{% translate "Required for:" %}</label>
<span class="tags-color-{{ report_type.label_style }}">{{ report_type.name }}</span>
</li>
{% endfor %}
</ul>
{% endif %}
{% endfor %}
</div>
{% endif %}
{% endfor %}
{% endif %}
{% if not remove_action_buttons %}
<div class="action-buttons">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ <h3 id="selected-report-types">{% translate "Selected Report Types" %} ({{ repor
<tr>
<td class="nowrap">
<ul class="tags horizontal-view">
<li class="label tags-color-{{ report_type.label_style }}">{{ report_type.name }}</li>
<li>
<span class="label tags-color-{{ report_type.label_style }}">{{ report_type.name }}</span>
</li>
</ul>
</td>
<td>{{ report_type.description }}</td>
Expand Down
20 changes: 13 additions & 7 deletions rocky/reports/templates/report_overview/report_history_table.html
Original file line number Diff line number Diff line change
Expand Up @@ -107,15 +107,19 @@
{% if report.parent_report.report_type == "concatenated-report" or report.parent_report.report_type is None %}
{% for report_type, total_objects in report.report_type_summary.items %}
{% if forloop.counter0 < 2 %}
<li class="label tags-color-{{ report_type|get_report_type_label_style }}">{{ report_type|get_report_type_name }}</li>
<li>
<span class="label tags-color-{{ report_type|get_report_type_label_style }}">{{ report_type|get_report_type_name }}</span>
</li>
{% endif %}
{% if forloop.counter0 == 2 %}
<li class="label tags-color-grey-2">+ {{ report.report_type_summary|length|add:"-2" }}</li>
<li>
<span class="label tags-color-grey-2">+ {{ report.report_type_summary|length|add:"-2" }}</span>
</li>
{% endif %}
{% endfor %}
{% else %}
<li class="label tags-color-{{ report.parent_report.report_type|get_report_type_label_style }}">
{{ report.parent_report.report_type|get_report_type_name }}
<li>
<span class="label tags-color-{{ report.parent_report.report_type|get_report_type_label_style }}">{{ report.parent_report.report_type|get_report_type_name }}</span>
</li>
{% endif %}
</ul>
Expand Down Expand Up @@ -168,7 +172,9 @@ <h5>{% translate "Report types" %}</h5>
<tr>
<td>
<ul class="tags horizontal-view">
<li class="label tags-color-{{ report_type|get_report_type_label_style }}">{{ report_type|get_report_type_name }}</li>
<li>
<span class="label tags-color-{{ report_type|get_report_type_label_style }}">{{ report_type|get_report_type_name }}</span>
</li>
</ul>
</td>
<td>{{ total_objects }}</td>
Expand All @@ -193,8 +199,8 @@ <h5>
<tr>
<td>
<ul class="tags horizontal-view">
<li class="label tags-color-{{ child_report.report_type|get_report_type_label_style }}">
{{ child_report.report_type|get_report_type_name }}
<li>
<span class="label tags-color-{{ child_report.report_type|get_report_type_label_style }}">{{ child_report.report_type|get_report_type_name }}</span>
</li>
</ul>
</td>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,20 @@
<td>
<ul class="tags horizontal-view">
{% if schedule.recipe.parent_report_type == "aggregate-organisation-report" %}
<li class="label tags-color-{{ schedule.recipe.parent_report_type|get_report_type_label_style }}">
{{ schedule.recipe.parent_report_type|get_report_type_name }}
<li>
<span class="label tags-color-{{ schedule.recipe.parent_report_type|get_report_type_label_style }}">{{ schedule.recipe.parent_report_type|get_report_type_name }}</span>
</li>
{% else %}
{% for report_type in schedule.recipe.report_types %}
{% if forloop.counter0 < 2 %}
<li class="label tags-color-{{ report_type|get_report_type_label_style }}">{{ report_type|get_report_type_name }}</li>
<li>
<span class="label tags-color-{{ report_type|get_report_type_label_style }}">{{ report_type|get_report_type_name }}</span>
</li>
{% endif %}
{% if forloop.counter0 == 2 %}
<li class="label tags-color-grey-2">+ {{ schedule.recipe.report_types|length|add:"-2" }}</li>
<li>
<span class="label tags-color-grey-2">+ {{ schedule.recipe.report_types|length|add:"-2" }}</span>
</li>
{% endif %}
{% endfor %}
{% endif %}
Expand Down
4 changes: 2 additions & 2 deletions rocky/reports/templates/report_overview/subreports_table.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
</td>
<td>
<ul class="tags horizontal-view">
<li class="label tags-color-{{ subreport.report_type|get_report_type_label_style }}">
{{ subreport.report_type|get_report_type_name }}
<li>
<span class="label tags-color-{{ subreport.report_type|get_report_type_label_style }}">{{ subreport.report_type|get_report_type_name }}</span>
</li>
</ul>
</td>
Expand Down
4 changes: 3 additions & 1 deletion rocky/reports/templates/summary/report_asset_overview.html
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ <h3>{% translate "Selected Report Types" %} ({{ report_types|length }})</h3>
<tr>
<td>
<ul class="tags horizontal-view">
<li class="label tags-color-{{ report_type.label_style }}">{{ report_type.name }}</li>
<li>
<span class="label tags-color-{{ report_type.label_style }}">{{ report_type.name }}</span>
</li>
</ul>
</td>
<td>{{ report_type.description }}</td>
Expand Down
16 changes: 14 additions & 2 deletions rocky/rocky/locale/django.pot
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-11-12 15:31+0000\n"
"POT-Creation-Date: 2024-11-18 15:24+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
Expand Down Expand Up @@ -1019,6 +1019,18 @@ msgstr ""
msgid "Tableview"
msgstr ""

#: katalogus/templates/partials/modal_report_types.html
msgid "Required for"
msgstr ""

#: katalogus/templates/partials/modal_report_types.html
msgid "report types"
msgstr ""

#: katalogus/templates/partials/modal_report_types.html
msgid "Report types for "
msgstr ""

#: katalogus/templates/partials/objects_to_scan.html
#: rocky/templates/findings/finding_list.html
#: rocky/templates/forms/widgets/checkbox_group_table.html
Expand Down Expand Up @@ -4479,7 +4491,7 @@ msgstr ""

#: reports/views/report_overview.py
msgid ""
"Multiorganization report cannot go through a rerun. It consists of imported "
"Multi organization reports cannot be rescheduled. It consists of imported "
"data from different organizations and not based on new generated data."
msgstr ""

Expand Down

0 comments on commit 8f41293

Please sign in to comment.