Skip to content

Commit

Permalink
feat: add strategic scenario filters
Browse files Browse the repository at this point in the history
  • Loading branch information
Mohamed-Hacene committed Dec 17, 2024
1 parent 417041f commit 22696ec
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
15 changes: 15 additions & 0 deletions backend/ebios_rm/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,21 @@ def get_scope(self):
def save(self, *args, **kwargs):
self.folder = self.ebios_rm_study.folder
super().save(*args, **kwargs)

def get_gravity_display(self):
if self.ro_to_couple.get_gravity() < 0:
return {
"abbreviation": "--",
"name": "--",
"description": "not rated",
"value": -1,
"hexcolor": "#f9fafb",
}
risk_matrix = self.parsed_matrix
return {
**risk_matrix["impact"][self.ro_to_couple.get_gravity()],
"value": self.ro_to_couple.get_gravity(),
}


class AttackPath(NameDescriptionMixin, FolderMixin):
Expand Down
1 change: 1 addition & 0 deletions backend/ebios_rm/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ class StrategicScenarioReadSerializer(BaseModelSerializer):
ebios_rm_study = FieldsRelatedField()
folder = FieldsRelatedField()
ro_to_couple = FieldsRelatedField()
gravity = serializers.JSONField(source="get_gravity_display")

class Meta:
model = StrategicScenario
Expand Down
8 changes: 5 additions & 3 deletions frontend/src/lib/utils/table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import SelectFilter from '$lib/components/Filters/SelectFilter.svelte';
import type { ComponentType } from 'svelte';
import { LOCALE_DISPLAY_MAP } from './constants';
import type { Row } from '@vincjo/datatables';
import { category, entity } from '$paraglide/messages';

interface ListViewFilterConfig {
component: ComponentType;
Expand Down Expand Up @@ -705,8 +704,11 @@ export const listViewFields: ListViewFieldsConfig = {
}
},
'strategic-scenarios': {
head: ['ref_id', 'name', 'description', 'ro_to_couple', 'attackPaths'],
body: ['ref_id', 'name', 'description', 'ro_to_couple', 'attack_paths']
head: ['ref_id', 'name', 'description', 'ro_to_couple', 'attackPaths', 'gravity'],
body: ['ref_id', 'name', 'description', 'ro_to_couple', 'attack_paths', 'gravity'],
filters: {
gravity: GRAVITY_FILTER
}
},
'attack-paths': {
head: ['is_selected', 'name', 'stakeholders', 'description'],
Expand Down

0 comments on commit 22696ec

Please sign in to comment.