Skip to content

Commit 98d4c40

Browse files
committed
chore: Readd userinfo to header
1 parent 72a38d8 commit 98d4c40

File tree

2 files changed

+20
-4
lines changed

2 files changed

+20
-4
lines changed

packages/compas-open-scd/src/addons/CompasLayout.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ import '@material/mwc-switch';
4848
import '@material/mwc-select';
4949
import '@material/mwc-textfield';
5050
import { EditCompletedEvent } from '@openscd/core';
51+
import { UserInfoEvent } from '../compas/foundation';
5152

5253
export function compasOpenMenuEvent(): CustomEvent<void> {
5354
return new CustomEvent<void>('open-drawer', { bubbles: true, composed: true });
@@ -76,6 +77,9 @@ export class CompasLayout extends LitElement {
7677
@property({ type: Object })
7778
host!: HTMLElement;
7879

80+
@property({ type: String })
81+
username: string | undefined;
82+
7983
@state()
8084
validated: Promise<void> = Promise.resolve();
8185

@@ -408,6 +412,12 @@ export class CompasLayout extends LitElement {
408412
this.requestUpdate();
409413
}
410414
);
415+
416+
this.addEventListener('userinfo', this.onUserInfo);
417+
}
418+
419+
private onUserInfo(event: UserInfoEvent) {
420+
this.username = event.detail.name;
411421
}
412422

413423
private renderMenuItem(me: MenuItem | 'divider'): TemplateResult {
@@ -456,6 +466,16 @@ export class CompasLayout extends LitElement {
456466
@click=${() => (this.menuUI.open = true)}
457467
></mwc-icon-button>
458468
<div slot="title" id="title">${this.docName}</div>
469+
${this.username != undefined
470+
? html`<span
471+
id="userField"
472+
slot="actionItems"
473+
style="font-family:Roboto"
474+
>${get('userinfo.loggedInAs', {
475+
name: this.username,
476+
})}</span
477+
>`
478+
: ``}
459479
${this.menu.map(this.renderActionItem)}
460480
</mwc-top-app-bar-fixed>`;
461481
}

packages/compas-open-scd/src/open-scd.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,6 @@ export class OpenSCD extends LitElement {
9797
}
9898

9999
connectedCallback(): void {
100-
console.log('COMPAS OPEN SCD CONNECTED CALLBACK');
101100
super.connectedCallback();
102101
this.addEventListener('reset-plugins', this.resetPlugins);
103102
this.addEventListener(
@@ -127,7 +126,6 @@ export class OpenSCD extends LitElement {
127126
}
128127

129128
render(): TemplateResult {
130-
console.log('COMPAS OPEN SCD RENDER');
131129
return html`<compas-session>
132130
<oscd-waiter>
133131
<compas-settings-addon .host=${this}>
@@ -203,7 +201,6 @@ export class OpenSCD extends LitElement {
203201
}
204202

205203
private get sortedStoredPlugins(): Plugin[] {
206-
console.log('----> sortedStoredPlugins')
207204
const plugins = this.storedPlugins
208205
.map(plugin => {
209206
if (!plugin.official) return plugin;
@@ -218,7 +215,6 @@ export class OpenSCD extends LitElement {
218215
.sort(compareNeedsDoc)
219216
.sort(menuCompare);
220217

221-
console.log(plugins);
222218
return plugins;
223219
}
224220

0 commit comments

Comments
 (0)