refactor: el UserError se lanza en back
gitea/salix/pipeline/head There was a failure building this commit Details

This commit is contained in:
Vicent Llopis 2022-10-26 09:33:03 +02:00
parent c77999871e
commit ec81b12239
2 changed files with 2 additions and 3 deletions

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;
});
}