-
Notifications
You must be signed in to change notification settings - Fork 4
refactoring #3496
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
refactoring #3496
Changes from 2 commits
55fd46b
cade03b
bc9e548
1b40228
a214372
ab3aa99
60c605f
c4a18e9
79f3efe
6de23d6
777c590
4fa7f07
1c4ca30
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| /* eslint-disable prettier/prettier */ | ||
souissimai marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| import { EquipmentInfos, EquipmentType } from '@gridsuite/commons-ui'; | ||
|
Check warning on line 2 in src/components/tooltips/branch-popover-content.tsx
|
||
| import { Grid } from '@mui/material'; | ||
| import { RunningStatus } from '../utils/running-status'; | ||
| import { IntlShape } from 'react-intl'; | ||
| 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; | ||
| intl: IntlShape; | ||
| equipmentType?: EquipmentType; | ||
| } | ||
|
|
||
| export const BranchPopoverContent: React.FC<BranchPopoverContentProps> = ({ | ||
| equipmentInfos, | ||
| loadFlowStatus, | ||
| intl, | ||
| equipmentType, | ||
| }) => { | ||
| return ( | ||
| <Grid container direction="column" rowSpacing={2} alignItems="center"> | ||
| <CharacteristicsTable | ||
| equipmentInfos={equipmentInfos} | ||
| intl={intl} | ||
| renderVoltageLevelCharacteristics={(equipmentInfos, intl) => | ||
| renderVoltageLevelCharacteristics(equipmentInfos, equipmentType, intl) | ||
| } | ||
| /> | ||
| <CurrentTable equipmentInfos={equipmentInfos} intl={intl} loadFlowStatus={loadFlowStatus} /> | ||
|
|
||
| <LimitsTable equipmentInfos={equipmentInfos} intl={intl} loadFlowStatus={loadFlowStatus} /> | ||
| </Grid> | ||
| ); | ||
| }; | ||
|
|
||
| export default BranchPopoverContent; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| import { EquipmentInfos } from '@gridsuite/commons-ui'; | ||
|
Check warning on line 1 in src/components/tooltips/carateristics-table.tsx
|
||
souissimai marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| import { Table, TableHead, TableRow, TableCell, TableBody, TableContainer, Paper, Grid } from '@mui/material'; | ||
|
Check warning on line 2 in src/components/tooltips/carateristics-table.tsx
|
||
| import { MuiStyles } from '@gridsuite/commons-ui'; | ||
|
Check warning on line 3 in src/components/tooltips/carateristics-table.tsx
|
||
| import { IntlShape } from 'react-intl'; | ||
| import { renderCommonCharacteristics, styles } from './generic-equipment-popover-utils'; | ||
|
|
||
| interface CharacteristicsTableProps { | ||
| equipmentInfos: EquipmentInfos; | ||
| intl: IntlShape; | ||
| renderVoltageLevelCharacteristics?: (equipmentInfos: EquipmentInfos, intl: IntlShape) => JSX.Element; | ||
| } | ||
|
|
||
| export const CharacteristicsTable: React.FC<CharacteristicsTableProps> = ({ | ||
| equipmentInfos, | ||
| intl, | ||
| renderVoltageLevelCharacteristics, | ||
| }) => { | ||
| return ( | ||
| <Grid item sx={{ width: '100%' }}> | ||
| <TableContainer sx={styles.table}> | ||
| <Table size="small" sx={{ width: '100%', tableLayout: 'auto' }}> | ||
| <TableHead> | ||
| <TableRow> | ||
| <TableCell sx={styles.cell} /> | ||
| <TableCell sx={{ ...styles.cell, fontWeight: 'bold' }}> | ||
| {intl.formatMessage({ id: 'characteristic' })} | ||
| </TableCell> | ||
| <TableCell sx={{ ...styles.cell, fontWeight: 'bold' }}> | ||
| {intl.formatMessage({ id: 'values' })} | ||
| </TableCell> | ||
| </TableRow> | ||
| </TableHead> | ||
| <TableBody> | ||
| {renderCommonCharacteristics(equipmentInfos, intl)} | ||
| {renderVoltageLevelCharacteristics && renderVoltageLevelCharacteristics(equipmentInfos, intl)} | ||
|
Check warning on line 35 in src/components/tooltips/carateristics-table.tsx
|
||
| </TableBody> | ||
| </Table> | ||
| </TableContainer> | ||
| </Grid> | ||
| ); | ||
| }; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| import React from 'react'; | ||
souissimai marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| import { Table, TableHead, TableRow, TableCell, TableBody, TableContainer, Paper, Grid } from '@mui/material'; | ||
|
Check warning on line 2 in src/components/tooltips/current-table.tsx
|
||
| import { EquipmentInfos, mergeSx } from '@gridsuite/commons-ui'; | ||
|
Check warning on line 3 in src/components/tooltips/current-table.tsx
|
||
| import { RunningStatus } from '../utils/running-status'; | ||
| import { IntlShape } from 'react-intl'; | ||
| import { formatValue, styles } from './generic-equipment-popover-utils'; | ||
|
|
||
| interface CurrentTableProps { | ||
| equipmentInfos: any; | ||
| intl: IntlShape; | ||
| loadFlowStatus?: RunningStatus; | ||
| } | ||
|
|
||
| export const CurrentTable: React.FC<CurrentTableProps> = ({ equipmentInfos, intl, loadFlowStatus }) => { | ||
| return ( | ||
| <Grid item sx={{ width: '100%' }}> | ||
| <TableContainer sx={styles.table}> | ||
| <Table size="small" sx={{ width: '100%', tableLayout: 'auto' }}> | ||
| <TableHead> | ||
| <TableRow> | ||
| <TableCell sx={{ ...styles.cell, fontWeight: 'bold' }}> | ||
| {intl.formatMessage({ id: 'CURRENT' })} | ||
| </TableCell> | ||
| <TableCell sx={{ ...styles.cell, fontWeight: 'bold' }}> | ||
| {formatValue(equipmentInfos?.voltageLevelId1)} | ||
| </TableCell> | ||
| <TableCell sx={{ ...styles.cell, fontWeight: 'bold' }}> | ||
| {formatValue(equipmentInfos?.voltageLevelId2)} | ||
| </TableCell> | ||
| </TableRow> | ||
| </TableHead> | ||
| <TableBody> | ||
| <TableRow> | ||
| <TableCell sx={styles.cell}>{intl.formatMessage({ id: 'I_(A)' })}</TableCell> | ||
| <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> | ||
| ); | ||
| }; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| import { EQUIPMENT_TYPES } from 'components/utils/equipment-types'; | ||
souissimai marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| import BranchPopoverContent from './branch-popover-content'; | ||
|
|
||
| export const EquipmentPopoverMap: Record<string, React.FC<any>> = { | ||
| [(EQUIPMENT_TYPES.LINE, EQUIPMENT_TYPES.TWO_WINDINGS_TRANSFORMER)]: BranchPopoverContent, | ||
| }; | ||
Uh oh!
There was an error while loading. Please reload this page.