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

Add method for updating flows in NAD viewer #137

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

massimo-ferraro
Copy link
Contributor

Please check if the PR fulfills these requirements

  • The commit message follows our guidelines
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)

Does this PR already have an issue describing the problem?
no

What kind of change does this PR introduce?
feature

What is the current behavior?
The NAD viewer does not allow to change the flows shown in the SVG

What is the new behavior (if this is a feature change)?
The NAD viewer provide a method for changing the flows shown in the SVG

Does this PR introduce a breaking change or deprecate an API?

  • Yes
  • No

Other information:
In the demo, in the add-diagram.ts file, examples of code changing flows are provided

Signed-off-by: massimo.ferraro <massimo.ferraro@soft.it>
Signed-off-by: massimo.ferraro <massimo.ferraro@soft.it>
demo/src/diagram-viewers/add-diagrams.ts Outdated Show resolved Hide resolved
demo/src/diagram-viewers/add-diagrams.ts Outdated Show resolved Hide resolved
@@ -16,6 +16,7 @@ import { debounce } from '@mui/material';

type DIMENSIONS = { width: number; height: number; viewbox: VIEWBOX };
type VIEWBOX = { x: number; y: number; width: number; height: number };
export type FLOW = { branchId: string; side: number; p: number };
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. It's strange to have this class in upper case, I think it's only for constants. Besides we could put any kind of values on arrow one day, so you'd better name it BranchSideLabel.
  2. You named the value p, but it could be any value. And about the side, it would be more compact to have it directly in two parameters, I mean value1 and value2.
  3. In typescript is it possible to define value1 and value2 to be either a number or a string?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed for handling generic branch labels: type renamed to BranchLabel, and now containing 2 generic values, numbers or strings

}

private setFlow(branchId: string, side: number, p: number) {
const edge: EdgeMetadata | undefined = this.diagramMetadata?.edges.find((edge) => edge.equipmentId == branchId);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For a big network, we should probably have a map to access directly the edge with its equipmentId.

Note that the same kind of direct access should be considered also for other edges.find() if we notice it's slow for a big network.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a map for caching edges. The map could possibly be used also in other class methods

Signed-off-by: Florian Dupuy <florian.dupuy@rte-france.com>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can revert those changes

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These changes to the SVG were done for showing the arrows, even without the update of the branch labels. Why revert these changes?

…d add caching map

Signed-off-by: massimo.ferraro <massimo.ferraro@soft.it>
Signed-off-by: massimo.ferraro <massimo.ferraro@soft.it>
Copy link

sonarcloud bot commented Dec 12, 2024

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants