From 8ba5ace4479d1b42f9b09cf57c9f6dfed003c362 Mon Sep 17 00:00:00 2001 From: Nassim Tabchiche Date: Thu, 5 Dec 2024 16:53:05 +0100 Subject: [PATCH 01/26] Add stakeholders urlmodel --- frontend/src/lib/utils/crud.ts | 13 +++++++++++++ frontend/src/lib/utils/schemas.ts | 20 +++++++++++++++++++- frontend/src/lib/utils/table.ts | 4 ++++ frontend/src/lib/utils/types.ts | 3 ++- 4 files changed, 38 insertions(+), 2 deletions(-) diff --git a/frontend/src/lib/utils/crud.ts b/frontend/src/lib/utils/crud.ts index b0e762ebe..a7c1dab01 100644 --- a/frontend/src/lib/utils/crud.ts +++ b/frontend/src/lib/utils/crud.ts @@ -641,6 +641,19 @@ export const URL_MODEL_MAP: ModelMap = { { field: 'resources', valueType: 'number' }, { field: 'pertinence', valueType: 'number' } ] + }, + stakeholders: { + endpointUrl: 'ebios-rm/stakeholders', + name: 'stakeholder', + localName: 'stakeholder', + localNamePlural: 'stakeholders', + verboseName: 'Stakeholder', + verboseNamePlural: 'Stakeholders', + foreignKeyFields: [ + { field: 'entity', urlModel: 'entities' }, + { field: 'applied_controls', urlModel: 'applied-controls' } + ], + selectFields: [{ field: 'category' }] } }; diff --git a/frontend/src/lib/utils/schemas.ts b/frontend/src/lib/utils/schemas.ts index ed65b698d..39190290e 100644 --- a/frontend/src/lib/utils/schemas.ts +++ b/frontend/src/lib/utils/schemas.ts @@ -426,6 +426,23 @@ export const roToSchema = z.object({ justification: z.string().optional() }); +export const StakeholderSchema = z.object({ + ebios_rm_study: z.string(), + applied_controls: z.string().uuid().optional().array().optional(), + category: z.string().optional(), + entity: z.string().optional(), + current_dependency: z.number().min(0).max(4).optional(), + current_penetration: z.number().min(0).max(4).optional(), + current_maturity: z.number().min(1).max(4).optional(), + current_trust: z.number().min(1).max(4).optional(), + residual_dependency: z.number().min(0).max(4).optional(), + residual_penetration: z.number().min(0).max(4).optional(), + residual_maturity: z.number().min(1).max(4).optional(), + residual_trust: z.number().min(1).max(4).optional(), + is_selected: z.boolean().optional(), + justification: z.string().optional() +}); + const SCHEMA_MAP: Record = { folders: FolderSchema, projects: ProjectSchema, @@ -453,7 +470,8 @@ const SCHEMA_MAP: Record = { 'filtering-labels': FilteringLabelSchema, 'ebios-rm': ebiosRMSchema, 'feared-events': fearedEventsSchema, - 'ro-to': roToSchema + 'ro-to': roToSchema, + stakeholders: StakeholderSchema }; export const modelSchema = (model: string) => { diff --git a/frontend/src/lib/utils/table.ts b/frontend/src/lib/utils/table.ts index 07e8f9bc3..5ef8651f6 100644 --- a/frontend/src/lib/utils/table.ts +++ b/frontend/src/lib/utils/table.ts @@ -573,5 +573,9 @@ export const listViewFields: ListViewFieldsConfig = { 'feared_events', 'pertinence' ] + }, + stakeholders: { + head: ['entity', 'current_criticality'], + body: ['entity', 'current_criticality'] } }; diff --git a/frontend/src/lib/utils/types.ts b/frontend/src/lib/utils/types.ts index 0e1dde450..48bd379f0 100644 --- a/frontend/src/lib/utils/types.ts +++ b/frontend/src/lib/utils/types.ts @@ -53,7 +53,8 @@ export const URL_MODEL = [ 'vulnerabilities', 'filtering-labels', 'feared-events', - 'ro-to' + 'ro-to', + 'stakeholders' // 'ebios-rm', ] as const; From 6121a30236e2982dc0fa218384a796537730fabb Mon Sep 17 00:00:00 2001 From: Nassim Tabchiche Date: Thu, 5 Dec 2024 16:53:47 +0100 Subject: [PATCH 02/26] Write StakeholderForm --- .../src/lib/components/Forms/ModelForm.svelte | 3 + .../Forms/ModelForm/StakeholderForm.svelte | 117 ++++++++++++++++++ 2 files changed, 120 insertions(+) create mode 100644 frontend/src/lib/components/Forms/ModelForm/StakeholderForm.svelte diff --git a/frontend/src/lib/components/Forms/ModelForm.svelte b/frontend/src/lib/components/Forms/ModelForm.svelte index 3866c9d84..c3edbebd3 100644 --- a/frontend/src/lib/components/Forms/ModelForm.svelte +++ b/frontend/src/lib/components/Forms/ModelForm.svelte @@ -29,6 +29,7 @@ import EbiosRmForm from './ModelForm/EbiosRmForm.svelte'; import FearedEventForm from './ModelForm/FearedEventForm.svelte'; import RoToForm from './ModelForm/RoToForm.svelte'; + import StakeholderForm from './ModelForm/StakeholderForm.svelte'; import AutocompleteSelect from './AutocompleteSelect.svelte'; @@ -264,6 +265,8 @@ {:else if URLModel === 'ro-to'} + {:else if URLModel === 'stakeholders'} + {/if}
{#if closeModal} diff --git a/frontend/src/lib/components/Forms/ModelForm/StakeholderForm.svelte b/frontend/src/lib/components/Forms/ModelForm/StakeholderForm.svelte new file mode 100644 index 000000000..561b7ea4d --- /dev/null +++ b/frontend/src/lib/components/Forms/ModelForm/StakeholderForm.svelte @@ -0,0 +1,117 @@ + + +