Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ import {
import LinearProgress from '@mui/material/LinearProgress';
import Box from '@mui/material/Box';
import { AppState } from 'redux/reducer';
import EquipmentPopover from 'components/tooltips/equipment-popover';
import type { UUID } from 'node:crypto';
import { Point } from '@svgdotjs/svg.js';
import {
ComputingType,
ElementType,
EquipmentInfos,
EquipmentType,
ExtendedEquipmentType,
IElementCreationDialog,
Expand All @@ -53,6 +53,10 @@ import { styles } from '../diagram-styles';
import { fetchNetworkElementInfos } from 'services/study/network';
import { EQUIPMENT_INFOS_TYPES } from 'components/utils/equipment-types';

import { EquipmentPopoverMap } from 'components/tooltips/equipment-popover-map';
import BranchPopoverContent from 'components/tooltips/branch-popover-content';
import GenericEquipmentPopover from 'components/tooltips/generic-equipment-popover';

type NetworkAreaDiagramContentProps = {
readonly voltageLevelIds: string[];
readonly voltageLevelToExpandIds: string[];
Expand Down Expand Up @@ -467,23 +471,37 @@ function NetworkAreaDiagramContent(props: NetworkAreaDiagramContentProps) {
setMenuAnchorPosition(null);
setShouldDisplayMenu(false);
};

/**
* RENDER
*/

const displayTooltip = () => {
const PopoverContent = EquipmentPopoverMap[hoveredEquipmentType] || BranchPopoverContent;

return (
<GenericEquipmentPopover
studyUuid={studyUuid}
anchorPosition={anchorPosition}
anchorEl={null}
equipmentId={hoveredEquipmentId}
equipmentType={hoveredEquipmentType as EquipmentType}
loadFlowStatus={loadFlowStatus}
>
{(equipmentInfos: EquipmentInfos) => (
<PopoverContent
equipmentInfos={equipmentInfos}
loadFlowStatus={loadFlowStatus}
equipmentType={hoveredEquipmentType}
/>
)}
</GenericEquipmentPopover>
);
};
return (
<>
<Box height={2}>{loadingState && <LinearProgress />}</Box>
{visible && shouldDisplayTooltip && (
<EquipmentPopover
studyUuid={studyUuid}
anchorPosition={anchorPosition}
anchorEl={null}
equipmentType={hoveredEquipmentType}
equipmentId={hoveredEquipmentId}
loadFlowStatus={loadFlowStatus}
/>
)}
{visible && shouldDisplayTooltip && displayTooltip()}
{shouldDisplayMenu && (
<NodeContextMenu
open={!!menuAnchorPosition}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,16 @@ import {
import { isNodeReadOnly } from '../../../../graph/util/model-functions';
import { useIsAnyNodeBuilding } from '../../../../utils/is-any-node-building-hook';
import { useTheme } from '@mui/material/styles';
import { ComputingType, EquipmentType, mergeSx, snackWithFallback, useSnackMessage } from '@gridsuite/commons-ui';
import {
ComputingType,
EquipmentInfos,
EquipmentType,
mergeSx,
snackWithFallback,
useSnackMessage,
} from '@gridsuite/commons-ui';
import Box from '@mui/material/Box';
import LinearProgress from '@mui/material/LinearProgress';
import EquipmentPopover from '../../../../tooltips/equipment-popover';
import { updateSwitchState } from '../../../../../services/study/network-modifications';
import { BusMenu } from 'components/menus/bus-menu';
import { PARAM_DEVELOPER_MODE } from 'utils/config-params';
Expand All @@ -47,6 +53,10 @@ import { useEquipmentMenu } from '../../../../../hooks/use-equipment-menu';
import useEquipmentDialogs from 'hooks/use-equipment-dialogs';
import useComputationDebug from '../../../../../hooks/use-computation-debug';

import GenericEquipmentPopover from 'components/tooltips/generic-equipment-popover';
import { BranchPopoverContent } from 'components/tooltips/branch-popover-content';
import { EquipmentPopoverMap } from 'components/tooltips/equipment-popover-map';

interface SingleLineDiagramContentProps {
readonly showInSpreadsheet: (menu: { equipmentId: string | null; equipmentType: EquipmentType | null }) => void;
readonly studyUuid: UUID;
Expand Down Expand Up @@ -222,7 +232,10 @@ function SingleLineDiagramContent(props: SingleLineDiagramContentProps) {
debug && subscribeDebug(ComputingType.SHORT_CIRCUIT_ONE_BUS);
})
.catch((error) => {
snackWithFallback(snackError, error, { headerId: 'startShortCircuitError' });
snackError({
messageTxt: error.message,
headerId: 'startShortCircuitError',
});
dispatch(setComputingStatus(ComputingType.SHORT_CIRCUIT_ONE_BUS, RunningStatus.FAILED));
resetOneBusShortcircuitAnalysisLoader();
})
Expand Down Expand Up @@ -311,14 +324,23 @@ function SingleLineDiagramContent(props: SingleLineDiagramContentProps) {
);

const displayTooltip = () => {
const PopoverContent = EquipmentPopoverMap[hoveredEquipmentType] || BranchPopoverContent;
return (
<EquipmentPopover
<GenericEquipmentPopover
studyUuid={studyUuid}
anchorEl={equipmentPopoverAnchorEl}
equipmentType={hoveredEquipmentType}
anchorEl={equipmentPopoverAnchorEl as HTMLElement}
equipmentId={hoveredEquipmentId}
equipmentType={hoveredEquipmentType as EquipmentType}
loadFlowStatus={loadFlowStatus}
/>
>
{(equipmentInfos: EquipmentInfos) => (
<PopoverContent
equipmentInfos={equipmentInfos}
loadFlowStatus={loadFlowStatus}
equipmentType={hoveredEquipmentType}
/>
)}
</GenericEquipmentPopover>
);
};

Expand Down
41 changes: 27 additions & 14 deletions src/components/network/network-map-panel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ import { EQUIPMENT_TYPES } from '../utils/equipment-types';
import { deleteEquipment } from '../../services/study/network-modifications';
import { fetchLinePositions, fetchSubstationPositions } from '../../services/study/geo-data';
import { useMapBoxToken } from './network-map/use-mapbox-token';
import EquipmentPopover from '../tooltips/equipment-popover';
import RunningStatus from 'components/utils/running-status';
import { useGetStudyImpacts } from 'hooks/use-get-study-impacts';
import { ROOT_NODE_LABEL } from '../../constants/node.constant';
Expand All @@ -71,6 +70,9 @@ import SelectionCreationPanel from './selection-creation-panel/selection-creatio
import { useEquipmentMenu } from '../../hooks/use-equipment-menu';
import useEquipmentDialogs from 'hooks/use-equipment-dialogs';
import { getNominalVoltageColor } from 'utils/colors';
import GenericEquipmentPopover from 'components/tooltips/generic-equipment-popover';
import { EquipmentPopoverMap } from 'components/tooltips/equipment-popover-map';
import BranchPopoverContent from 'components/tooltips/branch-popover-content';

const LABELS_ZOOM_THRESHOLD = 9;
const ARROWS_ZOOM_THRESHOLD = 7;
Expand Down Expand Up @@ -919,19 +921,6 @@ export const NetworkMapPanel = ({
);
}

const renderLinePopover = useCallback<NonNullable<NetworkMapProps['renderPopover']>>(
(elementId, ref) => (
<EquipmentPopover
studyUuid={studyUuid}
anchorEl={ref.current}
equipmentId={elementId}
equipmentType={EQUIPMENT_TYPES.LINE}
loadFlowStatus={loadFlowStatus}
/>
),
[loadFlowStatus, studyUuid]
);

const loadMapManually = useCallback(() => {
if (!isMapEquipmentsInitialized) {
// load default node map equipments
Expand All @@ -955,6 +944,30 @@ export const NetworkMapPanel = ({
updateMapEquipmentsAndGeoData,
]);

const renderLinePopover = useCallback<NonNullable<NetworkMapProps['renderPopover']>>(
(elementId, ref) => {
const PopoverContent = EquipmentPopoverMap[EQUIPMENT_TYPES.LINE] || BranchPopoverContent;

return (
<GenericEquipmentPopover
studyUuid={studyUuid}
anchorEl={ref.current}
equipmentId={elementId}
equipmentType={EquipmentType.LINE}
loadFlowStatus={loadFlowStatus}
>
{(equipmentInfos: EquipmentInfos) => (
<PopoverContent
equipmentInfos={equipmentInfos}
loadFlowStatus={loadFlowStatus}
equipmentType={EQUIPMENT_TYPES.LINE}
/>
)}
</GenericEquipmentPopover>
);
},
[loadFlowStatus, studyUuid]
);
const leaveDrawingMode = useCallback(() => {
// clear the user drawing and go back to simple select.
networkMapRef.current?.getMapDrawer().deleteAll();
Expand Down
42 changes: 42 additions & 0 deletions src/components/tooltips/branch-popover-content.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/**
* Copyright (c) 2025, RTE (http://www.rte-france.com)
* This Source Code Form is subject to the terms of the Mozilla Public
* 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 { Grid } from '@mui/material';
import { RunningStatus } from '../utils/running-status';
import { renderVoltageLevelCharacteristics } from './generic-equipment-popover-utils';
import { CharacteristicsTable } from './carateristics-table';
import { CurrentTable } from './current-table';
import { LimitsTable } from './limit-table';

interface BranchPopoverContentProps {
equipmentInfos: any;
loadFlowStatus?: RunningStatus;
equipmentType?: EquipmentType;
}

export const BranchPopoverContent: React.FC<BranchPopoverContentProps> = ({
equipmentInfos,
loadFlowStatus,
equipmentType,
}) => {
return (
<Grid container direction="column" rowSpacing={2} alignItems="center">
<CharacteristicsTable
equipmentInfos={equipmentInfos}
renderVoltageLevelCharacteristics={(equipmentInfos) =>
renderVoltageLevelCharacteristics(equipmentInfos, equipmentType)
}
/>
<CurrentTable equipmentInfos={equipmentInfos} loadFlowStatus={loadFlowStatus} />

<LimitsTable equipmentInfos={equipmentInfos} loadFlowStatus={loadFlowStatus} />
</Grid>
);
};

export default BranchPopoverContent;
49 changes: 49 additions & 0 deletions src/components/tooltips/carateristics-table.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/**
* Copyright (c) 2025, RTE (http://www.rte-france.com)
* This Source Code Form is subject to the terms of the Mozilla Public
* 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 { EquipmentInfos } from '@gridsuite/commons-ui';
import { Table, TableHead, TableRow, TableCell, TableBody, TableContainer, Grid } from '@mui/material';
import { renderCommonCharacteristics, styles } from './generic-equipment-popover-utils';
import { CellRender } from './cell-render';

interface CharacteristicsTableProps {
equipmentInfos: EquipmentInfos;
renderVoltageLevelCharacteristics?: (equipmentInfos: EquipmentInfos) => JSX.Element;
}

export const CharacteristicsTable: React.FC<CharacteristicsTableProps> = ({
equipmentInfos,
renderVoltageLevelCharacteristics,
}) => {
return (
<Grid item sx={styles.grid}>
<TableContainer sx={styles.table}>
<Table size="small" sx={styles.layout}>
<TableHead>
<TableRow>
<TableCell sx={styles.cell} />
<CellRender
isLabel={true}
label="characteristic"
colStyle={{ ...styles.cell, fontWeight: 'bold' }}
></CellRender>
<CellRender
isLabel={true}
label="values"
colStyle={{ ...styles.cell, fontWeight: 'bold' }}
></CellRender>
</TableRow>
</TableHead>
<TableBody>
{renderCommonCharacteristics(equipmentInfos)}
{renderVoltageLevelCharacteristics?.(equipmentInfos)}
</TableBody>
</Table>
</TableContainer>
</Grid>
);
};
25 changes: 25 additions & 0 deletions src/components/tooltips/cell-render.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/**
* Copyright (c) 2025, RTE (http://www.rte-france.com)
* This Source Code Form is subject to the terms of the Mozilla Public
* 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 React from 'react';
import { TableCell } from '@mui/material';
import { useIntl } from 'react-intl';

interface CellRenderProps {
label?: string;
value?: string | number;
isLabel: boolean;
colStyle: React.CSSProperties;
}

export const CellRender: React.FC<CellRenderProps> = ({ label, value, isLabel, colStyle }) => {
const intl = useIntl();

const cellLabel = label ? intl.formatMessage({ id: label }) : '';

return <TableCell sx={colStyle}>{isLabel ? cellLabel : value}</TableCell>;
};
67 changes: 67 additions & 0 deletions src/components/tooltips/current-table.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/**
* Copyright (c) 2025, RTE (http://www.rte-france.com)
* This Source Code Form is subject to the terms of the Mozilla Public
* 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 React from 'react';
import { Table, TableHead, TableRow, TableCell, TableBody, TableContainer, Grid } from '@mui/material';
import { mergeSx } from '@gridsuite/commons-ui';
import { RunningStatus } from '../utils/running-status';
import { formatValue, styles } from './generic-equipment-popover-utils';
import { CellRender } from './cell-render';

interface CurrentTableProps {
equipmentInfos: any;
loadFlowStatus?: RunningStatus;
}

export const CurrentTable: React.FC<CurrentTableProps> = ({ equipmentInfos, loadFlowStatus }) => {
return (
<Grid item sx={styles.grid}>
<TableContainer sx={styles.table}>
<Table size="small" sx={styles.layout}>
<TableHead>
<TableRow>
<CellRender
isLabel={true}
label="CURRENT"
colStyle={{ ...styles.cell, fontWeight: 'bold' }}
></CellRender>
<TableCell sx={{ ...styles.cell, fontWeight: 'bold' }}>
{formatValue(equipmentInfos?.voltageLevelId1)}
</TableCell>
<TableCell sx={{ ...styles.cell, fontWeight: 'bold' }}>
{formatValue(equipmentInfos?.voltageLevelId2)}
</TableCell>
</TableRow>
</TableHead>
<TableBody>
<TableRow>
<CellRender
isLabel={true}
label="I_(A)"
colStyle={{ ...styles.cell, fontWeight: 'bold' }}
></CellRender>
<TableCell
sx={mergeSx(styles.cell, {
opacity: loadFlowStatus === RunningStatus.SUCCEED ? 1 : 0.2,
})}
>
{formatValue(Math.round(equipmentInfos?.i1))}
</TableCell>
<TableCell
sx={mergeSx(styles.cell, {
opacity: loadFlowStatus === RunningStatus.SUCCEED ? 1 : 0.2,
})}
>
{formatValue(Math.round(equipmentInfos?.i2))}
</TableCell>
</TableRow>
</TableBody>
</Table>
</TableContainer>
</Grid>
);
};
Loading
Loading