Skip to content

Commit 45587ae

Browse files
committed
chore: added latest oscd changes in compas package
Signed-off-by: Stef3st <[email protected]>
2 parents 2b3cc11 + 2c9c422 commit 45587ae

Some content is hidden

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

46 files changed

+59226
-37422
lines changed

package-lock.json

Lines changed: 57939 additions & 35456 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/compas-open-scd/.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
.DS_Store
77

88
## npm
9-
/node_modules/
9+
node_modules/
1010
/npm-debug.log
1111

1212
## testing

packages/compas-open-scd/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
{
22
"name": "compas-open-scd",
3-
"version": "0.33.6",
3+
"version": "0.33.0-6",
44
"repository": "https://github.com/openscd/open-scd.git",
5-
"description": "A bottom-up substation configuration designer for projects described using SCL `IEC 61850-6` Edition 2 or greater.",
5+
"description": "OpenSCD CoMPAS Edition",
6+
"directory": "packages/compas-open-scd",
67
"keywords": [
78
"SCL",
89
"substation configuration",

packages/compas-open-scd/src/Logging.ts renamed to packages/compas-open-scd/src/Historing.ts

Lines changed: 140 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,11 @@ import { Snackbar } from '@material/mwc-snackbar';
2121

2222
import './filtered-list.js';
2323
import {
24+
CommitDetail,
2425
CommitEntry,
2526
ifImplemented,
27+
InfoDetail,
28+
InfoEntry,
2629
invert,
2730
IssueDetail,
2831
IssueEvent,
@@ -44,7 +47,6 @@ const icons = {
4447
info: 'info',
4548
warning: 'warning',
4649
error: 'report',
47-
action: 'history',
4850
};
4951

5052
function getPluginName(src: string): string {
@@ -70,13 +72,18 @@ function getPluginName(src: string): string {
7072
* Renders the `history` to `logUI` and the latest `'error'` [[`LogEntry`]] to
7173
* `messageUI`.
7274
*/
73-
export type LoggingElement = Mixin<typeof Logging>;
75+
export type HistoringElement = Mixin<typeof Historing>;
7476

75-
export function Logging<TBase extends LitElementConstructor>(Base: TBase) {
76-
class LoggingElement extends Base {
77+
export function Historing<TBase extends LitElementConstructor>(Base: TBase) {
78+
class HistoringElement extends Base {
7779
/** All [[`LogEntry`]]s received so far through [[`LogEvent`]]s. */
7880
@property({ type: Array })
79-
history: LogEntry[] = [];
81+
log: InfoEntry[] = [];
82+
83+
/** All [[`CommitEntry`]]s received so far through [[`LogEvent`]]s */
84+
@property({ type: Array })
85+
history: CommitEntry[] = [];
86+
8087
/** Index of the last [[`EditorAction`]] applied. */
8188
@property({ type: Number })
8289
editCount = -1;
@@ -86,6 +93,7 @@ export function Logging<TBase extends LitElementConstructor>(Base: TBase) {
8693
latestIssue!: IssueDetail;
8794

8895
@query('#log') logUI!: Dialog;
96+
@query('#history') historyUI!: Dialog;
8997
@query('#diagnostic') diagnosticUI!: Dialog;
9098
@query('#error') errorUI!: Snackbar;
9199
@query('#warning') warningUI!: Snackbar;
@@ -144,16 +152,10 @@ export function Logging<TBase extends LitElementConstructor>(Base: TBase) {
144152
return true;
145153
}
146154

147-
private onLog(le: LogEvent): void {
148-
if (le.detail.kind === 'reset') {
149-
this.history = [];
150-
this.editCount = -1;
151-
return;
152-
}
153-
154-
const entry: LogEntry = {
155+
private onHistory(detail: CommitDetail) {
156+
const entry: CommitEntry = {
155157
time: new Date(),
156-
...le.detail,
158+
...detail,
157159
};
158160

159161
if (entry.kind === 'action') {
@@ -164,22 +166,51 @@ export function Logging<TBase extends LitElementConstructor>(Base: TBase) {
164166
}
165167

166168
this.history.push(entry);
169+
this.requestUpdate('history', []);
170+
}
171+
172+
private onReset() {
173+
this.log = [];
174+
this.history = [];
175+
this.editCount = -1;
176+
}
177+
178+
private onInfo(detail: InfoDetail) {
179+
const entry: InfoEntry = {
180+
time: new Date(),
181+
...detail,
182+
};
183+
184+
this.log.push(entry);
167185
if (!this.logUI.open) {
168186
const ui = {
169187
error: this.errorUI,
170188
warning: this.warningUI,
171189
info: this.infoUI,
172-
action: this.infoUI,
173-
}[le.detail.kind];
190+
}[detail.kind];
174191

175192
ui.close();
176193
ui.show();
177194
}
178-
if (le.detail.kind == 'error') {
195+
if (detail.kind == 'error') {
179196
this.errorUI.close(); // hack to reset timeout
180197
this.errorUI.show();
181198
}
182-
this.requestUpdate('history', []);
199+
this.requestUpdate('log', []);
200+
}
201+
202+
private onLog(le: LogEvent): void {
203+
switch (le.detail.kind) {
204+
case 'reset':
205+
this.onReset();
206+
break;
207+
case 'action':
208+
this.onHistory(le.detail);
209+
break;
210+
default:
211+
this.onInfo(le.detail);
212+
break;
213+
}
183214
}
184215

185216
async performUpdate() {
@@ -201,7 +232,36 @@ export function Logging<TBase extends LitElementConstructor>(Base: TBase) {
201232
}
202233

203234
renderLogEntry(
204-
entry: LogEntry,
235+
entry: InfoEntry,
236+
index: number,
237+
log: LogEntry[]
238+
): TemplateResult {
239+
return html` <abbr title="${entry.title}">
240+
<mwc-list-item
241+
class="${entry.kind}"
242+
graphic="icon"
243+
?twoline=${!!entry.message}
244+
?activated=${this.editCount == log.length - index - 1}
245+
>
246+
<span>
247+
<!-- FIXME: replace tt with mwc-chip asap -->
248+
<tt>${entry.time?.toLocaleString()}</tt>
249+
${entry.title}</span
250+
>
251+
<span slot="secondary">${entry.message}</span>
252+
<mwc-icon
253+
slot="graphic"
254+
style="--mdc-theme-text-icon-on-background:var(${ifDefined(
255+
iconColors[entry.kind]
256+
)})"
257+
>${icons[entry.kind]}</mwc-icon
258+
>
259+
</mwc-list-item></abbr
260+
>`;
261+
}
262+
263+
renderHistoryEntry(
264+
entry: CommitEntry,
205265
index: number,
206266
history: LogEntry[]
207267
): TemplateResult {
@@ -223,18 +283,31 @@ export function Logging<TBase extends LitElementConstructor>(Base: TBase) {
223283
style="--mdc-theme-text-icon-on-background:var(${ifDefined(
224284
iconColors[entry.kind]
225285
)})"
226-
>${icons[entry.kind]}</mwc-icon
286+
>history</mwc-icon
227287
>
228288
</mwc-list-item></abbr
229289
>`;
230290
}
231291

292+
private renderLog(): TemplateResult[] | TemplateResult {
293+
if (this.log.length > 0)
294+
return this.log.slice().reverse().map(this.renderLogEntry, this);
295+
else
296+
return html`<mwc-list-item disabled graphic="icon">
297+
<span>${translate('log.placeholder')}</span>
298+
<mwc-icon slot="graphic">info</mwc-icon>
299+
</mwc-list-item>`;
300+
}
301+
232302
private renderHistory(): TemplateResult[] | TemplateResult {
233303
if (this.history.length > 0)
234-
return this.history.slice().reverse().map(this.renderLogEntry, this);
304+
return this.history
305+
.slice()
306+
.reverse()
307+
.map(this.renderHistoryEntry, this);
235308
else
236309
return html`<mwc-list-item disabled graphic="icon">
237-
<span>${translate('log.placeholder')}</span>
310+
<span>${translate('history.placeholder')}</span>
238311
<mwc-icon slot="graphic">info</mwc-icon>
239312
</mwc-list-item>`;
240313
}
@@ -310,6 +383,42 @@ export function Logging<TBase extends LitElementConstructor>(Base: TBase) {
310383
);
311384
}
312385

386+
private renderLogDialog(): TemplateResult {
387+
return html` <mwc-dialog id="log" heading="${translate('log.name')}">
388+
${this.renderFilterButtons()}
389+
<mwc-list id="content" wrapFocus>${this.renderLog()}</mwc-list>
390+
<mwc-button slot="primaryAction" dialogaction="close"
391+
>${translate('close')}</mwc-button
392+
>
393+
</mwc-dialog>`;
394+
}
395+
396+
private renderHistoryDialog(): TemplateResult {
397+
return html` <mwc-dialog
398+
id="history"
399+
heading="${translate('history.name')}"
400+
>
401+
<mwc-list id="content" wrapFocus>${this.renderHistory()}</mwc-list>
402+
<mwc-button
403+
icon="undo"
404+
label="${translate('undo')}"
405+
?disabled=${!this.canUndo}
406+
@click=${this.undo}
407+
slot="secondaryAction"
408+
></mwc-button>
409+
<mwc-button
410+
icon="redo"
411+
label="${translate('redo')}"
412+
?disabled=${!this.canRedo}
413+
@click=${this.redo}
414+
slot="secondaryAction"
415+
></mwc-button>
416+
<mwc-button slot="primaryAction" dialogaction="close"
417+
>${translate('close')}</mwc-button
418+
>
419+
</mwc-dialog>`;
420+
}
421+
313422
render(): TemplateResult {
314423
return html`${ifImplemented(super.render())}
315424
<style>
@@ -327,13 +436,9 @@ export function Logging<TBase extends LitElementConstructor>(Base: TBase) {
327436
#log > mwc-icon-button-toggle:nth-child(4) {
328437
right: 158px;
329438
}
330-
#log > mwc-icon-button-toggle:nth-child(5) {
331-
right: 206px;
332-
}
333439
#content mwc-list-item.info,
334440
#content mwc-list-item.warning,
335-
#content mwc-list-item.error,
336-
#content mwc-list-item.action {
441+
#content mwc-list-item.error {
337442
display: none;
338443
}
339444
#infofilter[on] ~ #content mwc-list-item.info {
@@ -345,9 +450,6 @@ export function Logging<TBase extends LitElementConstructor>(Base: TBase) {
345450
#errorfilter[on] ~ #content mwc-list-item.error {
346451
display: flex;
347452
}
348-
#actionfilter[on] ~ #content mwc-list-item.action {
349-
display: flex;
350-
}
351453
352454
#infofilter[on] {
353455
color: var(--cyan);
@@ -365,7 +467,8 @@ export function Logging<TBase extends LitElementConstructor>(Base: TBase) {
365467
color: var(--blue);
366468
}
367469
368-
#log {
470+
#log,
471+
#history {
369472
--mdc-dialog-min-width: 92vw;
370473
}
371474
@@ -379,28 +482,7 @@ export function Logging<TBase extends LitElementConstructor>(Base: TBase) {
379482
--mdc-list-item-meta-size: 48px;
380483
}
381484
</style>
382-
<mwc-dialog id="log" heading="${translate('log.name')}">
383-
${this.renderFilterButtons()}
384-
<mwc-list id="content" wrapFocus>${this.renderHistory()}</mwc-list>
385-
<mwc-button
386-
icon="undo"
387-
label="${translate('undo')}"
388-
?disabled=${!this.canUndo}
389-
@click=${this.undo}
390-
slot="secondaryAction"
391-
></mwc-button>
392-
<mwc-button
393-
icon="redo"
394-
label="${translate('redo')}"
395-
?disabled=${!this.canRedo}
396-
@click=${this.redo}
397-
slot="secondaryAction"
398-
></mwc-button>
399-
<mwc-button slot="primaryAction" dialogaction="close"
400-
>${translate('close')}</mwc-button
401-
>
402-
</mwc-dialog>
403-
485+
${this.renderLogDialog()} ${this.renderHistoryDialog()}
404486
<mwc-dialog id="diagnostic" heading="${translate('diag.name')}">
405487
<filtered-list id="content" wrapFocus
406488
>${this.renderIssues()}</filtered-list
@@ -413,18 +495,18 @@ export function Logging<TBase extends LitElementConstructor>(Base: TBase) {
413495
<mwc-snackbar
414496
id="info"
415497
timeoutMs="4000"
416-
labelText="${this.history
498+
labelText="${this.log
417499
.slice()
418500
.reverse()
419-
.find(le => le.kind === 'info' || le.kind === 'action')?.title ??
501+
.find(le => le.kind === 'info')?.title ??
420502
get('log.snackbar.placeholder')}"
421503
>
422504
<mwc-icon-button icon="close" slot="dismiss"></mwc-icon-button>
423505
</mwc-snackbar>
424506
<mwc-snackbar
425507
id="warning"
426508
timeoutMs="6000"
427-
labelText="${this.history
509+
labelText="${this.log
428510
.slice()
429511
.reverse()
430512
.find(le => le.kind === 'warning')?.title ??
@@ -441,7 +523,7 @@ export function Logging<TBase extends LitElementConstructor>(Base: TBase) {
441523
<mwc-snackbar
442524
id="error"
443525
timeoutMs="10000"
444-
labelText="${this.history
526+
labelText="${this.log
445527
.slice()
446528
.reverse()
447529
.find(le => le.kind === 'error')?.title ??
@@ -472,5 +554,5 @@ export function Logging<TBase extends LitElementConstructor>(Base: TBase) {
472554
}
473555
}
474556

475-
return LoggingElement;
557+
return HistoringElement;
476558
}

0 commit comments

Comments
 (0)