diff --git a/packages/file-handling/src/nextcloud-file-picker.js b/packages/file-handling/src/nextcloud-file-picker.js index aadf95ed4e13d2dfff96ddf8e38fd68392b8f2a8..0f046620d00540b48eb75673384b6e62e49bd6a0 100644 --- a/packages/file-handling/src/nextcloud-file-picker.js +++ b/packages/file-handling/src/nextcloud-file-picker.js @@ -5,7 +5,7 @@ import DBPLitElement from '@dbp-toolkit/common/dbp-lit-element'; import {Icon, MiniSpinner} from '@dbp-toolkit/common'; import * as commonUtils from '@dbp-toolkit/common/utils'; import * as commonStyles from '@dbp-toolkit/common/styles'; -import {createClient, parseXML, parseStat} from 'webdav/web'; +import {createClient, parseXML} from 'webdav/web'; //parseStat import {classMap} from 'lit-html/directives/class-map.js'; import {humanFileSize} from '@dbp-toolkit/common/i18next'; import Tabulator from 'tabulator-tables'; @@ -107,10 +107,7 @@ export class NextcloudFilePicker extends ScopedElementsMixin(DBPLitElement) { userName: { type: Boolean, attribute: false }, storeSession: {type: Boolean, attribute: 'store-nextcloud-session'}, showSubmenu: {type: Boolean, attribute: false}, - showAdditionalMenu: { type: Boolean, attribute: 'show-nextcloud-additional-menu' }, - userName: { type: Boolean, attribute: false }, }; - } update(changedProperties) { @@ -424,8 +421,6 @@ export class NextcloudFilePicker extends ScopedElementsMixin(DBPLitElement) { return (!this.isLoggedIn() && this.auth.token !== undefined); } - - /** * */ @@ -568,74 +563,6 @@ export class NextcloudFilePicker extends ScopedElementsMixin(DBPLitElement) { return result; } - /** - * - * @param {*} path - * @returns array including file path and base name - */ - parseFileAndBaseName(path) { - if (path[0] !== "/") { //TODO verify - path = "/" + path; - } - while (/^.+\/$/.test(path)) { - path = path.substr(0, path.length - 1); - } - path = decodeURIComponent(path); - - let array1 = this.webDavUrl.split('/'); - let array2 = path.split('/'); - for (let i = 0; i < array2.length; i++) { - let item2 = array2[i]; - array1.forEach(item1 => { - if (item1 === item2) { - array2.shift(); - i--; - } - }); - } - array2.shift(); - - let basename = array2[array2.length - 1]; - let filename = '/' + array2.join('/'); - - return [ filename, basename ]; - } - - /** - * - * @param {*} response - * @returns list of file objects containing corresponding information - */ - mapResponseToObject(response) { - let results = []; - - response.forEach(item => { - const [ filePath, baseName ] = this.parseFileAndBaseName(item.href); - - const prop = item.propstat.prop; - let etag = typeof prop.getetag === 'string' ? prop.getetag.replace(/"/g, '') : null; - let sizeVal = prop.getcontentlength ? prop.getcontentlength : '0'; - let fileType = prop.resourcetype && typeof prop.resourcetype === 'object' && typeof prop.resourcetype.collection !== 'undefined' ? 'directory' : 'file'; - - let mimeType; - if (fileType === 'file') { - mimeType = prop.getcontenttype && typeof prop.getcontenttype === 'string' ? prop.getcontenttype.split(';')[0] : ''; - } - - let propsObject = { getetag: etag, getlastmodified: prop.getlastmodified, getcontentlength: sizeVal, - permissions: prop.permissions, resourcetype: fileType, getcontenttype: prop.getcontenttype }; - - let statObject = { basename: baseName, etag: etag, filename: filePath, lastmod: prop.getlastmodified, - mime: mimeType, props: propsObject, size: parseInt(sizeVal, 10), type: fileType }; - - results.push(statObject); - }); - - return results; - } - - - /** * * @param {*} path