This commit is contained in:
Gerard 2019-01-23 11:17:35 +01:00
commit e6213fb83f
21 changed files with 115 additions and 103 deletions

1
.gitignore vendored
View File

@ -3,4 +3,5 @@ dist/*
npm-debug.log
.eslintcache
datasources.*.json
print.*.json
db.json

View File

@ -6,6 +6,7 @@ RUN apt-get update \
curl \
ca-certificates \
gnupg2 \
libfontconfig \
&& curl -sL https://deb.nodesource.com/setup_8.x | bash - \
&& apt-get install -y --no-install-recommends \
nodejs \

View File

@ -7,11 +7,12 @@
</vn-crud-model>
<vn-horizontal>
<vn-vertical vn-one>
<vn-vertical vn-one>
<vn-card>
<vn-vertical>
<vn-horizontal class="catalog-header" pad-medium-h>
<vn-one><!-- {{model.data.length || 0}} <span translate>results</span> --></vn-one>
<vn-one ng-if="model.moreRows">
<span translate>More than</span> {{model.limit}} <span translate>results</span></vn-one>
<vn-one>
<vn-horizontal>
<vn-autocomplete vn-id="field" vn-one

View File

@ -39,12 +39,13 @@ class Controller {
return order.field == itemTag.tagFk;
});
if (!alreadyAdded)
if (!alreadyAdded) {
this.fieldList.push({
name: itemTag.name,
field: itemTag.tagFk,
isTag: true
});
}
});
});
}

View File

@ -2,6 +2,7 @@ Address: Consignatario
Catalog: Catálogo
from: desde
results: resultados
More than: Más de
No results: Sin resultados
Enter a new search: Introduce una nueva búsqueda
Plant: Planta

53
package-lock.json generated
View File

@ -4019,7 +4019,7 @@
"dot-prop": {
"version": "4.2.0",
"resolved": "https://registry.npmjs.org/dot-prop/-/dot-prop-4.2.0.tgz",
"integrity": "sha512-tUMXrxlExSW6U2EXiiKGSBVdYgtV8qlHL+C10TsW4PURY/ic+eaysnSkwB4kA/mBlCyy/IKDJ+Lc3wbWeaXtuQ==",
"integrity": "sha1-HxngwuGqDjJ5fEl5nyg3rGr2nFc=",
"dev": true,
"requires": {
"is-obj": "^1.0.0"
@ -4192,7 +4192,7 @@
},
"jsonfile": {
"version": "2.4.0",
"resolved": "http://registry.npmjs.org/jsonfile/-/jsonfile-2.4.0.tgz",
"resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-2.4.0.tgz",
"integrity": "sha1-NzaitCi4e72gzIO1P6PWM6NcKug=",
"dev": true,
"requires": {
@ -5517,7 +5517,8 @@
"ansi-regex": {
"version": "2.1.1",
"bundled": true,
"dev": true
"dev": true,
"optional": true
},
"aproba": {
"version": "1.2.0",
@ -5538,12 +5539,14 @@
"balanced-match": {
"version": "1.0.0",
"bundled": true,
"dev": true
"dev": true,
"optional": true
},
"brace-expansion": {
"version": "1.1.11",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"balanced-match": "^1.0.0",
"concat-map": "0.0.1"
@ -5558,17 +5561,20 @@
"code-point-at": {
"version": "1.1.0",
"bundled": true,
"dev": true
"dev": true,
"optional": true
},
"concat-map": {
"version": "0.0.1",
"bundled": true,
"dev": true
"dev": true,
"optional": true
},
"console-control-strings": {
"version": "1.1.0",
"bundled": true,
"dev": true
"dev": true,
"optional": true
},
"core-util-is": {
"version": "1.0.2",
@ -5685,7 +5691,8 @@
"inherits": {
"version": "2.0.3",
"bundled": true,
"dev": true
"dev": true,
"optional": true
},
"ini": {
"version": "1.3.5",
@ -5697,6 +5704,7 @@
"version": "1.0.0",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"number-is-nan": "^1.0.0"
}
@ -5711,6 +5719,7 @@
"version": "3.0.4",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"brace-expansion": "^1.1.7"
}
@ -5718,12 +5727,14 @@
"minimist": {
"version": "0.0.8",
"bundled": true,
"dev": true
"dev": true,
"optional": true
},
"minipass": {
"version": "2.2.4",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"safe-buffer": "^5.1.1",
"yallist": "^3.0.0"
@ -5742,6 +5753,7 @@
"version": "0.5.1",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"minimist": "0.0.8"
}
@ -5822,7 +5834,8 @@
"number-is-nan": {
"version": "1.0.1",
"bundled": true,
"dev": true
"dev": true,
"optional": true
},
"object-assign": {
"version": "4.1.1",
@ -5834,6 +5847,7 @@
"version": "1.4.0",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"wrappy": "1"
}
@ -5919,7 +5933,8 @@
"safe-buffer": {
"version": "5.1.1",
"bundled": true,
"dev": true
"dev": true,
"optional": true
},
"safer-buffer": {
"version": "2.1.2",
@ -5955,6 +5970,7 @@
"version": "1.0.2",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"code-point-at": "^1.0.0",
"is-fullwidth-code-point": "^1.0.0",
@ -5974,6 +5990,7 @@
"version": "3.0.1",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"ansi-regex": "^2.0.0"
}
@ -6017,12 +6034,14 @@
"wrappy": {
"version": "1.0.2",
"bundled": true,
"dev": true
"dev": true,
"optional": true
},
"yallist": {
"version": "3.0.2",
"bundled": true,
"dev": true
"dev": true,
"optional": true
}
}
},
@ -8160,7 +8179,7 @@
"karma-chrome-launcher": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/karma-chrome-launcher/-/karma-chrome-launcher-2.2.0.tgz",
"integrity": "sha512-uf/ZVpAabDBPvdPdveyk1EPgbnloPvFFGgmRhYLTDH7gEB4nZdSBk8yTU47w1g/drLSx5uMOkjKk7IWKfWg/+w==",
"integrity": "sha1-zxudBxNswY/iOTJ9JGVMPbw2is8=",
"dev": true,
"requires": {
"fs-access": "^1.0.0",
@ -14271,7 +14290,7 @@
"split2": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/split2/-/split2-2.2.0.tgz",
"integrity": "sha512-RAb22TG39LhI31MbreBgIuKiIKhVsawfTgEGqKHTK87aG+ul/PB8Sqoi3I7kVdRWiCfrKxK3uo4/YUkpNvhPbw==",
"integrity": "sha1-GGsldbz4PoW30YRldWI47k7kJJM=",
"dev": true,
"requires": {
"through2": "^2.0.2"
@ -15303,7 +15322,7 @@
"touch": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/touch/-/touch-3.1.0.tgz",
"integrity": "sha512-WBx8Uy5TLtOSRtIq+M03/sKDrXCLHxwDcquSP2c43Le03/9serjQBIztjRz6FkJez9D/hleyAXTBGLwwZUw9lA==",
"integrity": "sha1-/jZfX3XsntTlaCXgu3bSSrdK+Ds=",
"dev": true,
"requires": {
"nopt": "~1.0.10"
@ -16925,7 +16944,7 @@
"write-file-atomic": {
"version": "2.3.0",
"resolved": "https://registry.npmjs.org/write-file-atomic/-/write-file-atomic-2.3.0.tgz",
"integrity": "sha512-xuPeK4OdjWqtfi59ylvVL0Yn35SF3zgcAcv7rBPFHVaEapaDr4GdGgm3j7ckTwH9wHL7fGmgfAnb0+THrHb8tA==",
"integrity": "sha1-H/YVdcLipOjlENb6TiQ8zhg5mas=",
"dev": true,
"requires": {
"graceful-fs": "^4.1.11",

View File

@ -4,6 +4,7 @@ let env = process.env.NODE_ENV ? process.env.NODE_ENV : 'development';
let configPath = `/etc/salix`;
let config = require('../config/print.json');
let configFiles = [
`${appPath}/config/print.${env}.json`,
`${configPath}/print.json`,
`${configPath}/print.${env}.json`
];
@ -28,5 +29,4 @@ for (let proxyFile of proxyFiles) {
// config.proxy = proxyConf;
config.env = env;
module.exports = config;

View File

@ -47,9 +47,10 @@ module.exports = {
* @param {Object} ctx - Request context
*/
async preFetch(component, ctx) {
const preFetchData = {attachments: []};
let params = {};
let mergedData = {attachments: []};
let asyncData = {};
let data = {};
let params = {};
if (Object.keys(ctx.body).length > 0)
params = ctx.body;
@ -63,36 +64,34 @@ module.exports = {
data = component.data();
if (component.hasOwnProperty('asyncData')) {
const asyncData = await component.asyncData(ctx, params);
asyncData = await component.asyncData(ctx, params);
if (asyncData.locale) {
const locale = component.i18n.messages[asyncData.locale];
preFetchData.subject = locale.subject;
mergedData.subject = locale.subject;
}
if (asyncData.recipient)
preFetchData.recipient = asyncData.recipient;
const mergedData = {...data, ...asyncData};
component.data = function data() {
return mergedData;
};
}
if (data && data.hasOwnProperty('attachments')) {
const fileNames = data.attachments;
fileNames.forEach(attachment => {
mergedData = Object.assign(mergedData, data, asyncData);
component.data = function data() {
return mergedData;
};
if (data.hasOwnProperty('files')) {
const files = data.files;
files.forEach(file => {
const componentPath = `${this.path}/${component.name}`;
let fileSrc = componentPath + attachment;
let fileSrc = componentPath + file;
if (attachment.slice(0, 4) === 'http' || attachment.slice(0, 4) === 'https')
fileSrc = attachment;
if (file.slice(0, 4) === 'http' || file.slice(0, 4) === 'https')
fileSrc = file;
const fileName = attachment.split('/').pop();
preFetchData.attachments.push({
const fileName = file.split('/').pop();
mergedData.attachments.push({
filename: fileName,
path: fileSrc,
cid: attachment,
cid: file,
});
});
}
@ -108,14 +107,14 @@ module.exports = {
return Promise.all(promises).then(results => {
results.forEach(result => {
result.attachments.forEach(atth => {
preFetchData.attachments.push(atth);
mergedData.attachments.push(atth);
});
});
return preFetchData;
return mergedData;
});
}
return preFetchData;
return mergedData;
},
async attachAssets(component) {

View File

@ -1,21 +0,0 @@
module.exports = app => {
process.on('uncaughtException', err => {
console.error(`Caught exception: ${err}`);
});
process.on('warning', () => {
console.error(`My warning err`);
});
app.use(function(error, request, response, next) {
if (!error.httpStatusCode)
return next(error);
response.status(error.httpStatusCode);
response.json({
httpStatusCode: error.httpStatusCode,
name: error.name,
message: error.message,
});
});
};

View File

@ -43,21 +43,29 @@ module.exports = {
* @param {Object} ctx - Request context
*/
async preFetch(component, ctx) {
let mergedData = {};
let asyncData = {};
let data = {};
if (Object.keys(ctx.body).length > 0)
params = ctx.body;
if (Object.keys(ctx.query).length > 0)
params = ctx.query;
await this.attachAssets(component);
if (component.hasOwnProperty('data'))
data = component.data();
if (component.hasOwnProperty('asyncData')) {
const fetch = await component.asyncData(ctx, ctx.body);
const mergedData = {...data, ...fetch};
if (component.hasOwnProperty('asyncData'))
asyncData = await component.asyncData(ctx, params);
component.data = function data() {
return mergedData;
};
}
mergedData = Object.assign(mergedData, data, asyncData);
component.data = function data() {
return mergedData;
};
if (component.components) {
const components = component.components;

View File

@ -4,7 +4,6 @@ const UserException = require(`${appPath}/lib/exceptions/userException`);
module.exports = {
name: 'delivery-note',
async asyncData(ctx, params) {
console.log(params);
const promises = [];
const dataIndex = promises.push(this.methods.fetchData()) - 1;
const itemsIndex = promises.push(this.methods.fetchItems()) - 1;

View File

@ -1,21 +1,21 @@
module.exports = {
name: 'email-footer',
asyncData(ctx, params) {
asyncData(ctx) {
return {
isPreview: ctx.method === 'GET',
};
},
created() {
const embeded = [];
this.attachments.map((attachment) => {
const src = this.isPreview ? attachment : `cid:${attachment}`;
embeded[attachment] = src;
this.files.map(file => {
const src = this.isPreview ? file : `cid:${file}`;
embeded[file] = src;
});
this.embeded = embeded;
},
data() {
return {
attachments: [
files: [
'/assets/images/facebook.png',
'/assets/images/twitter.png',
'/assets/images/youtube.png',

View File

@ -1,22 +1,22 @@
module.exports = {
name: 'email-header',
asyncData(ctx, params) {
asyncData(ctx) {
return {
isPreview: ctx.method === 'GET',
};
},
created() {
const embeded = [];
this.attachments.map((attachment) => {
const src = this.isPreview ? attachment : `cid:${attachment}`;
embeded[attachment] = src;
this.files.map(file => {
const src = this.isPreview ? file : `cid:${file}`;
embeded[file] = src;
});
this.embeded = embeded;
},
data() {
return {
attachments: ['/assets/images/logo.png'],
files: ['/assets/images/logo.png'],
};
},
};

View File

@ -13,6 +13,9 @@ module.exports = {
if (!params.clientFk)
throw new UserException('No client id specified');
if (!params.companyFk)
throw new UserException('No company id specified');
return this.methods.fetchClientData(params.clientFk, params.companyFk)
.then(([result]) => {
return Object.assign(data, result[0]);

View File

@ -1,11 +1,14 @@
const database = require(`${appPath}/lib/database`);
const reportEngine = require(`${appPath}/lib/reportEngine.js`);
const emailHeader = require('../email-header');
const emailFooter = require('../email-footer');
const UserException = require(`${appPath}/lib/exceptions/userException`);
module.exports = {
name: 'letter-debtor-st',
async asyncData(ctx, params) {
const promises = [];
const data = {
isPreview: ctx.method === 'GET',
};
@ -16,23 +19,24 @@ module.exports = {
if (!params.companyFk)
throw new UserException('No company id specified');
return this.methods.fetchClientData(params.clientFk, params.companyFk)
.then(([[result]]) => {
if (!result) throw new UserException('Client data not found');
promises.push(reportEngine.toPdf('delivery-note', ctx));
promises.push(this.methods.fetchClient(params.clientFk, params.companyFk));
return Object.assign(data, result);
});
return Promise.all(promises).then(result => {
const stream = result[0];
const [[client]] = result[1];
Object.assign(data, client);
Object.assign(data, {attachments: [{filename: 'delivery-note.pdf', content: stream}]});
return data;
});
},
created() {
this.$i18n.locale = this.locale;
},
data() {
return {
attachments: ['http://localhost:5000/report/delivery-note'],
};
},
methods: {
fetchClientData(clientFk, companyFk) {
fetchClient(clientFk, companyFk) {
return database.pool.query(`
SELECT
u.lang locale,
@ -47,7 +51,7 @@ module.exports = {
JOIN bankEntity be ON be.id = sa.bankEntityFk
JOIN account.user u ON u.id = c.id
WHERE c.id = ? AND cny.id = ?`, [clientFk, companyFk]);
},
}
},
computed: {
accountAddress: function() {

View File

@ -23,7 +23,7 @@ module.exports = {
},
data() {
return {
attachments: ['/assets/files/model.ezp'],
files: ['/assets/files/model.ezp'],
};
},
methods: {

View File

@ -1,18 +1,14 @@
const database = require('./lib/database');
const smtp = require('./lib/smtp');
module.exports = app => {
global.appPath = __dirname;
process.env.OPENSSL_CONF = '/etc/ssl/';
// Init database instance
database.init();
require('./lib/database').init();
// Init SMTP Instance
smtp.init();
require('./lib/smtp').init();
require('./lib/router')(app);
// require('./lib/errorHandler')(app);
};