From 72430919bf2200c3cc9c070f7dfe09a36541a8a8 Mon Sep 17 00:00:00 2001
From: Patrizio Bekerle <patrizio@bekerle.com>
Date: Thu, 27 May 2021 13:51:29 +0200
Subject: [PATCH] Introduce nextcloud-auth-info

---
 README.md                                     |  4 ++++
 assets/dbp-signature.html.ejs                 | 22 +++++++++++++++++++
 src/dbp-official-signature-pdf-upload.js      |  3 +++
 ...fficial-signature-pdf-upload.metadata.json |  2 +-
 src/dbp-qualified-signature-pdf-upload.js     |  3 +++
 ...alified-signature-pdf-upload.metadata.json |  2 +-
 vendor/toolkit                                |  2 +-
 7 files changed, 35 insertions(+), 3 deletions(-)

diff --git a/README.md b/README.md
index f6f5b6d..8a2e8df 100644
--- a/README.md
+++ b/README.md
@@ -71,6 +71,8 @@ Note that you will need a Keycloak server along with a client id for the domain
     - example `nextcloud-file-url="http://localhost:8081/apps/files/?dir="`
 - `nextcloud-name` (optional): Name of the Nextcloud service
     - example `nextcloud-name="My Nextcloud"`
+- `nextcloud-auth-info` (optional): Additional authentication information text that is shown in the Nextcloud file picker
+    - example `nextcloud-auth-info="You need special permissions for this function"`
 - `allow-annotating` (optional): Needs to be set to allow annotating the PDFs
     - example `allow-annotating`
 
@@ -102,6 +104,8 @@ Note that you will need a Keycloak server along with a client id for the domain
     - example `nextcloud-file-url="http://localhost:8081/apps/files/?dir="`
 - `nextcloud-name` (optional): Name of the Nextcloud service
     - example `nextcloud-name="My Nextcloud"`
+- `nextcloud-auth-info` (optional): Additional authentication information text that is shown in the Nextcloud file picker
+    - example `nextcloud-auth-info="You need special permissions for this function"`
 - `allow-annotating` (optional): Needs to be set to allow annotating the PDFs
     - example `allow-annotating`
 - `show-clipboard` (optional): Needs to be set to allow using the clipboard in the file picker dialog
diff --git a/assets/dbp-signature.html.ejs b/assets/dbp-signature.html.ejs
index 3e45988..f5a5c48 100644
--- a/assets/dbp-signature.html.ejs
+++ b/assets/dbp-signature.html.ejs
@@ -59,6 +59,7 @@
 
 <body>
 <<%= name %>
+    id="app"
     lang="de" entry-point-url="<%= entryPointURL %>"
     show-nextcloud-file-picker
     <%= buildInfo.env !== 'production' ? 'show-clipboard' : '' %>
@@ -66,6 +67,7 @@
     nextcloud-web-app-password-url="<%= nextcloudWebAppPasswordURL %>"
     nextcloud-webdav-url="<%= nextcloudWebDavURL %>"
     nextcloud-name="<%= nextcloudName %>"
+    nextcloud-auth-info=""
     nextcloud-file-url="<%= nextcloudFileURL %>"
     initial-file-handling-state
     clipboard-files
@@ -84,5 +86,25 @@
 <!-- Error handling for too old browsers -->
 <script src="<%= getPrivateUrl('browser-check.js') %>" defer></script>
 <noscript>Diese Applikation benötigt Javascript / This application requires Javascript</noscript>
+<script>
+    const langTexts = {
+        "de": {
+            "nextcloud-auth-info": "Für diese Funktion ist ein TU Graz Bediensteten Account nötig!",
+        },
+        "en": {
+            "nextcloud-auth-info": "A TU Graz employee account is required for this function!",
+        },
+    }
+
+    window.addEventListener('dbp-lang', function (e) {
+        const lang = e.detail;
+        if (!lang) {
+            return;
+        }
+
+        const app = document.getElementById("app");
+        app.setAttribute("nextcloud-auth-info", langTexts[lang]["nextcloud-auth-info"]);
+    });
+</script>
 </body>
 </html>
\ No newline at end of file
diff --git a/src/dbp-official-signature-pdf-upload.js b/src/dbp-official-signature-pdf-upload.js
index b37a893..811bcba 100644
--- a/src/dbp-official-signature-pdf-upload.js
+++ b/src/dbp-official-signature-pdf-upload.js
@@ -31,6 +31,7 @@ class OfficialSignaturePdfUpload extends ScopedElementsMixin(DBPSignatureLitElem
         this.nextcloudWebDavURL = "";
         this.nextcloudName = "";
         this.nextcloudFileURL = "";
+        this.nextcloudAuthInfo = "";
         this.signedFiles = [];
         this.signedFilesCount = 0;
         this.signedFilesToDownload = 0;
@@ -85,6 +86,7 @@ class OfficialSignaturePdfUpload extends ScopedElementsMixin(DBPSignatureLitElem
             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: false },
             signedFilesCount: { type: Number, attribute: false },
             signedFilesToDownload: { type: Number, attribute: false },
@@ -854,6 +856,7 @@ class OfficialSignaturePdfUpload extends ScopedElementsMixin(DBPSignatureLitElem
                             nextcloud-auth-url="${this.nextcloudWebAppPasswordURL}"
                             nextcloud-web-dav-url="${this.nextcloudWebDavURL}"
                             nextcloud-name="${this.nextcloudName}"
+                            nextcloud-auth-info="${this.nextcloudAuthInfo}"
                             nextcloud-file-url="${this.nextcloudFileURL}"
                             decompress-zip
                             lang="${this.lang}"
diff --git a/src/dbp-official-signature-pdf-upload.metadata.json b/src/dbp-official-signature-pdf-upload.metadata.json
index fc6e455..e14ba4f 100644
--- a/src/dbp-official-signature-pdf-upload.metadata.json
+++ b/src/dbp-official-signature-pdf-upload.metadata.json
@@ -14,6 +14,6 @@
     "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-file-url,show-nextcloud-file-picker,auth,allow-annotating,show-clipboard",
+  "subscribe": "lang,entry-point-url,nextcloud-web-app-password-url,nextcloud-webdav-url,nextcloud-name,nextcloud-auth-info,nextcloud-file-url,show-nextcloud-file-picker,auth,allow-annotating,show-clipboard",
   "required_roles": ["ROLE_SCOPE_OFFICIAL-SIGNATURE"]
 }
diff --git a/src/dbp-qualified-signature-pdf-upload.js b/src/dbp-qualified-signature-pdf-upload.js
index 5b337e2..7757bdd 100644
--- a/src/dbp-qualified-signature-pdf-upload.js
+++ b/src/dbp-qualified-signature-pdf-upload.js
@@ -32,6 +32,7 @@ class QualifiedSignaturePdfUpload extends ScopedElementsMixin(DBPSignatureLitEle
         this.nextcloudWebDavURL = "";
         this.nextcloudName = "";
         this.nextcloudFileURL = "";
+        this.nextcloudAuthInfo = "";
         this.externalAuthInProgress = false;
         this.signedFiles = [];
         this.signedFilesCount = 0;
@@ -88,6 +89,7 @@ class QualifiedSignaturePdfUpload extends ScopedElementsMixin(DBPSignatureLitEle
             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: false },
             signedFilesCount: { type: Number, attribute: false },
             signedFilesToDownload: { type: Number, attribute: false },
@@ -996,6 +998,7 @@ class QualifiedSignaturePdfUpload extends ScopedElementsMixin(DBPSignatureLitEle
                             nextcloud-auth-url="${this.nextcloudWebAppPasswordURL}"
                             nextcloud-web-dav-url="${this.nextcloudWebDavURL}"
                             nextcloud-name="${this.nextcloudName}"
+                            nextcloud-auth-info="${this.nextcloudAuthInfo}"
                             nextcloud-file-url="${this.nextcloudFileURL}"
                             decompress-zip
                             lang="${this.lang}"
diff --git a/src/dbp-qualified-signature-pdf-upload.metadata.json b/src/dbp-qualified-signature-pdf-upload.metadata.json
index 5ff488d..d88d5dc 100644
--- a/src/dbp-qualified-signature-pdf-upload.metadata.json
+++ b/src/dbp-qualified-signature-pdf-upload.metadata.json
@@ -14,5 +14,5 @@
     "de": "Erlaubt das Hochladen von PDF-Dokumenten, um sie mit einer persönlichen elektronischen Signatur zu versehen",
     "en": "Allows upload of PDF-documents to personally sign them"
   },
-  "subscribe": "lang,entry-point-url,nextcloud-web-app-password-url,nextcloud-webdav-url,nextcloud-name,nextcloud-file-url,show-nextcloud-file-picker,auth,allow-annotating"
+  "subscribe": "lang,entry-point-url,nextcloud-web-app-password-url,nextcloud-webdav-url,nextcloud-name,nextcloud-auth-info,nextcloud-file-url,show-nextcloud-file-picker,auth,allow-annotating"
 }
diff --git a/vendor/toolkit b/vendor/toolkit
index 18901b3..0711b12 160000
--- a/vendor/toolkit
+++ b/vendor/toolkit
@@ -1 +1 @@
-Subproject commit 18901b3baf6a317fd98f6d995ada35f0101f5686
+Subproject commit 0711b12be3dc814cdbf15a0779e8f2098448835d
-- 
GitLab