Skip to content

Commit e9a6cfe

Browse files
author
Dennis Labordus
committed
Updated documentation for development.
Signed-off-by: Dennis Labordus <[email protected]>
1 parent a997620 commit e9a6cfe

File tree

3 files changed

+112
-58
lines changed

3 files changed

+112
-58
lines changed

DEVELOPMENT.md

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
<!--
2+
SPDX-FileCopyrightText: 2021 Alliander N.V.
3+
4+
SPDX-License-Identifier: Apache-2.0
5+
-->
6+
7+
# Development for CoMPAS OpenSCD
8+
9+
## Building
10+
11+
If you want to build CoMPAS OpenSCD yourself in order to make some changes to your local installation or to contribute
12+
to the project, you may first want to install [Node.js](https://nodejs.org/) in order to be able to use our local
13+
development setup.
14+
15+
Once Node.js is installed on your system, you may get started by entering the following lines in your command prompt:
16+
17+
```
18+
git clone https://github.com/com-pas/compas-open-scd
19+
cd compas-open-scd
20+
npm install
21+
npm start
22+
```
23+
24+
This will start a local development server and open a browser window which will automatically be reloaded as soon as you
25+
save any changes to your local source code files.
26+
27+
## Linting & Formatting
28+
29+
If you use VSCode to develop, we recommend you install and use
30+
the [ESLint](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint)
31+
and [Prettier](https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode) extensions in order to
32+
automatically lint and format your code as you edit it. There are similar plugins available for
33+
using [ESLint](https://eslint.org/) and [Prettier](https://prettier.io/) from within other IDEs and text editors.
34+
35+
## Scripts
36+
37+
We provide the following `npm` scripts for your convenience:
38+
39+
- `npm start` runs `CoMPAS OpenSCD` for development, reloading on file changes
40+
- `npm test` runs the test suite with Karma
41+
- `npm run lint` runs the linter (fixes problems in your code)
42+
- `npm run format` runs the formatter (formats your code in a unified way)
43+
- `npm run doc` builds HTML documentation into the `doc` directory
44+
- `npm run build` builds a deployable version of the project into the `dist` directory
45+
46+
## Docker
47+
48+
It's also possible to run CoMPAS OpenSCD as a docker. Of every release a docker image is created and pushed to Docker
49+
Hub. To run the docker container use the following command.
50+
51+
```
52+
docker run -it --rm -d -p 8080:80 --name compas-open-scd lfenergy/compas-open-scd:latest
53+
```
54+
55+
Now open a browser and go to "http://localhost:8080". CoMPAS OpenSCD is shown.
56+
57+
## CoMPAS Service
58+
59+
During development, it is sometimes handy to use running backend services, like CIM Mapping or SCL Data Service.
60+
The problem is that these services need an Authorization Header to work. Normally these are injected by a reverse proxy
61+
or something like that.
62+
63+
There is a work-around and that is using the ModHeader Extension of the Browser (Chrome, Firefox, ...).
64+
With this extension the header 'Authorization' can be added with a value 'Bearer <access token>'.
65+
66+
![ModHeader Screenshot](ModHeader.png)
67+
68+
URL Filters is used to only send this Request Header to the configured URLs.
69+
70+
To retrieve an Access Token from a running KeyCloak instance there is a Postman collection, see below.
71+
72+
### CoMPAS Services depends on a running KeyCloak instance
73+
74+
A KeyCloak instance needs to be running on port 8089 by default in dev mode. If a custom KeyCloak instance is used see
75+
[Security](README.md#security) for more details.
76+
77+
There is a preconfigured Demo KeyCloak instance available for CoMPAS in the
78+
[CoMPAS Deployment Repository](https://github.com/com-pas/compas-deployment). This repository can be cloned and
79+
used to execute the following commands to create a local Docker Image with the CoMPAS Demo configuration.
80+
81+
```shell
82+
cd <CoMPAS Deployment Repository Directory>/compas/keycloak
83+
docker build -t compas_keycloak .
84+
```
85+
86+
A Docker Image `compas_keycloak` is created that can be started using the following command
87+
88+
```shell
89+
docker run --rm --name compas_keycloak \
90+
-p 8089:8080
91+
-d compas_keycloak:latest
92+
```
93+
94+
There are now 3 users available to be used, `scl-data-editor`, `scl-data-reader`, `scd-reader`. See
95+
[CoMPAS Deployment Repository](https://github.com/com-pas/compas-deployment) for more information about the users.
96+
97+
### Postman
98+
99+
To make a call to the CoMPAS Backend Service work in CoMPAS OpenSCD we need to import an environment and authorisation
100+
collection. These files can be found in [CoMPAS Deployment Repository](https://github.com/com-pas/compas-deployment)
101+
in the directory `postman` (`auth.collection.json` and `local.environment.json`).
102+
103+
In the authorisation collection there are called for the 3 users known within the Demo KeyCloak instance.
104+
If one of these calls are executed you can switch to the tab `Visualize`. There is a button to copy the bearer to the
105+
clipboard. This will also be done automatically when switching to the tab (label becomes `Copied!`).
106+
The value of the clipboard can be copied in ModHeader Extension as Authorization Header.
107+
108+
Hint: `Bearer` is included in the value of the clipboard, so the complete value in ModHeader can be replaced.

ModHeader.png

46.2 KB
Loading

README.md

Lines changed: 4 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -4,68 +4,14 @@
44
[![CII Best Practices](https://bestpractices.coreinfrastructure.org/projects/5925/badge)](https://bestpractices.coreinfrastructure.org/projects/5925)
55
[![Slack](https://raw.githubusercontent.com/com-pas/compas-architecture/master/public/LFEnergy-slack.svg)](http://lfenergy.slack.com/)
66

7-
Open Substation Communication Designer is an editor for SCL files as described in `IEC 61850-6`.
7+
CoMPAS Open Substation Communication Designer is an editor for SCL files as described in `IEC 61850-6`.
88

9-
> Try it out at [openscd.github.io](https://openscd.github.io)!
10-
11-
## Installation
12-
13-
In order to install OpenSCD on your local device (only for you), simply visit [openscd.github.io](https://openscd.github.io), click the "Install OpenSCD" button in your address bar (Chrome or Edge on desktop) or click the "Add OpenSCD to home screen" notification in any mobile browser.
14-
15-
In order to install your own instance of OpenSCD on your own webserver (e.g. on your company intranet), simply download [our latest release](https://github.com/openscd/open-scd/releases/latest) (`open-scd.zip` or `open-scd.tar.gz`) and extract the archive contents into the "webroot" directory of your web server.
16-
17-
If you don't have your own webserver but still want your own version of OpenSCD hosted locally (e.g. on a system without an internet connection), you can [use a browser plugin that acts as a local webserver](https://github.com/openscd/open-scd/wiki/Install-OpenSCD#offline) (only for you) instead.
9+
CoMPAS OpenSCD is a fork of the [OpenSCD](https://github.com/openscd/open-scd) project. The idea is to add functionality
10+
to use the CoMPAS Backend Service to open and save SCL Files and more.
1811

1912
## Contributing
2013

21-
### Building
22-
23-
If you want to build OpenSCD yourself in order to make some changes to your local installation or to contribute to the project, you may first want to install [Node.js](https://nodejs.org/) in order to be able to use our local development setup.
24-
25-
Once Node.js is installed on your system, you may get started by entering the following lines in your command prompt:
26-
27-
```
28-
git clone https://github.com/openscd/open-scd.git
29-
cd open-scd
30-
npm install
31-
npm start
32-
```
33-
34-
This will start a local development server and open a browser window which will automatically be reloaded as soon as you save any changes to your local source code files.
35-
36-
### Linting & Formatting
37-
38-
If you use VSCode to develop, we recommend you install and use the [ESLint](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint) and [Prettier](https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode) extensions in order to automatically lint and format your code as you edit it. There are similar plugins available for using [ESLint](https://eslint.org/) and [Prettier](https://prettier.io/) from within other IDEs and text editors.
39-
40-
### Scripts
41-
42-
We provide the following `npm` scripts for your convenience:
43-
44-
- `npm start` runs `OpenSCD` for development, reloading on file changes
45-
- `npm test` runs the test suite with Karma
46-
- `npm run lint` runs the linter (fixes problems in your code)
47-
- `npm run format` runs the formatter (formats your code in a unified way)
48-
- `npm run doc` builds HTML documentation into the `doc` directory
49-
- `npm run build` builds a deployable version of the project into the `dist` directory
50-
51-
### Docker
52-
It's also possible to run OpenSCD CoMPAS Edition as a docker. Of every release a docker image is created and pushed to Docker Hub.
53-
To run the docker container use the following command.
54-
55-
```
56-
docker run -it --rm -d -p 8080:80 --name compas-open-scd lfenergy/compas-open-scd:latest
57-
```
58-
Now open a browser and go to "http://localhost:8080". OpenSCD is shown.
59-
60-
### CoMPAS Service
61-
62-
During development, it is sometimes handy to use running backend services, like CIM Mapping or SCL Data Service.
63-
The problem is that these services need an Authorization Header to work. Normally these are injected by a reverse proxy
64-
or something like that.
65-
66-
There is a work-around and that is using the ModHeader Extension of the Browser (Chrome, Firefox, ...).
67-
With this extension the header 'Authorization' can be added with a value 'Bearer <access token>'.
68-
The AccessToken can be retrieved from a running KeyCloak instance.
14+
See [Development](DEVELOPMENT.md) for more information about how to build and run CoMPAS OpenSCD locally.
6915

7016
## License
7117

0 commit comments

Comments
 (0)