Skip to content

Commit

Permalink
fix: risk assessment pdf export
Browse files Browse the repository at this point in the history
  • Loading branch information
Mohamed-Hacene committed May 17, 2024
1 parent 50a231f commit 1335193
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 23 deletions.
9 changes: 9 additions & 0 deletions backend/core/templates/core/base_pdf.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
.flex {
display: flex;
}
.flex-row {
flex-direction: row;
}
.table {
display: table;
}
Expand Down Expand Up @@ -234,6 +237,9 @@
.ml-3 {
margin-left: 0.75rem;
}
.ml-13 {
margin-left: 3.25rem;
}
.p-1 {
padding: 0.25rem;
}
Expand Down Expand Up @@ -267,6 +273,9 @@
.mt-10 {
margin-top: 2.5rem;
}
.mt-45{
margin-top: 11.25rem;
}

.justify-center {
justify-content: center;
Expand Down
31 changes: 21 additions & 10 deletions backend/core/templates/snippets/ra_data.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,43 @@
<main class="flex-grow main">
<!--Information banner-->
<div class="">
<div class="bg-white py-4 px-12 m-4 shadow rounded-lg flex space-x-2 relative">
<div class="container w-1/3 ">
<div class="bg-white py-4 px-12 m-4 shadow rounded-lg flex flex-row space-x-2 relative">
<div class="container w-1/3">
<div class="text-sm font-semibold ">{% trans "Risk assessment" %}</div>
<div id="name" class="text-lg font-semibold ">{{ risk_assessment }}</div>
<div id="name" class="text-base font-semibold ">{{ risk_assessment }}</div>
<br>
<div class="text-sm">
<ul class="">
<li class="pb-1"><span class="font-semibold">{% trans "Risk matrix:" %}</span>
<ul>
<li>{{ risk_assessment.risk_matrix }}</li>
</ul>
</li>
<li class="pb-1"><span class="font-semibold">{% trans "Authors:" %}</span>
<ul>
{% for author in risk_assessment.authors.all %}
<li>{{ author }}</li>
{% endfor %}
</ul>
</li>
<li class="pb-1"><span class="font-semibold">{% trans "Status:" %}</span> {% if risk_assessment.is_draft %}
<span class="bg-blue-200 py-1 px-2 rounded-lg">{% trans "Draft" %}</span> {% else %} <span class="bg-green-200 py-1 px-2 rounded-lg">{% trans "Ready" %} </span>{% endif %}
<li class="pb-1"><span class="font-semibold">{% trans "Reviewers:" %}</span>
<ul>
{% for author in risk_assessment.reviewers.all %}
<li>{{ author }}</li>
{% endfor %}
</ul>
</li>
<li class="pb-1"><span class="font-semibold">{% trans "Status:" %}</span>
{% if risk_assessment.status %} {{risk_assessment.status}} {% else %} -- {% endif %}
</li>
<li class="pb-1"><span class="font-semibold">{% trans "ETA:" %}</span> {{ risk_assessment.eta|date }}</li>
<li class="pb-1"><span class="font-semibold">{% trans "Due date:" %}</span> {{ risk_assessment.due_date|date }}</li>
<li class="pb-1"><span class="font-semibold">{% trans "Created at:" %}</span> {{ risk_assessment.created_at|date }}</li>
<li class="pb-1"><span class="font-semibold">{% trans "Updated at:" %}</span> {{ risk_assessment.updated_at|date }}</li>
</ul>
</div>
</div>
<div class="container w-2/3 rounded">
<div class="text-sm"><span class="font-semibold">{% trans "Risk matrix:" %}</span> <p>{{ risk_assessment.risk_matrix }}</p>
</div>
<br>
<div class="text-sm"><span class="font-semibold">{% trans "Description" %}:</div>
<div class="text-sm"> {% if risk_assessment.description %}{{ risk_assessment.description|linebreaksbr }}{% endif %}</div>
</div>
Expand All @@ -37,12 +48,12 @@
</div>
<!--Risk risk_assessment-->
<div class="m-4 px-4 py-10 shadow rounded-lg bg-white">
<div class="text-lg pb-2"> {% trans "Risk scenarios" %} ({{ context|length }})</div>
<p class="text-lg font-semibold pb-2"> {% trans "Associated Risk scenarios" %} ({{ context|length }}):</p>
{% include 'snippets/ri_list_nested.html' %}
</div>
<!--Risk matrix view-->
<div class="m-4 px-4 py-8 shadow rounded-lg bg-white page-break">
<div class="text-xl pb-4">{% trans "Risk matrix view" %}</div>
<div class="text-xl pb-4 font-semibold">{% trans "Risk matrix view" %}</div>
<div class="flex space-x-3">
<div class="w-1/2 shadow rounded-lg p-6">
<h3 class="font-bold p-2 m-2 text-lg">{% trans "Current" %}</h3>
Expand Down
20 changes: 15 additions & 5 deletions backend/core/templates/snippets/ri_list_nested.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
{% load i18n %}
{% load static tailwind_tags %}

<table class="min-w-full leading-normal">
<style>
th, td {
border: 1px solid black;
}
</style>

<table class="w-full p-4 leading-normal">
<thead>
<th class="px-4 py-3 border-b border-gray-200 bg-white text-left text-xs font-semibold text-gray-600 uppercase tracking-wider">
{% trans "ID" %}
Expand Down Expand Up @@ -30,7 +36,7 @@
</thead>
<tbody>
{% for scenario in scenarios %}
<tr class="hover:text-indigo-500 cursor-pointer hover:scale-[0.99] duration-500">
<tr class="hover:text-indigo-500 cursor-pointer hover:scale-[0.99] duration-500 text-center">
<td class="px-5 py-5 border-b border-gray-200 text-sm">
{{ scenario.rid }}
</td>
Expand All @@ -45,9 +51,13 @@
</div>
</td>
<td class="px-4 py-5 border-b border-gray-200 text-sm">
<p class="whitespace-no-wrap">
{% if scenario.threat %}{{ scenario.threat }}{% else %}--{% endif %}
</p>
{% for threat in scenario.threats.all %}
<p class="whitespace-no-wrap">
{{ threat }}
</p>
{% empty %}
--
{% endfor %}
</td>
<td class="px-4 py-5 border-b border-gray-200 text-sm">
<p class="max-h-64 max-w-full box overflow-hidden">{{ scenario.existing_controls|linebreaksbr }}</p>
Expand Down
16 changes: 8 additions & 8 deletions backend/core/templates/snippets/risk_matrix.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,18 +41,18 @@
</div>
{% else %}
<div class="w-full">
<div class="flex flex-row justify-center">
<div class="text-black font-bold text-center print-impact flex items-center">
<div class="flex flex-row h-full">
<div class="text-black font-bold mt-45">
<p class="-rotate-90">{% trans "Probability" %}</p>
</div>
<table class="w-3/4 mt-10">
<table class="w-3/4 mt-10 ml-13">
{% for row in risk_matrix.render_grid_as_colors reversed %}
{% with row_index=forloop.revcounter0 %}
<tr>
<td class="w-1/6 text-center text-black bg-gray-200 border-4 border-white pr-2">
{% with impact=risk_matrix.parse_json.impact|index:row_index %}
{{ impact.name }}:
{{ impact.description|linebreaksbr }}
{% with probability=risk_matrix.parse_json.probability|index:row_index %}
{{ probability.name }}:
{{ probability.description|linebreaksbr }}
{% endwith %}
</td>
{% if enriched_data %}
Expand All @@ -73,14 +73,14 @@
{% endfor %}
<tr>
<td></td>
{% for probability in risk_matrix.parse_json.probability %}
{% for impact in risk_matrix.parse_json.impact %}
<td class="w-1/6 h-16 text-center text-black bg-gray-200 border-4 border-white">
{{ impact.name }}:
{{ impact.description|linebreaksbr }}
</td>
{% endfor %}
</tr>
</table>
</table>
</div>
<div class="text-black font-bold text-center mx-auto mt-4">
{% trans "Impact" %}
Expand Down

0 comments on commit 1335193

Please sign in to comment.