Newer
Older
import {AuthKeycloak, LoginButton} from '@dbp-toolkit/auth';
import {createInstance} from './i18n.js';
import {css, html} from 'lit-element';
import {ScopedElementsMixin} from '@open-wc/scoped-elements';
import DBPLitElement from '@dbp-toolkit/common/dbp-lit-element';
import * as commonUtils from '@dbp-toolkit/common/utils';
import * as commonStyles from '@dbp-toolkit/common/styles';
import {PersonSelect} from '@dbp-toolkit/person-select';
export class PersonProfileDemo extends ScopedElementsMixin(DBPLitElement) {
this._i18n = createInstance();
this.lang = this._i18n.language;
this.person = '';
this.selectedPerson = '';
'dbp-person-profile': PersonProfile,
'dbp-auth-keycloak': AuthKeycloak,
'dbp-login-button': LoginButton,
'dbp-person-select': PersonSelect,
entryPointUrl: { type: String, attribute: 'entry-point-url' },
person: { type: String, attribute: false },
selectedPerson: { type: String, attribute: false },
noAuth: { type: Boolean, attribute: 'no-auth' },
if (changedProperties.has("lang")) {
this._i18n.changeLanguage(this.lang);
}
changedProperties.forEach((oldValue, propName) => {
switch (propName) {
case 'auth':
{
const person = this.auth.person;
if (person) {
this.person = person.identifier;
}
}
break;
}
});
super.update(changedProperties);
}
connectedCallback() {
super.connectedCallback();
const personSelect = that._(this.getScopedTagName('dbp-person-select'));
personSelect.onchange = function () {
that.selectedPerson = $(this).data("object").identifier;
};
static get styles() {
// language=css
return css`
${commonStyles.getThemeCSS()}
${commonStyles.getGeneralCSS()}
h1.title {margin-bottom: 1em;}
div.container {margin-bottom: 1.5em;}
`;
}
return this.noAuth ? html`<dbp-login-button subscribe="auth" lang="${this.lang}" show-image></dbp-login-button>` : html`
<dbp-auth-keycloak subscribe="requested-login-status" lang="${this.lang}" entry-point-url="${this.entryPointUrl}" silent-check-sso-redirect-uri="/dist/silent-check-sso.html"
url="https://auth-dev.tugraz.at/auth" realm="tugraz"
client-id="auth-dev-mw-frontend-local" load-person try-login></dbp-auth-keycloak>
<dbp-login-button subscribe="auth" lang="${this.lang}" show-image></dbp-login-button>
<section class="section">
<div class="container">
<h1 class="title">Person-Profile-Demo</h1>
</div>
<div class="container">
<dbp-person-profile subscribe="auth" lang="${this.lang}" entry-point-url="${this.entryPointUrl}" value="${this.person}"></dbp-person-profile>
</div>
</section>
<section class="section">
<div class="container">
<h1 class="title">Select-Profile-Demo</h1>
</div>
<div class="container">
<dbp-person-select subscribe="auth" lang="${this.lang}" entry-point-url="${this.entryPointUrl}"></dbp-person-select>
<dbp-person-profile subscribe="auth" lang="${this.lang}" entry-point-url="${this.entryPointUrl}" value="${this.selectedPerson}"></dbp-person-profile>
</div>
</section>
`;
}
}
commonUtils.defineCustomElement('dbp-person-profile-demo', PersonProfileDemo);