Attachment fixes
gitea/salix/pipeline/head This commit looks good Details

This commit is contained in:
Joan Sanchez 2022-11-10 11:51:14 +01:00
parent 133897c29f
commit 303020a731
15 changed files with 101 additions and 71 deletions

20
package-lock.json generated
View File

@ -60,6 +60,7 @@
"del": "^2.2.2",
"eslint": "^7.11.0",
"eslint-config-google": "^0.11.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-jasmine": "^2.10.1",
"eslint-plugin-prettier": "^4.2.1",
"fancy-log": "^1.3.2",
@ -7231,6 +7232,18 @@
"eslint": ">=5.4.0"
}
},
"node_modules/eslint-config-prettier": {
"version": "8.5.0",
"resolved": "https://registry.npmjs.org/eslint-config-prettier/-/eslint-config-prettier-8.5.0.tgz",
"integrity": "sha512-obmWKLUNCnhtQRKc+tmnYuQl0pFU1ibYJQ5BGhTVB08bHe9wC8qUeG7c08dj9XX+AuPj1YSGSQIHl1pnDHZR0Q==",
"dev": true,
"bin": {
"eslint-config-prettier": "bin/cli.js"
},
"peerDependencies": {
"eslint": ">=7.0.0"
}
},
"node_modules/eslint-plugin-jasmine": {
"version": "2.10.1",
"dev": true,
@ -31744,6 +31757,13 @@
"dev": true,
"requires": {}
},
"eslint-config-prettier": {
"version": "8.5.0",
"resolved": "https://registry.npmjs.org/eslint-config-prettier/-/eslint-config-prettier-8.5.0.tgz",
"integrity": "sha512-obmWKLUNCnhtQRKc+tmnYuQl0pFU1ibYJQ5BGhTVB08bHe9wC8qUeG7c08dj9XX+AuPj1YSGSQIHl1pnDHZR0Q==",
"dev": true,
"requires": {}
},
"eslint-plugin-jasmine": {
"version": "2.10.1",
"dev": true

View File

@ -63,6 +63,7 @@
"del": "^2.2.2",
"eslint": "^7.11.0",
"eslint-config-google": "^0.11.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-jasmine": "^2.10.1",
"eslint-plugin-prettier": "^4.2.1",
"fancy-log": "^1.3.2",

View File

@ -1,17 +1,15 @@
<!DOCTYPE html>
<html v-bind:lang="$i18n.locale">
<head>
<meta name="viewport" content="width=device-width" />
<meta name="format-detection" content="telephone=no" />
</head>
<head>
<meta name="viewport" content="width=device-width">
<meta name="format-detection" content="telephone=no">
</head>
<body>
<body>
<table class="grid">
<tbody>
<tr>
<td>
<!-- Empty block -->
<div class="grid-row">
<div class="grid-block empty"></div>
</div>
@ -30,7 +28,6 @@
</div>
</div>
</slot>
<!-- Empty block -->
<div class="grid-row">
<div class="grid-block empty"></div>
</div>
@ -38,6 +35,5 @@
</tr>
</tbody>
</table>
</body>
</body>
</html>

View File

@ -1,7 +1,7 @@
<header>
<div class="logo">
<a href="https://www.verdnatura.es" target="_blank">
<img v-bind:src="getEmailSrc('logo-black.png')" alt="VerdNatura"/>
<img v-bind:src="getEmailSrc('logo-black.png')" alt="VerdNatura" />
</a>
</div>
<div class="topbar"></div>

View File

@ -1,4 +1,5 @@
const Component = require(`vn-print/core/component`);
const reportHeader = new Component('report-header');
const reportFooter = new Component('report-footer');

View File

@ -32,7 +32,7 @@ class Email extends Component {
const rendered = await this.render();
const attachments = [];
const getAttachments = async(componentPath, files) => {
for (file of files) {
for (const file of files) {
const fileCopy = Object.assign({}, file);
const fileName = fileCopy.filename;
@ -54,14 +54,21 @@ class Email extends Component {
}
};
async function getSubcomponentAttachments(instance) {
if (instance.components) {
const components = instance.components;
for (let componentName in components) {
const component = components[componentName];
const componentPath = `./components/${componentName}`;
await getAttachments(componentPath, component.attachments);
if (component.components)
await getSubcomponentAttachments(component)
}
}
}
await getSubcomponentAttachments(instance)
if (this.attachments)
await getAttachments(this.path, this.attachments);

View File

@ -0,0 +1,6 @@
[
{
"filename": "client-debt-statement.pdf",
"component": "client-debt-statement"
}
]

View File

@ -1,4 +1,4 @@
<report-body v-bind="$props">
<email-body v-bind="$props">
<div class="grid-row">
<div class="grid-block vn-pa-ml">
<h1>{{ $t('title') }}</h1>
@ -28,4 +28,4 @@
</attachment>
</div>
</div>
</report-body>
</email-body>

View File

@ -1,4 +1,4 @@
<report-body v-bind="$props">
<email-body v-bind="$props">
<div class="grid-row">
<div class="grid-block vn-pa-ml">
<h1>{{ $t('title') }}</h1>
@ -7,8 +7,10 @@
<p v-html="$t('totalResolved', [resolvedTickets])"></p>
<p v-html="$t('grafanaLink')"></p>
<div class="external-link vn-pa-sm vn-m-md">
<a v-bind:href="'https://grafana.verdnatura.es/d/2kaHDi9Mk/osticket?orgId=1&from=' + startedTime + '&to=' + endedTime"
target="_blank">
<a
v-bind:href="'https://grafana.verdnatura.es/d/2kaHDi9Mk/osticket?orgId=1&from=' + startedTime + '&to=' + endedTime"
target="_blank"
>
https://grafana.verdnatura.es/d/2kaHDi9Mk/osticket?orgId=1&from={{startedTime}}&to={{endedTime}}
</a>
</div>
@ -39,12 +41,8 @@
<tr>
<td>{{ticket.author}}</td>
<td class="font light-gray">
<div v-bind:title="$t('opened')">
&#128275; {{ticket.created | date('%d-%m-%Y %H:%M')}}
</div>
<div v-bind:title="$t('closed')">
&#128274; {{ticket.closed | date('%d-%m-%Y %H:%M')}}
</div>
<div v-bind:title="$t('opened')">&#128275; {{ticket.created | date('%d-%m-%Y %H:%M')}}</div>
<div v-bind:title="$t('closed')">&#128274; {{ticket.closed | date('%d-%m-%Y %H:%M')}}</div>
</td>
<td>
<a v-bind:href="'https://cau.verdnatura.es/scp/tickets.php?id=' + ticket.ticket_id">
@ -58,4 +56,4 @@
</table>
</div>
</div>
</report-body>
</email-body>

View File

@ -1,4 +1,4 @@
<report-body v-bind="$props">
<email-body v-bind="$props">
<div class="grid-row">
<div class="grid-block vn-pa-ml">
<h1>{{ $t('title') }}</h1>
@ -25,4 +25,4 @@
<p>{{ $t('notifyAnError') }}</p>
</div>
</div>
</report-body>
</email-body>

View File

@ -1,4 +1,4 @@
<report-body v-bind="$props">
<email-body v-bind="$props">
<div class="grid-row">
<div class="grid-block vn-pa-ml">
<h1>{{ $t('title') }}</h1>
@ -46,4 +46,4 @@
</attachment>
</div>
</div>
</report-body>
</email-body>

View File

@ -1,4 +1,4 @@
<report-body v-bind="$props">
<email-body v-bind="$props">
<div class="grid-row">
<div class="grid-block vn-pa-ml">
<h1>{{ $t('title') }}</h1>
@ -9,9 +9,13 @@
</div>
<div class="grid-row" v-if="isPreview">
<div class="grid-block vn-pa-ml">
<attachment v-for="attachment in attachments" v-bind:key="attachment.filename"
v-bind:attachment="attachment" v-bind:args="$props">
<attachment
v-for="attachment in attachments"
v-bind:key="attachment.filename"
v-bind:attachment="attachment"
v-bind:args="$props"
>
</attachment>
</div>
</div>
</report-body>
</email-body>

View File

@ -8,8 +8,7 @@ module.exports = {
return {attachments};
},
components: {
'email-body': emailBody.build(),
'attachment': attachments.build()
'email-body': emailBody.build()
},
props: {
id: {

View File

@ -1,4 +1,4 @@
<report-body v-bind="$props">
<email-body v-bind="$props">
<div class="grid-row">
<div class="grid-block vn-pa-ml">
<h1>{{ $t('title') }}</h1>
@ -6,4 +6,4 @@
<p v-html="$t('description', [minDate, maxDate])"></p>
</div>
</div>
</report-body>
</email-body>

View File

@ -1,6 +1,5 @@
const Component = require(`vn-print/core/component`);
const reportBody = new Component('report-body');
const reportHeader = new Component('report-header');
const reportBody = new Component('report-body')
const reportFooter = new Component('report-footer');
const rptCreditRequest = {
@ -14,7 +13,6 @@ const rptCreditRequest = {
},
components: {
'report-body': reportBody.build(),
'report-header': reportHeader.build(),
'report-footer': reportFooter.build()
}
};