Skip to content

Commit

Permalink
feat(ui-thermals): add v8.7 thermal cluster fields
Browse files Browse the repository at this point in the history
  • Loading branch information
skamril authored May 3, 2024
2 parents c132082 + 9de4e43 commit ac1d270
Show file tree
Hide file tree
Showing 8 changed files with 200 additions and 154 deletions.
12 changes: 9 additions & 3 deletions webapp/public/locales/en/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@
"form.field.minLength": "{{0}} character(s) minimum",
"form.field.minValue": "The minimum value is {{0}}",
"form.field.maxValue": "The maximum value is {{0}}",
"form.field.invalidNumber": "Invalid number",
"form.field.notAllowedValue": "Not allowed value",
"form.field.specialChars": "Special characters allowed: {{0}}",
"form.field.specialCharsNotAllowed": "Special characters are not allowed",
Expand Down Expand Up @@ -202,7 +203,7 @@
"settings.error.groupRolesSave": "Role(s) for group '{{0}}' not saved",
"settings.error.tokenSave": "'{{0}}' token not saved",
"settings.error.updateMaintenance": "Maintenance mode not updated",
"settings.user.form.confirmPassword":"Confirm password",
"settings.user.form.confirmPassword": "Confirm password",
"settings.user.form.error.passwordMismatch": "Passwords do not match",
"launcher.additionalModes": "Additional modes",
"launcher.autoUnzip": "Automatically unzip",
Expand Down Expand Up @@ -487,10 +488,13 @@
"study.modelization.clusters.thermal.op5": "Other pollutant 5 (t/MWh)",
"study.modelization.clusters.operatingCosts": "Operating costs",
"study.modelization.clusters.marginalCost": "Marginal cost (€/MWh)",
"study.modelization.clusters.fixedCost": "Fixed costs (€/h)",
"study.modelization.clusters.fixedCost": "Fixed O&M costs (€/h)",
"study.modelization.clusters.startupCost": "Startup cost (€)",
"study.modelization.clusters.marketBidCost": "Market bid cost (€/MWh)",
"study.modelization.clusters.spreadCost": "Spread cost (€/MWh)",
"study.modelization.clusters.spreadCost": "Random spread (€/MWh)",
"study.modelization.clusters.variableOMCost": "Variable O&M cost (€/MWh)",
"study.modelization.clusters.costGeneration": "TS Cost",
"study.modelization.clusters.efficiency": "Efficiency (%)",
"study.modelization.clusters.timeSeriesGen": "Time-Series generation",
"study.modelization.clusters.genTs": "Generate Time-Series",
"study.modelization.clusters.volatilityForced": "Volatility forced",
Expand All @@ -500,6 +504,8 @@
"study.modelization.clusters.matrix.common": "Common",
"study.modelization.clusters.matrix.tsGen": "TS generator",
"study.modelization.clusters.matrix.timeSeries": "Time-Series",
"study.modelization.clusters.matrix.fuelCost": "Fuel Cost",
"study.modelization.clusters.matrix.co2Cost": "CO2 Cost",
"study.modelization.clusters.backClusterList": "Back to cluster list",
"study.modelization.clusters.tsInterpretation": "TS interpretation",
"studies.modelization.clusters.question.delete_one": "Are you sure you want to delete this cluster?",
Expand Down
12 changes: 9 additions & 3 deletions webapp/public/locales/fr/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@
"form.field.minLength": "{{0}} caractère(s) minimum",
"form.field.minValue": "La valeur minimum est {{0}}",
"form.field.maxValue": "La valeur maximum est {{0}}",
"form.field.invalidNumber": "Nombre invalide",
"form.field.notAllowedValue": "Valeur non autorisée",
"form.field.specialChars": "Caractères spéciaux autorisés: {{0}}",
"form.field.specialCharsNotAllowed": "Les caractères spéciaux ne sont pas autorisés",
Expand Down Expand Up @@ -486,11 +487,14 @@
"study.modelization.clusters.thermal.op4": "Autre polluant 4 (t/MWh)",
"study.modelization.clusters.thermal.op5": "Autre polluant 5 (t/MWh)",
"study.modelization.clusters.operatingCosts": "Coûts d'exploitation",
"study.modelization.clusters.marginalCost": "Coûts marginaux (€/MWh)",
"study.modelization.clusters.fixedCost": "Coûts fixes (€/h)",
"study.modelization.clusters.marginalCost": "Coût marginal (€/MWh)",
"study.modelization.clusters.fixedCost": "Coûts fixes O&M (€/h)",
"study.modelization.clusters.startupCost": "Coûts de démarrage (€)",
"study.modelization.clusters.marketBidCost": "Offre de marché (€/MWh)",
"study.modelization.clusters.spreadCost": "Spread (€/MWh)",
"study.modelization.clusters.spreadCost": "Random Spread (€/MWh)",
"study.modelization.clusters.variableOMCost": "Coût variable O&M (€/MWh)",
"study.modelization.clusters.costGeneration": "TS Cost",
"study.modelization.clusters.efficiency": "Rendement (%)",
"study.modelization.clusters.timeSeriesGen": "Génération des Séries temporelles",
"study.modelization.clusters.genTs": "Générer des Séries temporelles",
"study.modelization.clusters.volatilityForced": "Volatilité forcée",
Expand All @@ -500,6 +504,8 @@
"study.modelization.clusters.matrix.common": "Common",
"study.modelization.clusters.matrix.tsGen": "TS generator",
"study.modelization.clusters.matrix.timeSeries": "Séries temporelles",
"study.modelization.clusters.matrix.fuelCost": "Fuel Cost",
"study.modelization.clusters.matrix.co2Cost": "CO2 Cost",
"study.modelization.clusters.backClusterList": "Retour à la liste des clusters",
"study.modelization.clusters.tsInterpretation": "TS interpretation",
"studies.modelization.clusters.question.delete_one": "Êtes-vous sûr de vouloir supprimer ce cluster ?",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,32 +1,37 @@
import { useTranslation } from "react-i18next";
import { useOutletContext } from "react-router";
import { StudyMetadata } from "../../../../../../../common/types";
import Box from "@mui/material/Box";
import NumberFE from "../../../../../../common/fieldEditors/NumberFE";
import SelectFE from "../../../../../../common/fieldEditors/SelectFE";
import StringFE from "../../../../../../common/fieldEditors/StringFE";
import SwitchFE from "../../../../../../common/fieldEditors/SwitchFE";
import Fieldset from "../../../../../../common/Fieldset";
import { useFormContextPlus } from "../../../../../../common/Form";
import {
COST_GENERATION_OPTIONS,
THERMAL_GROUPS,
THERMAL_POLLUTANTS,
ThermalCluster,
TS_GENERATION_OPTIONS,
TS_LAW_OPTIONS,
} from "./utils";
import { validateNumber } from "../../../../../../../utils/validationUtils";

