Skip to content
Snippets Groups Projects
Unverified Commit afddc5c9 authored by Bekerle, Patrizio's avatar Bekerle, Patrizio :fire:
Browse files

Migrate from EventBus to provider

parent ed98dbe0
No related branches found
No related tags found
No related merge requests found
Pipeline #16681 passed
...@@ -63,7 +63,7 @@ ...@@ -63,7 +63,7 @@
nextcloud-file-url="<%= nextcloudFileURL %>"> nextcloud-file-url="<%= nextcloudFileURL %>">
<<%= name %> <<%= name %>
subscribe="lang:lang,entry-point-url:entry-point-url" subscribe="lang:lang,entry-point-url:entry-point-url"
auth auth requested-login-status
src="<%= getUrl(name + '.topic.metadata.json') %>" src="<%= getUrl(name + '.topic.metadata.json') %>"
base-path="<%= getUrl('') %>" base-path="<%= getUrl('') %>"
keycloak-config='{"url": "<%= keyCloakBaseURL %>", "realm": "tugraz", "clientId": "<%= keyCloakClientId %>", "silentCheckSsoRedirectUri": "<%= getUrl('silent-check-sso.html') %>"}' keycloak-config='{"url": "<%= keyCloakBaseURL %>", "realm": "tugraz", "clientId": "<%= keyCloakClientId %>", "silentCheckSsoRedirectUri": "<%= getUrl('silent-check-sso.html') %>"}'
......
import {EventBus} from '@dbp-toolkit/common';
import * as utils from "./utils"; import * as utils from "./utils";
import {AdapterLitElement} from "@dbp-toolkit/provider/src/adapter-lit-element"; import {AdapterLitElement} from "@dbp-toolkit/provider/src/adapter-lit-element";
import JSONLD from "@dbp-toolkit/common/jsonld";
export class DBPSignatureBaseLitElement extends AdapterLitElement { export class DBPSignatureBaseLitElement extends AdapterLitElement {
constructor() { constructor() {
...@@ -23,8 +23,8 @@ export class DBPSignatureBaseLitElement extends AdapterLitElement { ...@@ -23,8 +23,8 @@ export class DBPSignatureBaseLitElement extends AdapterLitElement {
return (this.auth.person && Array.isArray(this.auth.person.roles) && this.auth.person.roles.indexOf(roleName) !== -1); return (this.auth.person && Array.isArray(this.auth.person.roles) && this.auth.person.roles.indexOf(roleName) !== -1);
} }
_updateAuth(e) { _updateAuth() {
this._loginStatus = e.status; this._loginStatus = this.auth['login-status'];
// Every time isLoggedIn()/isLoading() return something different we request a re-render // Every time isLoggedIn()/isLoading() return something different we request a re-render
let newLoginState = [this.isLoggedIn(), this.isLoading()]; let newLoginState = [this.isLoggedIn(), this.isLoading()];
if (this._loginState.toString() !== newLoginState.toString()) { if (this._loginState.toString() !== newLoginState.toString()) {
...@@ -33,20 +33,24 @@ export class DBPSignatureBaseLitElement extends AdapterLitElement { ...@@ -33,20 +33,24 @@ export class DBPSignatureBaseLitElement extends AdapterLitElement {
this._loginState = newLoginState; this._loginState = newLoginState;
} }
update(changedProperties) {
changedProperties.forEach((oldValue, propName) => {
switch (propName) {
case "auth":
JSONLD.doInitializationOnce(this.entryPointUrl, this.auth.token);
this._updateAuth();
break;
}
});
super.update(changedProperties);
}
connectedCallback() { connectedCallback() {
super.connectedCallback(); super.connectedCallback();
this._loginStatus = ''; this._loginStatus = '';
this._loginState = []; this._loginState = [];
this._bus = new EventBus();
this._updateAuth = this._updateAuth.bind(this);
this._bus.subscribe('auth-update', this._updateAuth);
}
disconnectedCallback() {
this._bus.close();
super.disconnectedCallback();
} }
isLoggedIn() { isLoggedIn() {
......
Subproject commit 92da0f592b3828477fde02a784436be89d67d660 Subproject commit e86f826479612647cf9b945c987d87f5a165beb6
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment