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
Show file tree
Hide file tree
Changes from 33 commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
471d1da
first commit
etiennehomer May 9, 2022
ac82a1b
clean
etiennehomer May 9, 2022
07a8473
clean
etiennehomer May 9, 2022
c1ea028
clean package-lock
etiennehomer May 9, 2022
741bb2a
fill readme
etiennehomer May 10, 2022
084c90c
clean package.json
etiennehomer May 10, 2022
d4d49df
clean
etiennehomer May 10, 2022
8288e91
change name
etiennehomer May 10, 2022
d0dc079
remove env from .gitignore
etiennehomer May 10, 2022
d6f43fc
clean depedencies
etiennehomer May 10, 2022
4c1e7d9
add demo
etiennehomer May 12, 2022
16bfff7
clean
etiennehomer May 12, 2022
cf006c0
clean
etiennehomer May 12, 2022
e6e6c80
use DomPArser
etiennehomer May 13, 2022
9ce83ba
type all variables
etiennehomer May 13, 2022
89a6e9b
fix demo
etiennehomer May 13, 2022
1c1baf1
fix demo
etiennehomer May 13, 2022
6395eb7
configure eslint and prettier
etiennehomer May 16, 2022
2d572bf
fix eslint
etiennehomer May 16, 2022
2dee762
fix readMe and remove comment'
etiennehomer May 17, 2022
9117ff9
fix hoempage
etiennehomer May 17, 2022
1b4520d
use regex to parse svg only
etiennehomer May 17, 2022
2289900
Unit tests not working
etiennehomer May 17, 2022
376bf60
remove console.info
etiennehomer May 17, 2022
d7a1b06
github actions
etiennehomer May 17, 2022
fa7f314
empty test
etiennehomer May 17, 2022
968dadc
temporary disable eslint
etiennehomer May 17, 2022
153d19f
add end line
etiennehomer May 17, 2022
a8d220b
clean
etiennehomer May 17, 2022
dec7a1d
add simple UT
etiennehomer May 19, 2022
8f92639
fix regex
etiennehomer May 20, 2022
eff4153
fix readme
etiennehomer May 20, 2022
87171be
return null if svg invalid
etiennehomer May 20, 2022
a26c384
fix review
etiennehomer May 24, 2022
9d9c076
clean regex
etiennehomer May 30, 2022
2504195
fix demo
etiennehomer Jun 1, 2022
9e37b2c
remove start-demo
etiennehomer Jun 2, 2022
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
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
dist/
node_modules/
19 changes: 19 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
module.exports = {
root: true,
parser: '@typescript-eslint/parser',
plugins: [
'@typescript-eslint',
],
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
"plugin:prettier/recommended",
'prettier'
],
env : {
"browser": true
},
rules: {
"prettier/prettier": "warn"
},
};
29 changes: 29 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: CI
on: [push]

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v2
with:
persist-credentials: false

- name: FixForNodeWarnings
run: |
echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p

- name: Build
run: |
npm install
npm run test
npx eslint . --ext .js,.jsx,.ts,.tsx --max-warnings=0
npm run build

- name: Broadcast update event
if: github.ref == 'refs/heads/main'
uses: gridsuite/broadcast-event@main
with:
token: ${{ secrets.REPO_ACCESS_TOKEN }}
event-type: powsybl-diagram-viewer-updated
13 changes: 13 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# dependencies
/node_modules

# distribution
/dist

# webstorm
/.idea

# parcel
/.parcel-cache


4 changes: 4 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"tabWidth": 4,
"singleQuote": true
}
33 changes: 32 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,32 @@
# powsybl-diagram-viewer
# powsybl-diagram-viewer

Typescript library to integrate a powsybl svg diagram in a javascript project. The library is built with the Parcel bundler.
Node from v16.15.0 is required to build with Parcel.

Use:
'npm install'
'npm run build'


#### For developers

For development purpose, you can run 'npm run watch' for hot building (rebuild after a code save).
Your consumer project should point on the local distribution. Edit your package.json depedencies :
'"powsybl-diagram-viewer": "file: path/to/powsybl-diagram-viewer",'

#### For integrators

If you want to deploy a new version of powsybl-diagram-viewer in the [NPM package registry](https://www.npmjs.com/package/@powsybl/powsybl-diagram-viewer),
you need to follow the steps below:

- Update to the new version in [package.json](https://github.com/powsybl/powsybl-diagram-viewer/blob/main/package.json) (example `0.6.0`)
- Build it: `npm install`
- Commit the package.json and package-lock.json files, push to a branch, make a PR, have it reviewed and merged to main.
- Pull and checkout main on your last commit.
- [Tag your last commit](https://semver.org/) : `git tag <tag>` (example: `v0.6.0`)
- Push tag : `git push origin <tag>`
- Checkout the tag in a fresh repo copy : `cd $(mktemp -d) && git clone https://github.com/powsybl/powsybl-diagram-viewer.git` then `cd powsybl-diagram-viewer && git checkout <tag>`
- [Test your package](https://docs.npmjs.com/creating-and-publishing-scoped-public-packages#testing-your-package): `npm install`
- [Login on the command line to the npm registry](https://docs.npmjs.com/logging-in-to-an-npm-enterprise-registry-from-the-command-line): `npm login`
- [Publish the package](https://docs.npmjs.com/creating-and-publishing-scoped-public-packages#publishing-scoped-public-packages): `npm publish`

21 changes: 21 additions & 0 deletions __tests__/network-area-diagram.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { NetworkAreaDiagramViewer } from '../src/network-area-diagram-viewer';

describe('Test network-area-diagram-viewer.ts', () => {
// SVG not loaded properly in DOM with Jest. Has to be enrich...
test('nad creation', () => {
const container: HTMLDivElement = document.createElement('div');

const nad: NetworkAreaDiagramViewer = new NetworkAreaDiagramViewer(
container,
'',
0,
0,
0,
0
);

expect(container.getElementsByTagName('svg').length).toBe(0);
expect(nad.getContainer().outerHTML).toBe('<div></div>');
expect(nad.getSvgContent()).toBe('');
});
});
Loading