Skip to content

Commit

Permalink
Merge pull request #1883 from AntaresSimulatorTeam/feature/ANT-968_mo…
Browse files Browse the repository at this point in the history
…ve_table_mode
  • Loading branch information
skamril authored Jan 9, 2024
2 parents f5c4146 + 6454267 commit abb141f
Show file tree
Hide file tree
Showing 43 changed files with 631 additions and 466 deletions.
8 changes: 4 additions & 4 deletions antarest/study/web/study_data_blueprint.py
Original file line number Diff line number Diff line change
Expand Up @@ -757,14 +757,14 @@ def set_timeseries_form_values(
study_service.ts_config_manager.set_field_values(study, field_values)

@bp.get(
path="/studies/{uuid}/tablemode/form",
path="/studies/{uuid}/tablemode",
tags=[APITag.study_data],
summary="Get table data for table form",
# `Any` because `Union[AreaColumns, LinkColumns]` not working
response_model=Dict[str, Dict[str, Any]],
response_model_exclude_none=True,
)
def get_table_data(
def get_table_mode(
uuid: str,
table_type: TableTemplateType,
columns: str,
Expand All @@ -780,11 +780,11 @@ def get_table_data(
return study_service.table_mode_manager.get_table_data(study, table_type, columns.split(","))

@bp.put(
path="/studies/{uuid}/tablemode/form",
path="/studies/{uuid}/tablemode",
tags=[APITag.study_data],
summary="Set table data with values from table form",
)
def set_table_data(
def set_table_mode(
uuid: str,
table_type: TableTemplateType,
data: Dict[str, ColumnsModelTypes],
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -1271,7 +1271,7 @@ def test_area_management(client: TestClient, admin_access_token: str, study_id:

# --- TableMode START ---

table_mode_url = f"/v1/studies/{study_id}/tablemode/form"
table_mode_url = f"/v1/studies/{study_id}/tablemode"

# Table Mode - Area

Expand Down
17 changes: 9 additions & 8 deletions webapp/public/locales/en/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -266,13 +266,6 @@
"study.modelization.links.matrix.columns.loopFlow": "Loop flow",
"study.modelization.links.matrix.columns.pShiftMin": "P.Shift Min",
"study.modelization.links.matrix.columns.pShiftMax": "P.Shift Max",
"study.modelization.tableMode": "Table Mode",
"study.modelization.tableMode.template.economicOpt": "Economic Opt.",
"study.modelization.tableMode.template.geographicTrimmingAreas": "Geographic Trimming (areas)",
"study.modelization.tableMode.template.geographicTrimmingLinks": "Geographic Trimming (links)",
"study.modelization.tableMode.dialog.add.title": "Add table",
"study.modelization.tableMode.dialog.edit.title": "Edit table",
"study.modelization.tableMode.dialog.delete.text": "Are you sure you want to delete '{{0}}' table?",
"study.configuration.general.legend.simulation": "Simulation",
"study.configuration.general.legend.calendar": "Calendar",
"study.configuration.general.legend.monteCarloScenarios": "Monte-Carlo Scenarios",
Expand Down Expand Up @@ -337,7 +330,8 @@
"study.configuration.optimization.exportMps": "Export MPS",
"study.configuration.optimization.unfeasibleProblemBehavior": "Unfeasible problem behavior",
"study.configuration.optimization.simplexOptimizationRange": "Simplex optimization range",
"study.configuration.adequacyPatch.legend.general": "General",
"study.configuration.adequacyPatch.tab.general": "General",
"study.configuration.adequacyPatch.tab.perimeter": "Perimeter",
"study.configuration.adequacyPatch.legend.localMatchingRule": "Local matching rule",
"study.configuration.adequacyPatch.legend.curtailmentSharing": "Curtailment sharing",
"study.configuration.adequacyPatch.legend.advanced": "Advanced",
Expand Down Expand Up @@ -374,6 +368,9 @@
"study.configuration.advancedParameters.unitCommitmentMode": "Unit commitment mode",
"study.configuration.advancedParameters.simulationCores": "Simulation cores",
"study.configuration.advancedParameters.renewableGenerationModeling": "Renewable generation modeling",
"study.configuration.economicOpt": "Economic Opt.",
"study.configuration.geographicTrimmingAreas": "Geographic Trimming (areas)",
"study.configuration.geographicTrimmingLinks": "Geographic Trimming (links)",
"study.modelization.properties": "Properties",
"study.modelization.properties.posX": "Position X",
"study.modelization.properties.posY": "Position Y",
Expand Down Expand Up @@ -494,6 +491,10 @@
"study.modelization.bindingConst.offset": "Offset",
"study.modelization.bindingConst.question.deleteConstraintTerm": "Are you sure you want to delete this constraint term?",
"study.modelization.bindingConst.question.deleteBindingConstraint": "Are you sure you want to delete this binding constraint?",
"study.tableMode": "Table Mode",
"study.tableMode.dialog.add.title": "Add table",
"study.tableMode.dialog.edit.title": "Edit table",
"study.tableMode.dialog.delete.text": "Are you sure you want to delete '{{name}}' table?",
"study.results.mc": "Monte-Carlo",
"study.results.display": "Display",
"study.results.temporality": "Temporality",
Expand Down
18 changes: 9 additions & 9 deletions webapp/public/locales/fr/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,6 @@
"study.archiveOutputMode": "Mode archivé",
"study.postProcessing": "Post-traitement",
"study.timeLimit": "Limite de temps (h)",
"study.timeLimitHelper": "(heures) max: {{max}}h",
"study.nbCpu": "Nombre de coeurs",
"study.clusterLoad": "Charge du cluster",
"study.synthesis": "Synthèse",
Expand Down Expand Up @@ -267,13 +266,6 @@
"study.modelization.links.matrix.columns.loopFlow": "Loop flow",
"study.modelization.links.matrix.columns.pShiftMin": "P.Shift Min",
"study.modelization.links.matrix.columns.pShiftMax": "P.Shift Max",
"study.modelization.tableMode": "Table Mode",
"study.modelization.tableMode.template.economicOpt": "Options économiques",
"study.modelization.tableMode.template.geographicTrimmingAreas": "Filtre géographique (zones)",
"study.modelization.tableMode.template.geographicTrimmingLinks": "Filtre géographique (liens)",
"study.modelization.tableMode.dialog.add.title": "Ajouter une table",
"study.modelization.tableMode.dialog.edit.title": "Modifier une table",
"study.modelization.tableMode.dialog.delete.text": "Êtes-vous sûr de vouloir supprimer la table '{{0}}' ?",
"study.configuration.general.legend.simulation": "Simulation",
"study.configuration.general.legend.calendar": "Calendrier",
"study.configuration.general.legend.monteCarloScenarios": "Scénarios Monte-Carlo",
Expand Down Expand Up @@ -338,7 +330,8 @@
"study.configuration.optimization.exportMps": "Export MPS",
"study.configuration.optimization.unfeasibleProblemBehavior": "Unfeasible problem behavior",
"study.configuration.optimization.simplexOptimizationRange": "Simplex optimization range",
"study.configuration.adequacyPatch.legend.general": "Générale",
"study.configuration.adequacyPatch.tab.general": "Général",
"study.configuration.adequacyPatch.tab.perimeter": "Périmètre",
"study.configuration.adequacyPatch.legend.localMatchingRule": "Règle de correspondance locale",
"study.configuration.adequacyPatch.legend.curtailmentSharing": "Partage de réduction",
"study.configuration.adequacyPatch.legend.advanced": "Avancée",
Expand Down Expand Up @@ -375,6 +368,9 @@
"study.configuration.advancedParameters.unitCommitmentMode": "Unit commitment mode",
"study.configuration.advancedParameters.simulationCores": "Simulation cores",
"study.configuration.advancedParameters.renewableGenerationModeling": "Renewable generation modeling",
"study.configuration.economicOpt": "Options économiques",
"study.configuration.geographicTrimmingAreas": "Filtre géographique (zones)",
"study.configuration.geographicTrimmingLinks": "Filtre géographique (liens)",
"study.modelization.properties": "Propriétés",
"study.modelization.properties.posX": "Position X",
"study.modelization.properties.posY": "Position Y",
Expand Down Expand Up @@ -495,6 +491,10 @@
"study.modelization.bindingConst.offset": "Décalage",
"study.modelization.bindingConst.question.deleteConstraintTerm": "Êtes-vous sûr de vouloir supprimer ce terme ?",
"study.modelization.bindingConst.question.deleteBindingConstraint": "Êtes-vous sûr de vouloir supprimer cette contrainte couplante ?",
"study.tableMode": "Table Mode",
"study.tableMode.dialog.add.title": "Ajouter une table",
"study.tableMode.dialog.edit.title": "Modifier une table",
"study.tableMode.dialog.delete.text": "Êtes-vous sûr de vouloir supprimer la table '{{name}}' ?",
"study.results.mc": "Monte-Carlo",
"study.results.display": "Affichage",
"study.results.temporality": "Temporalité",
Expand Down
2 changes: 1 addition & 1 deletion webapp/src/components/App/Settings/Groups/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import Header from "./Header";
import UpdateGroupDialog from "./dialog/UpdateGroupDialog";
import { getAuthUser } from "../../../../redux/selectors";
import useAppSelector from "../../../../redux/hooks/useAppSelector";
import { isSearchMatching } from "../../../../utils/textUtils";
import { isSearchMatching } from "../../../../utils/stringUtils";

/**
* Types
Expand Down
2 changes: 1 addition & 1 deletion webapp/src/components/App/Settings/Tokens/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import Header from "./Header";
import { getAuthUser } from "../../../../redux/selectors";
import TokenInfoDialog from "./dialog/TokenInfoDialog";
import useAppSelector from "../../../../redux/hooks/useAppSelector";
import { isSearchMatching } from "../../../../utils/textUtils";
import { isSearchMatching } from "../../../../utils/stringUtils";

/**
* Types
Expand Down
2 changes: 1 addition & 1 deletion webapp/src/components/App/Settings/Users/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import { RESERVED_USER_NAMES } from "../utils";
import { UserDetailsDTO } from "../../../../common/types";
import UpdateUserDialog from "./dialog/UpdateUserDialog";
import { sortByName } from "../../../../services/utils";
import { isSearchMatching } from "../../../../utils/textUtils";
import { isSearchMatching } from "../../../../utils/stringUtils";

/**
* Types
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,7 @@ function Fields() {

return (
<Box>
<Fieldset
legend={t("study.configuration.adequacyPatch.legend.general")}
fullFieldWidth
>
<Fieldset fullFieldWidth>
<SwitchFE
label={t("study.configuration.adequacyPatch.enableAdequacyPatch")}
name="enableAdequacyPatch"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { useOutletContext } from "react-router";
import { useTranslation } from "react-i18next";
import { StudyMetadata } from "../../../../../../common/types";
import Form from "../../../../../common/Form";
import { SubmitHandlerPlus } from "../../../../../common/Form/types";
Expand All @@ -8,9 +9,12 @@ import {
getAdequacyPatchFormFields,
setAdequacyPatchFormFields,
} from "./utils";
import TableMode from "../../../../../common/TableMode";
import TabsView from "../../../../../common/TabsView";

function AdequacyPatch() {
const { study } = useOutletContext<{ study: StudyMetadata }>();
const { t } = useTranslation();

////////////////////////////////////////////////////////////////
// Event Handlers
Expand All @@ -27,16 +31,36 @@ function AdequacyPatch() {
////////////////////////////////////////////////////////////////

return (
<Form
key={study.id}
config={{
defaultValues: () => getAdequacyPatchFormFields(study.id),
}}
onSubmit={handleSubmit}
enableUndoRedo
>
<Fields />
</Form>
<TabsView
items={[
{
label: t("study.configuration.adequacyPatch.tab.general"),
content: (
<Form
key={study.id}
config={{
defaultValues: () => getAdequacyPatchFormFields(study.id),
}}
onSubmit={handleSubmit}
enableUndoRedo
>
<Fields />
</Form>
),
},
{
label: t("study.configuration.adequacyPatch.tab.perimeter"),
content: (
<TableMode
studyId={study.id}
type="area"
columns={["adequacyPatchMode"]}
/>
),
},
]}
TabListProps={{ sx: { mt: -2 } }}
/>
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
getAreas,
getLinks,
} from "../../../../../../../../../redux/selectors";
import FormTable from "../../../../../../../../common/FormTable";
import TableForm from "../../../../../../../../common/TableForm";
import ConfigContext from "../ConfigContext";
import { updateScenarioBuilderConfig } from "../utils";
import { SubmitHandlerPlus } from "../../../../../../../../common/Form/types";
Expand Down Expand Up @@ -116,7 +116,7 @@ function Table(props: Props) {
////////////////////////////////////////////////////////////////

return (
<FormTable
<TableForm
key={JSON.stringify(defaultValues)}
defaultValues={defaultValues}
tableProps={{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useContext, useEffect, useMemo, useState } from "react";
import useStudySynthesis from "../../../../../../../../../redux/hooks/useStudySynthesis";
import { getAreas } from "../../../../../../../../../redux/selectors";
import { isSearchMatching } from "../../../../../../../../../utils/textUtils";
import { isSearchMatching } from "../../../../../../../../../utils/stringUtils";
import PropertiesView from "../../../../../../../../common/PropertiesView";
import SplitLayoutView from "../../../../../../../../common/SplitLayoutView";
import UsePromiseCond from "../../../../../../../../common/utils/UsePromiseCond";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import Handsontable from "handsontable";
import { StudyMetadata } from "../../../../../../../../common/types";
import usePromise from "../../../../../../../../hooks/usePromise";
import BasicDialog from "../../../../../../../common/dialogs/BasicDialog";
import FormTable from "../../../../../../../common/FormTable";
import TableForm from "../../../../../../../common/TableForm";
import BackdropLoading from "../../../../../../../common/loaders/BackdropLoading";
import UsePromiseCond from "../../../../../../../common/utils/UsePromiseCond";
import {
Expand Down Expand Up @@ -115,7 +115,7 @@ function ScenarioPlaylistDialog(props: Props) {
)}
</Button>
</Box>
<FormTable
<TableForm
defaultValues={defaultValues}
onSubmit={handleSubmit}
sx={{ pt: 2, m: "0 auto" }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
UseFormReturnPlus,
} from "../../../../../../../common/Form/types";
import SearchFE from "../../../../../../../common/fieldEditors/SearchFE";
import { isSearchMatching } from "../../../../../../../../utils/textUtils";
import { isSearchMatching } from "../../../../../../../../utils/stringUtils";
import FormDialog from "../../../../../../../common/dialogs/FormDialog";
import {
getFieldNames,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ function Fields() {
////////////////////////////////////////////////////////////////

return (
<TableContainer sx={{ mb: 1 }}>
<TableContainer>
<Table sx={{ minWidth: "1050px" }} size="small">
<TableHead>
<TableRow sx={{ th: { py: 1, borderBottom: "none" } }}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { Paper } from "@mui/material";
import * as R from "ramda";
import { useMemo, useState } from "react";
import { useOutletContext } from "react-router";
import { useTranslation } from "react-i18next";
import { StudyMetadata } from "../../../../../common/types";
import UnderConstruction from "../../../../common/page/UnderConstruction";
import PropertiesView from "../../../../common/PropertiesView";
Expand All @@ -14,10 +15,12 @@ import General from "./General";
import Optimization from "./Optimization";
import RegionalDistricts from "./RegionalDistricts";
import TimeSeriesManagement from "./TimeSeriesManagement";
import TableMode from "../../../../common/TableMode";

function Configuration() {
const { study } = useOutletContext<{ study: StudyMetadata }>();
const [currentTabIndex, setCurrentTabIndex] = useState(0);
const { t } = useTranslation();

// TODO i18n
const tabList = useMemo(
Expand All @@ -29,8 +32,11 @@ function Configuration() {
{ id: 3, name: "Optimization preferences" },
Number(study.version) >= 830 && { id: 4, name: "Adequacy Patch" },
{ id: 5, name: "Advanced parameters" },
{ id: 6, name: t("study.configuration.economicOpt") },
{ id: 7, name: t("study.configuration.geographicTrimmingAreas") },
{ id: 8, name: t("study.configuration.geographicTrimmingLinks") },
].filter(Boolean),
[study.version],
[study.version, t],
);

return (
Expand Down Expand Up @@ -58,6 +64,44 @@ function Configuration() {
[R.equals(3), () => <Optimization />],
[R.equals(4), () => <AdequacyPatch />],
[R.equals(5), () => <AdvancedParameters />],
[
R.equals(6),
() => (
<TableMode
studyId={study.id}
type="area"
columns={[
"averageUnsuppliedEnergyCost",
"spreadUnsuppliedEnergyCost",
"averageSpilledEnergyCost",
"spreadSpilledEnergyCost",
"nonDispatchablePower",
"dispatchableHydroPower",
"otherDispatchablePower",
]}
/>
),
],
[
R.equals(7),
() => (
<TableMode
studyId={study.id}
type="area"
columns={["filterYearByYear", "filterSynthesis"]}
/>
),
],
[
R.equals(8),
() => (
<TableMode
studyId={study.id}
type="link"
columns={["filterYearByYear", "filterSynthesis"]}
/>
),
],
])(tabList[currentTabIndex].id)}
</Paper>
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
} from "../../../../../../../redux/selectors";
import useAppDispatch from "../../../../../../../redux/hooks/useAppDispatch";
import AreaConfig from "./AreaConfig";
import { isSearchMatching } from "../../../../../../../utils/textUtils";
import { isSearchMatching } from "../../../../../../../utils/stringUtils";
import { setCurrentArea } from "../../../../../../../redux/ducks/studySyntheses";
import { StudyMapNode } from "../../../../../../../redux/ducks/studyMaps";

Expand Down
Loading

0 comments on commit abb141f

Please sign in to comment.