Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Translate/last pages #83

Merged
merged 15 commits into from
Feb 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion backend/core/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -803,6 +803,7 @@ def compile_risk_assessment_for_composer(user, risk_assessment_list: list):
v = {"value": count, "itemStyle": {"color": STATUS_COLOR_MAP[st[0]]}}
values.append(v)
labels.append(st[1])
local_lables = [camel_case(str(l)) for l in labels]

risk_assessment_objects = list()

Expand Down Expand Up @@ -843,6 +844,6 @@ def compile_risk_assessment_for_composer(user, risk_assessment_list: list):
"untreated_h_vh": untreated_h_vh,
"accepted": accepted,
},
"security_measure_status": {"labels": labels, "values": values},
"security_measure_status": {"localLables":local_lables, "labels": labels, "values": values},
"colors": get_risk_color_ordered_list(user, risk_assessment_list),
}
31 changes: 29 additions & 2 deletions frontend/messages/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"governance": "Governance",
"risk": "Risk",
"compliance": "Compliance",
"organization": "Organisation",
"organization": "Organization",
"extra": "Extra",
"analytics": "Analytics",
"calendar": "Calendar",
Expand Down Expand Up @@ -224,6 +224,7 @@
"infosFound": "info{s} found",
"remediationPlan": "Remediation plan",
"treatmentPlan": "Treatment plan",
"plan": "Plan",
"asPDF": "as PDF",
"asCSV": "as CSV",
"draft": "Draft",
Expand Down Expand Up @@ -338,5 +339,31 @@
"dependencies": "Dependencies",
"copyright": "Copyright",
"uploadYourLibrary": "Upload your own library",
"libraryFileInYaml": "Library file in YAML format"
"libraryFileInYaml": "Library file in YAML format",
"scope": "Scope",
"auditor": "Auditor",
"lastUpdate": "Last update",
"riskScenarioAssetHelpText": "Assets impacted by this risk scenario",
"riskScenarioMeasureHelpText": "The existing security measures to manage this risk",
"currentAssessment": "Current assessment",
"targetAssessment": "Target assessment",
"currentRiskLevel": "Current risk level",
"residualRiskLevel": "Residual risk level",
"currentRiskLevelHelpText": "The risk level given the current measures",
"residualRiskLevelHelpText": "The risk level when all the extra measures are done",
"yourSelection": "Your selection",
"composerHint": "Hint: you can bookmark this page for future usage",
"composerTitle": "Here is the overview for the selected risk assessment",
"composerTitlePlural": "Here is the overview for the {number} selected risk assessments",
"statusOfAssociatedMeasures": "Status of associated measures",
"forTheSelectedScope": "For the selected scope, you have",
"untreatedRiskScenarios": "{count} untreated risk scenario{s}",
"acceptedRiskScenarios": "{count} accepted risk scenario{s}",
"reviewNeeded": "Review needed",
"ok": "Ok",
"inconsistenciesFoundComposer": "Found {count} inconsistenc{plural}. For more details, check",
"current": "Current",
"residual": "Residual",
"jumpToRiskAssessment": "Jump to risk assessment",
"additionalMeasures": "Additional measures"
}
31 changes: 29 additions & 2 deletions frontend/messages/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@
"statistics": "Statistiques",
"myProjects": "Mes projets",
"scenarios": "Scénarios",
"assignedProjects": "Assigné à {number} project{s}",
"assignedProjects": "Assigné à {number} projet{s}",
"currentRiskLevelPerScenario": "Niveau de risque courant par scénario de risque",
"residualRiskLevelPerScenario": "Niveau de risque résiduel par scénario de risque",
"securityMeasuresStatus": "Statut des mesures de sécurité",
Expand Down Expand Up @@ -224,6 +224,7 @@
"infosFound": "info{s} trouvée{s}",
"remediationPlan": "Plan de remédiation",
"treatmentPlan": "Plan de traitement",
"plan": "Plan",
"asPDF": "en PDF",
"asCSV": "en CSV",
"draft": "Brouillon",
Expand Down Expand Up @@ -338,5 +339,31 @@
"dependencies": "Dépendances",
"copyright": "Droits d'auteur",
"uploadYourLibrary": "Téléchargez votre propre bibliothèque",
"libraryFileInYaml": "Fichier de librairie en format YAML"
"libraryFileInYaml": "Fichier de librairie en format YAML",
"scope": "Périmètre",
"auditor": "Auditeur",
"lastUpdate": "Dernière mise à jour",
"riskScenarioAssetHelpText": "Biens sensibles impactés par ce scénario de risque",
"riskScenarioMeasureHelpText": "Les mesures de sécurité existantes pour gérer ce risque",
"currentAssessment": "Évaluation actuelle",
"targetAssessment": "Évaluation cible",
"currentRiskLevel": "Niveau de risque courrant",
"residualRiskLevel": "Niveau de risque résiduel",
"currentRiskLevelHelpText": "Le niveau de risque compte tenu des mesures actuelles",
"residualRiskLevelHelpText": "Le niveau de risque lorsque toutes les mesures supplémentaires sont prises",
"yourSelection": "Votre sélection",
"composerHint": "Astuce : vous pouvez ajouter cette page à vos favoris pour une utilisation future",
"composerTitle": "Voici l’aperçu de l’évaluation de risque sélectionnée",
"composerTitlePlural": "Voici l'aperçu des {number} évaluations de risques sélectionnées",
"statusOfAssociatedMeasures": "Statut des mesures associées",
"forTheSelectedScope": "Pour le périmètre sélectionné, vous avez",
"untreatedRiskScenarios": "{count} scénario{s} de risque non traité{s}",
"acceptedRiskScenarios": "{count} scénario{s} de risque accepté{s}",
"reviewNeeded": "Révision nécessaire",
"ok": "Ok",
"inconsistenciesFoundComposer": "Il y a {count} incohérence{s}. Pour plus de détail, vérifiez",
"current": "Courrant",
"residual": "Résiduel",
"jumpToRiskAssessment": "Passer à l'évaluation des risques",
"additionalMeasures": "Mesures supplémentaires"
}
12 changes: 7 additions & 5 deletions frontend/src/lib/components/Breadcrumbs/Breadcrumbs.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,17 @@
crumbs = tokens.map((t) => {
tokenPath += '/' + t;
if (t === $breadcrumbObject.id) {
if ($breadcrumbObject.name) title = $breadcrumbObject.name;
else title = $breadcrumbObject.email;
if ($breadcrumbObject.name) t = $breadcrumbObject.name;
else t = $breadcrumbObject.email;
} else if (t === 'folders') {
t = 'domains';
}
t = t.replace(/-/g, ' ');
t = capitalizeSecondWord(t);
else{
t = t.replace(/-/g, ' ');
t = capitalizeSecondWord(t);
}
return {
label: $page.data.label || title || t,
label: $page.data.label || t,
href: Object.keys(listViewFields).includes(tokens[0]) ? tokenPath : null
};
});
Expand Down
4 changes: 3 additions & 1 deletion frontend/src/lib/utils/locales.ts
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,9 @@ export function localItems(languageTag: string): LocalItems {
lossOfAccountabilityText: m.lossOfAccountabilityText({ languageTag: languageTag }),
lossOfAccountabilityChoice1: m.lossOfAccountabilityChoice1({ languageTag: languageTag }),
lossOfAccountabilityChoice2: m.lossOfAccountabilityChoice2({ languageTag: languageTag }),
lossOfAccountabilityChoice3: m.lossOfAccountabilityChoice3({ languageTag: languageTag })
lossOfAccountabilityChoice3: m.lossOfAccountabilityChoice3({ languageTag: languageTag }),
composer: m.composer({ languageTag: languageTag }),
plan: m.plan({ languageTag: languageTag }),
};
return LOCAL_ITEMS;
}
68 changes: 41 additions & 27 deletions frontend/src/routes/(app)/analytics/composer/+page.svelte
Original file line number Diff line number Diff line change
@@ -1,44 +1,55 @@
<script lang="ts">
import DonutChart from '$lib/components/Chart/DonutChart.svelte';
import BarChart from '$lib/components/Chart/BarChart.svelte';
import * as m from '$paraglide/messages';
import {localItems} from '$lib/utils/locales';
import {languageTag} from '$paraglide/runtime';
import type { SecurityMeasureStatus } from '$lib/utils/types';
import { RISK_COLOR_PALETTE } from '$lib/utils/constants.js';
export let data;
data.risk_assessment_objects.forEach((risk_assessment: Record<string, any>) => {
risk_assessment.show = false;
});
let security_measure_status: SecurityMeasureStatus = data.security_measure_status;
for (const item in security_measure_status.labels) {
security_measure_status.labels[item] = localItems(languageTag())[
security_measure_status.localLables[item]
];
}
</script>

