Skip to content

Commit

Permalink
Added nsd initializing to OpenSCD (#1461)
Browse files Browse the repository at this point in the history
  • Loading branch information
pascalwilbrink committed Feb 26, 2024
1 parent 7ab3553 commit 248c959
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
8 changes: 5 additions & 3 deletions packages/open-scd/src/addons/Settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,11 @@ export function newLoadNsdocEvent(

@customElement('oscd-settings')
export class OscdSettings extends LitElement {
@property({
type: Object,
})
nsdoc!: Nsdoc;

/** Current [[`Settings`]] in `localStorage`, default to [[`defaults`]]. */
@property()
get settings(): Settings {
Expand All @@ -103,9 +108,6 @@ export class OscdSettings extends LitElement {
'IEC 61850-8-1': this.getSetting('IEC 61850-8-1'),
};
}
/** Object containing all *.nsdoc files and a function extracting element's label form them*/
@property({ attribute: false })
nsdoc: Nsdoc = initializeNsdoc();

@property({
type: Object,
Expand Down
10 changes: 9 additions & 1 deletion packages/open-scd/src/open-scd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,25 @@ import { Wizarding } from './Wizarding.js';

import './addons/Settings.js';
import './addons/Waiter.js';
import { initializeNsdoc, Nsdoc } from './foundation/nsdoc.js';

/** The `<open-scd>` custom element is the main entry point of the
* Open Substation Configuration Designer. */
@customElement('open-scd')
export class OpenSCD extends Hosting(
Wizarding(Plugging(Editing(Historing(LitElement))))
) {
/** Object containing all *.nsdoc files and a function extracting element's label form them*/
@property({ attribute: false })
nsdoc: Nsdoc = initializeNsdoc();

private currentSrc = '';
/** The current file's URL. `blob:` URLs are *revoked after parsing*! */
@property({ type: String })
get src(): string {
return this.currentSrc;
}

set src(value: string) {
this.currentSrc = value;
this.dispatchEvent(newPendingStateEvent(this.loadDoc(value)));
Expand Down Expand Up @@ -89,7 +95,9 @@ export class OpenSCD extends Hosting(

render(): TemplateResult {
return html`<oscd-waiter>
<oscd-settings .host=${this}> ${super.render()} </oscd-settings>
<oscd-settings .host=${this} .nsdoc=${this.nsdoc}>
${super.render()}
</oscd-settings>
</oscd-waiter>`;
}

Expand Down

0 comments on commit 248c959

Please sign in to comment.