error handling fixes
gitea/salix/dev This commit looks good
Details
gitea/salix/dev This commit looks good
Details
This commit is contained in:
parent
cba578d42e
commit
ed5458a264
|
@ -15,6 +15,7 @@
|
||||||
|
|
||||||
.grid-block {
|
.grid-block {
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
|
background-color: #FFF;
|
||||||
min-height: 40px
|
min-height: 40px
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,10 +23,6 @@
|
||||||
height: 40px
|
height: 40px
|
||||||
}
|
}
|
||||||
|
|
||||||
.grid-block.white {
|
|
||||||
background-color: #FFF
|
|
||||||
}
|
|
||||||
|
|
||||||
.columns {
|
.columns {
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
|
|
|
@ -16,7 +16,7 @@ const validator = {
|
||||||
if (invalidProps.length > 0) {
|
if (invalidProps.length > 0) {
|
||||||
const required = invalidProps.join(', ');
|
const required = invalidProps.join(', ');
|
||||||
|
|
||||||
throw new Error(`Required params not found [${required}]`);
|
throw new Error(`Required properties not found [${required}]`);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
props: ['isPreview']
|
props: ['isPreview']
|
||||||
|
|
|
@ -1,33 +1,32 @@
|
||||||
const Email = require('../core/email');
|
const Email = require('../core/email');
|
||||||
|
|
||||||
module.exports = app => {
|
module.exports = app => {
|
||||||
app.get(`/api/email/:name`, async(req, res) => {
|
app.get(`/api/email/:name`, async(req, res, next) => {
|
||||||
const args = req.query;
|
const args = req.query;
|
||||||
const requiredArgs = ['recipient', 'clientId'];
|
const requiredArgs = ['clientId', 'recipient'];
|
||||||
|
const argList = requiredArgs.join(',');
|
||||||
const hasRequiredArgs = requiredArgs.every(arg => {
|
const hasRequiredArgs = requiredArgs.every(arg => {
|
||||||
return args[arg];
|
return args[arg];
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!hasRequiredArgs) {
|
|
||||||
return res.status(400).json({
|
|
||||||
message: 'Required params recipient, clientId'
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
if (!hasRequiredArgs)
|
||||||
|
throw new Error(`Required properties not found [${argList}]`);
|
||||||
|
|
||||||
const email = new Email(req.params.name, args);
|
const email = new Email(req.params.name, args);
|
||||||
if (args.isPreview === 'true') {
|
if (args.isPreview === 'true') {
|
||||||
const rendered = await email.render();
|
const rendered = await email.render();
|
||||||
|
|
||||||
res.send(rendered);
|
res.send(rendered);
|
||||||
} else await email.send();
|
} else {
|
||||||
|
await email.send();
|
||||||
|
|
||||||
|
res.status(200).json({
|
||||||
|
message: 'Sent'
|
||||||
|
});
|
||||||
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(e);
|
next(e);
|
||||||
|
|
||||||
return res.status(500).json({message: 'Email not sent'});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
res.status(200).json({message: 'Sent'});
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
|
@ -4,21 +4,21 @@ module.exports = app => {
|
||||||
app.get(`/api/report/:name`, async(req, res, next) => {
|
app.get(`/api/report/:name`, async(req, res, next) => {
|
||||||
const args = req.query;
|
const args = req.query;
|
||||||
const requiredArgs = ['clientId'];
|
const requiredArgs = ['clientId'];
|
||||||
|
const argList = requiredArgs.join(',');
|
||||||
const hasRequiredArgs = requiredArgs.every(arg => {
|
const hasRequiredArgs = requiredArgs.every(arg => {
|
||||||
return args[arg];
|
return args[arg];
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!hasRequiredArgs)
|
|
||||||
res.json({message: 'Required params recipient, clientId'});
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
if (!hasRequiredArgs)
|
||||||
|
throw new Error(`Required properties not found [${argList}]`);
|
||||||
|
|
||||||
const report = new Report(req.params.name, args);
|
const report = new Report(req.params.name, args);
|
||||||
const stream = await report.toPdfStream();
|
const stream = await report.toPdfStream();
|
||||||
res.setHeader('Content-type', 'application/pdf');
|
res.setHeader('Content-type', 'application/pdf');
|
||||||
stream.pipe(res);
|
stream.pipe(res);
|
||||||
} catch (e) {
|
} catch (error) {
|
||||||
next(e);
|
next(error);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
[{
|
[
|
||||||
"filename": "claim-pickup-order.pdf",
|
{
|
||||||
"component": "claim-pickup"
|
"filename": "claim-pickup-order.pdf",
|
||||||
}]
|
"component": "claim-pickup"
|
||||||
|
}
|
||||||
|
]
|
|
@ -25,7 +25,7 @@
|
||||||
</div>
|
</div>
|
||||||
<!-- Block -->
|
<!-- Block -->
|
||||||
<div class="grid-row">
|
<div class="grid-row">
|
||||||
<div class="grid-block white vn-pa-lg">
|
<div class="grid-block vn-pa-lg">
|
||||||
<h1>{{ $t('title') }}</h1>
|
<h1>{{ $t('title') }}</h1>
|
||||||
<p>{{$t('description.dear')}},</p>
|
<p>{{$t('description.dear')}},</p>
|
||||||
<p>{{$t('description.instructions')}}</p>
|
<p>{{$t('description.instructions')}}</p>
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
</div>
|
</div>
|
||||||
<!-- Block -->
|
<!-- Block -->
|
||||||
<div class="grid-row">
|
<div class="grid-row">
|
||||||
<div class="grid-block white vn-pa-lg">
|
<div class="grid-block vn-pa-lg">
|
||||||
<h1>{{ $t('title') }}</h1>
|
<h1>{{ $t('title') }}</h1>
|
||||||
<p>{{$t('dearClient')}},</p>
|
<p>{{$t('dearClient')}},</p>
|
||||||
<p v-html="$t('clientData')"></p>
|
<p v-html="$t('clientData')"></p>
|
||||||
|
|
|
@ -30,7 +30,7 @@
|
||||||
</div>
|
</div>
|
||||||
<!-- Block -->
|
<!-- Block -->
|
||||||
<div class="grid-row">
|
<div class="grid-row">
|
||||||
<div class="grid-block white vn-pa-lg">
|
<div class="grid-block vn-pa-lg">
|
||||||
<h1>{{ $t('title') }}</h1>
|
<h1>{{ $t('title') }}</h1>
|
||||||
<p>{{$t('dear')}}</p>
|
<p>{{$t('dear')}}</p>
|
||||||
<p v-html="$t('description', [ticketId])"></p>
|
<p v-html="$t('description', [ticketId])"></p>
|
||||||
|
@ -38,7 +38,7 @@
|
||||||
</div>
|
</div>
|
||||||
<!-- Block -->
|
<!-- Block -->
|
||||||
<div class="grid-row">
|
<div class="grid-row">
|
||||||
<div class="grid-block white vn-px-lg">
|
<div class="grid-block vn-px-lg">
|
||||||
<p>{{$t('copyLink')}}</p>
|
<p>{{$t('copyLink')}}</p>
|
||||||
<div class="external-link vn-pa-sm vn-m-md">
|
<div class="external-link vn-pa-sm vn-m-md">
|
||||||
https://www.verdnatura.es/#!form=ecomerce/ticket&ticket={{ticketId}}
|
https://www.verdnatura.es/#!form=ecomerce/ticket&ticket={{ticketId}}
|
||||||
|
@ -47,7 +47,7 @@
|
||||||
</div>
|
</div>
|
||||||
<!-- Block -->
|
<!-- Block -->
|
||||||
<div class="grid-row">
|
<div class="grid-row">
|
||||||
<div class="grid-block white vn-pa-lg">
|
<div class="grid-block vn-pa-lg">
|
||||||
<p v-html="$t('poll')"></p>
|
<p v-html="$t('poll')"></p>
|
||||||
<p v-html="$t('help')"></p>
|
<p v-html="$t('help')"></p>
|
||||||
<p v-html="$t('conclusion')"></p>
|
<p v-html="$t('conclusion')"></p>
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
[{
|
[
|
||||||
"filename": "delivery-note.pdf",
|
{
|
||||||
"component": "delivery-note"
|
"filename": "delivery-note.pdf",
|
||||||
}]
|
"component": "delivery-note"
|
||||||
|
}
|
||||||
|
]
|
|
@ -25,7 +25,7 @@
|
||||||
</div>
|
</div>
|
||||||
<!-- Block -->
|
<!-- Block -->
|
||||||
<div class="grid-row">
|
<div class="grid-row">
|
||||||
<div class="grid-block white vn-pa-lg">
|
<div class="grid-block vn-pa-lg">
|
||||||
<h1>{{ $t('title') }}</h1>
|
<h1>{{ $t('title') }}</h1>
|
||||||
<p>{{$t('dear')}},</p>
|
<p>{{$t('dear')}},</p>
|
||||||
<p v-html="$t('description', [ticketId])"></p>
|
<p v-html="$t('description', [ticketId])"></p>
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
[{
|
[
|
||||||
"filename": "driver-route.pdf",
|
{
|
||||||
"component": "driver-route"
|
"filename": "driver-route.pdf",
|
||||||
}]
|
"component": "driver-route"
|
||||||
|
}
|
||||||
|
]
|
|
@ -25,7 +25,7 @@
|
||||||
</div>
|
</div>
|
||||||
<!-- Block -->
|
<!-- Block -->
|
||||||
<div class="grid-row">
|
<div class="grid-row">
|
||||||
<div class="grid-block white vn-pa-lg">
|
<div class="grid-block vn-pa-lg">
|
||||||
<h1>{{ $t('title') }}</h1>
|
<h1>{{ $t('title') }}</h1>
|
||||||
<p>{{$t('description.instructions')}}</p>
|
<p>{{$t('description.instructions')}}</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
[{
|
[
|
||||||
"filename": "letter-debtor.pdf",
|
{
|
||||||
"component": "letter-debtor"
|
"filename": "letter-debtor.pdf",
|
||||||
}]
|
"component": "letter-debtor"
|
||||||
|
}
|
||||||
|
]
|
|
@ -25,7 +25,7 @@
|
||||||
</div>
|
</div>
|
||||||
<!-- Block -->
|
<!-- Block -->
|
||||||
<div class="grid-row">
|
<div class="grid-row">
|
||||||
<div class="grid-block white vn-pa-lg">
|
<div class="grid-block vn-pa-lg">
|
||||||
<h1>{{ $t('title') }}</h1>
|
<h1>{{ $t('title') }}</h1>
|
||||||
<p>{{ $t('sections.introduction.title') }},</p>
|
<p>{{ $t('sections.introduction.title') }},</p>
|
||||||
<p>{{ $t('sections.introduction.description') }}</p>
|
<p>{{ $t('sections.introduction.description') }}</p>
|
||||||
|
@ -65,7 +65,7 @@
|
||||||
</div>
|
</div>
|
||||||
<!-- Block -->
|
<!-- Block -->
|
||||||
<div class="grid-row" v-if="isPreview">
|
<div class="grid-row" v-if="isPreview">
|
||||||
<div class="grid-block white vn-pa-lg">
|
<div class="grid-block vn-pa-lg">
|
||||||
<attachment v-for="attachment in attachments"
|
<attachment v-for="attachment in attachments"
|
||||||
v-bind:key="attachment.filename"
|
v-bind:key="attachment.filename"
|
||||||
v-bind:attachment="attachment"
|
v-bind:attachment="attachment"
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
[{
|
[
|
||||||
"filename": "letter-debtor.pdf",
|
{
|
||||||
"component": "letter-debtor"
|
"filename": "letter-debtor.pdf",
|
||||||
}]
|
"component": "letter-debtor"
|
||||||
|
}
|
||||||
|
]
|
|
@ -25,7 +25,7 @@
|
||||||
</div>
|
</div>
|
||||||
<!-- Block -->
|
<!-- Block -->
|
||||||
<div class="grid-row">
|
<div class="grid-row">
|
||||||
<div class="grid-block white vn-pa-lg">
|
<div class="grid-block vn-pa-lg">
|
||||||
<h1>{{ $t('title') }}</h1>
|
<h1>{{ $t('title') }}</h1>
|
||||||
<p>{{ $t('sections.introduction.title') }},</p>
|
<p>{{ $t('sections.introduction.title') }},</p>
|
||||||
<p>{{ $t('sections.introduction.description') }}</p>
|
<p>{{ $t('sections.introduction.description') }}</p>
|
||||||
|
@ -48,7 +48,7 @@
|
||||||
</div>
|
</div>
|
||||||
<!-- Block -->
|
<!-- Block -->
|
||||||
<div class="grid-row" v-if="isPreview">
|
<div class="grid-row" v-if="isPreview">
|
||||||
<div class="grid-block white vn-pa-lg">
|
<div class="grid-block vn-pa-lg">
|
||||||
<attachment v-for="attachment in attachments"
|
<attachment v-for="attachment in attachments"
|
||||||
v-bind:key="attachment.filename"
|
v-bind:key="attachment.filename"
|
||||||
v-bind:attachment="attachment"
|
v-bind:attachment="attachment"
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
</div>
|
</div>
|
||||||
<!-- Block -->
|
<!-- Block -->
|
||||||
<div class="grid-row">
|
<div class="grid-row">
|
||||||
<div class="grid-block white vn-pa-lg">
|
<div class="grid-block vn-pa-lg">
|
||||||
<h1>{{ $t('title') }}</h1>
|
<h1>{{ $t('title') }}</h1>
|
||||||
<p>{{ $t('sections.introduction.title') }},</p>
|
<p>{{ $t('sections.introduction.title') }},</p>
|
||||||
<p v-html="`${$t('sections.introduction.description')}:`"></p>
|
<p v-html="`${$t('sections.introduction.description')}:`"></p>
|
||||||
|
|
|
@ -1,12 +1,14 @@
|
||||||
[{
|
[
|
||||||
"filename": "model.ezp",
|
{
|
||||||
"component": "printer-setup",
|
"filename": "model.ezp",
|
||||||
"path": "/assets/files/model.ezp",
|
"component": "printer-setup",
|
||||||
"cid": "model.ezp"
|
"path": "/assets/files/model.ezp",
|
||||||
},
|
"cid": "model.ezp"
|
||||||
{
|
},
|
||||||
"filename": "port.png",
|
{
|
||||||
"component": "printer-setup",
|
"filename": "port.png",
|
||||||
"path": "/assets/files/port.png",
|
"component": "printer-setup",
|
||||||
"cid": "port.png"
|
"path": "/assets/files/port.png",
|
||||||
}]
|
"cid": "port.png"
|
||||||
|
}
|
||||||
|
]
|
|
@ -25,7 +25,7 @@
|
||||||
</div>
|
</div>
|
||||||
<!-- Block -->
|
<!-- Block -->
|
||||||
<div class="grid-row">
|
<div class="grid-row">
|
||||||
<div class="grid-block white vn-pa-lg">
|
<div class="grid-block vn-pa-lg">
|
||||||
<h1>{{ $t('title') }}</h1>
|
<h1>{{ $t('title') }}</h1>
|
||||||
<p>{{$t('description.dear')}},</p>
|
<p>{{$t('description.dear')}},</p>
|
||||||
<p>{{$t('description.instructions')}}</p>
|
<p>{{$t('description.instructions')}}</p>
|
||||||
|
@ -43,7 +43,7 @@
|
||||||
</div>
|
</div>
|
||||||
<!-- Block -->
|
<!-- Block -->
|
||||||
<div class="grid-row">
|
<div class="grid-row">
|
||||||
<div class="grid-block white vn-pa-lg">
|
<div class="grid-block vn-pa-lg">
|
||||||
<h1>{{$t('sections.help.title')}}</h1>
|
<h1>{{$t('sections.help.title')}}</h1>
|
||||||
<p>{{$t('sections.help.description')}}</p>
|
<p>{{$t('sections.help.description')}}</p>
|
||||||
<p v-html="$t('sections.help.remoteSupport')"></p>
|
<p v-html="$t('sections.help.remoteSupport')"></p>
|
||||||
|
@ -51,7 +51,7 @@
|
||||||
</div>
|
</div>
|
||||||
<!-- Block -->
|
<!-- Block -->
|
||||||
<div class="grid-row">
|
<div class="grid-row">
|
||||||
<div class="grid-block white vn-pa-lg">
|
<div class="grid-block vn-pa-lg">
|
||||||
<div v-if="client.salesPersonName">
|
<div v-if="client.salesPersonName">
|
||||||
{{$t('salesPersonName')}}: <strong>{{client.salesPersonName}}</strong>
|
{{$t('salesPersonName')}}: <strong>{{client.salesPersonName}}</strong>
|
||||||
</div>
|
</div>
|
||||||
|
@ -66,7 +66,7 @@
|
||||||
</div>
|
</div>
|
||||||
<!-- Block -->
|
<!-- Block -->
|
||||||
<div class="grid-row" v-if="isPreview">
|
<div class="grid-row" v-if="isPreview">
|
||||||
<div class="grid-block white vn-pa-lg">
|
<div class="grid-block vn-pa-lg">
|
||||||
<attachment v-for="attachment in attachments"
|
<attachment v-for="attachment in attachments"
|
||||||
v-bind:key="attachment.filename"
|
v-bind:key="attachment.filename"
|
||||||
v-bind:attachment="attachment"
|
v-bind:attachment="attachment"
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
</div>
|
</div>
|
||||||
<!-- Block -->
|
<!-- Block -->
|
||||||
<div class="grid-row">
|
<div class="grid-row">
|
||||||
<div class="grid-block white vn-pa-lg">
|
<div class="grid-block vn-pa-lg">
|
||||||
<h1>{{ $t('title') }}</h1>
|
<h1>{{ $t('title') }}</h1>
|
||||||
<p>{{$t('description.dear')}},</p>
|
<p>{{$t('description.dear')}},</p>
|
||||||
<div v-html="$t('description.instructions')"></div>
|
<div v-html="$t('description.instructions')"></div>
|
||||||
|
@ -34,7 +34,7 @@
|
||||||
</div>
|
</div>
|
||||||
<!-- Attachments block -->
|
<!-- Attachments block -->
|
||||||
<div class="grid-row" v-if="isPreview">
|
<div class="grid-row" v-if="isPreview">
|
||||||
<div class="grid-block white vn-pa-lg">
|
<div class="grid-block vn-pa-lg">
|
||||||
<attachment v-for="attachment in attachments"
|
<attachment v-for="attachment in attachments"
|
||||||
v-bind:key="attachment.filename"
|
v-bind:key="attachment.filename"
|
||||||
v-bind:attachment="attachment"
|
v-bind:attachment="attachment"
|
||||||
|
|
|
@ -33,7 +33,7 @@
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td class="font gray uppercase">{{$t('date')}}</td>
|
<td class="font gray uppercase">{{$t('date')}}</td>
|
||||||
<th>{{currentDate}}</th>
|
<th>{{dated}}</th>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
|
@ -13,7 +13,7 @@ module.exports = {
|
||||||
throw new Error('Something went wrong');
|
throw new Error('Something went wrong');
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
currentDate: function() {
|
dated: function() {
|
||||||
const filters = this.$options.filters;
|
const filters = this.$options.filters;
|
||||||
|
|
||||||
return filters.date(new Date(), '%d-%m-%Y');
|
return filters.date(new Date(), '%d-%m-%Y');
|
||||||
|
|
|
@ -12,13 +12,6 @@ module.exports = {
|
||||||
if (!this.route)
|
if (!this.route)
|
||||||
throw new Error('Something went wrong');
|
throw new Error('Something went wrong');
|
||||||
},
|
},
|
||||||
computed: {
|
|
||||||
dated: function() {
|
|
||||||
const filters = this.$options.filters;
|
|
||||||
|
|
||||||
return filters.date(new Date(), '%d-%m-%Y');
|
|
||||||
}
|
|
||||||
},
|
|
||||||
methods: {
|
methods: {
|
||||||
fetchRoute(id) {
|
fetchRoute(id) {
|
||||||
return db.findOne(
|
return db.findOne(
|
||||||
|
|
Loading…
Reference in New Issue