3951-invoiceOut.index_downloadPdfs #1110

Merged
joan merged 7 commits from 3951-invoiceOut.index_downloadPdfs into dev 2022-11-04 10:42:35 +00:00
2 changed files with 2 additions and 3 deletions
Showing only changes of commit ec81b12239 - Show all commits

View File

@ -1,5 +1,6 @@
const JSZip = require('jszip');
const fs = require('fs-extra');
const UserError = require('vn-loopback/util/user-error');
module.exports = Self => {
Self.remoteMethodCtx('downloadZip', {
@ -34,7 +35,7 @@ module.exports = Self => {
let totalSize = 0;
const zipConfig = await models.ZipConfig.findOne();
for (let id of ids) {
if (zipConfig && totalSize > zipConfig.maxSize) return false;
if (zipConfig && totalSize > zipConfig.maxSize) throw new UserError('Files are too large');
const invoiceOutPdf = await models.InvoiceOut.download(ctx, id, myOptions);
const fileName = extractFileName(invoiceOutPdf[2]);
const body = invoiceOutPdf[0];

View File

@ -1,6 +1,5 @@
import ngModule from '../module';
import Section from 'salix/components/section';
const UserError = require('vn-loopback/util/user-error');
export default class Controller extends Section {
get checked() {
@ -35,7 +34,6 @@ export default class Controller extends Section {
};
this.$http.post(`InvoiceOuts/downloadZip`, params)
.then(res => {
if (res.data == false) throw new UserError('Files are too large');
location.href = 'data:application/zip;base64,' + res.data;
vicent marked this conversation as resolved
Review

Se podría hacer para que en vez de que la ruta devuelva un base64, que hiciese algo similar a InvoiceOut/download? Podrías abrirlo directamente con window.open

Se podría hacer para que en vez de que la ruta devuelva un base64, que hiciese algo similar a InvoiceOut/download? Podrías abrirlo directamente con window.open
Review

No se podia crear el stream directamente. Al final se ha dejado como estaba planteado.

No se podia crear el stream directamente. Al final se ha dejado como estaba planteado.
});
}