diff --git a/packages/file-handling/src/clipboard.js b/packages/file-handling/src/clipboard.js index 7ad1476e51b653b10ca05133b5357e8b2a59ec22..15cb2128846c081def02d0e75b5e4485e81b65da 100644 --- a/packages/file-handling/src/clipboard.js +++ b/packages/file-handling/src/clipboard.js @@ -37,6 +37,7 @@ export class Clipboard extends ScopedElementsMixin(AdapterLitElement) { this.nextcloudWebDavURL = ""; this.nextcloudName = ""; this.nextcloudFileURL = ""; + this.nextcloudStoreSession = false; this.authInfo = ''; this.allowNesting = false; @@ -71,6 +72,7 @@ export class Clipboard extends ScopedElementsMixin(AdapterLitElement) { nextcloudName: { type: String, attribute: 'nextcloud-name' }, nextcloudFileURL: { type: String, attribute: 'nextcloud-file-url' }, nextcloudAuthInfo: {type: String, attribute: 'nextcloud-auth-info'}, + nextcloudStoreSession: {type: Boolean, attribute: 'nextcloud-store-session'}, mode: {type: String, attribute: 'mode'}, @@ -621,6 +623,7 @@ export class Clipboard extends ScopedElementsMixin(AdapterLitElement) { nextcloud-name="${this.nextcloudName}" nextcloud-file-url="${this.nextcloudFileURL}" nexcloud-auth-info="${this.nextcloudAuthInfo}" + ?nextcloud-store-session="${this.nextcloudStoreSession}" enabled-targets="${this.allowNesting ? this.enabledTargets : this.enabledTargets.replace('clipboard', '')}" decompress-zip lang="${this.lang}" @@ -640,6 +643,7 @@ export class Clipboard extends ScopedElementsMixin(AdapterLitElement) { nextcloud-name="${this.nextcloudName}" nextcloud-file-url="${this.nextcloudFileURL}" nexcloud-auth-info="${this.nextcloudAuthInfo}" + ?nextcloud-store-session="${this.nextcloudStoreSession}" lang="${this.lang}" ></dbp-file-sink> `; diff --git a/packages/file-handling/src/file-sink.js b/packages/file-handling/src/file-sink.js index db3e6790ed6674ad1660a276881fa2317398ccac..6c87b9fc49ba4f051507eb87ff2885e176b29e9e 100644 --- a/packages/file-handling/src/file-sink.js +++ b/packages/file-handling/src/file-sink.js @@ -28,6 +28,7 @@ export class FileSink extends ScopedElementsMixin(DbpFileHandlingLitElement) { this.nextcloudName ='Nextcloud'; this.nextcloudPath = ''; this.nextcloudFileURL = ''; + this.nextcloudStoreSession = false; this.buttonLabel = ''; this.filename = "files.zip"; this.files = []; @@ -66,6 +67,7 @@ export class FileSink extends ScopedElementsMixin(DbpFileHandlingLitElement) { nextcloudName: {type: String, attribute: 'nextcloud-name'}, nextcloudFileURL: {type: String, attribute: 'nextcloud-file-url'}, nextcloudAuthInfo: {type: String, attribute: 'nextcloud-auth-info'}, + nextcloudStoreSession: {type: Boolean, attribute: 'nextcloud-store-session'}, buttonLabel: {type: String, attribute: 'button-label'}, isDialogOpen: {type: Boolean, attribute: false}, activeTarget: {type: String, attribute: 'active-target'}, @@ -301,7 +303,7 @@ export class FileSink extends ScopedElementsMixin(DbpFileHandlingLitElement) { auth-info="${this.nextcloudAuthInfo}" directory-path="${this.nextcloudPath}" nextcloud-file-url="${this.nextcloudFileURL}" - store-nextcloud-session="true" + ?store-nextcloud-session="${this.nextcloudStoreSession}" @dbp-nextcloud-file-picker-file-uploaded="${(event) => { this.uploadToNextcloud(event.detail); }}" diff --git a/packages/file-handling/src/file-source.js b/packages/file-handling/src/file-source.js index 622a2ae90c34d099f01163d5ceb1e83b835d0da1..bbe713d7bd9ad6d47b0213eded49b1a30b2b2063 100644 --- a/packages/file-handling/src/file-source.js +++ b/packages/file-handling/src/file-source.js @@ -45,6 +45,7 @@ export class FileSource extends ScopedElementsMixin(DbpFileHandlingLitElement) { this.nextcloudWebDavUrl = ''; this.nextcloudPath = ''; this.nextcloudFileURL = ''; + this.nextcloudStoreSession = false; this.dropArea = null; this.allowedMimeTypes = ''; this.enabledTargets = 'local'; @@ -86,6 +87,7 @@ export class FileSource extends ScopedElementsMixin(DbpFileHandlingLitElement) { nextcloudName: { type: String, attribute: 'nextcloud-name' }, nextcloudFileURL: { type: String, attribute: 'nextcloud-file-url' }, nextcloudAuthInfo: {type: String, attribute: 'nextcloud-auth-info'}, + nextcloudStoreSession: {type: Boolean, attribute: 'nextcloud-store-session'}, buttonLabel: { type: String, attribute: 'button-label' }, disabled: { type: Boolean }, decompressZip: { type: Boolean, attribute: 'decompress-zip' }, @@ -520,7 +522,7 @@ export class FileSource extends ScopedElementsMixin(DbpFileHandlingLitElement) { web-dav-url="${this.nextcloudWebDavUrl}" nextcloud-name="${this.nextcloudName}" nextcloud-file-url="${this.nextcloudFileURL}" - store-nextcloud-session="true" + ?store-nextcloud-session="${this.nextcloudStoreSession}" auth-info="${this.nextcloudAuthInfo}" allowed-mime-types="${this.allowedMimeTypes}" max-selected-items="${this.multipleFiles}" diff --git a/packages/file-handling/src/nextcloud-file-picker.js b/packages/file-handling/src/nextcloud-file-picker.js index fc3c5b954eb27ce6f417ba5e0ef2c0b4d5ec6253..e6d54f7d957c38d23f88b42be2ed88bd81fc3a48 100644 --- a/packages/file-handling/src/nextcloud-file-picker.js +++ b/packages/file-handling/src/nextcloud-file-picker.js @@ -428,13 +428,13 @@ export class NextcloudFilePicker extends ScopedElementsMixin(DBPLitElement) { const token = parseJwt(this.auth.token); const sessionId = token ? token.sid : ""; if (this.storeSession && sessionId - && localStorage.getItem("nextcloud-webdav-username" + publicId) - && localStorage.getItem("nextcloud-webdav-password" + publicId) ){ + && localStorage.getItem('nextcloud-webdav-username-' + publicId) + && localStorage.getItem('nextcloud-webdav-password-' + publicId) ){ try { - const userName = await decrypt(sessionId, localStorage.getItem("nextcloud-webdav-username" + publicId)); - const password = await decrypt(sessionId, localStorage.getItem("nextcloud-webdav-password" + publicId)); + const userName = await decrypt(sessionId, localStorage.getItem('nextcloud-webdav-username-' + publicId)); + const password = await decrypt(sessionId, localStorage.getItem('nextcloud-webdav-password-' + publicId)); this.webDavClient = createClient( - this.webDavUrl + "/" + userName, + this.webDavUrl + '/' + userName, { username: userName, password: password @@ -444,8 +444,8 @@ export class NextcloudFilePicker extends ScopedElementsMixin(DBPLitElement) { this.isPickerActive = true; this.loadDirectory(this.directoryPath); } catch (e) { - localStorage.removeItem('nextcloud-webdav-username' + publicId); - localStorage.removeItem('nextcloud-webdav-password' + publicId); + localStorage.removeItem('nextcloud-webdav-username-' + publicId); + localStorage.removeItem('nextcloud-webdav-password-' + publicId); return; } } @@ -492,15 +492,6 @@ export class NextcloudFilePicker extends ScopedElementsMixin(DBPLitElement) { return this.shadowRoot === null ? this.querySelectorAll(selector) : this.shadowRoot.querySelectorAll(selector); } - async persistStorageMaybe() { - if (navigator.storage && navigator.storage.persist) { - if (await navigator.storage.persist()) - console.log("Storage will not be cleared except by explicit user action"); - else - console.log("Storage may be cleared by the UA under storage pressure."); - } - } - async onReceiveWindowMessage(event) { if (this.webDavClient === null) { const data = event.data; @@ -521,16 +512,14 @@ export class NextcloudFilePicker extends ScopedElementsMixin(DBPLitElement) { if (this.storeSession && this.isLoggedIn() && this._("#remember-checkbox") && this._("#remember-checkbox").checked) { - this.persistStorageMaybe(); const publicId = this.auth['person-id']; const token = parseJwt(this.auth.token); const sessionId = token ? token.sid : ""; if (sessionId) { const encrytedName = await encrypt(sessionId, data.loginName); const encrytedToken = await encrypt(sessionId, data.token); - localStorage.setItem('nextcloud-webdav-username' + publicId, encrytedName); - localStorage.setItem('nextcloud-webdav-password' + publicId, encrytedToken); - + localStorage.setItem('nextcloud-webdav-username-' + publicId, encrytedName); + localStorage.setItem('nextcloud-webdav-password-' + publicId, encrytedToken); } } @@ -1644,7 +1633,7 @@ export class NextcloudFilePicker extends ScopedElementsMixin(DBPLitElement) { .remember-container{ display: inline-block; line-height: 28px; - padding-left: 34px; + padding-left: 28px; } .remember-container .checkmark{ @@ -1824,7 +1813,7 @@ export class NextcloudFilePicker extends ScopedElementsMixin(DBPLitElement) { }}">${i18n.t('nextcloud-file-picker.connect-nextcloud', {name: this.nextcloudName})} </button> </div> - <div class="block text-center m-inherit ${classMap({hidden: this.isPickerActive && !this.storeSession || !this.isLoggedIn()})}"> <!-- remove hidden to enable remember me --> + <div class="block text-center m-inherit ${classMap({hidden: !this.storeSession || !this.isLoggedIn()})}"> <label class="button-container remember-container"> ${i18n.t('nextcloud-file-picker.remember-me', {name: this.nextcloudName})} <input type="checkbox" id="remember-checkbox" name="remember">