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

feat(editors/ied): add read only data model structure #423

Merged
merged 50 commits into from
Jan 11, 2022
Merged
Show file tree
Hide file tree
Changes from 49 commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
b5a070a
Added IED Container
Flurb Dec 10, 2021
70dc504
Added tests
Flurb Dec 10, 2021
807e9b5
Added Access Point container
Flurb Dec 10, 2021
e0058be
Added Server container
Flurb Dec 10, 2021
746380e
Added LDevice container
Flurb Dec 10, 2021
e86e18f
Added LN Container
Flurb Dec 10, 2021
8335abd
Added DO container
Flurb Dec 10, 2021
7da736a
Fixing unit tests IED container
Flurb Dec 11, 2021
6e3ab8c
Fixing Unit tests AccessPoint container
Flurb Dec 11, 2021
abee3ac
Fixing Unit tests Server container
Flurb Dec 11, 2021
c71496e
Fix unit tests LDevice container
Flurb Dec 11, 2021
4b4a094
Added padding
Flurb Dec 11, 2021
dfa8897
fix broken test
Flurb Dec 11, 2021
dec44af
Fixing LN container unit tests
Flurb Dec 12, 2021
a874edd
Added IED drop down
Flurb Dec 14, 2021
d9dd661
Small addition
Flurb Dec 14, 2021
ea04aa3
Added integration test for IED filter
Flurb Dec 15, 2021
a86d14e
Small refactoring
Flurb Dec 15, 2021
8fb77f9
IED list is now ordered alphabetically
Flurb Dec 15, 2021
fee5044
Refactoring
Flurb Dec 15, 2021
d78c963
Added check for available IEDs
Flurb Dec 15, 2021
0a60741
First batch of review adjustments
Flurb Dec 16, 2021
8a88e10
Second batch of review stuff
Flurb Dec 16, 2021
6bcf680
Some more refactoring
Flurb Dec 16, 2021
9b9fe78
Batch review comments
Flurb Dec 20, 2021
151921e
Batch review comments
Flurb Dec 20, 2021
e52798c
Main merge
Flurb Dec 20, 2021
f4904f6
refactor(editors/IED): add german translation
Dec 20, 2021
21f2ebf
feat(editors/ied): add DO elements to IED editor (#454)
Flurb Jan 6, 2022
d752b4c
Added basic DA container for DA/DAI show
Flurb Dec 30, 2021
fb9f833
Added BDA container
Flurb Jan 2, 2022
eb3712d
Added value css
Flurb Jan 2, 2022
0b3b88a
Added Enum container
Flurb Jan 3, 2022
d0234f7
Refactoring
Flurb Jan 3, 2022
c50ee55
Refactoring + Adding Unit Tests
Flurb Jan 3, 2022
9a25d79
Added Enum Tests
Flurb Jan 3, 2022
1fa5abd
Small refactoring
Flurb Jan 3, 2022
ebc0dfe
First review comments + Added toggle action
Flurb Jan 6, 2022
a7a4ab1
Bugfix when showing DA data
Flurb Jan 7, 2022
eb15312
Small refactoring
Flurb Jan 7, 2022
cbaac14
Added toggle test for ln-container
Flurb Jan 7, 2022
3e8aa5b
refactor(ied/da-container,do-container): code improvements
JakobVogelsang Jan 8, 2022
8a81df1
Added consistent toggle functionality
Flurb Jan 10, 2022
fc39bb7
Added da container unit tests
Flurb Jan 10, 2022
13c12fb
Added da container unit tests
Flurb Jan 10, 2022
6106c03
Small typo
Flurb Jan 10, 2022
b601f41
Revert browserLogs to false
Flurb Jan 10, 2022
081eac7
Merge pull request #464 from openscd/minor-improvements-to-da-container
Flurb Jan 10, 2022
541b347
Merge pull request #461 from openscd/add-da-container
Flurb Jan 10, 2022
7e99d52
Merge with main
Flurb Jan 10, 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
8 changes: 7 additions & 1 deletion public/js/plugins.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@ export const officialPlugins = [
default: true,
kind: 'editor',
},
{
name: 'IED',
src: '/src/editors/IED.js',
icon: 'edit',
JakobVogelsang marked this conversation as resolved.
Show resolved Hide resolved
default: false,
kind: 'editor',
},
{
name: 'Single Line Diagram',
src: '/src/editors/SingleLineDiagram.js',
Expand All @@ -19,7 +26,6 @@ export const officialPlugins = [
icon: 'settings_ethernet',
default: true,
kind: 'editor',

},
{
name: 'Templates',
Expand Down
98 changes: 98 additions & 0 deletions src/editors/IED.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
import { css, html, LitElement, property, query, state, TemplateResult } from 'lit-element';

import '@material/mwc-fab';
import '@material/mwc-select';
import '@material/mwc-list/mwc-list-item';

import '../zeroline-pane.js';
import './ied/ied-container.js'

import { translate } from 'lit-translate';
import { Select } from '@material/mwc-select';
import { SingleSelectedEvent } from '@material/mwc-list/mwc-list-foundation';
import { compareNames, getDescriptionAttribute, getNameAttribute } from '../foundation.js';

/** An editor [[`plugin`]] for editing the `IED` section. */
export default class IedPlugin extends LitElement {
/** The document being edited as provided to plugins by [[`OpenSCD`]]. */
@property()
doc!: XMLDocument;

/** Query holding the current selected IEDs. */
@state()
currentSelectedIEDs = ':root > IED';

@query('#iedSelect') iedSelector?: Select;

private get alphabeticOrderedIeds() : Element[] {
return Array.from(this.doc?.querySelectorAll(':root > IED'))
.sort((a,b) => compareNames(a,b));
}

/**
* When selecting drop down, update the search query.
* Because an event only returns an index, we need to retrieve the
* actual IED before getting the actual value (in this case the name).
*/
private onSelect(event: SingleSelectedEvent): void {
const ied = this.alphabeticOrderedIeds[event.detail.index];
this.currentSelectedIEDs = `:root > IED[name="${getNameAttribute(ied)}"]`;
}

render(): TemplateResult {
return this.doc?.querySelector(':root > IED')
? html`<section>
<mwc-select
id="iedSelect"
label="${translate("iededitor.searchHelper")}"
@selected=${this.onSelect}>
${this.alphabeticOrderedIeds.map(
ied =>
html`<mwc-list-item
?selected=${ied == this.alphabeticOrderedIeds[0]}
value="${getNameAttribute(ied)}"
>${getNameAttribute(ied)} ${ied.hasAttribute('desc') ? translate('iededitor.searchHelperDesc', {
description: getDescriptionAttribute(ied)!,
}) : ''}
</mwc-list-item>`
)}
</mwc-select>
${Array.from(this.doc?.querySelectorAll(this.currentSelectedIEDs)).map(
ied => html`<ied-container
.element=${ied}
></ied-container>`
)}</section>`
: html`<h1>
<span style="color: var(--base1)"
>${translate('iededitor.missing')}</span
>
</h1>`;
}

static styles = css`
:host {
width: 100vw;
}

section {
padding: 8px 12px 16px;
}

#iedSelect {
width: 35vw;
padding-bottom: 20px;
}

h1 {
color: var(--mdc-theme-on-surface);
font-family: 'Roboto', sans-serif;
font-weight: 300;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
margin: 0px;
line-height: 48px;
padding-left: 0.3em;
}
`;
}
4 changes: 1 addition & 3 deletions src/editors/SingleLineDiagram.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@ import {
query,
TemplateResult,
} from 'lit-element';

import panzoom from 'panzoom';

import { identity, newWizardEvent, SCLTag } from '../foundation.js';
import { identity, getPathNameAttribute, newWizardEvent, SCLTag } from '../foundation.js';
import {
getAbsolutePosition,
createTerminalElement,
Expand All @@ -30,7 +29,6 @@ import {
import {
isBusBar,
getConnectedTerminals,
getPathNameAttribute,
} from './singlelinediagram/foundation.js';
import { wizards } from '../wizards/wizard-library.js';

Expand Down
38 changes: 38 additions & 0 deletions src/editors/ied/access-point-container.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import {
css,
customElement,
html,
LitElement,
property,
TemplateResult,
} from 'lit-element';

import '../../action-pane.js';
import './server-container.js'
Flurb marked this conversation as resolved.
Show resolved Hide resolved
import { nothing } from 'lit-html';
import { getDescriptionAttribute, getNameAttribute } from '../../foundation.js';

/** [[`IED`]] plugin subeditor for editing `AccessPoint` element. */
@customElement('access-point-container')
export class AccessPointContainer extends LitElement {
@property({ attribute: false })
element!: Element;

private header(): TemplateResult {
const name = getNameAttribute(this.element);
const desc = getDescriptionAttribute(this.element);

return html`${name}${desc ? html` &mdash; ${desc}` : nothing}`;
}

render(): TemplateResult {
return html`<action-pane .label="${this.header()}">
${Array.from(this.element.querySelectorAll(':scope > Server')).map(
server => html`<server-container
.element=${server}
></server-container>`)}
</action-pane>`;
}

static styles = css``;
}
116 changes: 116 additions & 0 deletions src/editors/ied/da-container.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
import {
css,
customElement,
html,
LitElement,
property,
query,
TemplateResult,
} from 'lit-element';
import { nothing } from 'lit-html';
import { translate } from 'lit-translate';

import '@material/mwc-icon-button-toggle';
import { IconButtonToggle } from '@material/mwc-icon-button-toggle';

import '../../action-pane.js';
import { getNameAttribute } from '../../foundation.js';

/** [[`IED`]] plugin subeditor for editing `(B)DA` element. */
@customElement('da-container')
export class DAContainer extends LitElement {
/**
* The DA itself.
*/
@property({ attribute: false })
element!: Element;

/**
* The optional DAI of this (B)DA.
*/
@property({ attribute: false })
instanceElement!: Element;

@query('#toggleButton') toggleButton: IconButtonToggle | undefined;

private header(): TemplateResult {
const name = getNameAttribute(this.element);
const bType = this.element!.getAttribute('bType') ?? nothing;

if (this.instanceElement) {
return html`<b>${name}</b> &mdash; ${bType}`;
} else {
return html`${name} &mdash; ${bType}`;
}
}

/**
* Rendering an optional value of this (B)DA container.
* If there is a DAI, it get's priority on top of (B)DA values.
* @returns TemplateResult containing the value of the instance, element or nothing.
*/
private renderValue(): TemplateResult {
if (this.instanceElement) {
return html`${this.getValueElement(this.instanceElement)?.textContent}`
}

return html`${this.getValueElement(this.element)?.textContent}`;
}

/**
* Get the 'Val' element of another element.
* @param element - The element to search for an 'Val' element.
* @returns the 'Val' element, or null if not found.
*/
private getValueElement(element: Element): Element | null {
return element.querySelector('Val') ?? null;
}

/**
* Get the nested (B)DA element(s) if available.
* @returns The nested (B)DA element(s) of this (B)DA container.
*/
private getBDAElements(): Element[] {
const type = this.element!.getAttribute('type') ?? undefined;
const doType = this.element!.closest('SCL')!.querySelector(`:root > DataTypeTemplates > DAType[id="${type}"]`);
if (doType != null) {
return Array.from(doType!.querySelectorAll(':scope > BDA'))
}
return [];
}

render(): TemplateResult {
const bType = this.element!.getAttribute('bType');

return html`<action-pane .label="${this.header()}" icon="${this.instanceElement != null ? 'done' : ''}">
${bType == 'Struct' ? html`<abbr slot="action" title="${translate('iededitor.toggleChildElements')}">
<mwc-icon-button-toggle
id="toggleButton"
onIcon="keyboard_arrow_up"
offIcon="keyboard_arrow_down"
@click=${() => this.requestUpdate()}
></mwc-icon-button-toggle>
</abbr>` : nothing}
<h6>${this.renderValue()}</h6>
${this.toggleButton?.on && bType == 'Struct' ? this.getBDAElements().map(element =>
html`<da-container
.element=${element}>
</da-container>`) : nothing}
</action-pane>
`;
}

static styles = css`
h6 {
color: var(--mdc-theme-on-surface);
font-family: 'Roboto', sans-serif;
font-weight: 500;
font-size: 0.8em;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
margin: 0px;
padding-left: 0.3em;
}
`;
}
Loading