Skip to content
Snippets Groups Projects
Commit c011909e authored by Bekerle, Patrizio's avatar Bekerle, Patrizio :fire: Committed by Reiter, Christoph
Browse files

Merge branch 'nc-filepicker-sink' into 'master'

Preparing Nc-filepicker for file upload and small features added

See merge request VPU/WebComponents/FileHandling!1
parent 54fb21a4
No related branches found
No related tags found
No related merge requests found
...@@ -348,6 +348,7 @@ export class FileSource extends ScopedElementsMixin(VPULitElement) { ...@@ -348,6 +348,7 @@ export class FileSource extends ScopedElementsMixin(VPULitElement) {
lang="${this.lang}" lang="${this.lang}"
auth-url="${this.nextcloudAuthUrl}" auth-url="${this.nextcloudAuthUrl}"
web-dav-url="${this.nextcloudWebDavUrl}" web-dav-url="${this.nextcloudWebDavUrl}"
allowed-mime-types="${this.allowedMimeTypes}"
@vpu-nextcloud-file-picker-file-downloaded="${(event) => { @vpu-nextcloud-file-picker-file-downloaded="${(event) => {
this.sendFileEvent(event.detail.file); this.sendFileEvent(event.detail.file);
}}"></vpu-nextcloud-file-picker> }}"></vpu-nextcloud-file-picker>
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
"open-nextcloud-file-picker": "Dateien von Ihrer Nextcloud auswählen", "open-nextcloud-file-picker": "Dateien von Ihrer Nextcloud auswählen",
"folder-last": "In das zuletzt ausgewählte Verzeichnis springen", "folder-last": "In das zuletzt ausgewählte Verzeichnis springen",
"folder-up": "In das übergeordnete Verzeichnis springen", "folder-up": "In das übergeordnete Verzeichnis springen",
"folder-home": "In das Home Verzeichnis springen",
"select-files": "Dateien auswählen" "select-files": "Dateien auswählen"
} }
} }
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
"open-nextcloud-file-picker": "Select files from your Nextcloud", "open-nextcloud-file-picker": "Select files from your Nextcloud",
"folder-last": "Jump to the last directory", "folder-last": "Jump to the last directory",
"folder-up": "Jump to the parent directory", "folder-up": "Jump to the parent directory",
"folder-up": "Jump to the home directory",
"select-files": "Select files" "select-files": "Select files"
} }
} }
...@@ -21,11 +21,13 @@ export class NextcloudFilePicker extends ScopedElementsMixin(VPULitElement) { ...@@ -21,11 +21,13 @@ export class NextcloudFilePicker extends ScopedElementsMixin(VPULitElement) {
this.webDavUrl = ''; this.webDavUrl = '';
this.loginWindow = null; this.loginWindow = null;
this.isPickerActive = false; this.isPickerActive = false;
this.statusText = ""; this.statusText = '';
this.lastDirectoryPath = "/"; this.lastDirectoryPath = '/';
this.directoryPath = "/"; this.directoryPath = '/';
this.webDavClient = null; this.webDavClient = null;
this.tabulatorTable = null; this.tabulatorTable = null;
this.allowedMimeTypes = '*/*';
this.directoriesOnly = null;
this._onReceiveWindowMessage = this.onReceiveWindowMessage.bind(this); this._onReceiveWindowMessage = this.onReceiveWindowMessage.bind(this);
} }
...@@ -43,12 +45,13 @@ export class NextcloudFilePicker extends ScopedElementsMixin(VPULitElement) { ...@@ -43,12 +45,13 @@ export class NextcloudFilePicker extends ScopedElementsMixin(VPULitElement) {
static get properties() { static get properties() {
return { return {
lang: { type: String }, lang: { type: String },
authUrl: { type: String, attribute: "auth-url" }, authUrl: { type: String, attribute: 'auth-url' },
webDavUrl: { type: String, attribute: "web-dav-url" }, webDavUrl: { type: String, attribute: 'web-dav-url' },
isPickerActive: { type: Boolean, attribute: false }, isPickerActive: { type: Boolean, attribute: false },
statusText: { type: String, attribute: false }, statusText: { type: String, attribute: false },
directoryPath: { type: String, attribute: false }, directoryPath: { type: String, attribute: false },
allowedMimeTypes: { type: String, attribute: 'allowed-mime-types' }, allowedMimeTypes: { type: String, attribute: 'allowed-mime-types' },
directoriesOnly: { type: Boolean, attribute: 'directories-only' },
}; };
} }
...@@ -112,18 +115,34 @@ export class NextcloudFilePicker extends ScopedElementsMixin(VPULitElement) { ...@@ -112,18 +115,34 @@ export class NextcloudFilePicker extends ScopedElementsMixin(VPULitElement) {
return date + "." + month + "." + year + " " + hours + ":" + minutes; return date + "." + month + "." + year + " " + hours + ":" + minutes;
}}, }},
], ],
initialSort:[
{column:"basename", dir:"asc"},
{column:"type", dir:"asc"},
],
rowClick: (e, row) => { rowClick: (e, row) => {
const data = row.getData(); const data = row.getData();
switch(data.type) { if(this.directoriesOnly) {
case "directory": console.log("directory selected", data);
this.directoryClicked(e, data); }
break; else
case "file": {
console.log("file selected", data); switch(data.type) {
break; case "directory":
this.directoryClicked(e, data);
break;
case "file":
console.log("file selected", data);
break;
}
} }
}, },
rowDblClick: (e, row) => {
const data = row.getData();
if(this.directoriesOnly) {
this.directoryClicked(e, data);
}
}
}); });
function checkFileType(data, filterParams) { function checkFileType(data, filterParams) {
...@@ -141,7 +160,6 @@ export class NextcloudFilePicker extends ScopedElementsMixin(VPULitElement) { ...@@ -141,7 +160,6 @@ export class NextcloudFilePicker extends ScopedElementsMixin(VPULitElement) {
}); });
if (deny) { if (deny) {
console.log(`mime type ${data.type} of file '${data.filename}' is not compatible with ${filterParams}`);
return false; return false;
} }
return true; return true;
...@@ -149,6 +167,13 @@ export class NextcloudFilePicker extends ScopedElementsMixin(VPULitElement) { ...@@ -149,6 +167,13 @@ export class NextcloudFilePicker extends ScopedElementsMixin(VPULitElement) {
if(typeof this.allowedMimeTypes !== 'undefined') { if(typeof this.allowedMimeTypes !== 'undefined') {
this.tabulatorTable.setFilter(checkFileType, this.allowedMimeTypes); this.tabulatorTable.setFilter(checkFileType, this.allowedMimeTypes);
} }
if(typeof this.directoriesOnly !== 'undefined' && this.directoriesOnly)
{
console.log("filter " + this.directoriesOnly);
this.tabulatorTable.setFilter([
{field:"type", type:"=", value:"directory"},
]);
}
}); });
} }
...@@ -284,6 +309,9 @@ export class NextcloudFilePicker extends ScopedElementsMixin(VPULitElement) { ...@@ -284,6 +309,9 @@ export class NextcloudFilePicker extends ScopedElementsMixin(VPULitElement) {
</div> </div>
<div class="block ${classMap({hidden: !this.isPickerActive})}"> <div class="block ${classMap({hidden: !this.isPickerActive})}">
<h2>${this.directoryPath}</h2> <h2>${this.directoryPath}</h2>
<button class="button is-small"
title="${i18n.t('nextcloud-file-picker.folder-home')}"
@click="${() => { this.loadDirectory("/"); }}"><vpu-icon name="home"></vpu-icon></button>
<button class="button is-small" <button class="button is-small"
title="${i18n.t('nextcloud-file-picker.folder-last')}" title="${i18n.t('nextcloud-file-picker.folder-last')}"
@click="${() => { this.loadDirectory(this.lastDirectoryPath); }}">&#8678;</button> @click="${() => { this.loadDirectory(this.lastDirectoryPath); }}">&#8678;</button>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment