Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] New IHM : root network #2457

Open
wants to merge 15 commits into
base: main
Choose a base branch
from
Open
2 changes: 2 additions & 0 deletions src/components/app-top-bar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ const AppTopBar = ({ user, tabIndex, onChangeTab, userManager }) => {
const theme = useSelector((state) => state[PARAM_THEME]);
const studyUuid = useSelector((state) => state.studyUuid);
const currentNode = useSelector((state) => state.currentTreeNode);
const currentRootNetworkUuid = useSelector((state) => state.currentRootNetwork);

const [isDialogSearchOpen, setIsDialogSearchOpen] = useState(false);
const [appsAndUrls, setAppsAndUrls] = useState([]);
Expand Down Expand Up @@ -175,6 +176,7 @@ const AppTopBar = ({ user, tabIndex, onChangeTab, userManager }) => {
<RunButtonContainer
studyUuid={studyUuid}
currentNode={currentNode}
currentRootNetworkUuid={currentRootNetworkUuid}
disabled={!isNodeBuilt(currentNode) || isNodeReadOnly(currentNode)}
/>
</Box>
Expand Down
11 changes: 10 additions & 1 deletion src/components/computing-status/use-all-computing-status.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ const dynamicSimulationStatusCompletions = ['dynamicSimulationResult', 'dynamicS
const voltageInitStatusCompletions = ['voltageInitResult', 'voltageInit_failed'];
const stateEstimationStatusCompletions = ['stateEstimationResult', 'stateEstimation_failed'];
// this hook loads all current computation status into redux then keeps them up to date according to notifications
export const useAllComputingStatus = (studyUuid: UUID, currentNodeUuid: UUID): void => {
export const useAllComputingStatus = (studyUuid: UUID, currentNodeUuid: UUID, currentRootNetworkUuid: UUID): void => {
const securityAnalysisAvailability = useOptionalServiceStatus(OptionalServicesNames.SecurityAnalysis);
const sensitivityAnalysisAvailability = useOptionalServiceStatus(OptionalServicesNames.SensitivityAnalysis);
const nonEvacuatedEnergyAvailability = useOptionalServiceStatus(OptionalServicesNames.SensitivityAnalysis);
Expand All @@ -72,6 +72,7 @@ export const useAllComputingStatus = (studyUuid: UUID, currentNodeUuid: UUID): v
useComputingStatus(
studyUuid,
currentNodeUuid,
currentRootNetworkUuid,
fetchLoadFlowStatus,
loadFlowStatusInvalidations,
loadFlowStatusCompletions,
Expand All @@ -82,6 +83,7 @@ export const useAllComputingStatus = (studyUuid: UUID, currentNodeUuid: UUID): v
useComputingStatus(
studyUuid,
currentNodeUuid,
currentRootNetworkUuid,
fetchSecurityAnalysisStatus,
securityAnalysisStatusInvalidations,
securityAnalysisStatusCompletions,
Expand All @@ -93,6 +95,7 @@ export const useAllComputingStatus = (studyUuid: UUID, currentNodeUuid: UUID): v
useComputingStatus(
studyUuid,
currentNodeUuid,
currentRootNetworkUuid,
fetchSensitivityAnalysisStatus,
sensitivityAnalysisStatusInvalidations,
sensitivityAnalysisStatusCompletions,
Expand All @@ -104,6 +107,7 @@ export const useAllComputingStatus = (studyUuid: UUID, currentNodeUuid: UUID): v
useComputingStatus(
studyUuid,
currentNodeUuid,
currentRootNetworkUuid,
fetchNonEvacuatedEnergyStatus,
nonEvacuatedEnergyStatusInvalidations,
nonEvacuatedEnergyStatusCompletions,
Expand All @@ -115,6 +119,7 @@ export const useAllComputingStatus = (studyUuid: UUID, currentNodeUuid: UUID): v
useComputingStatus(
studyUuid,
currentNodeUuid,
currentRootNetworkUuid,
fetchShortCircuitAnalysisStatus,
shortCircuitAnalysisStatusInvalidations,
shortCircuitAnalysisStatusCompletions,
Expand All @@ -126,6 +131,7 @@ export const useAllComputingStatus = (studyUuid: UUID, currentNodeUuid: UUID): v
useComputingStatus(
studyUuid,
currentNodeUuid,
currentRootNetworkUuid,
fetchOneBusShortCircuitAnalysisStatus,
oneBusShortCircuitAnalysisStatusInvalidations,
oneBusShortCircuitAnalysisStatusCompletions,
Expand All @@ -137,6 +143,7 @@ export const useAllComputingStatus = (studyUuid: UUID, currentNodeUuid: UUID): v
useComputingStatus(
studyUuid,
currentNodeUuid,
currentRootNetworkUuid,
fetchDynamicSimulationStatus,
dynamicSimulationStatusInvalidations,
dynamicSimulationStatusCompletions,
Expand All @@ -148,6 +155,7 @@ export const useAllComputingStatus = (studyUuid: UUID, currentNodeUuid: UUID): v
useComputingStatus(
studyUuid,
currentNodeUuid,
currentRootNetworkUuid,
fetchVoltageInitStatus,
voltageInitStatusInvalidations,
voltageInitStatusCompletions,
Expand All @@ -159,6 +167,7 @@ export const useAllComputingStatus = (studyUuid: UUID, currentNodeUuid: UUID): v
useComputingStatus(
studyUuid,
currentNodeUuid,
currentRootNetworkUuid,
fetchStateEstimationStatus,
stateEstimationStatusInvalidations,
stateEstimationStatusCompletions,
Expand Down
19 changes: 15 additions & 4 deletions src/components/computing-status/use-computing-status.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ interface UseComputingStatusProps {
(
studyUuid: UUID,
nodeUuid: UUID,
fetcher: (studyUuid: UUID, nodeUuid: UUID) => Promise<string>,
rootNetworkUuid: UUID,
fetcher: (studyUuid: UUID, nodeUuid: UUID, rootNetworkUuid: UUID) => Promise<string>,
invalidations: string[],
completions: string[],
resultConversion: (x: string) => RunningStatus,
Expand All @@ -31,7 +32,7 @@ interface UseComputingStatusProps {

interface LastUpdateProps {
studyUpdatedForce: StudyUpdated;
fetcher: (studyUuid: UUID, nodeUuid: UUID) => Promise<string>;
fetcher: (studyUuid: UUID, nodeUuid: UUID, rootNetworkUuid: UUID) => Promise<string>;
}

function isWorthUpdate(
Expand Down Expand Up @@ -84,6 +85,7 @@ function isWorthUpdate(
export const useComputingStatus: UseComputingStatusProps = (
studyUuid,
nodeUuid,
rootNetworkUuid,
fetcher,
invalidations,
completions,
Expand Down Expand Up @@ -114,7 +116,7 @@ export const useComputingStatus: UseComputingStatusProps = (
dispatch(setLastCompletedComputation());

nodeUuidRef.current = nodeUuid;
fetcher(studyUuid, nodeUuid)
fetcher(studyUuid, nodeUuid, rootNetworkUuid)
.then((res: string) => {
if (!canceledRequest && nodeUuidRef.current === nodeUuid) {
const status = resultConversion(res);
Expand All @@ -133,7 +135,16 @@ export const useComputingStatus: UseComputingStatusProps = (
return () => {
canceledRequest = true;
};
}, [nodeUuid, fetcher, studyUuid, resultConversion, dispatch, computingType, isComputationCompleted]);
}, [
nodeUuid,
rootNetworkUuid,
fetcher,
studyUuid,
resultConversion,
dispatch,
computingType,
isComputationCompleted,
]);

/* initial fetch and update */
useEffect(() => {
Expand Down
13 changes: 9 additions & 4 deletions src/components/diagrams/diagram-pane.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ import { AppState, CurrentTreeNode, DiagramState } from 'redux/reducer';
import { SLDMetadata, DiagramMetadata } from '@powsybl/network-viewer';

// Returns a callback that returns a promise
const useDisplayView = (studyUuid: UUID, currentNode: CurrentTreeNode) => {
const useDisplayView = (studyUuid: UUID, currentNode: CurrentTreeNode, currentRootNetworkUuid: UUID) => {
const { snackError } = useSnackMessage();
const paramUseName = useSelector((state: AppState) => state[PARAM_USE_NAME]);
const { getNameOrId } = useNameOrId();
Expand All @@ -72,6 +72,7 @@ const useDisplayView = (studyUuid: UUID, currentNode: CurrentTreeNode) => {
? getVoltageLevelSingleLineDiagram(
studyUuid,
currentNode?.id,
currentRootNetworkUuid,
voltageLevelId,
paramUseName,
centerName,
Expand All @@ -90,6 +91,7 @@ const useDisplayView = (studyUuid: UUID, currentNode: CurrentTreeNode) => {
? getSubstationSingleLineDiagram(
studyUuid,
currentNode?.id,
currentRootNetworkUuid,
voltageLevelId,
paramUseName,
centerName,
Expand All @@ -105,7 +107,7 @@ const useDisplayView = (studyUuid: UUID, currentNode: CurrentTreeNode) => {
const checkAndGetNetworkAreaDiagramUrl = useCallback(
(voltageLevelsIds: UUID[], depth: number) =>
isNodeBuilt(currentNode)
? getNetworkAreaDiagramUrl(studyUuid, currentNode?.id, voltageLevelsIds, depth, initNadWithGeoData)
? getNetworkAreaDiagramUrl(studyUuid, currentNode?.id,currentRootNetworkUuid, voltageLevelsIds, depth, initNadWithGeoData)
: null,
[studyUuid, currentNode, initNadWithGeoData]
);
Expand Down Expand Up @@ -294,6 +296,7 @@ const styles = {
interface DiagramPaneProps {
studyUuid: UUID;
currentNode: CurrentTreeNode;
currentRootNetworkUuid: UUID;
showInSpreadsheet: (equipment: { equipmentId: string | null; equipmentType: EquipmentType | null }) => void;
visible: boolean;
}
Expand All @@ -313,17 +316,18 @@ type DiagramView = {
depth?: number;
error?: string;
nodeId?: UUID;
rootNetworkId?: UUID;
additionalMetadata?: any;
fetchSvg?: () => Promise<Partial<DiagramView>>;
};

export function DiagramPane({ studyUuid, currentNode, showInSpreadsheet, visible }: DiagramPaneProps) {
export function DiagramPane({ studyUuid, currentNode, currentRootNetworkUuid, showInSpreadsheet, visible }: DiagramPaneProps) {
const dispatch = useDispatch();
const intl = useIntl();
const studyUpdatedForce = useSelector((state: AppState) => state.studyUpdated);
const [views, setViews] = useState<DiagramView[]>([]);
const fullScreenDiagram = useSelector((state: AppState) => state.fullScreenDiagram);
const createView = useDisplayView(studyUuid, currentNode);
const createView = useDisplayView(studyUuid, currentNode, currentRootNetworkUuid);
const diagramStates = useSelector((state: AppState) => state.diagramStates);
const networkAreaDiagramDepth = useSelector((state: AppState) => state.networkAreaDiagramDepth);
const previousNetworkAreaDiagramDepth = useRef(networkAreaDiagramDepth);
Expand Down Expand Up @@ -767,6 +771,7 @@ export function DiagramPane({ studyUuid, currentNode, showInSpreadsheet, visible

// This effect will trigger the diagrams' forced update
useEffect(() => {
console.log('TEST', studyUpdatedForce);
if (studyUpdatedForce.eventData.headers) {
if (studyUpdatedForce.eventData.headers['updateType'] === 'loadflowResult') {
//TODO reload data more intelligently
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ interface PositionDiagramPaneProps {
onClose: () => void;
voltageLevelId?: { id: UUID };
currentNodeUuid: UUID;
currentRootNetworkUuid: UUID;
studyUuid: UUID;
}

Expand All @@ -36,6 +37,7 @@ const PositionDiagramPane: FC<PositionDiagramPaneProps> = ({
onClose,
voltageLevelId,
currentNodeUuid,
currentRootNetworkUuid,
studyUuid,
}) => {
const useName = useSelector((state: AppState) => state[PARAM_USE_NAME]);
Expand All @@ -55,6 +57,7 @@ const PositionDiagramPane: FC<PositionDiagramPaneProps> = ({
getVoltageLevelSingleLineDiagram(
studyUuid,
currentNodeUuid,
currentRootNetworkUuid,
voltageLevelId?.id,
useName,
centerName,
Expand All @@ -63,7 +66,7 @@ const PositionDiagramPane: FC<PositionDiagramPaneProps> = ({
SLD_DISPLAY_MODE.FEEDER_POSITION,
language
),
[studyUuid, currentNodeUuid, voltageLevelId?.id, useName, centerName, diagonalName, componentLibrary, language]
[studyUuid, currentNodeUuid,currentRootNetworkUuid, voltageLevelId?.id, useName, centerName, diagonalName, componentLibrary, language]
);

useEffect(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,8 @@ function SingleLineDiagramContent(props: SingleLineDiagramContentProps) {
const diagramViewerRef = useRef<SingleLineDiagramViewer>();
const { snackError } = useSnackMessage();
const currentNode = useSelector((state: AppState) => state.currentTreeNode);
const currentRootNetworkUuid = useSelector((state: AppState) => state.currentRootNetwork);

const [modificationInProgress, setModificationInProgress] = useState(false);
const isAnyNodeBuilding = useIsAnyNodeBuilding();
const [locallySwitchedBreaker, setLocallySwitchedBreaker] = useState<string>();
Expand Down Expand Up @@ -488,6 +490,7 @@ function SingleLineDiagramContent(props: SingleLineDiagramContentProps) {
open={true}
studyUuid={studyUuid}
currentNode={currentNode}
currentRootNetworkUuid={currentRootNetworkUuid}
defaultIdValue={equipmentToModify?.equipmentId}
isUpdate={true}
onClose={() => closeModificationDialog()}
Expand All @@ -505,6 +508,7 @@ function SingleLineDiagramContent(props: SingleLineDiagramContentProps) {
open={true}
studyUuid={studyUuid}
currentNode={currentNode}
currentRootNetworkUuid={currentRootNetworkUuid}
defaultIdValue={equipmentToDelete?.equipmentId}
isUpdate={true}
onClose={() => closeDeletionDialog()}
Expand Down
Loading