Skip to content

Commit

Permalink
Associate default model parameters (for security analysis, sensitivit…
Browse files Browse the repository at this point in the history
…y analysis, short circuit, voltage init) with a user profile (#59)

* Associate default model parameters (for security analysis, sensitivity analysis, short circuit, voltage init) with a user profile.

Signed-off-by: Franck LECUYER <franck.lecuyer@rte-france.com>
  • Loading branch information
FranckLecuyer authored Dec 13, 2024
1 parent b464968 commit 158aff4
Show file tree
Hide file tree
Showing 6 changed files with 80 additions and 6 deletions.
9 changes: 9 additions & 0 deletions src/pages/profiles/modification/parameter-selection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export interface ParameterSelectionProps {
| ElementType.LOADFLOW_PARAMETERS
| ElementType.SECURITY_ANALYSIS_PARAMETERS
| ElementType.SENSITIVITY_PARAMETERS
| ElementType.SHORT_CIRCUIT_PARAMETERS
| ElementType.VOLTAGE_INIT_PARAMETERS;
parameterFormId: string;
}
Expand Down Expand Up @@ -78,6 +79,14 @@ const ParameterSelection: FunctionComponent<ParameterSelectionProps> = (props) =
switch (props.elementType) {
case ElementType.LOADFLOW_PARAMETERS:
return 'profiles.form.modification.loadflow.name';
case ElementType.SECURITY_ANALYSIS_PARAMETERS:
return 'profiles.form.modification.securityAnalysis.name';
case ElementType.SENSITIVITY_PARAMETERS:
return 'profiles.form.modification.sensitivityAnalysis.name';
case ElementType.SHORT_CIRCUIT_PARAMETERS:
return 'profiles.form.modification.shortcircuit.name';
case ElementType.VOLTAGE_INIT_PARAMETERS:
return 'profiles.form.modification.voltageInit.name';
}
return 'cannot happen';
};
Expand Down
32 changes: 28 additions & 4 deletions src/pages/profiles/modification/profile-modification-dialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@
*/

import ProfileModificationForm, {
LF_PARAM_ID,
LOADFLOW_PARAM_ID,
SECURITY_ANALYSIS_PARAM_ID,
SENSITIVITY_ANALYSIS_PARAM_ID,
SHORTCIRCUIT_PARAM_ID,
VOLTAGE_INIT_PARAM_ID,
PROFILE_NAME,
USER_QUOTA_BUILD_NB,
USER_QUOTA_CASE_NB,
Expand Down Expand Up @@ -47,7 +51,11 @@ const ProfileModificationDialog: FunctionComponent<ProfileModificationDialogProp
.object()
.shape({
[PROFILE_NAME]: yup.string().trim().required('nameEmpty'),
[LF_PARAM_ID]: yup.string().optional(),
[LOADFLOW_PARAM_ID]: yup.string().optional(),
[SECURITY_ANALYSIS_PARAM_ID]: yup.string().optional(),
[SENSITIVITY_ANALYSIS_PARAM_ID]: yup.string().optional(),
[SHORTCIRCUIT_PARAM_ID]: yup.string().optional(),
[VOLTAGE_INIT_PARAM_ID]: yup.string().optional(),
[USER_QUOTA_CASE_NB]: yup.number().positive('userQuotaPositive').nullable(),
[USER_QUOTA_BUILD_NB]: yup.number().positive('userQuotaPositive').nullable(),
})
Expand All @@ -65,7 +73,11 @@ const ProfileModificationDialog: FunctionComponent<ProfileModificationDialogProp
const profileData: UserProfile = {
id: profileId,
name: profileFormData[PROFILE_NAME],
loadFlowParameterId: profileFormData[LF_PARAM_ID],
loadFlowParameterId: profileFormData[LOADFLOW_PARAM_ID],
securityAnalysisParameterId: profileFormData[SECURITY_ANALYSIS_PARAM_ID],
sensitivityAnalysisParameterId: profileFormData[SENSITIVITY_ANALYSIS_PARAM_ID],
shortcircuitParameterId: profileFormData[SHORTCIRCUIT_PARAM_ID],
voltageInitParameterId: profileFormData[VOLTAGE_INIT_PARAM_ID],
maxAllowedCases: profileFormData[USER_QUOTA_CASE_NB],
maxAllowedBuilds: profileFormData[USER_QUOTA_BUILD_NB],
};
Expand Down Expand Up @@ -97,7 +109,19 @@ const ProfileModificationDialog: FunctionComponent<ProfileModificationDialogProp
setDataFetchStatus(FetchStatus.FETCH_SUCCESS);
reset({
[PROFILE_NAME]: response.name,
[LF_PARAM_ID]: response.loadFlowParameterId ? response.loadFlowParameterId : undefined,
[LOADFLOW_PARAM_ID]: response.loadFlowParameterId ? response.loadFlowParameterId : undefined,
[SECURITY_ANALYSIS_PARAM_ID]: response.securityAnalysisParameterId
? response.securityAnalysisParameterId
: undefined,
[SENSITIVITY_ANALYSIS_PARAM_ID]: response.sensitivityAnalysisParameterId
? response.sensitivityAnalysisParameterId
: undefined,
[SHORTCIRCUIT_PARAM_ID]: response.shortcircuitParameterId
? response.shortcircuitParameterId
: undefined,
[VOLTAGE_INIT_PARAM_ID]: response.voltageInitParameterId
? response.voltageInitParameterId
: undefined,
[USER_QUOTA_CASE_NB]: response.maxAllowedCases,
[USER_QUOTA_BUILD_NB]: response.maxAllowedBuilds,
});
Expand Down
33 changes: 31 additions & 2 deletions src/pages/profiles/modification/profile-modification-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,12 @@ import { FormattedMessage } from 'react-intl';
import React, { FunctionComponent } from 'react';

export const PROFILE_NAME = 'name';
export const LF_PARAM_ID = 'lfParamId';
export const LOADFLOW_PARAM_ID = 'loadFlowParamId';
export const SECURITY_ANALYSIS_PARAM_ID = 'securityAnalysisParamId';
export const SENSITIVITY_ANALYSIS_PARAM_ID = 'sensitivityAnalysisParamId';
export const SHORTCIRCUIT_PARAM_ID = 'shortcircuitParamId';
export const VOLTAGE_INIT_PARAM_ID = 'voltageInitParamId';

export const USER_QUOTA_CASE_NB = 'userQuotaCaseNb';
export const USER_QUOTA_BUILD_NB = 'userQuotaBuildNb';

Expand All @@ -28,7 +33,31 @@ const ProfileModificationForm: FunctionComponent = () => {
</h3>
</Grid>
<Grid item xs={12}>
<ParameterSelection elementType={ElementType.LOADFLOW_PARAMETERS} parameterFormId={LF_PARAM_ID} />
<ParameterSelection elementType={ElementType.LOADFLOW_PARAMETERS} parameterFormId={LOADFLOW_PARAM_ID} />
</Grid>
<Grid item xs={12}>
<ParameterSelection
elementType={ElementType.SECURITY_ANALYSIS_PARAMETERS}
parameterFormId={SECURITY_ANALYSIS_PARAM_ID}
/>
</Grid>
<Grid item xs={12}>
<ParameterSelection
elementType={ElementType.SENSITIVITY_PARAMETERS}
parameterFormId={SENSITIVITY_ANALYSIS_PARAM_ID}
/>
</Grid>
<Grid item xs={12}>
<ParameterSelection
elementType={ElementType.SHORT_CIRCUIT_PARAMETERS}
parameterFormId={SHORTCIRCUIT_PARAM_ID}
/>
</Grid>
<Grid item xs={12}>
<ParameterSelection
elementType={ElementType.VOLTAGE_INIT_PARAMETERS}
parameterFormId={VOLTAGE_INIT_PARAM_ID}
/>
</Grid>
<Grid item xs={12}>
<h3>
Expand Down
4 changes: 4 additions & 0 deletions src/services/user-admin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,10 @@ export type UserProfile = {
name: string;
allParametersLinksValid?: boolean;
loadFlowParameterId?: UUID;
securityAnalysisParameterId?: UUID;
sensitivityAnalysisParameterId?: UUID;
shortcircuitParameterId?: UUID;
voltageInitParameterId?: UUID;
maxAllowedCases?: number;
maxAllowedBuilds?: number;
};
Expand Down
4 changes: 4 additions & 0 deletions src/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@
"profiles.form.modification.parameterSelection.dialog.title": "Choose parameters",
"profiles.form.modification.parameterSelection.dialog.message": "Please choose parameters",
"profiles.form.modification.loadflow.name": "Loadflow",
"profiles.form.modification.securityAnalysis.name": "Security analysis",
"profiles.form.modification.sensitivityAnalysis.name": "Sensitivity analysis",
"profiles.form.modification.shortcircuit.name": "Short-circuit",
"profiles.form.modification.voltageInit.name": "Voltage init",
"profiles.form.modification.readError": "Error while reading the profile",
"profiles.form.modification.updateError": "Error while updating the profile",

Expand Down
4 changes: 4 additions & 0 deletions src/translations/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@
"profiles.form.modification.parameterSelection.dialog.title": "Choisir des paramètres",
"profiles.form.modification.parameterSelection.dialog.message": "Veuillez choisir des paramètres",
"profiles.form.modification.loadflow.name": "Calcul de répartition",
"profiles.form.modification.securityAnalysis.name": "Analyse de sécurité",
"profiles.form.modification.sensitivityAnalysis.name": "Analyse de sensibilités",
"profiles.form.modification.shortcircuit.name": "Calcul de court-circuit",
"profiles.form.modification.voltageInit.name": "Initialisation du plan de tension",
"profiles.form.modification.readError": "Erreur lors de la lecture du profil",
"profiles.form.modification.updateError": "Erreur lors de la modification du profil",

Expand Down

0 comments on commit 158aff4

Please sign in to comment.