Skip to content
Snippets Groups Projects
Select Git revision
  • 0fe5ff95567510b1aeab9a9da1f72b9c7e4d56e6
  • main default protected
  • renovate/lock-file-maintenance
  • demo protected
  • person-select-custom
  • dbp-translation-component
  • icon-set-mapping
  • port-i18next-parser
  • remove-sentry
  • favorites-and-recent-files
  • revert-6c632dc6
  • lit2
  • advertisement
  • wc-part
  • automagic
  • publish
  • wip-cleanup
  • demo-file-handling
18 results

index3.html.ejs

Blame
  • 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';
        }