<div class="flex flex-col space-y-4">
<div>
<div class="px-2 mx-2 font-semibold text-xl">Your selection</div>
<div class="px-2 mx-2 font-semibold text-xl">{m.yourSelection()}</div>
<div class="px-2 mx-2 text-sm">
<i class="fa-solid fa-info-circle mr-2" />Hint: you can bookmark this page for future usage
<i class="fa-solid fa-info-circle mr-2" />{m.composerHint()}
</div>
</div>
<div class="card p-4 bg-white shadow">
<div class="p-2 font-semibold text-lg">
Here is the overview for the {data.risk_assessment_objects.length <= 1
? 'selected risk_assessment'
: `${data.risk_assessment_objects.length} selected risk assessments`}:
{data.risk_assessment_objects.length <= 1
? m.composerTitle()
: m.composerTitlePlural({ number: data.risk_assessment_objects.length})}:
</div>
<div class="flex space-x-2">
<div class="w-1/3">
<div>
<div class="p-2 text-sm font-semibold">Current risk level per risk scenario</div>
<div class="p-2 text-sm font-semibold">{m.currentRiskLevelPerScenario()}</div>

<div class="items-center h-96">
<DonutChart
name="current_risk_level"
s_label="Current risk level per risk scenario"
s_label={m.currentRiskLevelPerScenario()}
values={data.current_level}
colors={data.current_level.map(object => object.color)}
/>
</div>
</div>
</div>
<div class="w-1/3">
<div class="p-2 text-sm font-semibold">Status of associated measures</div>
<div class="p-2 text-sm font-semibold">{m.statusOfAssociatedMeasures()}</div>
<div>
<div class="items-center justify-center h-96">
<BarChart
Expand All @@ -50,7 +61,7 @@
</div>
</div>
<div class="w-1/3">
<div class="p-2 text-sm font-semibold">Residual risk level per risk scenario</div>
<div class="p-2 text-sm font-semibold">{m.residualRiskLevelPerScenario()}</div>
<div class="items-center h-96">
<DonutChart
name="residual_risk_level"
Expand All @@ -64,23 +75,26 @@
<div class="bg-zinc-100 shadow rounded p-3 flex flex-col space-y-2">
<div>
<i class="far fa-lightbulb mr-1" />&nbsp;<span class="font-semibold"
>For the selected scope, you have:</span
>{m.forTheSelectedScope()}:</span
>
</div>
<ul class="list-disc px-6">
<li>
<b>{data.counters.untreated}</b> untreated risk scenario{data.counters.untreated > 1
? 's'
: ''}
{m.untreatedRiskScenarios({
count: data.counters.untreated,
s: data.counters.untreated > 1 ? 's' : ''
})}
<ul class="list-circle ml-4">
{#each data.riskscenarios.untreated as scenario}
<li>{scenario.name}</li>
{/each}
</ul>
</li>
<li>
and
<b>{data.counters.accepted}</b> risk scenario{data.counters.accepted > 1 ? 's' : ''} accepted
{m.acceptedRiskScenarios({
count: data.counters.accepted,
s: data.counters.accepted > 1 ? 's' : ''
})}
<ul class="list-circle ml-4">
{#each data.riskscenarios.accepted as scenario}
<li>{scenario.name}</li>
Expand Down Expand Up @@ -116,9 +130,9 @@
</button>
<div>
{#if item.risk_assessment.quality_check.count > 0}
<span class="text-xs px-2 py-1 rounded bg-orange-200 shadow">Review needed</span>
<span class="text-xs px-2 py-1 rounded bg-orange-200 shadow">{m.reviewNeeded()}</span>
{:else}
<span class="text-xs px-2 py-1 rounded bg-green-200 shadow">Ok</span>
<span class="text-xs px-2 py-1 rounded bg-green-200 shadow">{m.ok()}</span>
{/if}
</div>
</div>
Expand All @@ -127,23 +141,23 @@
<div>
<div class="pb-2">
{#if item.risk_assessment.quality_check.count > 0}➡️ <span class="text-sm"
>Found
<b>{item.risk_assessment.quality_check.count}</b> inconsistenc{item
.risk_assessment.quality_check.count > 1
? 'es'
: 'y'} that you need to check (use
>{m.inconsistenciesFoundComposer({
count: item.risk_assessment.quality_check.count,
s: item.risk_assessment.quality_check.count > 1 ? 's' : '',
plural: item.risk_assessment.quality_check.count > 1 ? 'ies' : 'y'
})}
<a class="simple-link hover:underline visited:text-indigo-600" href="/x-rays"
>x-rays</a
> for more information).</span
>
></span
>.
{/if}
</div>
<div>
<table class="border border-collapse my-2 p-2 rounded">
<tr class="">
<th class="border p-2 bg-gray-200" />
<th class="border p-2 bg-gray-200">Current</th>
<th class="border p-2 bg-gray-200">Residual</th>
<th class="border p-2 bg-gray-200">{m.current()}</th>
<th class="border p-2 bg-gray-200">{m.residual()}</th>
</tr>
{#each item.synth_table as lvl}
<tr>
Expand All @@ -159,7 +173,7 @@
<a
class="text-indigo-800 hover:text-indigo-600 py-2 my-2"
href="/risk-assessments/{item.risk_assessment.id}/"
><i class="fas fa-external-link-square-alt" />Jump to full risk risk_assessment</a
><i class="fas fa-external-link-square-alt" /> {m.jumpToRiskAssessment()}</a
>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { BASE_API_URL } from '$lib/utils/constants';
import type { UUID } from 'crypto';

import type { PageServerLoad } from './$types';

Expand All @@ -9,11 +8,12 @@ export const load = (async ({ fetch, params }) => {

const res = await fetch(endpoint);
const risk_assessment = await res.json();
const folder = await fetch(`${BASE_API_URL}/folders/${risk_assessment.project.id.folder}/`).then(
const project = await fetch(`${BASE_API_URL}/projects/${risk_assessment.project.id}/`).then(
(res) => res.json()
);
const folder = await fetch(`${BASE_API_URL}/folders/${project.folder.id}/`).then(
(res) => res.json()
);

risk_assessment.folder = folder;

return { URLModel, risk_assessment };
}) satisfies PageServerLoad;
Loading
Loading