Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
<template>
<!-- <div style="height: 300px;">

</div> -->

<lightning-card title="Mass File Downloader">
<div class="slds-box slds-theme_default slds-p-around_medium">
<lightning-textarea label="Download URL" value={downloadUrl} readonly></lightning-textarea>
</div>
<lightning-button
variant="brand"
label="Download Files"
Expand All @@ -16,7 +15,8 @@
<lightning-datatable
key-field="Id"
data={files.data}
columns={columns}>
columns={columns}
onrowselection={handleRowSelection}>
</lightning-datatable>
</lightning-card>
</template>
22 changes: 18 additions & 4 deletions Mass File Downloader/lwc/massFileDownloader/massFileDownloader.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ const BASE_DOWNLOAD_PATH = '/sfc/servlet.shepherd/version/download';
export default class MassFileDownloader extends LightningElement {

columns = COLUMNS;
downloadString = '';

@wire(getFiles) files;

Expand All @@ -40,6 +41,11 @@ export default class MassFileDownloader extends LightningElement {
);
}

handleRowSelection(event) {
let selectedFiles = event.detail.selectedRows;
this.downloadString = this.getDownloadString(selectedFiles);
}

getDownloadString(files) {
let downloadString = '';
files.forEach(item => {
Expand All @@ -48,12 +54,20 @@ export default class MassFileDownloader extends LightningElement {
return downloadString;
}

initDownloading(downloadString) {
alert(BASE_DOWNLOAD_PATH + downloadString);
//window.open(BASE_DOWNLOAD_PATH + downloadString, '_blank');
get downloadUrl() {
return BASE_DOWNLOAD_PATH + this.downloadString;
}

initDownloading() {
if (this.downloadString === '') {
alert('No files selected');
return;
}
//alert(this.downloadUrl);
window.open(this.downloadUrl, '_blank');
}

getSelectedRows() {
return this.template.querySelector('lightning-datatable').getSelectedRows();
}
}
}