Skip to content

Commit

Permalink
Merge branch 'main' into debounce_nad_generation
Browse files Browse the repository at this point in the history
  • Loading branch information
ayolab authored Jul 12, 2024
2 parents 0831ee9 + 14d2840 commit 93cc067
Show file tree
Hide file tree
Showing 13 changed files with 93 additions and 59 deletions.
20 changes: 10 additions & 10 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -256,9 +256,11 @@ const BatteryModificationDialog = ({
setDataFetchStatus(FetchStatus.SUCCEED);
})
.catch(() => {
setBatteryToModify(null);
setDataFetchStatus(FetchStatus.FAILED);
reset(emptyFormData);
if (editData?.equipmentId !== equipmentId) {
setBatteryToModify(null);
reset(emptyFormData);
}
});
} else {
setValuesAndEmptyOthers();
Expand All @@ -272,6 +274,7 @@ const BatteryModificationDialog = ({
setValue,
setValuesAndEmptyOthers,
reset,
editData,
]
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -310,9 +310,11 @@ const GeneratorModificationDialog = ({
setDataFetchStatus(FetchStatus.SUCCEED);
})
.catch(() => {
setGeneratorToModify(null);
reset(emptyFormData);
setDataFetchStatus(FetchStatus.FAILED);
if (editData?.equipmentId !== equipmentId) {
setGeneratorToModify(null);
reset(emptyFormData);
}
});
} else {
setValuesAndEmptyOthers();
Expand All @@ -326,6 +328,7 @@ const GeneratorModificationDialog = ({
getValues,
setValue,
setValuesAndEmptyOthers,
editData,
]
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -328,9 +328,11 @@ const LineModificationDialog = ({
setDataFetchStatus(FetchStatus.SUCCEED);
})
.catch(() => {
setLineToModify(null);
setDataFetchStatus(FetchStatus.FAILED);
reset(emptyFormData);
if (editData?.equipmentId !== equipmentId) {
setLineToModify(null);
reset(emptyFormData);
}
});
} else {
setLineToModify(null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,19 +177,21 @@ const ShuntCompensatorModificationDialog = ({
setLoading(false);
})
.catch((error) => {
setShuntCompensatorInfos(null);
setDataFetchStatus(FetchStatus.FAILED);
if (error.status === 404) {
setIdExists(true);
}
setLoading(false);
reset(emptyFormData);
if (editData?.equipmentId !== equipmentId) {
setShuntCompensatorInfos(null);
reset(emptyFormData);
}
});
} else {
setShuntCompensatorInfos(null);
}
},
[currentNode.id, snackError, studyUuid, reset, getValues]
[currentNode.id, snackError, studyUuid, reset, getValues, editData]
);

useEffect(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -760,8 +760,11 @@ const TwoWindingsTransformerModificationDialog = ({
setDataFetchStatus(FetchStatus.SUCCEED);
})
.catch(() => {
setTwtToModify(null);
setDataFetchStatus(FetchStatus.FAILED);
if (editData?.equipmentId !== equipmentId) {
setTwtToModify(null);
reset(emptyFormData);
}
});
} else {
setTwtToModify(null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,16 +162,18 @@ const VoltageLevelModificationDialog = ({
}
})
.catch(() => {
setVoltageLevelInfos(null);
setDataFetchStatus(FetchStatus.FAILED);
reset(emptyFormData);
if (editData?.equipmentId !== equipmentId) {
setVoltageLevelInfos(null);
reset(emptyFormData);
}
});
} else {
setVoltageLevelInfos(null);
reset(emptyFormData, { keepDefaultValues: true });
}
},
[studyUuid, currentNodeUuid, reset, getValues]
[studyUuid, currentNodeUuid, reset, getValues, editData]
);

