Merge branch 'dev' into 2444-entry_latestBuys_v2
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
This commit is contained in:
commit
a767d256b2
|
@ -108,7 +108,7 @@
|
||||||
<vn-td center shrink>
|
<vn-td center shrink>
|
||||||
<a ng-show="balance.hasPdf"
|
<a ng-show="balance.hasPdf"
|
||||||
target="_blank"
|
target="_blank"
|
||||||
href="InvoiceOuts/{{::balance.id}}/download?access_token={{::$ctrl.vnToken.token}}">
|
href="api/InvoiceOuts/{{::balance.id}}/download?access_token={{::$ctrl.vnToken.token}}">
|
||||||
<vn-icon-button
|
<vn-icon-button
|
||||||
icon="cloud_download"
|
icon="cloud_download"
|
||||||
title="{{'Download PDF' | translate}}">
|
title="{{'Download PDF' | translate}}">
|
||||||
|
|
|
@ -1,11 +1,13 @@
|
||||||
const express = require('express');
|
const express = require('express');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
|
const puppeteer = require('puppeteer');
|
||||||
|
|
||||||
const templatesPath = path.resolve(__dirname, './templates');
|
const templatesPath = path.resolve(__dirname, './templates');
|
||||||
const componentsPath = path.resolve(__dirname, './core/components');
|
const componentsPath = path.resolve(__dirname, './core/components');
|
||||||
|
const config = require('./core/config');
|
||||||
|
|
||||||
module.exports = app => {
|
module.exports = async app => {
|
||||||
global.appPath = __dirname;
|
global.appPath = __dirname;
|
||||||
|
|
||||||
process.env.OPENSSL_CONF = '/etc/ssl/';
|
process.env.OPENSSL_CONF = '/etc/ssl/';
|
||||||
|
@ -51,4 +53,16 @@ module.exports = app => {
|
||||||
app.use(`/api/${templateName}/assets`, express.static(assetsDir));
|
app.use(`/api/${templateName}/assets`, express.static(assetsDir));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Instantiate Puppeteer browser
|
||||||
|
async function launchBrowser() {
|
||||||
|
config.browser = await puppeteer.launch({
|
||||||
|
headless: true,
|
||||||
|
args: ['--no-sandbox', '--disable-setuid-sandbox']
|
||||||
|
});
|
||||||
|
|
||||||
|
config.browser.on('disconnected', launchBrowser);
|
||||||
|
}
|
||||||
|
|
||||||
|
launchBrowser();
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
const fs = require('fs-extra');
|
const fs = require('fs-extra');
|
||||||
|
const path = require('path');
|
||||||
let env = process.env.NODE_ENV ? process.env.NODE_ENV : 'development';
|
let env = process.env.NODE_ENV ? process.env.NODE_ENV : 'development';
|
||||||
|
|
||||||
let configPath = `/etc/salix`;
|
let configPath = `/etc/salix`;
|
||||||
|
@ -12,8 +13,9 @@ let configFiles = [
|
||||||
];
|
];
|
||||||
|
|
||||||
for (let configFile of configFiles) {
|
for (let configFile of configFiles) {
|
||||||
if (fs.existsSync(configFile)) {
|
const filePath = path.join(__dirname, configFile);
|
||||||
const conf = require(configFile);
|
if (fs.existsSync(filePath)) {
|
||||||
|
const conf = require(filePath);
|
||||||
for (let prop in conf)
|
for (let prop in conf)
|
||||||
Object.assign(config[prop], conf[prop]);
|
Object.assign(config[prop], conf[prop]);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const puppeteer = require('puppeteer');
|
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const config = require('./config');
|
const config = require('./config');
|
||||||
const Component = require('./component');
|
const Component = require('./component');
|
||||||
|
@ -28,11 +27,7 @@ class Report extends Component {
|
||||||
if (fs.existsSync(fullPath))
|
if (fs.existsSync(fullPath))
|
||||||
options = require(optionsPath);
|
options = require(optionsPath);
|
||||||
|
|
||||||
const browser = await puppeteer.launch({
|
const page = (await config.browser.pages())[0];
|
||||||
headless: true,
|
|
||||||
args: ['--no-sandbox', '--disable-setuid-sandbox']
|
|
||||||
});
|
|
||||||
const page = await browser.newPage();
|
|
||||||
await page.emulateMedia('screen');
|
await page.emulateMedia('screen');
|
||||||
await page.setContent(template);
|
await page.setContent(template);
|
||||||
|
|
||||||
|
@ -51,7 +46,6 @@ class Report extends Component {
|
||||||
options.footerTemplate = footer;
|
options.footerTemplate = footer;
|
||||||
|
|
||||||
const buffer = await page.pdf(options);
|
const buffer = await page.pdf(options);
|
||||||
await browser.close();
|
|
||||||
|
|
||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,12 +10,15 @@ module.exports = {
|
||||||
const routes = await this.fetchRoutes(routesId);
|
const routes = await this.fetchRoutes(routesId);
|
||||||
const tickets = await this.fetchTickets(routesId);
|
const tickets = await this.fetchTickets(routesId);
|
||||||
|
|
||||||
for (let route of routes) {
|
const map = new Map();
|
||||||
const routeTickets = tickets.filter(ticket => {
|
|
||||||
return ticket.routeFk == route.id;
|
|
||||||
});
|
|
||||||
|
|
||||||
route.tickets = routeTickets;
|
for (let route of routes)
|
||||||
|
map.set(route.id, route);
|
||||||
|
|
||||||
|
for (let ticket of tickets) {
|
||||||
|
const route = map.get(ticket.routeFk);
|
||||||
|
if (!route.tickets) route.tickets = [];
|
||||||
|
route.tickets.push(ticket);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.routes = routes;
|
this.routes = routes;
|
||||||
|
@ -61,7 +64,7 @@ module.exports = {
|
||||||
a.postalCode,
|
a.postalCode,
|
||||||
LPAD(a.id, 5, '0') AS addressFk,
|
LPAD(a.id, 5, '0') AS addressFk,
|
||||||
p.name province,
|
p.name province,
|
||||||
vn.ticketGetTotal(t.id) AS import,
|
0 AS import,
|
||||||
am.name ticketAgency,
|
am.name ticketAgency,
|
||||||
tob.description,
|
tob.description,
|
||||||
s.shipFk,
|
s.shipFk,
|
||||||
|
|
Loading…
Reference in New Issue