Select Git revision
index3.html.ejs
dbp-signature-lit-element.js 6.34 KiB
import {EventBus} from '@dbp-toolkit/common';
import buildinfo from 'consts:buildinfo';
import * as utils from "./utils";
import {AdapterLitElement} from "@dbp-toolkit/provider/src/adapter-lit-element";
export class DBPSignatureBaseLitElement extends AdapterLitElement {
constructor() {
super();
}
_(selector) {
return this.shadowRoot === null ? this.querySelector(selector) : this.shadowRoot.querySelector(selector);
}
_hasSignaturePermissions(roleName) {
return (window.DBPPerson && Array.isArray(window.DBPPerson.roles) && window.DBPPerson.roles.indexOf(roleName) !== -1);
}
_updateAuth(e) {
this._loginStatus = e.status;
// Every time isLoggedIn()/isLoading() return something different we request a re-render
let newLoginState = [this.isLoggedIn(), this.isLoading()];
if (this._loginState.toString() !== newLoginState.toString()) {
this.requestUpdate();
}
this._loginState = newLoginState;
}
connectedCallback() {
super.connectedCallback();
this._loginStatus = '';
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() {
return (window.DBPPerson !== undefined && window.DBPPerson !== null);
}
isLoading() {
if (this._loginStatus === "logged-out")
return false;
return (!this.isLoggedIn() && window.DBPAuthToken !== undefined);
}
}
export default class DBPSignatureLitElement extends DBPSignatureBaseLitElement {
constructor() {
super();
this.queuedFiles = [];
this.queuedFilesCount = 0;
this.uploadInProgress = false;
this.queueBlockEnabled = false;
this._queueKey = 0;
// will be set in function update
this.fileSourceUrl = "";
this.showTestNextcloudFilePicker = buildinfo.env !== 'production';
}