useEffect(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,15 +174,15 @@ const VscModificationDialog: React.FC<any> = ({
);

const onEquipmentIdChange = useCallback(
(equipementId: string | null) => {
if (equipementId) {
(equipmentId: string | null) => {
if (equipmentId) {
setDataFetchStatus(FetchStatus.RUNNING);
fetchNetworkElementInfos(
studyUuid,
currentNodeUuid,
EQUIPMENT_TYPES.HVDC_LINE,
EQUIPMENT_INFOS_TYPES.FORM.type,
equipementId,
equipmentId,
true
)
.then((value: any) => {
Expand Down Expand Up @@ -243,10 +243,12 @@ const VscModificationDialog: React.FC<any> = ({
}));
setDataFetchStatus(FetchStatus.SUCCEED);
})
.catch((_error) => {
.catch(() => {
setDataFetchStatus(FetchStatus.FAILED);
setVcsToModify(null);
reset(emptyFormData);
if (editData?.equipmentId !== equipmentId) {
setVcsToModify(null);
reset(emptyFormData);
}
});
} else {
setValuesAndEmptyOthers();
Expand All @@ -260,6 +262,7 @@ const VscModificationDialog: React.FC<any> = ({
getValues,
reset,
setValuesAndEmptyOthers,
editData,
]
);
useEffect(() => {
Expand Down
3 changes: 2 additions & 1 deletion src/components/network/use-save-map.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ export const useSaveMap = (): UseSaveMapOutput => {
distDir,
studyUuid,
currentNodeUuid,
equipments
equipments,
nominalVoltages
);
snackInfo({
messageTxt: intl.formatMessage({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
import { EquipmentType } from '@gridsuite/commons-ui';
import { EquipmentType, FILTER_EQUIPMENTS } from '@gridsuite/commons-ui';
import { Search, SearchOff, Tune } from '@mui/icons-material';
import {
AutocompleteRenderInputParams,
Expand Down Expand Up @@ -79,7 +79,14 @@ export const TopBarEquipmentSearchInput = (
onDelete={() => setEquipmentType(null)}
label={
<FormattedMessage
id={equipmentType.toString()}
id={
Object.values(
FILTER_EQUIPMENTS
).find(
(eq) =>
eq.id === equipmentType
)?.label
}
/>
}
sx={styles.chip}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,23 +90,17 @@ export const TopBarEquipmentSearchPopover = (
<HorizontalRule />
<FormattedMessage id="NoFilter" />
</Box>
{Object.values(FILTER_EQUIPMENTS)
.map((type) => type.id)
.map((type) => {
return (
<FormControlLabel
key={type.toString()}
value={type.toString()}
control={<Radio />}
sx={styles.radioButtonColor}
label={
<FormattedMessage
id={type.toString()}
/>
}
/>
);
})}
{Object.values(FILTER_EQUIPMENTS).map((type) => {
return (
<FormControlLabel
key={type.id}
value={type.id}
control={<Radio />}
sx={styles.radioButtonColor}
label={<FormattedMessage id={type.label} />}
/>
);
})}
</RadioGroup>
</FormControl>
</Box>
Expand Down
6 changes: 4 additions & 2 deletions src/services/study/network-map.js
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,8 @@ export async function createMapContingencyList(
distDir,
studyUuid,
currentNodeUuid,
selectedEquipments
selectedEquipments,
nominalVoltages
) {
let equipmentContingencyList = [];
switch (contingencyList.equipmentType) {
Expand All @@ -270,7 +271,8 @@ export async function createMapContingencyList(
selectedEquipmentsIds,
contingencyList.equipmentType,
EQUIPMENT_INFOS_TYPES.LIST.type,
false
false,
nominalVoltages
);

if (elementsIds?.length === 0) {
Expand Down
28 changes: 20 additions & 8 deletions src/services/study/network.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
backendFetch,
backendFetchJson,
backendFetchText,
getQueryParamsList,
getUrlWithToken,
} from '../utils';

Expand Down Expand Up @@ -138,16 +139,25 @@ export function fetchNetworkElementsInfos(
substationsIds,
elementType,
infoType,
inUpstreamBuiltParentNode
inUpstreamBuiltParentNode,
nominalVoltages = undefined
) {
const substationsCount = substationsIds ? substationsIds.length : 0;
const nominalVoltagesStr = nominalVoltages ? `[${nominalVoltages}]` : '[]';

console.info(
`Fetching network '${elementType}' elements '${infoType}' infos of study '${studyUuid}' and node '${currentNodeUuid}' with substations ids '${substationsIds}'...`
`Fetching network '${elementType}' elements '${infoType}' infos of study '${studyUuid}' and node '${currentNodeUuid}' with ${substationsCount} substations ids and ${nominalVoltagesStr} nominal voltages.`
);

const elementInfos = {
elementType: elementType,
substationsIds: substationsIds ?? null,
};
const nominalVoltagesParams = getQueryParamsList(
nominalVoltages,
'nominalVoltages'
);

const nominalVoltagesParamsList =
nominalVoltages && nominalVoltages?.length > 0
? '&' + nominalVoltagesParams
: '';

const urlSearchParams = new URLSearchParams();
if (inUpstreamBuiltParentNode !== undefined) {
Expand All @@ -157,18 +167,20 @@ export function fetchNetworkElementsInfos(
);
}
urlSearchParams.append('infoType', infoType);
urlSearchParams.append('elementType', elementType);

const fetchElementsUrl =
getStudyUrlWithNodeUuid(studyUuid, currentNodeUuid) +
'/network/elements' +
'?' +
urlSearchParams;
urlSearchParams +
nominalVoltagesParamsList;
console.debug(fetchElementsUrl);

return backendFetchJson(fetchElementsUrl, {
method: 'post',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(elementInfos),
body: JSON.stringify(substationsIds ?? null),
});
}

Expand Down

0 comments on commit 93cc067

Please sign in to comment.