Skip to content

Commit 67c06d6

Browse files
author
Rob Tjalma
authored
Merge pull request #118 from com-pas/upstream-v0.10
Merge upstream version 0.10 from OpenSCD
2 parents 4e2bf44 + b2a97c5 commit 67c06d6

File tree

73 files changed

+2253
-1612
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+2253
-1612
lines changed

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,16 @@
22

33
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
44

5+
## [0.10.0](https://github.com/openscd/open-scd/compare/v0.9.0...v0.10.0) (2022-02-21)
6+
7+
8+
### Features
9+
10+
* **editors/IED:** display IED data attributes namespace description ([#522](https://github.com/openscd/open-scd/issues/522)) ([02b8d97](https://github.com/openscd/open-scd/commits/02b8d97ddb066a1c0134b97aa1e50243f2628048)), closes [#516](https://github.com/openscd/open-scd/issues/516)
11+
* **Settings:** Handle difference in version before uploading nsdoc file ([#541](https://github.com/openscd/open-scd/issues/541)) ([2e470cb](https://github.com/openscd/open-scd/commits/2e470cb3da26adc46c111840d4c9322eb3af14b1))
12+
* **wizard-checkbox:** web component for xs:boolean XML attributes ([#537](https://github.com/openscd/open-scd/issues/537)) ([2b11ae8](https://github.com/openscd/open-scd/commits/2b11ae8ddcfb43a01f7b5d6fe7dae1bee128da39))
13+
* **wizard/sampledvaluecontrol:** allow removing including referenced elements ([#536](https://github.com/openscd/open-scd/issues/536)) ([1940571](https://github.com/openscd/open-scd/commits/194057113de4398209f963262fb8135fd9f5bc03))
14+
515
## [0.9.0](https://github.com/openscd/open-scd/compare/v0.8.2...v0.9.0) (2022-02-04)
616

717

manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,5 +40,5 @@
4040
"purpose": "maskable"
4141
}
4242
],
43-
"version": "0.9.0"
43+
"version": "0.10.0"
4444
}

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "open-scd",
3-
"version": "0.9.0",
3+
"version": "0.10.0",
44
"repository": "https://github.com/openscd/open-scd.git",
55
"description": "A bottom-up substation configuration designer for projects described using SCL `IEC 61850-6` Edition 2 or greater.",
66
"keywords": [

src/Plugging.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -451,11 +451,17 @@ export function Plugging<TBase extends new (...args: any[]) => EditingElement>(
451451
>
452452
</mwc-button>
453453
<mwc-button
454-
raised
454+
slot="secondaryAction"
455+
icon=""
456+
label="${translate('close')}"
457+
dialogAction="close"
458+
></mwc-button>
459+
<mwc-button
460+
outlined
455461
trailingIcon
456462
slot="primaryAction"
457463
icon="library_add"
458-
label="${translate('add')}&hellip;"
464+
label="${translate('plugins.add.heading')}&hellip;"
459465
@click=${() => this.pluginDownloadUI.show()}
460466
>
461467
</mwc-button>

src/Setting.ts

Lines changed: 79 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ import { Language, languages, loader } from './translations/loader.js';
1818
import './WizardDivider.js';
1919
import { WizardDialog } from './wizard-dialog.js';
2020

21+
import { iec6185072, iec6185073, iec6185074, iec6185081 } from "./validators/templates/foundation.js";
22+
2123
export type Settings = {
2224
language: Language;
2325
theme: 'light' | 'dark';
@@ -39,6 +41,19 @@ export const defaults: Settings = {
3941
'IEC 61850-8-1': undefined
4042
};
4143

44+
type NsdVersion = {
45+
version: string | undefined,
46+
revision: string | undefined,
47+
release: string | undefined
48+
}
49+
50+
type NsdVersions = {
51+
'IEC 61850-7-2': NsdVersion;
52+
'IEC 61850-7-3': NsdVersion;
53+
'IEC 61850-7-4': NsdVersion;
54+
'IEC 61850-8-1': NsdVersion;
55+
}
56+
4257
/** Mixin that saves [[`Settings`]] to `localStorage`, reflecting them in the
4358
* `settings` property, setting them through `setSetting(setting, value)`. */
4459
export type SettingElement = Mixin<typeof Setting>;
@@ -60,6 +75,38 @@ export function Setting<TBase extends LitElementConstructor>(Base: TBase) {
6075
};
6176
}
6277

78+
/**
79+
* Get the versions of the current OpenSCD NSD files.
80+
* @returns Current version, revision and release for all current OpenSCD NSD files.
81+
*/
82+
private async nsdVersions(): Promise<NsdVersions> {
83+
const [nsd72, nsd73, nsd74, nsd81] = await Promise.all([iec6185072, iec6185073, iec6185074, iec6185081]);
84+
const [nsd72Ns, nsd73Ns, nsd74Ns, nsd81Ns] = [nsd72.querySelector('NS'), nsd73.querySelector('NS'), nsd74.querySelector('NS'), nsd81.querySelector('ServiceNS')];
85+
86+
return {
87+
'IEC 61850-7-2': {
88+
version: nsd72Ns?.getAttribute('version') ?? undefined,
89+
revision: nsd72Ns?.getAttribute('revision') ?? undefined,
90+
release: nsd72Ns?.getAttribute('release') ?? undefined,
91+
},
92+
'IEC 61850-7-3': {
93+
version: nsd73Ns?.getAttribute('version') ?? undefined,
94+
revision: nsd73Ns?.getAttribute('revision') ?? undefined,
95+
release: nsd73Ns?.getAttribute('release') ?? undefined,
96+
},
97+
'IEC 61850-7-4': {
98+
version: nsd74Ns?.getAttribute('version') ?? undefined,
99+
revision: nsd74Ns?.getAttribute('revision') ?? undefined,
100+
release: nsd74Ns?.getAttribute('release') ?? undefined,
101+
},
102+
'IEC 61850-8-1': {
103+
version: nsd81Ns?.getAttribute('version') ?? undefined,
104+
revision: nsd81Ns?.getAttribute('revision') ?? undefined,
105+
release: nsd81Ns?.getAttribute('release') ?? undefined,
106+
}
107+
}
108+
}
109+
63110
@query('#settings')
64111
settingsUI!: Dialog;
65112
@query('#language')
@@ -133,14 +180,16 @@ export function Setting<TBase extends LitElementConstructor>(Base: TBase) {
133180
}
134181

135182
private async loadNsdocFile(evt: Event): Promise<void> {
183+
const nsdVersions = await this.nsdVersions();
136184
const files = Array.from(
137185
(<HTMLInputElement | null>evt.target)?.files ?? []
138186
);
139187

140188
if (files.length == 0) return;
141189
files.forEach(async file => {
142190
const text = await file.text();
143-
const id = this.parseToXmlObject(text).querySelector('NSDoc')?.getAttribute('id');
191+
const nsdocElement = this.parseToXmlObject(text).querySelector('NSDoc');
192+
const id = nsdocElement?.getAttribute('id');
144193
if (!id) {
145194
document
146195
.querySelector('open-scd')!
@@ -149,6 +198,25 @@ export function Setting<TBase extends LitElementConstructor>(Base: TBase) {
149198
);
150199
return;
151200
}
201+
const nsdVersion = nsdVersions[id as keyof NsdVersions];
202+
const nsdocVersion = {
203+
version: nsdocElement!.getAttribute('version') ?? undefined,
204+
revision: nsdocElement!.getAttribute('revision') ?? undefined,
205+
release: nsdocElement!.getAttribute('release') ?? undefined
206+
}
207+
208+
if (!this.isEqual(nsdVersion, nsdocVersion)) {
209+
document
210+
.querySelector('open-scd')!
211+
.dispatchEvent(
212+
newLogEvent({ kind: 'error', title: get('settings.invalidNsdocVersion', {
213+
id: id,
214+
nsdVersion: `${nsdVersion.version}${nsdVersion.revision}${nsdVersion.release}`,
215+
nsdocVersion: `${nsdocVersion.version}${nsdocVersion.revision}${nsdocVersion.release}`
216+
}) })
217+
);
218+
return;
219+
}
152220

153221
this.setSetting(id as keyof Settings, text);
154222
})
@@ -157,6 +225,16 @@ export function Setting<TBase extends LitElementConstructor>(Base: TBase) {
157225
this.requestUpdate();
158226
}
159227

228+
/**
229+
* Check the equality of two NsdVersions.
230+
* @param versionA - First version to compare.
231+
* @param versionB - Second version to compare.
232+
* @returns Are they equal or not.
233+
*/
234+
private isEqual(versionA: NsdVersion, versionB: NsdVersion): boolean {
235+
return versionA.version == versionB.version && versionA.revision == versionB.revision && versionA.release == versionB.release;
236+
}
237+
160238
/**
161239
* Render one .nsdoc item in the Settings wizard
162240
* @param key - The key of the nsdoc file in the settings.

src/editors/Communication.ts

Lines changed: 33 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,22 @@ import { translate, get } from 'lit-translate';
33

44
import '@material/mwc-fab';
55

6+
import './communication/subnetwork-editor.js';
67
import {
78
newWizardEvent,
89
newActionEvent,
910
createElement,
11+
isPublic,
1012
} from '../foundation.js';
11-
import { selectors, styles } from './communication/foundation.js';
12-
import './communication/subnetwork-editor.js';
13-
import { subNetworkWizard } from './communication/subnetwork-editor.js';
13+
import { createSubNetworkWizard } from '../wizards/subnetwork.js';
1414

1515
/** An editor [[`plugin`]] for editing the `Communication` section. */
1616
export default class CommunicationPlugin extends LitElement {
1717
/** The document being edited as provided to plugins by [[`OpenSCD`]]. */
1818
@property()
1919
doc!: XMLDocument;
2020

21-
createCommunication(): void {
21+
private createCommunication(): void {
2222
this.dispatchEvent(
2323
newActionEvent({
2424
new: {
@@ -30,21 +30,15 @@ export default class CommunicationPlugin extends LitElement {
3030
}
3131

3232
/** Opens a [[`WizardDialog`]] for creating a new `SubNetwork` element. */
33-
openCreateSubNetworkWizard(): void {
34-
if (!this.doc.querySelector(selectors.Communication))
35-
this.createCommunication();
33+
private openCreateSubNetworkWizard(): void {
34+
const parent = this.doc.querySelector(':root > Communication');
35+
if (!parent) this.createCommunication();
3636

37-
this.dispatchEvent(
38-
newWizardEvent(
39-
subNetworkWizard({
40-
parent: this.doc.querySelector('Communication')!,
41-
})
42-
)
43-
);
37+
this.dispatchEvent(newWizardEvent(createSubNetworkWizard(parent!)));
4438
}
4539

4640
render(): TemplateResult {
47-
if (!this.doc?.querySelector(selectors.SubNetwork))
41+
if (!this.doc?.querySelector(':root > Communication >SubNetwork'))
4842
return html`<h1>
4943
<span style="color: var(--base1)"
5044
>${translate('communication.missing')}</span
@@ -55,29 +49,43 @@ export default class CommunicationPlugin extends LitElement {
5549
@click=${() => this.openCreateSubNetworkWizard()}
5650
></mwc-fab>
5751
</h1>`;
52+
5853
return html`<mwc-fab
5954
extended
6055
icon="add"
6156
label="${get('subnetwork.wizard.title.add')}"
6257
@click=${() => this.openCreateSubNetworkWizard()}
63-
></mwc-fab
64-
>${Array.from(this.doc.querySelectorAll(selectors.SubNetwork) ?? []).map(
65-
subnetwork =>
66-
html`<subnetwork-editor .element=${subnetwork}></subnetwork-editor>`
67-
)}`;
58+
></mwc-fab>
59+
<section>
60+
${Array.from(this.doc.querySelectorAll('SubNetwork') ?? [])
61+
.filter(isPublic)
62+
.map(
63+
subnetwork =>
64+
html`<subnetwork-editor
65+
.element=${subnetwork}
66+
></subnetwork-editor>`
67+
)}
68+
</section> `;
6869
}
6970

7071
static styles = css`
71-
${styles}
72+
:host {
73+
width: 100vw;
74+
}
75+
76+
section {
77+
outline: none;
78+
padding: 8px 12px 16px;
79+
}
80+
81+
subnetwork-editor {
82+
margin: 8px 12px 16px;
83+
}
7284
7385
mwc-fab {
7486
position: fixed;
7587
bottom: 32px;
7688
right: 32px;
7789
}
78-
79-
:host {
80-
width: 100vw;
81-
}
8290
`;
8391
}

0 commit comments

Comments
 (0)