@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
305 lines (299 loc) • 22.9 kB
JavaScript
let e,i,t,s,r,n,a=e=>e;function l(){return l=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},l.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
* @digital-blueprint/annotpdf: MIT
* pdfjs-dist: Apache-2.0
* dommatrix: MIT
* web-streams-polyfill: MIT
* @dbp-toolkit/file-handling: LGPL-2.1-or-later
* webdav: MIT
* tabulator-tables: MIT
* jose: MIT
* file-saver: MIT
* jquery: MIT
* select2: MIT
* @dbp-toolkit/resource-select: LGPL-2.1-or-later
*/import{D as o,c as d,A as c}from"./shared/activity.9b918d92.es.js";import{S as u,I as h,m as f,o as p,i as v,g,a as b,d as m,b as F,y as $,n as y,h as P}from"./shared/dbp-lit-element.80eb49d3.es.js";import{F as w,P as k,g as x,n as E}from"./shared/styles.226a59b2.es.js";import{M as S,B as I,J as C,o as U}from"./shared/jsonld.78121145.es.js";var D={element:"dbp-signature-verification-full",module_src:"dbp-signature-verification-full.js",routing_name:"signature-verification-full",name:{de:"Signierte Dokumente verifizieren",en:"Verify signed documents"},short_name:{de:"Signierte Dokumente verifizieren",en:"Verify signed documents"},description:{de:"Erlaubt das Verifizieren von signierten PDF-Dokumenten",en:"Allows verification of signed PDF-documents"},subscribe:"lang,entry-point-url,nextcloud-web-app-password-url,nextcloud-webdav-url,nextcloud-name,nextcloud-file-url,file-handling-enabled-targets,auth"};class A extends(u(o)){constructor(){super(),this._i18n=d(),this.lang=this._i18n.language,this.entryPointUrl="",this.nextcloudWebAppPasswordURL="",this.nextcloudWebDavURL="",this.nextcloudName="",this.nextcloudFileURL="",this.verifiedFiles=[],this.verifiedFilesCount=0,this.errorFiles=[],this.errorFilesCount=0,this.uploadStatusFileName="",this.uploadStatusText="",this.currentFile={},this.currentFileName="",this.currentFilePlacementMode="",this.currentFileSignaturePlacement={},this.verificationProcessEnabled=!1,this.verificationProcessActive=!1,this.previewInProgress=!1,this.currentPreviewQueueKey="",this.fileHandlingEnabledTargets="local",this.verificationUrl=""}static get scopedElements(){return{"dbp-icon":h,"dbp-file-source":w,"dbp-pdf-preview":k,"dbp-mini-spinner":S,"dbp-button":I}}static get properties(){return l({},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"},verifiedFiles:{type:Array,attribute:!1},verifiedFilesCount:{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},verificationProcessEnabled:{type:Boolean,attribute:!1},verificationProcessActive:{type:Boolean,attribute:!1},queueBlockEnabled:{type:Boolean,attribute:!1},currentFile:{type:Object,attribute:!1},currentFileName:{type:String,attribute:!1},previewInProgress:{type:Boolean,attribute:!1},isSignaturePlacement:{type:Boolean,attribute:!1},fileHandlingEnabledTargets:{type:String,attribute:"file-handling-enabled-targets"}})}connectedCallback(){super.connectedCallback(),setInterval((()=>{this.handleQueuedFiles()}),1e3)}async handleQueuedFiles(){if(this.endVerificationProcessIfQueueEmpty(),0===this.queuedFilesCount)return void(this.verificationProcessEnabled=!1);if(!this.verificationProcessEnabled||this.uploadInProgress)return;this.previewInProgress=!1;const e=Object.keys(this.queuedFiles)[0];let i=this.takeFileFromQueue(e);this.currentFile=i,this.uploadInProgress=!0;this.uploadStatusText=this._i18n.t("signature-verification.upload-status-file-text",{fileName:i.name,fileSize:f(i.size,!1)}),await this.uploadFile(i,{}),this.uploadInProgress=!1}hidePDF(e){this.previewInProgress=!1}onReceiveBeforeUnload(e){if(0!==this.verifiedFilesCount){if(!e.isTrusted){if(confirm(this._i18n.t("signature-verification.confirm-page-leave")))return}e.preventDefault(),e.returnValue=""}}endVerificationProcessIfQueueEmpty(){0===this.queuedFilesCount&&this.verificationProcessActive&&(this.verificationProcessActive=!1)}onFileSelected(e){console.log("File was selected: ev",e),this.queueFile(e.detail.file)}addToErrorFiles(e){this.endVerificationProcessIfQueueEmpty(),this.errorFiles[Math.floor(1e6*Math.random())]=e,this.errorFilesCount++,this.sendSetPropertyEvent("analytics-event",{category:"officiallyVerification",action:"VerificationFailed",name:e.json["hydra:description"]})}onFileUploadFinished(e){if(201!==e.status)this.addToErrorFiles(e);else if("https://schema.tugraz.at/ElectronicSignatureVerificationReport"===e.json["@type"]){this.verifiedFiles.push(e.json),this.verifiedFilesCount++;const i=e.json;this.currentFileName=i.name,this.endVerificationProcessIfQueueEmpty()}}update(e){e.forEach(((e,i)=>{switch(i){case"lang":this._i18n.changeLanguage(this.lang);break;case"entryPointUrl":C.getInstance(this.entryPointUrl).then((e=>{let i;try{i=e.getApiUrlForEntityName("EsignElectronicSignatureVerificationReport")}catch(t){i=e.getApiUrlForEntityName("ElectronicSignatureVerificationReport")}this.fileSourceUrl=i}))}})),super.update(e)}onLanguageChanged(e){this.lang=e.detail.lang}reUploadAllClickHandler(){var e=this;const i=l({},this.errorFiles);this.errorFiles=[],this.errorFilesCount=0,p(i,(async function(i,t){await e.fileQueueingClickHandler(i.file,t)})),this._("#re-upload-all-button").stop()}async fileQueueingClickHandler(e,i){return this.takeFailedFileFromQueue(i),this.queueFile(e)}async showPreview(e){if(this.verificationProcessEnabled)return;const i=this.getQueuedFile(e);this.currentFile=i,this.currentPreviewQueueKey=e,console.log(i),this.previewInProgress=!0;const t=this.getScopedTagName("dbp-pdf-preview");await this._(t).showPDF(i)}takeFailedFileFromQueue(e){const i=this.errorFiles.splice(e,1);return this.errorFilesCount=Object.keys(this.errorFiles).length,i}clearVerifiedFiles(){this.verifiedFiles=[],this.verifiedFilesCount=0}clearErrorFiles(){this.errorFiles=[],this.errorFilesCount=0}isUserInterfaceDisabled(){return this.previewInProgress||this.externalAuthInProgress||this.uploadInProgress}static get styles(){return v(e||(e=a`
${0}
${0}
${0}
${0}
${0}
.file-block {
max-width: 320px;
}
.file-block.error .header {
grid-template-columns: auto 90px;
}
.file-block div.bottom-line {
display: grid;
align-items: center;
grid-template-columns: auto 190px;
grid-gap: 10px;
margin-top: 10px;
}
`),g(),b(!1),m(),F(),x())}getQueuedFilesHtml(){const e=this._i18n,t=Object.keys(this.queuedFiles);let s=[];return t.forEach((t=>{const r=this.queuedFiles[t];s.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}"
="${0}">
<dbp-icon name="trash"></dbp-icon>
</button>
</div>
<div class="bottom-line">
<div></div>
<button
class="button"
?disabled="${0}"
="${0}">
${0}
</button>
</div>
</div>
`),r.name,f(r.size),this.verificationProcessEnabled,e.t("signature-verification.remove-queued-file-button-title"),(()=>{this.takeFileFromQueue(t)}),this.verificationProcessEnabled,(()=>{this.showPreview(t)}),e.t("signature-verification.show-preview")))})),s}getVerifiedFilesHtml(){const e=Object.keys(this.verifiedFiles),i=this._i18n;let r=[];return e.forEach((e=>{const n=this.verifiedFiles[e];console.log("report",n);let l=[];n.signatures.forEach((e=>{console.log("signature",e),l.push($(t||(t=a`
<tr>
<td>${0}</td>
<td>${0}</td>
<td>${0}</td>
<td>${0}</td>
<td
class="${0}">
${0}
</td>
</tr>
`),e.givenName,e.familyName,e.nationality,e.serialNumber,U({"verification-ok":"OK"===e.valueMessage}),e.valueMessage))})),r.push($(s||(s=a`
<div class="file-block">
<div class="header">
<span class="filename"><strong>${0}</strong></span>
</div>
<table class="signatures ${0}">
<thead>
<th>${0}</th>
<th>${0}</th>
<th>${0}</th>
<th>${0}</th>
<th>${0}</th>
</thead>
<tbody>${0}</tbody>
</table>
<div class="${0}">
${0}
</div>
</div>
`),n.name,U({hidden:0===l.length}),i.t("signature-verification.given-name"),i.t("signature-verification.last-name"),i.t("signature-verification.nationality"),i.t("signature-verification.serial-number"),i.t("signature-verification.value-message"),l,U({hidden:0!==l.length}),i.t("signature-verification.no-signatures-found")))})),r}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($(r||(r=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}"
="${0}">
<dbp-icon name="reload"></dbp-icon>
</button>
<button
class="button"
title="${0}"
="${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("signature-verification.re-upload-file-button-title"),(()=>{this.fileQueueingClickHandler(s.file,e)}),i.t("signature-verification.remove-failed-file-button-title"),(()=>{this.takeFailedFileFromQueue(e)}),s.json["hydra:description"]))})),t}hasSignaturePermissions(){return this._hasSignaturePermissions("ROLE_SCOPE_OFFICIAL-SIGNATURE")}render(){const e=this._i18n,i=y(E,"official-signature-placeholder.png"),t=new c(D);return $(n||(n=a`
<div
class="${0}">
<div class="field">
<h2>${0}</h2>
<p class="subheadline">${0}</p>
<div class="control">
<p>${0}</p>
<button
="${0}"
?disabled="${0}"
class="button is-primary">
${0}
</button>
<dbp-file-source
id="file-source"
allowed-mime-types="application/pdf"
enabled-targets="${0}"
nextcloud-auth-url="${0}"
nextcloud-web-dav-url="${0}"
nextcloud-name="${0}"
nextcloud-file-url="${0}"
decompress-zip
lang="${0}"
?disabled="${0}"
context="${0}"
text="${0}"
button-label="${0}"
-file-source-file-selected="${0}"
-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 verification process and clear queue -->
<div class="control field">
<button
="${0}"
?disabled="${0}"
class="button ${0}">
${0}
</button>
<button
="${0}"
?disabled="${0}"
class="button is-right is-primary ${0}">
${0}
</button>
<!-- -->
<button
="${0}"
?disabled="${0}"
id="cancel-verification-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 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 ="${0}" class="button">
${0}
</button>
<dbp-button
id="re-upload-all-button"
?disabled="${0}"
value="${0}"
title="${0}"
class="is-right"
="${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}">
<h2>${0}</h2>
<div class="box-header">
<div class="filename">
<strong>${0}</strong>
(${0})
</div>
<button class="is-cancel" ="${0}">
<dbp-icon name="close"></dbp-icon>
</button>
</div>
<dbp-pdf-preview
lang="${0}"
allow-signature-rotation
signature-placeholder-image-src="${0}"
signature-width="146"
signature-height="42"
-pdf-preview-cancel="${0}"></dbp-pdf-preview>
</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>
<!-- List of verified PDFs -->
<div
class="verified-files files-block field ${0}">
<h3>${0}</h3>
<!-- Button to clear verified PDFs -->
<div class="field ${0}">
<div class="control">
<button ="${0}" class="button">
${0}
</button>
</div>
</div>
<div class="control">${0}</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>
`),U({hidden:!this.isLoggedIn()||!this.hasSignaturePermissions()||this.isLoading()}),t.getName(this.lang),t.getDescription(this.lang),e.t("signature-verification.upload-text"),(()=>{this._("#file-source").setAttribute("dialog-open","")}),this.signingProcessActive,e.t("signature-verification.upload-button-label"),this.fileHandlingEnabledTargets,this.nextcloudWebAppPasswordURL,this.nextcloudWebDavURL,this.nextcloudName,this.nextcloudFileURL,this.lang,this.verificationProcessActive,e.t("signature-verification.file-picker-context"),e.t("signature-verification.upload-area-text"),e.t("signature-verification.upload-button-label"),this.onFileSelected,this.onFileSourceSwitch,U({hidden:!this.queueBlockEnabled}),U({"is-disabled":this.isUserInterfaceDisabled()}),e.t("signature-verification.queued-files-label"),this.clearQueuedFiles,0===this.queuedFilesCount||this.verificationProcessActive||this.isUserInterfaceDisabled(),U({"is-disabled":this.isUserInterfaceDisabled()}),e.t("signature-verification.clear-all"),(()=>{this.verificationProcessEnabled=!0,this.verificationProcessActive=!0}),0===this.queuedFilesCount,U({"is-disabled":this.isUserInterfaceDisabled(),hidden:this.verificationProcessActive}),e.t("signature-verification.start-verification-process-button"),this.stopVerificationProcess,this.uploadInProgress,U({hidden:!this.verificationProcessActive}),e.t("signature-verification.stop-verification-process-button"),U({"is-disabled":this.isUserInterfaceDisabled()}),this.getQueuedFilesHtml(),U({hidden:0!==this.queuedFilesCount,"is-disabled":this.isUserInterfaceDisabled()}),e.t("signature-verification.queued-files-empty1"),e.t("signature-verification.queued-files-empty2"),U({hidden:0===this.errorFilesCount,"is-disabled":this.isUserInterfaceDisabled()}),e.t("signature-verification.error-files-label"),U({hidden:0===this.errorFilesCount}),this.clearErrorFiles,e.t("signature-verification.clear-all"),this.uploadInProgress,e.t("signature-verification.re-upload-all-button"),e.t("signature-verification.re-upload-all-button-title"),this.reUploadAllClickHandler,this.getErrorFilesHtml(),U({hidden:!this.previewInProgress}),e.t("signature-verification.preview-label"),this.currentFile.name,f(void 0!==this.currentFile?this.currentFile.size:0),this.hidePDF,this.lang,i,this.hidePDF,U({hidden:!this.uploadInProgress}),this.uploadStatusFileName,this.uploadStatusText,U({hidden:0===this.verifiedFilesCount,"is-disabled":this.isUserInterfaceDisabled()}),e.t("signature-verification.verified-files-label"),U({hidden:0===this.verifiedFilesCount}),this.clearVerifiedFiles,e.t("signature-verification.clear-all"),this.getVerifiedFilesHtml(),U({hidden:this.isLoggedIn()||this.isLoading()}),e.t("error-login-message"),U({hidden:this.hasSignaturePermissions()||!this.isLoggedIn()||this.isLoading()}),e.t("error-permission-message"),U({hidden:!this.isLoading()}))}}P("dbp-signature-verification-full",A);
//# sourceMappingURL=dbp-signature-verification-full.js.map