From ba3cdb61c88fa3e3dd0dc416dbae9203bbbec06c Mon Sep 17 00:00:00 2001 From: Mohamed-Hacene Date: Thu, 26 Dec 2024 16:03:44 +0100 Subject: [PATCH 1/5] feat: add ecosystem radar to ebios study --- frontend/messages/en.json | 3 +- frontend/messages/fr.json | 3 +- frontend/src/lib/utils/table.ts | 4 +- .../workshop-3/ecosystem/+page.server.ts | 7 ++- .../workshop-3/ecosystem/+page.svelte | 56 ++++++++++++++----- 5 files changed, 55 insertions(+), 18 deletions(-) diff --git a/frontend/messages/en.json b/frontend/messages/en.json index bfa9410dc..985cc8763 100644 --- a/frontend/messages/en.json +++ b/frontend/messages/en.json @@ -1066,5 +1066,6 @@ "operationalScenarioThreatsHelpText": "Unitary actions carried out by a risk source on a critical support asset as part of an operational scenario", "operationalScenarioIsSelectedHelpText": "Selection of the operational scenario for the study", "attackPathStakeholdersHelpText": "Stakeholders involved in the attack path", - "attackPathIsSelectedHelpText": "Selection of the attack path for the study" + "attackPathIsSelectedHelpText": "Selection of the attack path for the study", + "ecosystemRadar": "Ecosystem radar" } diff --git a/frontend/messages/fr.json b/frontend/messages/fr.json index 19b129a02..2c4795f26 100644 --- a/frontend/messages/fr.json +++ b/frontend/messages/fr.json @@ -1067,5 +1067,6 @@ "operationalScenarioThreatsHelpText": "Actions élémentaires réalisées par une source de risque sur un bien support critique dans le cadre d'un scénario opérationnel", "operationalScenarioIsSelectedHelpText": "Sélection du scénario opérationnel pour l'étude", "attackPathStakeholdersHelpText": "Parties prenantes impactées par le chemin d'attaque", - "attackPathIsSelectedHelpText": "Sélection du chemin d'attaque pour l'étude" + "attackPathIsSelectedHelpText": "Sélection du chemin d'attaque pour l'étude", + "ecosystemRadar": "Radar de l'écosystème" } diff --git a/frontend/src/lib/utils/table.ts b/frontend/src/lib/utils/table.ts index 3b83d61ef..003114169 100644 --- a/frontend/src/lib/utils/table.ts +++ b/frontend/src/lib/utils/table.ts @@ -230,7 +230,7 @@ const ENTITY_FILTER: ListViewFilterConfig = { const CURRENT_CRITICALITY_FILTER: ListViewFilterConfig = { component: SelectFilter, - getColumn: (row) => (console.log(row), row.current_criticality.toString()), + getColumn: (row) => row.current_criticality.toString(), extraProps: { defaultOptionName: 'current_criticality' }, @@ -239,7 +239,7 @@ const CURRENT_CRITICALITY_FILTER: ListViewFilterConfig = { const RESIDUAL_CRITICALITY_FILTER: ListViewFilterConfig = { component: SelectFilter, - getColumn: (row) => (console.log(row), row.residual_criticality.toString()), + getColumn: (row) => row.residual_criticality.toString(), extraProps: { defaultOptionName: 'residual_criticality' }, diff --git a/frontend/src/routes/(app)/(internal)/ebios-rm/[id=uuid]/workshop-3/ecosystem/+page.server.ts b/frontend/src/routes/(app)/(internal)/ebios-rm/[id=uuid]/workshop-3/ecosystem/+page.server.ts index 3449f6aa3..33bf83000 100644 --- a/frontend/src/routes/(app)/(internal)/ebios-rm/[id=uuid]/workshop-3/ecosystem/+page.server.ts +++ b/frontend/src/routes/(app)/(internal)/ebios-rm/[id=uuid]/workshop-3/ecosystem/+page.server.ts @@ -85,7 +85,12 @@ export const load: PageServerLoad = async ({ params, fetch }) => { meta: data // metaData }; - return { createForm, deleteForm, model, URLModel, table }; + const radarEndpoint = `${BASE_API_URL}/ebios-rm/stakeholders/chart_data/`; + + const radarRes = await fetch(radarEndpoint); + const radar = await radarRes.json(); + + return { createForm, deleteForm, model, URLModel, table, radar }; }; export const actions: Actions = { diff --git a/frontend/src/routes/(app)/(internal)/ebios-rm/[id=uuid]/workshop-3/ecosystem/+page.svelte b/frontend/src/routes/(app)/(internal)/ebios-rm/[id=uuid]/workshop-3/ecosystem/+page.svelte index 08ebedae8..afc750bcb 100644 --- a/frontend/src/routes/(app)/(internal)/ebios-rm/[id=uuid]/workshop-3/ecosystem/+page.svelte +++ b/frontend/src/routes/(app)/(internal)/ebios-rm/[id=uuid]/workshop-3/ecosystem/+page.svelte @@ -8,6 +8,8 @@ import MissingConstraintsModal from '$lib/components/Modals/MissingConstraintsModal.svelte'; import { checkConstraints } from '$lib/utils/crud'; import * as m from '$paraglide/messages.js'; + import EcosystemRadarChart from '$lib/components/Chart/EcosystemRadarChart.svelte'; + import { Accordion, AccordionItem } from '@skeletonlabs/skeleton'; const modalStore: ModalStore = getModalStore(); @@ -52,16 +54,44 @@ } - -
- - - -
-
+
+ + + + {m.ecosystemRadar()} + +
+
+ + +
+
+
+
+
+ +
+ + + +
+
+
From fc4bb860238f2370d474a29b5d37146c466b44c8 Mon Sep 17 00:00:00 2001 From: Mohamed-Hacene Date: Thu, 26 Dec 2024 17:07:06 +0100 Subject: [PATCH 2/5] style: use ebios support colors --- backend/ebios_rm/models.py | 2 +- frontend/messages/en.json | 7 +++- frontend/messages/fr.json | 7 +++- .../Chart/EcosystemRadarChart.svelte | 42 +++++++++++++------ 4 files changed, 42 insertions(+), 16 deletions(-) diff --git a/backend/ebios_rm/models.py b/backend/ebios_rm/models.py index a16407ebb..33b85abfa 100644 --- a/backend/ebios_rm/models.py +++ b/backend/ebios_rm/models.py @@ -463,7 +463,7 @@ def get_scope(self): return self.__class__.objects.filter(ebios_rm_study=self.ebios_rm_study) def __str__(self): - return f"{self.entity.name} - {self.get_category_display()}" + return f"{self.entity.name}-{self.get_category_display()}" def save(self, *args, **kwargs): self.folder = self.ebios_rm_study.folder diff --git a/frontend/messages/en.json b/frontend/messages/en.json index 985cc8763..998380bd0 100644 --- a/frontend/messages/en.json +++ b/frontend/messages/en.json @@ -1019,8 +1019,11 @@ "markAsInProgress": "Mark as in progress", "riskAnalyses": "Risk analyses", "client": "Client", + "clients": "Clients", "partner": "Partner", + "partners": "Partners", "supplier": "Supplier", + "suppliers": "Suppliers", "referenceEntity": "Reference entity", "referenceEntitySemiColon": "Reference entity:", "moderate": "Moderate", @@ -1067,5 +1070,7 @@ "operationalScenarioIsSelectedHelpText": "Selection of the operational scenario for the study", "attackPathStakeholdersHelpText": "Stakeholders involved in the attack path", "attackPathIsSelectedHelpText": "Selection of the attack path for the study", - "ecosystemRadar": "Ecosystem radar" + "ecosystemRadar": "Ecosystem radar", + "criticalitySemiColon": "Criticality:", + "cyberFiability": "Cyber fiability" } diff --git a/frontend/messages/fr.json b/frontend/messages/fr.json index 2c4795f26..84f07e272 100644 --- a/frontend/messages/fr.json +++ b/frontend/messages/fr.json @@ -1019,8 +1019,11 @@ "markAsInProgress": "Reprendre", "riskAnalyses": "Analyses de risques", "client": "Client", + "clients": "Clients", "partner": "Partenaire", + "partners": "Partenaires", "supplier": "Fournisseur", + "suppliers": "Fournisseurs", "referenceEntity": "Entité de référence", "referenceEntitySemiColon": "Entité de référence :", "moderate": "Modérée", @@ -1068,5 +1071,7 @@ "operationalScenarioIsSelectedHelpText": "Sélection du scénario opérationnel pour l'étude", "attackPathStakeholdersHelpText": "Parties prenantes impactées par le chemin d'attaque", "attackPathIsSelectedHelpText": "Sélection du chemin d'attaque pour l'étude", - "ecosystemRadar": "Radar de l'écosystème" + "ecosystemRadar": "Radar de l'écosystème", + "criticalitySemiColon": "Criticité :", + "cyberFiability": "Fiabilité cyber" } diff --git a/frontend/src/lib/components/Chart/EcosystemRadarChart.svelte b/frontend/src/lib/components/Chart/EcosystemRadarChart.svelte index df867d697..7c9dcc2df 100644 --- a/frontend/src/lib/components/Chart/EcosystemRadarChart.svelte +++ b/frontend/src/lib/components/Chart/EcosystemRadarChart.svelte @@ -1,8 +1,7 @@
- + {m.ecosystemRadar()} diff --git a/frontend/src/routes/(app)/(internal)/experimental/ecosystem/+page.svelte b/frontend/src/routes/(app)/(internal)/experimental/ecosystem/+page.svelte index d7cc6d15f..cbdd62642 100644 --- a/frontend/src/routes/(app)/(internal)/experimental/ecosystem/+page.svelte +++ b/frontend/src/routes/(app)/(internal)/experimental/ecosystem/+page.svelte @@ -2,13 +2,14 @@ import type { PageData } from './$types'; export let data: PageData; import EcosystemRadarChart from '$lib/components/Chart/EcosystemRadarChart.svelte'; + import * as m from '$paraglide/messages.js';
- + From 863ce604ce53f1111158aa6ba0ede5df2e996499 Mon Sep 17 00:00:00 2001 From: Mohamed-Hacene Date: Thu, 26 Dec 2024 17:21:58 +0100 Subject: [PATCH 4/5] chore: format --- backend/ebios_rm/helpers.py | 3 ++- backend/ebios_rm/views.py | 6 ++++-- .../ebios-rm/[id=uuid]/workshop-3/ecosystem/+page.svelte | 5 ++++- .../(app)/(internal)/experimental/ecosystem/+page.svelte | 6 +----- 4 files changed, 11 insertions(+), 9 deletions(-) diff --git a/backend/ebios_rm/helpers.py b/backend/ebios_rm/helpers.py index 0546ea62e..efd2d7779 100644 --- a/backend/ebios_rm/helpers.py +++ b/backend/ebios_rm/helpers.py @@ -1,6 +1,7 @@ from django.db.models.query import QuerySet import math + def ecosystem_radar_chart_data(stakeholders_queryset: QuerySet): qs = stakeholders_queryset @@ -83,4 +84,4 @@ def get_reliability_cluster(value): cluser_id = get_reliability_cluster(r_reliability) r_data[cluser_id].append(vector) - return {"current": c_data, "residual": r_data} \ No newline at end of file + return {"current": c_data, "residual": r_data} diff --git a/backend/ebios_rm/views.py b/backend/ebios_rm/views.py index 542cc666c..d1e78f9ab 100644 --- a/backend/ebios_rm/views.py +++ b/backend/ebios_rm/views.py @@ -83,10 +83,12 @@ def update_workshop_step_status(self, request, pk, workshop, step): workshop, step, new_status=request.data.get("status", "in_progress") ) return Response(EbiosRMStudyReadSerializer(ebios_rm_study).data) - + @action(detail=True, name="Get ecosystem radar chart data") def ecosystem_chart_data(self, request, pk): - return Response(ecosystem_radar_chart_data(Stakeholder.objects.filter(ebios_rm_study=pk))) + return Response( + ecosystem_radar_chart_data(Stakeholder.objects.filter(ebios_rm_study=pk)) + ) class FearedEventViewSet(BaseModelViewSet): diff --git a/frontend/src/routes/(app)/(internal)/ebios-rm/[id=uuid]/workshop-3/ecosystem/+page.svelte b/frontend/src/routes/(app)/(internal)/ebios-rm/[id=uuid]/workshop-3/ecosystem/+page.svelte index f17ce5b7b..5b80d47fe 100644 --- a/frontend/src/routes/(app)/(internal)/ebios-rm/[id=uuid]/workshop-3/ecosystem/+page.svelte +++ b/frontend/src/routes/(app)/(internal)/ebios-rm/[id=uuid]/workshop-3/ecosystem/+page.svelte @@ -55,7 +55,10 @@
- + {m.ecosystemRadar()} diff --git a/frontend/src/routes/(app)/(internal)/experimental/ecosystem/+page.svelte b/frontend/src/routes/(app)/(internal)/experimental/ecosystem/+page.svelte index cbdd62642..37a66b7c2 100644 --- a/frontend/src/routes/(app)/(internal)/experimental/ecosystem/+page.svelte +++ b/frontend/src/routes/(app)/(internal)/experimental/ecosystem/+page.svelte @@ -8,10 +8,6 @@
- +
From e3bdd8cbd856fc50bf7c6cdf3c021080f6fbeff1 Mon Sep 17 00:00:00 2001 From: Abderrahmane Smimite Date: Thu, 26 Dec 2024 19:10:31 +0100 Subject: [PATCH 5/5] back to the official colors --- .../components/Chart/EcosystemRadarChart.svelte | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/frontend/src/lib/components/Chart/EcosystemRadarChart.svelte b/frontend/src/lib/components/Chart/EcosystemRadarChart.svelte index 7c9dcc2df..dbe9b1cb9 100644 --- a/frontend/src/lib/components/Chart/EcosystemRadarChart.svelte +++ b/frontend/src/lib/components/Chart/EcosystemRadarChart.svelte @@ -137,7 +137,7 @@ series: [ { name: '<4', - color: '#b91c1c', + color: '#E73E51', type: 'scatter', coordinateSystem: 'polar', symbolSize: function (val) { @@ -150,7 +150,7 @@ }, { name: '4-5', - color: '#eab308', + color: '#DE8898', type: 'scatter', coordinateSystem: 'polar', symbolSize: function (val) { @@ -163,7 +163,7 @@ }, { name: '6-7', - color: '#3b82f6', + color: '#BAD9EA', type: 'scatter', coordinateSystem: 'polar', symbolSize: function (val) { @@ -176,7 +176,7 @@ }, { name: '>7', - color: '#16a34a', + color: '#8A8B8A', type: 'scatter', coordinateSystem: 'polar', symbolSize: function (val) { @@ -197,7 +197,7 @@ return [2.5, index]; }), lineStyle: { - color: '#ef4444', + color: '#E73E51', width: 5 }, // If you don't want this to show up in the legend: @@ -214,7 +214,7 @@ return [0.2, index]; }), lineStyle: { - color: '#84cc16', + color: '#00ADA8', width: 5 }, // If you don't want this to show up in the legend: @@ -231,7 +231,7 @@ return [0.9, index]; }), lineStyle: { - color: '#f97316', + color: '#F8EA47', width: 5 }, // If you don't want this to show up in the legend: