WebClient: allow to share multiple items from the files page

Signed-off-by: Nicola Murino <nicola.murino@gmail.com>
This commit is contained in:
Nicola Murino 2023-11-06 18:46:12 +01:00
parent 654ce2e349
commit 9e9d6a5585
No known key found for this signature in database
GPG key ID: 935D2952DEC4EECF

View file

@ -74,6 +74,13 @@ explicit grant from the SFTPGo Team (support@sftpgo.com).
</a>
</div>
{{- end}}
{{- if .CanShare}}
<div class="menu-item px-3">
<a href="#" class="menu-link px-3 fs-6" data-kt-filemanager-table-select="share_selected">
Share
</a>
</div>
{{- end}}
{{- if .CanDelete}}
<div class="menu-item px-3">
<a href="#" class="menu-link px-3 text-danger fs-6" data-kt-filemanager-table-select="delete_selected">
@ -801,6 +808,22 @@ explicit grant from the SFTPGo Team (support@sftpgo.com).
});
}
const shareButton = document.querySelector('[data-kt-filemanager-table-select="share_selected"]');
if (shareButton){
shareButton.addEventListener('click', function(e){
let filesArray = [];
dt.rows({ selected: true, search: 'applied' }).every(function (rowIdx, tableLoop, rowLoop){
let row = dt.row(rowIdx);
filesArray.push(getNameFromMeta(row.data()['meta']));
});
let files = encodeURIComponent(JSON.stringify(filesArray));
let shareURL = '{{.ShareURL}}';
let currentDir = '{{.CurrentDir}}';
let ts = new Date().getTime().toString();
window.open(`${shareURL}?path=${currentDir}&files=${files}&_=${ts}`,'_blank');
});
}
const deleteButton = document.querySelector('[data-kt-filemanager-table-select="delete_selected"]');
if (deleteButton) {
deleteButton.addEventListener('click', function(e){