function Fields() {
const [t] = useTranslation();
const { control } = useFormContextPlus<ThermalCluster>();
const { control, watch } = useFormContextPlus<ThermalCluster>();
const { study } = useOutletContext<{ study: StudyMetadata }>();
const studyVersion = Number(study.version);
const isTSCost = watch("costGeneration") === "useCostTimeseries";

////////////////////////////////////////////////////////////////
// JSX
////////////////////////////////////////////////////////////////

return (
<>
// TODO: remove the margin reset after updating MUI Theme.
<Box sx={{ "& .MuiFormControl-root": { margin: 0 } }}>
<Fieldset legend={t("global.general")}>
<StringFE
label={t("global.name")}
Expand All @@ -36,6 +41,7 @@ function Fields() {
/>
<SelectFE
label={t("global.group")}
variant="outlined"
name="group"
control={control}
options={THERMAL_GROUPS}
Expand Down Expand Up @@ -68,10 +74,7 @@ function Fields() {
name="unitCount"
control={control}
rules={{
min: {
value: 1,
message: t("form.field.minValue", { 0: 1 }),
},
validate: (v) => validateNumber(v, { min: 1 }),
setValueAs: Math.floor,
}}
/>
Expand All @@ -80,10 +83,7 @@ function Fields() {
name="nominalCapacity"
control={control}
rules={{
min: {
value: 0,
message: t("form.field.minValue", { 0: 0 }),
},
validate: (v) => validateNumber(v, { min: 0 }),
}}
/>
<NumberFE
Expand All @@ -96,29 +96,15 @@ function Fields() {
name="spinning"
control={control}
rules={{
min: {
value: 0,
message: t("form.field.minValue", { 0: 0 }),
},
max: {
value: 100,
message: t("form.field.maxValue", { 0: 100 }),
},
validate: (v) => validateNumber(v, { min: 0, max: 100 }),
}}
/>
<NumberFE
label={t("study.modelization.clusters.minUpTime")}
name="minUpTime"
control={control}
rules={{
min: {
value: 1,
message: t("form.field.minValue", { 0: 1 }),
},
max: {
value: 168,
message: t("form.field.maxValue", { 0: 168 }),
},
validate: (v) => validateNumber(v, { min: 1, max: 168 }),
setValueAs: Math.floor,
}}
/>
Expand All @@ -127,62 +113,72 @@ function Fields() {
name="minDownTime"
control={control}
rules={{
min: {
value: 1,
message: t("form.field.minValue", { 0: 1 }),
},
max: {
value: 168,
message: t("form.field.maxValue", { 0: 168 }),
},
validate: (v) => validateNumber(v, { min: 1, max: 168 }),
setValueAs: Math.floor,
}}
/>
</Fieldset>
<Fieldset legend={t("study.modelization.clusters.operatingCosts")}>
<SelectFE
variant="outlined"
label={t("study.modelization.clusters.costGeneration")}
name="costGeneration"
options={COST_GENERATION_OPTIONS}
control={control}
sx={{
alignSelf: "center",
}}
/>
<NumberFE
label={t("study.modelization.clusters.marginalCost")}
name="marginalCost"
label={t("study.modelization.clusters.efficiency")}
name="efficiency"
control={control}
rules={{
min: {
value: 0,
message: t("form.field.minValue", { 0: 0 }),
},
validate: (v) => validateNumber(v, { min: 0 }),
}}
disabled={!isTSCost}
/>
<NumberFE
label={t("study.modelization.clusters.fixedCost")}
name="fixedCost"
label={t("study.modelization.clusters.marginalCost")}
name="marginalCost"
control={control}
rules={{
min: {
value: 0,
message: t("form.field.minValue", { 0: 0 }),
},
validate: (v) => validateNumber(v, { min: 0 }),
}}
/>

<NumberFE
label={t("study.modelization.clusters.startupCost")}
name="startupCost"
control={control}
rules={{
min: {
value: 0,
message: t("form.field.minValue", { 0: 0 }),
},
validate: (v) => validateNumber(v, { min: 0 }),
}}
/>
<NumberFE
label={t("study.modelization.clusters.marketBidCost")}
name="marketBidCost"
control={control}
rules={{
min: {
value: 0,
message: t("form.field.minValue", { 0: 0 }),
},
validate: (v) => validateNumber(v, { min: 0 }),
}}
/>
<NumberFE
label={t("study.modelization.clusters.fixedCost")}
name="fixedCost"
control={control}
rules={{
validate: (v) => validateNumber(v, { min: 0 }),
}}
/>
<NumberFE
label={t("study.modelization.clusters.variableOMCost")}
name="variableOMCost"
control={control}
rules={{
validate: (v) => validateNumber(v, { min: 0 }),
}}
disabled={!isTSCost}
/>
<NumberFE
label={t("study.modelization.clusters.spreadCost")}
Expand All @@ -200,17 +196,15 @@ function Fields() {
name={name}
control={control}
rules={{
min: {
value: 0,
message: t("form.field.minValue", { 0: 0 }),
},
validate: (v) => validateNumber(v, { min: 0 }),
}}
/>
),
)}
</Fieldset>
<Fieldset legend={t("study.modelization.clusters.timeSeriesGen")}>
<SelectFE
variant="outlined"
label={t("study.modelization.clusters.genTs")}
name="genTs"
control={control}
Expand All @@ -224,14 +218,7 @@ function Fields() {
name="volatilityForced"
control={control}
rules={{
min: {
value: 0,
message: t("form.field.minValue", { 0: 0 }),
},
max: {
value: 1,
message: t("form.field.maxValue", { 0: 1 }),
},
validate: (v) => validateNumber(v, { min: 0, max: 1 }),
}}
inputProps={{ step: 0.1 }}
/>
Expand All @@ -240,18 +227,12 @@ function Fields() {
name="volatilityPlanned"
control={control}
rules={{
min: {
value: 0,
message: t("form.field.minValue", { 0: 0 }),
},
max: {
value: 1,
message: t("form.field.maxValue", { 0: 1 }),
},
validate: (v) => validateNumber(v, { min: 0, max: 1 }),
}}
inputProps={{ step: 0.1 }}
/>
<SelectFE
variant="outlined"
label={t("study.modelization.clusters.lawForced")}
name="lawForced"
control={control}
Expand All @@ -261,6 +242,7 @@ function Fields() {
}}
/>
<SelectFE
variant="outlined"
label={t("study.modelization.clusters.lawPlanned")}
name="lawPlanned"
control={control}
Expand All @@ -270,7 +252,7 @@ function Fields() {
}}
/>
</Fieldset>
</>
</Box>
);
}

Expand Down
Loading

0 comments on commit ac1d270

Please sign in to comment.