UNPKG

@dbp-topics/signature

Version:

[GitLab Repository](https://gitlab.tugraz.at/dbp/esign/signature) | [npmjs package](https://www.npmjs.com/package/@dbp-topics/signature) | [Unpkg CDN](https://unpkg.com/browse/@dbp-topics/signature/) | [Esign Bundle](https://gitlab.tugraz.at/dbp/esign/dbp

336 lines (335 loc) 27.8 kB
let e,i,t,s,n,l,a=e=>e;function o(){return o=Object.assign?Object.assign.bind():function(e){for(var i=1;i<arguments.length;i++){var t=arguments[i];for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&(e[s]=t[s])}return e},o.apply(this,arguments)} /*! * License: LGPL-2.1-or-later * Dependencies: * * @webcomponents/scoped-custom-element-registry: BSD-3-Clause * @dbp-toolkit/app-shell: LGPL-2.1-or-later * @dbp-toolkit/language-select: LGPL-2.1-or-later * @dbp-toolkit/common: LGPL-2.1-or-later * @dbp-toolkit/auth: LGPL-2.1-or-later * event-target-shim: MIT * @dbp-toolkit/notification: LGPL-2.1-or-later * @dbp-toolkit/theme-switcher: LGPL-2.1-or-later * path-to-regexp: MIT * universal-router: MIT * generateUrls: MIT * @dbp-toolkit/matomo: LGPL-2.1-or-later * @tugraz/web-components: LGPL-2.1-or-later * @babel/runtime: MIT * i18next: MIT * @lit/reactive-element: BSD-3-Clause * lit-html: BSD-3-Clause * lit-element: BSD-3-Clause * @open-wc/dedupe-mixin: MIT * @open-wc/scoped-elements: MIT */import{D as d,c as r,A as u,f as c}from"./shared/activity.9b918d92.es.js";import{S as p,I as h,m as f,i as g,g as b,a as m,d as v,b as F,y as $,n as P,h as y}from"./shared/dbp-lit-element.80eb49d3.es.js";import{F as w,a as x,P as S,g as A,n as q}from"./shared/styles.226a59b2.es.js";import{M as k,B as E,s as I,J as D,o as U}from"./shared/jsonld.78121145.es.js";import{T as C,P as L}from"./shared/dbp-pdf-annotation-view.3ed0f53e.es.js";var N={element:"dbp-official-signature-pdf-upload",module_src:"dbp-official-signature-pdf-upload.js",routing_name:"official-pdf-upload",name:{de:"Dokumente amtssignieren",en:"Officially sign documents"},short_name:{de:"Dokumente amtssignieren",en:"Officially sign documents"},description:{de:"Erlaubt das Hochladen von PDF-Dokumenten, um sie mit einer Amtssignatur zu versehen",en:"Allows upload of PDF-documents to officially sign them"},subscribe:"lang,entry-point-url,nextcloud-web-app-password-url,nextcloud-webdav-url,nextcloud-name,nextcloud-auth-info,nextcloud-file-url,auth,allow-annotating,file-handling-enabled-targets",required_roles:["ROLE_SCOPE_OFFICIAL-SIGNATURE"]};class j extends(p(d)){constructor(){super(),this._i18n=r(),this.lang=this._i18n.language,this.entryPointUrl="",this.nextcloudWebAppPasswordURL="",this.nextcloudWebDavURL="",this.nextcloudName="",this.nextcloudFileURL="",this.nextcloudAuthInfo="",this.signedFiles=[],this.signedFilesCount=0,this.signedFilesToDownload=0,this.errorFiles=[],this.errorFilesCount=0,this.uploadStatusFileName="",this.uploadStatusText="",this.currentFile={},this.currentFileName="",this.currentFilePlacementMode="",this.currentFileSignaturePlacement={},this.signingProcessEnabled=!1,this.signingProcessActive=!1,this.signaturePlacementInProgress=!1,this.withSigBlock=!1,this.queuedFilesSignaturePlacements=[],this.queuedFilesPlacementModes=[],this.queuedFilesNeedsPlacement=new Map,this.currentPreviewQueueKey="",this.allowAnnotating=!1,this.queuedFilesAnnotations=[],this.queuedFilesAnnotationModes=[],this.queuedFilesAnnotationsCount=0,this.queuedFilesAnnotationSaved=[],this.queuedFilesEnabledAnnotations=[],this.isAnnotationViewVisible=!1,this.addAnnotationInProgress=!1,this.activity=new u(N),this.fileHandlingEnabledTargets="local"}static get scopedElements(){return{"dbp-icon":h,"dbp-file-source":w,"dbp-file-sink":x,"dbp-pdf-preview":S,"dbp-mini-spinner":k,"dbp-button":E,"dbp-textswitch":C,"dbp-pdf-annotation-view":L}}static get properties(){return o({},super.properties,{lang:{type:String},entryPointUrl:{type:String,attribute:"entry-point-url"},nextcloudWebAppPasswordURL:{type:String,attribute:"nextcloud-web-app-password-url"},nextcloudWebDavURL:{type:String,attribute:"nextcloud-webdav-url"},nextcloudName:{type:String,attribute:"nextcloud-name"},nextcloudFileURL:{type:String,attribute:"nextcloud-file-url"},nextcloudAuthInfo:{type:String,attribute:"nextcloud-auth-info"},signedFiles:{type:Array,attribute:!1},signedFilesCount:{type:Number,attribute:!1},signedFilesToDownload:{type:Number,attribute:!1},queuedFilesCount:{type:Number,attribute:!1},errorFiles:{type:Array,attribute:!1},errorFilesCount:{type:Number,attribute:!1},uploadInProgress:{type:Boolean,attribute:!1},uploadStatusFileName:{type:String,attribute:!1},uploadStatusText:{type:String,attribute:!1},signingProcessEnabled:{type:Boolean,attribute:!1},signingProcessActive:{type:Boolean,attribute:!1},queueBlockEnabled:{type:Boolean,attribute:!1},currentFile:{type:Object,attribute:!1},currentFileName:{type:String,attribute:!1},signaturePlacementInProgress:{type:Boolean,attribute:!1},withSigBlock:{type:Boolean,attribute:!1},isSignaturePlacement:{type:Boolean,attribute:!1},allowAnnotating:{type:Boolean,attribute:"allow-annotating"},isAnnotationViewVisible:{type:Boolean,attribute:!1},queuedFilesAnnotations:{type:Array,attribute:!1},queuedFilesAnnotationsCount:{type:Number,attribute:!1},addAnnotationInProgress:{type:Boolean,attribute:!1},queuedFilesAnnotationModes:{type:Array,attribute:!1},queuedFilesAnnotationSaved:{type:Array,attribute:!1},fileHandlingEnabledTargets:{type:String,attribute:"file-handling-enabled-targets"}})}connectedCallback(){super.connectedCallback(),setInterval((()=>{this.handleQueuedFiles()}),1e3)}async queueFile(e){let i=await super.queueFile(e);return await this._updateNeedsPlacementStatus(i),this.requestUpdate(),i}async handleQueuedFiles(){const e=this._i18n;if(this.endSigningProcessIfQueueEmpty(),0===this.queuedFilesCount)return void(this.signingProcessEnabled=!1);if(!this.signingProcessEnabled||this.uploadInProgress||this.addAnnotationInProgress)return;this.signaturePlacementInProgress=!1;for(const i of Object.keys(this.queuedFiles)){const t="manual"===this.queuedFilesPlacementModes[i];if(this.queuedFilesNeedsPlacement.get(i)&&!t)return I({body:e.t("error-manual-positioning-missing"),type:"danger",timeout:5}),this.signingProcessEnabled=!1,void(this.signingProcessActive=!1)}const i=Object.keys(this.queuedFiles)[0],t=this.takeFileFromQueue(i).file;this.currentFile=t,this.currentFilePlacementMode=this.queuedFilesPlacementModes[i],this.currentFileSignaturePlacement=this.queuedFilesSignaturePlacements[i],this.uploadInProgress=!0;let s={};if("manual"===this.queuedFilesPlacementModes[i]){const e=this.queuedFilesSignaturePlacements[i];void 0!==e&&(s=c(e))}s.profile="official",this.uploadStatusText=e.t("official-pdf-upload.upload-status-file-text",{fileName:t.name,fileSize:f(t.size,!1)});const n=this.isAnnotationsEnabledForKey(i),l=this.takeAnnotationsFromQueue(i);await this.uploadFile(t,s,n?l:[]),this.uploadInProgress=!1}onReceiveBeforeUnload(e){const i=this._i18n;if(0!==this.signedFilesCount){if(!e.isTrusted){if(confirm(i.t("official-pdf-upload.confirm-page-leave")))return}e.preventDefault(),e.returnValue=""}}addToErrorFiles(e){this.endSigningProcessIfQueueEmpty(),this.errorFiles[Math.floor(1e6*Math.random())]=e,this.errorFilesCount++,this.sendSetPropertyEvent("analytics-event",{category:"officiallySigning",action:"SigningFailed",name:e.json["hydra:description"]})}onFileUploadFinished(e){if(201!==e.status)this.addToErrorFiles(e);else if("http://schema.org/MediaObject"===e.json["@type"]){this.signedFiles.push(e.json),this.signedFilesCount++;const i=e.json;this.currentFileName=i.name,this.endSigningProcessIfQueueEmpty(),this.sendSetPropertyEvent("analytics-event",{category:"OfficialSigning",action:"DocumentSigned",name:e.json.contentSize})}}update(e){e.forEach(((e,i)=>{switch(i){case"lang":this._i18n.changeLanguage(this.lang);break;case"entryPointUrl":D.getInstance(this.entryPointUrl).then((e=>{let i;try{i=e.getApiUrlForEntityName("EsignAdvancedlySignedDocument")}catch(t){i=e.getApiUrlForEntityName("AdvancedlySignedDocument")}this.fileSourceUrl=i}))}})),super.update(e)}clearQueuedFiles(){this.queuedFilesSignaturePlacements=[],this.queuedFilesPlacementModes=[],this.queuedFilesNeedsPlacement.clear(),super.clearQueuedFiles()}async stopSigningProcess(){if(console.log("stop"),this.signingProcessEnabled=!1,this.signingProcessActive=!1,void 0!==this.currentFile.file){const e=await this.queueFile(this.currentFile.file);this.queuedFilesPlacementModes[e]=this.currentFilePlacementMode,this.queuedFilesSignaturePlacements[e]=this.currentFileSignaturePlacement}}static get styles(){return g(e||(e=a` ${0} ${0} ${0} ${0} ${0} `),b(),m(!1),v(),F(),A())}getQueuedFilesHtml(){const e=this._i18n,s=Object.keys(this.queuedFiles);let n=[];return s.forEach((s=>{const l=this.queuedFiles[s].file,o="manual"===this.queuedFilesPlacementModes[s],d=this.queuedFilesNeedsPlacement.get(s)&&!o;n.push($(i||(i=a` <div class="file-block"> <div class="header"> <span class="filename"> <strong>${0}</strong> (${0}) </span> <button class="button close" ?disabled="${0}" title="${0}" @click="${0}"> <dbp-icon name="trash"></dbp-icon> </button> </div> <div class="bottom-line"> <div></div> <button class="button" ?disabled="${0}" @click="${0}"> ${0} </button> <span class="headline">${0}:</span> <dbp-textswitch name1="auto" name2="manual" name="${0}" class="${0}" value1="${0}" value2="${0}" ?disabled="${0}" @change=${0}></dbp-textswitch> <span class="headline ${0}"> ${0}: </span> <div class="${0}"> <dbp-textswitch id="annotation-switch" name1="no-text" name2="text-selected" name="${0}" class="${0}" value1="${0}" value2="${0}" ?disabled="${0}" @change=${0}></dbp-textswitch> </div> </div> <div class="error-line"> ${0} </div> </div> `),l.name,f(l.size),this.signingProcessEnabled,e.t("official-pdf-upload.remove-queued-file-button-title"),(()=>{this.takeFileFromQueue(s)}),this.signingProcessEnabled,(()=>{this.showPreview(s)}),e.t("official-pdf-upload.show-preview"),e.t("official-pdf-upload.positioning"),this.queuedFilesPlacementModes[s]||"auto",U({"placement-missing":d,switch:!0}),e.t("official-pdf-upload.positioning-automatic"),e.t("official-pdf-upload.positioning-manual"),this.signingProcessEnabled,(e=>this.queuePlacementSwitch(s,e.target.name)),U({hidden:!this.allowAnnotating}),e.t("official-pdf-upload.annotation"),U({hidden:!this.allowAnnotating}),this.queuedFilesAnnotationModes[s]||"no-text",U({switch:!0}),e.t("official-pdf-upload.annotation-no"),e.t("official-pdf-upload.annotation-yes"),this.signingProcessEnabled,(e=>this.showAnnotationView(s,e.target.name)),d?$(t||(t=a` ${0} `),e.t("label-manual-positioning-missing")):""))})),n}getSignedFilesHtml(){const e=Object.keys(this.signedFiles),i=this._i18n;let t=[];return e.forEach((e=>{const n=this.signedFiles[e];t.push($(s||(s=a` <div class="file-block" id="file-block-${0}"> <div class="header"> <span class="filename"> <span class="bold-filename">${0}</span> (${0}) </span> <button class="button" title="${0}" @click="${0}"> <dbp-icon name="download"></dbp-icon> </button> </div> </div> `),e,n.name,f(n.contentSize),i.t("official-pdf-upload.download-file-button-title"),(()=>{this.downloadFileClickHandler(n,"file-block-"+e)})))})),t}getErrorFilesHtml(){const e=Object.keys(this.errorFiles),i=this._i18n;let t=[];return e.forEach((e=>{const s=this.errorFiles[e];void 0!==s.file&&t.push($(n||(n=a` <div class="file-block error"> <div class="header"> <span class="filename"> <strong>${0}</strong> (${0}) </span> <div class="buttons"> <button class="button" title="${0}" @click="${0}"> <dbp-icon name="reload"></dbp-icon> </button> <button class="button" title="${0}" @click="${0}"> <dbp-icon name="trash"></dbp-icon> </button> </div> </div> <div class="bottom-line"> <strong class="error">${0}</strong> </div> </div> `),s.file.name,f(s.file.size),i.t("official-pdf-upload.re-upload-file-button-title"),(()=>{this.fileQueueingClickHandler(s.file,e)}),i.t("official-pdf-upload.remove-failed-file-button-title"),(()=>{this.takeFailedFileFromQueue(e)}),s.json["hydra:description"]))})),t}hasSignaturePermissions(){return this._hasSignaturePermissions("ROLE_SCOPE_OFFICIAL-SIGNATURE")}render(){const e=P(q,"official-signature-placeholder.png"),i=this._i18n;return $(l||(l=a` <div class="${0}"> <div class="field"> <h2>${0}</h2> <p class="subheadline">${0}</p> <div class="control"> <p>${0}</p> <button @click="${0}" ?disabled="${0}" class="button is-primary"> ${0} </button> <dbp-file-source id="file-source" context="${0}" subscribe="nextcloud-store-session:nextcloud-store-session" allowed-mime-types="application/pdf" enabled-targets="${0}" nextcloud-auth-url="${0}" nextcloud-web-dav-url="${0}" nextcloud-name="${0}" nextcloud-auth-info="${0}" nextcloud-file-url="${0}" decompress-zip max-file-size="32000" lang="${0}" ?disabled="${0}" text="${0}" button-label="${0}" @dbp-file-source-file-selected="${0}" @dbp-file-source-switched="${0}"></dbp-file-source> </div> </div> <div id="grid-container"> <div class="left-container"> <div class="files-block field ${0}"> <!-- Queued files headline and queueing spinner --> <h3 class="${0}"> ${0} </h3> <!-- Buttons to start/stop signing process and clear queue --> <div class="control field"> <button @click="${0}" ?disabled="${0}" class="button ${0}"> ${0} </button> <button @click="${0}" ?disabled="${0}" class="button is-right is-primary ${0}"> ${0} </button> <!-- --> <button @click="${0}" id="cancel-signing-process" class="button is-right ${0}"> ${0} </button> <!-- --> </div> <!-- List of queued files --> <div class="control file-list ${0}"> ${0} </div> <!-- Text "queue empty" --> <div class="empty-queue control ${0}"> ${0} <br /> ${0} </div> </div> <!-- List of signed PDFs --> <div class="files-block field ${0}"> <h3>${0}</h3> <!-- Button to download all signed PDFs --> <div class="field ${0}"> <div class="control"> <button @click="${0}" class="button"> ${0} </button> <dbp-button id="zip-download-button" value="${0}" title="${0}" class="is-right" @click="${0}" type="is-primary"></dbp-button> </div> </div> <div class="control">${0}</div> </div> <!-- List of errored files --> <div class="files-block error-files field ${0}"> <h3>${0}</h3> <!-- Button to upload errored files again --> <div class="field ${0}"> <div class="control"> <button @click="${0}" class="button"> ${0} </button> <dbp-button id="re-upload-all-button" ?disabled="${0}" value="${0}" title="${0}" class="is-right" @click="${0}" type="is-primary"></dbp-button> </div> </div> <div class="control">${0}</div> </div> </div> <div class="right-container"> <!-- PDF preview --> <div id="pdf-preview" class="field ${0}"> <h3> ${0} </h3> <div class="box-header"> <div class="filename"> <strong>${0}</strong> (${0}) </div> <button class="is-cancel" @click="${0}"> <dbp-icon name="close"></dbp-icon> </button> </div> <dbp-pdf-preview lang="${0}" allow-signature-rotation signature-placeholder-image-src="${0}" signature-width="162" signature-height="28" @dbp-pdf-preview-accept="${0}" @dbp-pdf-preview-cancel="${0}"></dbp-pdf-preview> </div> <!-- Annotation view --> <div id="annotation-view" class="field ${0}"> <h2>${0}</h2> <div class="box-header"> <div class="filename"> <strong> ${0} </strong> (${0}) </div> <button class="is-cancel annotation" @click="${0}"> <dbp-icon name="close" id="close-icon"></dbp-icon> </button> </div> <dbp-pdf-annotation-view lang="${0}" @dbp-pdf-annotations-save="${0}" @dbp-pdf-annotations-cancel="${0}"></dbp-pdf-annotation-view> </div> <!-- File upload progress --> <div id="upload-progress" class="field notification is-info ${0}"> <dbp-mini-spinner></dbp-mini-spinner> <strong>${0}</strong> ${0} </div> </div> </div> </div> <div class="notification is-warning ${0}"> ${0} </div> <div class="notification is-danger ${0}"> ${0} </div> <div class="${0}"> <dbp-mini-spinner></dbp-mini-spinner> </div> <dbp-file-sink id="file-sink" context="${0}" filename="signed-documents.zip" subscribe="initial-file-handling-state:initial-file-handling-state,clipboard-files:clipboard-files,nextcloud-store-session:nextcloud-store-session" enabled-targets="${0}" nextcloud-auth-url="${0}" nextcloud-web-dav-url="${0}" nextcloud-name="${0}" nextcloud-file-url="${0}" lang="${0}"></dbp-file-sink> `),U({hidden:!this.isLoggedIn()||!this.hasSignaturePermissions()||this.isLoading()}),this.activity.getName(this.lang),this.activity.getDescription(this.lang),i.t("official-pdf-upload.upload-text"),(()=>{this._("#file-source").setAttribute("dialog-open","")}),this.signingProcessActive,i.t("official-pdf-upload.upload-button-label"),i.t("official-pdf-upload.file-picker-context"),this.fileHandlingEnabledTargets,this.nextcloudWebAppPasswordURL,this.nextcloudWebDavURL,this.nextcloudName,this.nextcloudAuthInfo,this.nextcloudFileURL,this.lang,this.signingProcessActive,i.t("official-pdf-upload.upload-area-text"),i.t("official-pdf-upload.upload-button-label"),this.onFileSelected,this.onFileSourceSwitch,U({hidden:!this.queueBlockEnabled}),U({"is-disabled":this.isUserInterfaceDisabled()}),i.t("official-pdf-upload.queued-files-label"),this.clearQueuedFiles,0===this.queuedFilesCount||this.signingProcessActive||this.isUserInterfaceDisabled(),U({"is-disabled":this.isUserInterfaceDisabled()}),i.t("official-pdf-upload.clear-all"),(()=>{this.signingProcessEnabled=!0,this.signingProcessActive=!0}),0===this.queuedFilesCount,U({"is-disabled":this.isUserInterfaceDisabled(),hidden:this.signingProcessActive}),i.t("official-pdf-upload.start-signing-process-button"),this.stopSigningProcess,U({hidden:!this.signingProcessActive}),i.t("official-pdf-upload.stop-signing-process-button"),U({"is-disabled":this.isUserInterfaceDisabled()}),this.getQueuedFilesHtml(),U({hidden:0!==this.queuedFilesCount,"is-disabled":this.isUserInterfaceDisabled()}),i.t("official-pdf-upload.queued-files-empty1"),i.t("official-pdf-upload.queued-files-empty2"),U({hidden:0===this.signedFilesCount,"is-disabled":this.isUserInterfaceDisabled()}),i.t("official-pdf-upload.signed-files-label"),U({hidden:0===this.signedFilesCount}),this.clearSignedFiles,i.t("official-pdf-upload.clear-all"),i.t("official-pdf-upload.download-zip-button"),i.t("official-pdf-upload.download-zip-button-tooltip"),this.zipDownloadClickHandler,this.getSignedFilesHtml(),U({hidden:0===this.errorFilesCount,"is-disabled":this.isUserInterfaceDisabled()}),i.t("official-pdf-upload.error-files-label"),U({hidden:0===this.errorFilesCount}),this.clearErrorFiles,i.t("official-pdf-upload.clear-all"),this.uploadInProgress,i.t("official-pdf-upload.re-upload-all-button"),i.t("official-pdf-upload.re-upload-all-button-title"),this.reUploadAllClickHandler,this.getErrorFilesHtml(),U({hidden:!this.signaturePlacementInProgress}),this.withSigBlock?i.t("official-pdf-upload.signature-placement-label"):i.t("official-pdf-upload.preview-label"),this.currentFile.name,f(void 0!==this.currentFile?this.currentFile.size:0),this.hidePDF,this.lang,e,this.storePDFData,this.hidePDF,U({hidden:!this.isAnnotationViewVisible||!this.allowAnnotating}),i.t("official-pdf-upload.annotation-view-label"),void 0!==this.currentFile.file?this.currentFile.file.name:"",f(void 0!==this.currentFile.file?this.currentFile.file.size:0),this.hideAnnotationView,this.lang,this.processAnnotationEvent,this.processAnnotationCancelEvent,U({hidden:!this.uploadInProgress}),this.uploadStatusFileName,this.uploadStatusText,U({hidden:this.isLoggedIn()||this.isLoading()}),i.t("error-login-message"),U({hidden:this.hasSignaturePermissions()||!this.isLoggedIn()||this.isLoading()}),i.t("error-permission-message"),U({hidden:!this.isLoading()}),i.t("qualified-pdf-upload.save-field-label",{count:this.signedFilesToDownload}),this.fileHandlingEnabledTargets,this.nextcloudWebAppPasswordURL,this.nextcloudWebDavURL,this.nextcloudName,this.nextcloudFileURL,this.lang)}}y("dbp-official-signature-pdf-upload",j); //# sourceMappingURL=dbp-official-signature-pdf-upload.js.map