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

NAD viewer #1

Merged
merged 37 commits into from
Jun 3, 2022
Merged

NAD viewer #1

merged 37 commits into from
Jun 3, 2022

Conversation

etiennehomer
Copy link
Contributor

Please check if the PR fulfills these requirements (please use '[x]' to check the checkboxes, or submit the PR and then click the checkboxes)

  • 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)

What kind of change does this PR introduce? (Bug fix, feature, docs update, ...)
This PR gives a simple TS/JS component to integrate a network area diagram svg.

Signed-off-by: Etienne Homer <[email protected]>
Signed-off-by: Etienne Homer <[email protected]>
Signed-off-by: Etienne Homer <[email protected]>
Signed-off-by: Etienne Homer <[email protected]>
@etiennehomer etiennehomer changed the title NAD viewer NAD viewer [WIP] May 10, 2022
Signed-off-by: Etienne Homer <[email protected]>
Signed-off-by: Etienne Homer <[email protected]>
Signed-off-by: Etienne Homer <[email protected]>
Signed-off-by: Etienne Homer <[email protected]>
Signed-off-by: Etienne Homer <[email protected]>
Signed-off-by: Etienne Homer <[email protected]>
Signed-off-by: Etienne Homer <[email protected]>
@sylvlecl
Copy link

Tried to use it in pypowsybl-jupyter widget, worked fine

Signed-off-by: Etienne Homer <[email protected]>
@etiennehomer etiennehomer changed the title NAD viewer [WIP] NAD viewer May 12, 2022
Signed-off-by: Etienne Homer <[email protected]>
Signed-off-by: Etienne Homer <[email protected]>
Signed-off-by: Etienne Homer <[email protected]>
Signed-off-by: Etienne Homer <[email protected]>
Signed-off-by: Etienne Homer <[email protected]>
Signed-off-by: Etienne Homer <[email protected]>
Signed-off-by: Etienne Homer <[email protected]>
README.md Outdated

Typescript library to integrate a powsybl svg diagram in a javascript project. The library is built with the Parcel bundler.
Symply use: 'npm run build'
Copy link
Collaborator

Choose a reason for hiding this comment

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

remove "symply"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

README.md Outdated
#### For integrators

If you want to deploy a new version of commons-ui in the [NPM package registry](https://www.npmjs.com/package/@powsybl/powsybl-diagram-viewer),
Copy link
Collaborator

Choose a reason for hiding this comment

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

reference to commons-ui

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@@ -0,0 +1,6 @@
#svg-container {
position: relative; /* let it at the charge of the user? */
Copy link
Collaborator

Choose a reason for hiding this comment

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

remove ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

package.json Outdated
"version": "0.0.1",
"description": "Typescript library to integrate a powsybl svg diagram in a javascript project.",
"author": "powsybl team",
"homepage": "https://github.com/powsybl",
Copy link
Collaborator

Choose a reason for hiding this comment

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

link

Copy link
Collaborator

Choose a reason for hiding this comment

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

not sure maybe https://www.powsybl.org/ ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, and github repo is below in the file

package.json Outdated
"scripts": {
"watch": "parcel watch",
"build": "parcel build",
"test": "echo \"Error: no test specified\" && exit 1",
Copy link
Collaborator

Choose a reason for hiding this comment

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

to implement ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes it's in progress

Copy link
Contributor Author

Choose a reason for hiding this comment

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

A simple test has been implemented. getDimensionsFromSvg() isn't tested as Jest doesn't support svg manipulation in the DOM.

Signed-off-by: Etienne Homer <[email protected]>
Signed-off-by: Etienne Homer <[email protected]>
Signed-off-by: Etienne Homer <[email protected]>
Signed-off-by: Etienne Homer <[email protected]>
Signed-off-by: Etienne Homer <[email protected]>
Signed-off-by: Etienne Homer <[email protected]>
Signed-off-by: Etienne Homer <[email protected]>
Signed-off-by: Etienne Homer <[email protected]>
Signed-off-by: Etienne Homer <[email protected]>
Signed-off-by: Etienne Homer <[email protected]>
@@ -0,0 +1,5 @@
//FIXME workaround svg.panzoom.js import crash even though it's not used

Choose a reason for hiding this comment

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

I had the same issue in pypowsybl-jupyter, the problem is that svg.panzoom.js is somewhat broken.
A solution is to import the ESM module svg.panzoom.esm.js instead. This can be configured in jest config file.

Choose a reason for hiding this comment

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

See that issue for more background :

svgdotjs/svg.panzoom.js#82

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks. We already use that hack (global SVG with setupTests) in Gridstudy, we gonna do the same here. I use the jsdom environnement for tests, not the node.js one. I don't know if it would work.

Choose a reason for hiding this comment

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

Indeed, it actually requires jsdom to work since svg.js works on the DOM.
It would allow svg.js to actually modify the DOM, in the unit test.

Signed-off-by: Etienne Homer <[email protected]>
Signed-off-by: Etienne Homer <[email protected]>
Signed-off-by: Etienne Homer <[email protected]>
Signed-off-by: Etienne Homer <[email protected]>
src/network-area-diagram-viewer.ts Outdated Show resolved Hide resolved
src/network-area-diagram-viewer.ts Outdated Show resolved Hide resolved
src/network-area-diagram-viewer.ts Outdated Show resolved Hide resolved
const width: number = +svg.getAttribute('width');
const height: number = +svg.getAttribute('height');
const viewbox: VIEWBOX = svg.viewBox.baseVal;
return { width: width, height: height, viewbox: viewbox };

Choose a reason for hiding this comment

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

Add a test ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Svg manipulation isn't well supported with Jest. The test doesn't pass.

const width: number = +svg.getAttribute('width');
const height: number = +svg.getAttribute('height');
const viewbox: VIEWBOX = svg.viewBox.baseVal;
return { width: width, height: height, viewbox: viewbox };

Choose a reason for hiding this comment

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

Add a test ?

src/network-area-diagram-viewer.ts Outdated Show resolved Hide resolved
src/network-area-diagram-viewer.ts Outdated Show resolved Hide resolved
Signed-off-by: HOMER Etienne <[email protected]>
Signed-off-by: HOMER Etienne <[email protected]>
Signed-off-by: HOMER Etienne <[email protected]>
Signed-off-by: HOMER Etienne <[email protected]>
@etiennehomer etiennehomer merged commit 78d5b12 into main Jun 3, 2022
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.

4 participants