feat(editor): Add "Download" button if JSON data is to large (#6850)

* feat(editor): Add "Download" button if JSON data is to large

*  Some code improvements + change button style

---------

Co-authored-by: कारतोफ्फेलस्क्रिप्ट™ <aditya@netroy.in>
This commit is contained in:
Jan Oberhauser 2023-08-07 19:06:38 +02:00 committed by GitHub
parent 6499f42481
commit efe08cced3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -284,6 +284,12 @@
:label="$locale.baseText('ndv.output.tooMuchData.showDataAnyway')"
@click="showTooMuchData"
/>
<n8n-button
size="small"
:label="$locale.baseText('runData.downloadBinaryData')"
@click="downloadJsonData()"
/>
</div>
<div
@ -1290,6 +1296,14 @@ export default defineComponent({
saveAs(blob, fileName);
}
},
async downloadJsonData() {
const inputData = this.getNodeInputData(this.node, this.runIndex, this.currentOutputIndex);
const fileName = this.node!.name.replace(/[^\w\d]/g, '_');
const blob = new Blob([JSON.stringify(inputData, null, 2)], { type: 'application/json' });
saveAs(blob, `${fileName}.json`);
},
displayBinaryData(index: number, key: string) {
this.binaryDataDisplayVisible = true;