From 96cbd8b878c5fe3cf97d0612c768e5e82bd7b5a8 Mon Sep 17 00:00:00 2001 From: Mohamed-Hacene Date: Mon, 16 Dec 2024 14:07:04 +0100 Subject: [PATCH] style: adapt workshop 4 ux --- backend/ebios_rm/models.py | 8 +++ backend/ebios_rm/serializers.py | 4 +- frontend/messages/en.json | 3 +- frontend/src/lib/utils/table.ts | 2 +- .../[id=uuid]/+page.svelte | 55 +++++++++++++++---- 5 files changed, 57 insertions(+), 15 deletions(-) diff --git a/backend/ebios_rm/models.py b/backend/ebios_rm/models.py index 7bbdd41a1..07c5e6e33 100644 --- a/backend/ebios_rm/models.py +++ b/backend/ebios_rm/models.py @@ -471,6 +471,14 @@ def ref_id(self): def gravity(self): return self.attack_path.gravity + @property + def stakeholders(self): + return self.attack_path.stakeholders.all() + + @property + def ro_to(self): + return self.attack_path.ro_to_couple + def get_likelihood_display(self): if self.likelihood < 0: return { diff --git a/backend/ebios_rm/serializers.py b/backend/ebios_rm/serializers.py index dad215695..970106371 100644 --- a/backend/ebios_rm/serializers.py +++ b/backend/ebios_rm/serializers.py @@ -157,7 +157,9 @@ class OperationalScenarioReadSerializer(BaseModelSerializer): str = serializers.CharField(source="__str__") ebios_rm_study = FieldsRelatedField() folder = FieldsRelatedField() - attack_path = FieldsRelatedField() + attack_path = FieldsRelatedField(["id", "name", "description"]) + stakeholders = FieldsRelatedField(many=True) + ro_to = FieldsRelatedField(["risk_origin", "target_objective"]) threats = FieldsRelatedField(many=True) likelihood = serializers.JSONField(source="get_likelihood_display") gravity = serializers.JSONField(source="get_gravity_display") diff --git a/frontend/messages/en.json b/frontend/messages/en.json index cf202473a..3daf2e04f 100644 --- a/frontend/messages/en.json +++ b/frontend/messages/en.json @@ -1004,5 +1004,6 @@ "veryLikely": "Very likely", "certain": "Certain", "minor": "Minor", - "operatingModesDescription": "Operating modes description" + "operatingModesDescription": "Operating modes description", + "noStakeholders": "No stakeholders" } diff --git a/frontend/src/lib/utils/table.ts b/frontend/src/lib/utils/table.ts index a0532f21f..844034bb4 100644 --- a/frontend/src/lib/utils/table.ts +++ b/frontend/src/lib/utils/table.ts @@ -602,6 +602,6 @@ export const listViewFields: ListViewFieldsConfig = { }, 'operational-scenarios': { head: ['operatingModesDescription', 'threats', 'likelihood'], - body: ['operatoig_modes_descriptionn', 'threats', 'likelihood'] + body: ['operating_modes_description', 'threats', 'likelihood'] } }; diff --git a/frontend/src/routes/(app)/(internal)/operational-scenarios/[id=uuid]/+page.svelte b/frontend/src/routes/(app)/(internal)/operational-scenarios/[id=uuid]/+page.svelte index 048817c2e..f7ccd995a 100644 --- a/frontend/src/routes/(app)/(internal)/operational-scenarios/[id=uuid]/+page.svelte +++ b/frontend/src/routes/(app)/(internal)/operational-scenarios/[id=uuid]/+page.svelte @@ -88,18 +88,49 @@ {:else}

{m.noDescription()}

{/if} -
-

- - {m.attackPath()} -

- +
+
+ {m.attackPath()} +

{operationalScenario.attack_path.name}

+ {#if operationalScenario.attack_path.description} +

{operationalScenario.attack_path.description}

+ {/if} +
+
+
+

{m.riskOrigin()}

+ +

+ {operationalScenario.ro_to.risk_origin} +

+
+
+

{m.stakeholders()}

+ + {#each operationalScenario.stakeholders as stakeholder} +

+ {stakeholder.str} +

+ {:else} +

{m.noStakeholders()}

+ {/each} +
+
+

{m.targetObjective()}

+ +

{operationalScenario.ro_to.target_objective}

+
+