Skip to content
Snippets Groups Projects
Commit e23dc722 authored by Steinwender, Tamara's avatar Steinwender, Tamara
Browse files

Added abort process button, added functionality to create folder when press enter

parent c22b3eee
No related branches found
No related tags found
No related merge requests found
Pipeline #12901 passed
...@@ -48,6 +48,8 @@ export class NextcloudFilePicker extends ScopedElementsMixin(DBPLitElement) { ...@@ -48,6 +48,8 @@ export class NextcloudFilePicker extends ScopedElementsMixin(DBPLitElement) {
this.forAll = false; this.forAll = false;
this.uploadCount = 0; this.uploadCount = 0;
this.selectAllButton = true; this.selectAllButton = true;
this.abortUploadButton = false;
this.abortUpload = false;
} }
static get scopedElements() { static get scopedElements() {
...@@ -80,6 +82,7 @@ export class NextcloudFilePicker extends ScopedElementsMixin(DBPLitElement) { ...@@ -80,6 +82,7 @@ export class NextcloudFilePicker extends ScopedElementsMixin(DBPLitElement) {
activeDirectoryRights: { type: String, attribute: false }, activeDirectoryRights: { type: String, attribute: false },
activeDirectoryACL: { type: String, attribute: false }, activeDirectoryACL: { type: String, attribute: false },
selectAllButton: { type: Boolean, attribute: false }, selectAllButton: { type: Boolean, attribute: false },
abortUploadButton: { type: Boolean, attribute: false },
}; };
} }
...@@ -153,12 +156,12 @@ export class NextcloudFilePicker extends ScopedElementsMixin(DBPLitElement) { ...@@ -153,12 +156,12 @@ export class NextcloudFilePicker extends ScopedElementsMixin(DBPLitElement) {
const minutes = ("0" + timestamp.getMinutes()).slice(-2); const minutes = ("0" + timestamp.getMinutes()).slice(-2);
return date + "." + month + "." + year + " " + hours + ":" + minutes; return date + "." + month + "." + year + " " + hours + ":" + minutes;
}}, }},
{title: "rights", field: "props.permissions", visible:false}, {title: "rights", field: "props.permissions"},
{title: "acl", field: "props.acl-list.acl.acl-permissions", visible:false} {title: "acl", field: "props.acl-list.acl.acl-permissions"}
], ],
initialSort:[ initialSort:[
{column:"basename", dir:"asc"}, {column:"basename", dir:"asc", visible: false},
{column:"type", dir:"asc"}, {column:"type", dir:"asc", visible: false},
], ],
rowFormatter: (row) => { rowFormatter: (row) => {
...@@ -242,6 +245,12 @@ export class NextcloudFilePicker extends ScopedElementsMixin(DBPLitElement) { ...@@ -242,6 +245,12 @@ export class NextcloudFilePicker extends ScopedElementsMixin(DBPLitElement) {
} }
*/ */
// add folder on enter
this._('#new-folder').addEventListener('keydown', function(e) {
if (e.keyCode === 13) {
that.addFolder();
}
});
}); });
} }
...@@ -342,10 +351,11 @@ export class NextcloudFilePicker extends ScopedElementsMixin(DBPLitElement) { ...@@ -342,10 +351,11 @@ export class NextcloudFilePicker extends ScopedElementsMixin(DBPLitElement) {
" <nc:acl>" + " <nc:acl>" +
" <nc:acl-permissions />" + " <nc:acl-permissions />" +
" </nc:acl>" + " </nc:acl>" +
" </nc:acl-list>" + " </nc:acl-list>" +
" </d:prop>" + " </d:prop>" +
"</d:propfind>"}) "</d:propfind>"})
.then(contents => { .then(contents => {
console.log("------", contents);
this.loading = false; this.loading = false;
this.statusText = ""; this.statusText = "";
this.tabulatorTable.setData(contents.data); this.tabulatorTable.setData(contents.data);
...@@ -474,6 +484,7 @@ export class NextcloudFilePicker extends ScopedElementsMixin(DBPLitElement) { ...@@ -474,6 +484,7 @@ export class NextcloudFilePicker extends ScopedElementsMixin(DBPLitElement) {
this.statusText = i18n.t('nextcloud-file-picker.upload-to', {path: directory}); this.statusText = i18n.t('nextcloud-file-picker.upload-to', {path: directory});
this.fileList = files; this.fileList = files;
this.forAll = false; this.forAll = false;
this.setRepeatForAllConflicts()
this.uploadFile(directory); this.uploadFile(directory);
} }
...@@ -483,6 +494,14 @@ export class NextcloudFilePicker extends ScopedElementsMixin(DBPLitElement) { ...@@ -483,6 +494,14 @@ export class NextcloudFilePicker extends ScopedElementsMixin(DBPLitElement) {
* @param directory * @param directory
*/ */
async uploadFile(directory) { async uploadFile(directory) {
if (this.abortUpload) {
this.abortUpload = false;
this.abortUploadButton = false;
this.forAll = false;
this.statusText = "Vorgang wurde abgebrochen";
this._("#replace_mode_all").checked = false;
return;
}
if (this.fileList.length !== 0) { if (this.fileList.length !== 0) {
let file = this.fileList[0]; let file = this.fileList[0];
this.replaceFilename = file.name; this.replaceFilename = file.name;
...@@ -505,6 +524,7 @@ export class NextcloudFilePicker extends ScopedElementsMixin(DBPLitElement) { ...@@ -505,6 +524,7 @@ export class NextcloudFilePicker extends ScopedElementsMixin(DBPLitElement) {
if (this.forAll) { if (this.forAll) {
this.uploadFileObject = file; this.uploadFileObject = file;
this.uploadFileDirectory = directory; this.uploadFileDirectory = directory;
this.abortUploadButton = true;
this.uploadFileAfterConflict(); this.uploadFileAfterConflict();
} }
else { else {
...@@ -523,6 +543,8 @@ export class NextcloudFilePicker extends ScopedElementsMixin(DBPLitElement) { ...@@ -523,6 +543,8 @@ export class NextcloudFilePicker extends ScopedElementsMixin(DBPLitElement) {
const event = new CustomEvent("dbp-nextcloud-file-picker-file-uploaded-finished", const event = new CustomEvent("dbp-nextcloud-file-picker-file-uploaded-finished",
{ bubbles: true, composed: true , detail: this.uploadCount}); { bubbles: true, composed: true , detail: this.uploadCount});
this.uploadCount = 0; this.uploadCount = 0;
this.abortUpload = false;
this.abortUploadButton = false;
this.dispatchEvent(event); this.dispatchEvent(event);
} }
...@@ -533,6 +555,14 @@ export class NextcloudFilePicker extends ScopedElementsMixin(DBPLitElement) { ...@@ -533,6 +555,14 @@ export class NextcloudFilePicker extends ScopedElementsMixin(DBPLitElement) {
* *
*/ */
async uploadFileAfterConflict() { async uploadFileAfterConflict() {
if (this.abortUpload) {
this.abortUpload = false;
this.abortUploadButton = false;
this.forAll = false;
this.statusText = "Vorgang wurde abgebrochen";
this._("#replace_mode_all").checked = false;
return;
}
let path = ""; let path = "";
let overwrite = false; let overwrite = false;
let file = this.uploadFileObject; let file = this.uploadFileObject;
...@@ -578,6 +608,7 @@ export class NextcloudFilePicker extends ScopedElementsMixin(DBPLitElement) { ...@@ -578,6 +608,7 @@ export class NextcloudFilePicker extends ScopedElementsMixin(DBPLitElement) {
if (this.forAll) { if (this.forAll) {
this.uploadFileObject = file; this.uploadFileObject = file;
this.uploadFileDirectory = directory; this.uploadFileDirectory = directory;
this.abortUploadButton = true;
this.uploadFileAfterConflict(); this.uploadFileAfterConflict();
} }
else { else {
...@@ -813,6 +844,8 @@ export class NextcloudFilePicker extends ScopedElementsMixin(DBPLitElement) { ...@@ -813,6 +844,8 @@ export class NextcloudFilePicker extends ScopedElementsMixin(DBPLitElement) {
this._('#add-folder-button').setAttribute("title", i18n.t('nextcloud-file-picker.add-folder-close')); this._('#add-folder-button').setAttribute("title", i18n.t('nextcloud-file-picker.add-folder-close'));
this._('#new-folder').focus(); this._('#new-folder').focus();
} }
let that = this;
} }
/** /**
...@@ -1435,6 +1468,7 @@ export class NextcloudFilePicker extends ScopedElementsMixin(DBPLitElement) { ...@@ -1435,6 +1468,7 @@ export class NextcloudFilePicker extends ScopedElementsMixin(DBPLitElement) {
@click="${() => { this.deselectAll(); }}"> @click="${() => { this.deselectAll(); }}">
${i18n.t('nextcloud-file-picker.select-nothing')} ${i18n.t('nextcloud-file-picker.select-nothing')}
</button> </button>
</div> </div>
</div> </div>
<table id="directory-content-table" class="force-no-select"></table> <table id="directory-content-table" class="force-no-select"></table>
...@@ -1442,11 +1476,12 @@ export class NextcloudFilePicker extends ScopedElementsMixin(DBPLitElement) { ...@@ -1442,11 +1476,12 @@ export class NextcloudFilePicker extends ScopedElementsMixin(DBPLitElement) {
<div class="nextcloud-footer ${classMap({hidden: !this.isPickerActive})}"> <div class="nextcloud-footer ${classMap({hidden: !this.isPickerActive})}">
<div class="nextcloud-footer-grid"> <div class="nextcloud-footer-grid">
<button id="download-button" class="button select-button is-primary ${classMap({hidden: !this.directoriesOnly})}" <button id="download-button" class="button select-button is-primary ${classMap({hidden: (!this.directoriesOnly || this.directoriesOnly && this.abortUploadButton && this.forAll)})}"
@click="${() => { this.sendDirectory(this.tabulatorTable.getSelectedData()); }}">${this.folderIsSelected}</button> @click="${() => { this.sendDirectory(this.tabulatorTable.getSelectedData()); }}">${this.folderIsSelected}</button>
<button class="button select-button is-primary ${classMap({hidden: this.directoriesOnly})}" <button class="button select-button is-primary ${classMap({hidden: this.directoriesOnly})}"
@click="${() => { this.downloadFiles(this.tabulatorTable.getSelectedData()); }}">${i18n.t('nextcloud-file-picker.select-files')}</button> @click="${() => { this.downloadFiles(this.tabulatorTable.getSelectedData()); }}">${i18n.t('nextcloud-file-picker.select-files')}</button>
<button class="button select-button ${classMap({hidden: (!this.abortUploadButton && !this.forAll)})}"
title="${i18n.t('nextcloud-file-picker.abort')}" @click="${() => { this.abortUpload = true; }}">${i18n.t('nextcloud-file-picker.abort')}</button>
<div class="block info-box ${classMap({hidden: this.statusText === ""})}"> <div class="block info-box ${classMap({hidden: this.statusText === ""})}">
<dbp-mini-spinner class="spinner ${classMap({hidden: this.loading === false})}"></dbp-mini-spinner> <dbp-mini-spinner class="spinner ${classMap({hidden: this.loading === false})}"></dbp-mini-spinner>
......
...@@ -75,6 +75,7 @@ ...@@ -75,6 +75,7 @@
"select-all": "Alle auswählen", "select-all": "Alle auswählen",
"select-all-title": "Alle verfügbaren Dateien in diesem Ordner auswählen", "select-all-title": "Alle verfügbaren Dateien in diesem Ordner auswählen",
"select-nothing": "Nichts auswählen", "select-nothing": "Nichts auswählen",
"select-nothing-title": "Alle gewählten Dateien nicht mehr selektieren" "select-nothing-title": "Alle gewählten Dateien nicht mehr selektieren",
"abort": "Vorgang abbrechen"
} }
} }
...@@ -68,14 +68,14 @@ ...@@ -68,14 +68,14 @@
"replace-cancel-all": "Cancel all", "replace-cancel-all": "Cancel all",
"replace-mode-all": "Do this for the next conflicts", "replace-mode-all": "Do this for the next conflicts",
"something-went-wrong": "Something went wrong. Please reload.", "something-went-wrong": "Something went wrong. Please reload.",
"upload-to": "Uploading to {{path}} ...", "upload-to": "Uploading to {{- path}} ...",
"readonly": "You are not allowed to uploade files in this directory.", "readonly": "You are not allowed to uploade files in this directory.",
"onlycreate": "You are only allowed to create new files in this directory.", "onlycreate": "You are only allowed to create new files in this directory.",
"onlyedit": "You are only allowed to edit files in this directory.", "onlyedit": "You are only allowed to edit files in this directory.",
"select-all": "Select all", "select-all": "Select all",
"select-all-title": "Select all files in this folder", "select-all-title": "Select all files in this folder",
"select-nothing": "Select none", "select-nothing": "Select none",
"select-nothing-title": "Select no files" "select-nothing-title": "Select no files",
"abort": "Cancel process"
} }
} }
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