From 0711b12be3dc814cdbf15a0779e8f2098448835d Mon Sep 17 00:00:00 2001 From: Patrizio Bekerle <patrizio@bekerle.com> Date: Thu, 27 May 2021 13:48:01 +0200 Subject: [PATCH] Introduce nextcloud-auth-info / auth-info attribute --- packages/file-handling/README.md | 6 +++++- packages/file-handling/src/dbp-nextcloud-file-picker.js | 4 +++- packages/file-handling/src/file-sink.js | 5 +++-- packages/file-handling/src/file-source.js | 5 +++-- packages/file-handling/src/i18n/de/translation.json | 1 - packages/file-handling/src/i18n/en/translation.json | 1 - 6 files changed, 14 insertions(+), 8 deletions(-) diff --git a/packages/file-handling/README.md b/packages/file-handling/README.md index 1a8f48c9..0521df16 100644 --- a/packages/file-handling/README.md +++ b/packages/file-handling/README.md @@ -73,6 +73,8 @@ files from a [Nextcloud](https://nextcloud.com/) instance. - `nextcloud-auth-url` also needs to be set for the Nextcloud file picker to be active - `nextcloud-file-url` (optional): Nextcloud File Url to use with the Nextcloud file picker - example `<dbp-file-source nextcloud-file-url="http://localhost:8081/apps/files/?dir="></dbp-file-source>` +- `nextcloud-auth-info` (optional): Additional authentication information text that is shown in the Nextcloud file picker + - example `<dbp-file-source nextcloud-auth-info="You need special permissions for this function"></dbp-file-source>` - `dialog-open` (optional): if this attribute is set at runtime the dialog for selecting local or Nextcloud files will open - example `document.querySelector("dbp-file-source").setAttribute("dialog-open", "")` - `text` (optional): the text that is shown above the button to select files @@ -135,7 +137,9 @@ files to a [Nextcloud](https://nextcloud.com/) instance. - example `<dbp-file-sink nextcloud-web-dav-url="http://localhost:8081/remote.php/dav/files"></dbp-file-sink>` - `nextcloud-auth-url` also needs to be set for the Nextcloud file picker to be active - `nextcloud-file-url` (optional): Nextcloud File Url to use with the Nextcloud file picker - - example `<dbp-file-sink nextcloud-file-url="http://localhost:8081/apps/files/?dir="></dbp-file-sink>` + - example `<dbp-file-sink nextcloud-file-url="http://localhost:8081/apps/files/?dir="></dbp-file-sink>` +- `nextcloud-auth-info` (optional): Additional authentication information text that is shown in the Nextcloud file picker + - example `<dbp-file-sink nextcloud-auth-info="You need special permissions for this function"></dbp-file-sink>` - `text` (optional): the text that is shown above the button to download the zip file - example `<dbp-file-sink text="Download files as ZIP-file"></dbp-file-sink>` - `button-label` (optional): the text that is shown on the button to download the zip file diff --git a/packages/file-handling/src/dbp-nextcloud-file-picker.js b/packages/file-handling/src/dbp-nextcloud-file-picker.js index e03267ec..8cbaf987 100644 --- a/packages/file-handling/src/dbp-nextcloud-file-picker.js +++ b/packages/file-handling/src/dbp-nextcloud-file-picker.js @@ -53,6 +53,7 @@ export class NextcloudFilePicker extends ScopedElementsMixin(DBPLitElement) { this.abortUploadButton = false; this.abortUpload = false; this.isSelected = false; + this.authInfo = ''; } static get scopedElements() { @@ -76,6 +77,7 @@ export class NextcloudFilePicker extends ScopedElementsMixin(DBPLitElement) { isPickerActive: { type: Boolean, attribute: false }, statusText: { type: String, attribute: false }, folderIsSelected: { type: String, attribute: false }, + authInfo: { type: String, attribute: 'auth-info' }, directoryPath: { type: String, attribute: 'directory-path' }, allowedMimeTypes: { type: String, attribute: 'allowed-mime-types' }, directoriesOnly: { type: Boolean, attribute: 'directories-only' }, @@ -1469,7 +1471,7 @@ export class NextcloudFilePicker extends ScopedElementsMixin(DBPLitElement) { </div> <div class="block text-center m-inherit ${classMap({hidden: this.isPickerActive})}"> <p class="m-inherit"><br> - ${i18n.t('nextcloud-file-picker.auth-info')}<br>${i18n.t('nextcloud-file-picker.auth-info-2')} + ${i18n.t('nextcloud-file-picker.auth-info')}<br>${this.authInfo} </p> </div> </div> diff --git a/packages/file-handling/src/file-sink.js b/packages/file-handling/src/file-sink.js index cc38a6ec..9326d6d9 100644 --- a/packages/file-handling/src/file-sink.js +++ b/packages/file-handling/src/file-sink.js @@ -36,6 +36,7 @@ export class FileSink extends ScopedElementsMixin(DBPLitElement) { this.enabledTargets = 'local'; this.firstOpen = true; this.fullsizeModal = false; + this.nextcloudAuthInfo = ''; this.initialFileHandlingState = {target: '', path: ''}; } @@ -64,6 +65,7 @@ export class FileSink extends ScopedElementsMixin(DBPLitElement) { nextcloudWebDavUrl: {type: String, attribute: 'nextcloud-web-dav-url'}, nextcloudName: {type: String, attribute: 'nextcloud-name'}, nextcloudFileURL: {type: String, attribute: 'nextcloud-file-url'}, + nextcloudAuthInfo: {type: String, attribute: 'nextcloud-auth-info'}, text: {type: String}, buttonLabel: {type: String, attribute: 'button-label'}, isDialogOpen: {type: Boolean, attribute: false}, @@ -71,9 +73,7 @@ export class FileSink extends ScopedElementsMixin(DBPLitElement) { firstOpen: {type: Boolean, attribute: false}, nextcloudPath: {type: String, attribute: false}, fullsizeModal: { type: Boolean, attribute: 'fullsize-modal' }, - initialFileHandlingState: {type: Object, attribute: 'initial-file-handling-state'}, - }; } @@ -266,6 +266,7 @@ export class FileSink extends ScopedElementsMixin(DBPLitElement) { auth-url="${this.nextcloudAuthUrl}" web-dav-url="${this.nextcloudWebDavUrl}" nextcloud-name="${this.nextcloudName}" + auth-info="${this.nextcloudAuthInfo}" directory-path="${this.nextcloudPath}" nextcloud-file-url="${this.nextcloudFileURL}" @dbp-nextcloud-file-picker-file-uploaded="${(event) => { diff --git a/packages/file-handling/src/file-source.js b/packages/file-handling/src/file-source.js index ba4b48ef..9101c4fd 100644 --- a/packages/file-handling/src/file-source.js +++ b/packages/file-handling/src/file-source.js @@ -54,10 +54,9 @@ export class FileSource extends ScopedElementsMixin(DBPLitElement) { this.activeTarget = 'local'; this.isDialogOpen = false; this.firstOpen = true; + this.nextcloudAuthInfo = ''; this.initialFileHandlingState = {target: '', path: ''}; - - } static get scopedElements() { @@ -83,6 +82,7 @@ export class FileSource extends ScopedElementsMixin(DBPLitElement) { nextcloudWebDavUrl: { type: String, attribute: 'nextcloud-web-dav-url' }, nextcloudName: { type: String, attribute: 'nextcloud-name' }, nextcloudFileURL: { type: String, attribute: 'nextcloud-file-url' }, + nextcloudAuthInfo: {type: String, attribute: 'nextcloud-auth-info'}, text: { type: String }, buttonLabel: { type: String, attribute: 'button-label' }, disabled: { type: Boolean }, @@ -451,6 +451,7 @@ export class FileSource extends ScopedElementsMixin(DBPLitElement) { web-dav-url="${this.nextcloudWebDavUrl}" nextcloud-name="${this.nextcloudName}" nextcloud-file-url="${this.nextcloudFileURL}" + auth-info="${this.nextcloudAuthInfo}" allowed-mime-types="${this.allowedMimeTypes}" @dbp-nextcloud-file-picker-file-downloaded="${(event) => { this.sendFileEvent(event.detail.file);}}"> diff --git a/packages/file-handling/src/i18n/de/translation.json b/packages/file-handling/src/i18n/de/translation.json index 9fdbb079..b06a6151 100644 --- a/packages/file-handling/src/i18n/de/translation.json +++ b/packages/file-handling/src/i18n/de/translation.json @@ -63,7 +63,6 @@ "init-text-1": "Wählen Sie Ihre Dateien von {{name}}.", "init-text-2": "Sie müssen sich zuerst authentifizieren.", "auth-info": "Eine neue Seite wird geöffnet, um Ihr Konto zu verbinden.", - "auth-info-2": "Für diese Funktion ist ein TU Graz Bediensteten Account nötig!", "connect-nextcloud": "{{name}} verbinden", "open-in-nextcloud": "In {{name}} öffnen", "no-data": "In diesem Ordner befinden sich keine Dateien.", diff --git a/packages/file-handling/src/i18n/en/translation.json b/packages/file-handling/src/i18n/en/translation.json index 5d6afd36..17694556 100644 --- a/packages/file-handling/src/i18n/en/translation.json +++ b/packages/file-handling/src/i18n/en/translation.json @@ -63,7 +63,6 @@ "init-text-1": "Chose your files from {{name}}.", "init-text-2": "You need to authenticate first.", "auth-info": "A new page will open to connect your account.", - "auth-info-2": "A TU Graz employee account is required for this function!", "connect-nextcloud": "Connect {{name}}", "open-in-nextcloud": "Open in {{name}}", "no-data": "No data avaible in this folder.", -- GitLab